Message ID | 20240710093120.732208-2-daniel.vetter@ffwll.ch (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | [1/2] drm: Add might_fault to drm_modeset_lock priming | expand |
On 2024-07-10, Daniel Vetter <daniel.vetter@ffwll.ch> wrote: > console_lock is the outermost subsystem lock for a lot of subsystems, > which means get/put_user must nest within. Which means it cannot be > acquired somewhere deeply nested in other locks, and most definitely > not while holding fs locks potentially needed to resolve faults. > > console_trylock is the best we can do here. > > Including printk folks since even trylock feels realyl iffy here to > me. Using the console lock here at all is wrong. The console lock does not prevent other CPUs from calling printk() and inserting lines in between. There is no way to guarantee a contiguous ringbuffer block using multiple printk() calls. The console_lock usage should be removed. John Ogness
diff --git a/fs/bcachefs/util.c b/fs/bcachefs/util.c index de331dec2a99..02381c653603 100644 --- a/fs/bcachefs/util.c +++ b/fs/bcachefs/util.c @@ -255,13 +255,14 @@ void bch2_prt_u64_base2(struct printbuf *out, u64 v) void bch2_print_string_as_lines(const char *prefix, const char *lines) { const char *p; + int locked; if (!lines) { printk("%s (null)\n", prefix); return; } - console_lock(); + locked = console_trylock(); while (1) { p = strchrnul(lines, '\n'); printk("%s%.*s\n", prefix, (int) (p - lines), lines); @@ -269,7 +270,8 @@ void bch2_print_string_as_lines(const char *prefix, const char *lines) break; lines = p + 1; } - console_unlock(); + if (locked) + console_unlock(); } int bch2_save_backtrace(bch_stacktrace *stack, struct task_struct *task, unsigned skipnr,