Skip to content

Commit 1bf8012

Browse files
Wen Yangkees
authored andcommitted
pstore: replace spinlock_t by raw_spinlock_t
pstore_dump() is called when both preemption and local IRQ are disabled, and a spinlock is obtained, which is problematic for the RT kernel because in this configuration, spinlocks are sleep locks. Replace the spinlock_t with raw_spinlock_t to avoid sleeping in atomic context. Signed-off-by: Wen Yang <[email protected]> Cc: Kees Cook <[email protected]> Cc: Tony Luck <[email protected]> Cc: Guilherme G. Piccoli <[email protected]> Cc: [email protected] Cc: [email protected] Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Kees Cook <[email protected]>
1 parent a7050ca commit 1bf8012

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

fs/pstore/platform.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -288,13 +288,13 @@ static void pstore_dump(struct kmsg_dumper *dumper,
288288
why = kmsg_dump_reason_str(reason);
289289

290290
if (pstore_cannot_block_path(reason)) {
291-
if (!spin_trylock_irqsave(&psinfo->buf_lock, flags)) {
291+
if (!raw_spin_trylock_irqsave(&psinfo->buf_lock, flags)) {
292292
pr_err("dump skipped in %s path because of concurrent dump\n",
293293
in_nmi() ? "NMI" : why);
294294
return;
295295
}
296296
} else {
297-
spin_lock_irqsave(&psinfo->buf_lock, flags);
297+
raw_spin_lock_irqsave(&psinfo->buf_lock, flags);
298298
}
299299

300300
kmsg_dump_rewind(&iter);
@@ -364,7 +364,7 @@ static void pstore_dump(struct kmsg_dumper *dumper,
364364
total += record.size;
365365
part++;
366366
}
367-
spin_unlock_irqrestore(&psinfo->buf_lock, flags);
367+
raw_spin_unlock_irqrestore(&psinfo->buf_lock, flags);
368368

369369
if (saved_ret) {
370370
pr_err_once("backend (%s) writing error (%d)\n", psinfo->name,
@@ -503,7 +503,7 @@ int pstore_register(struct pstore_info *psi)
503503
psi->write_user = pstore_write_user_compat;
504504
psinfo = psi;
505505
mutex_init(&psinfo->read_mutex);
506-
spin_lock_init(&psinfo->buf_lock);
506+
raw_spin_lock_init(&psinfo->buf_lock);
507507

508508
if (psi->flags & PSTORE_FLAGS_DMESG)
509509
allocate_buf_for_compression();

include/linux/pstore.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ struct pstore_info {
182182
struct module *owner;
183183
const char *name;
184184

185-
spinlock_t buf_lock;
185+
raw_spinlock_t buf_lock;
186186
char *buf;
187187
size_t bufsize;
188188

0 commit comments

Comments
 (0)