fbdev/core: Disable console-lock warnings when fb.lockless_register_fb is set
Subsystems (4)
v3 cover fbdev/core: Disable console-lock warnings when fb.lockless_register_fb is set
Hi,
this is version 3 of the WARN_CONSOLE_UNLOCKED patch set. The macro prints a warning if the console's critical sections are entered without holding the console lock. This patch set allows to disable the warnings while debugging the console.
In the original approach, WARN_CONSOLE_UNLOCKED was disabled by setting ignore_console_lock_warning of type bool. As suggested by Petr Mladek, the new implementation is based on atomic_t and allows multiple threads to manipulate the warning state concurrently.
With version 3, the patch set now includes the patch for introducing ignore_console_lock_warning. This patch superseds all previous patches of the same purpose.
Best regards
Thomas
v3:
- implement ignore_console_lock_warning with atomic_t
v2:
- restore ignore_console_lock_warning if lock_fb_info() fails
Thomas Zimmermann (2):
console: Replace #if 0 with atomic var 'ignore_console_lock_warning' fbdev/core: Disable console-lock warnings when fb.lockless_register_fb
is set
drivers/video/fbdev/core/fbmem.c | 13 +++++++++---- include/linux/console.h | 14 +++++++++----- kernel/printk/printk.c | 3 +++ 3 files changed, 21 insertions(+), 9 deletions(-)
--
2.18.0
PATCH v3 1/2 console: Replace #if 0 with atomic var 'ignore_console_lock_warning'
The macro WARN_CONSOLE_UNLOCKED prints a warning when a thread enters the console's critical section without having acquired the console lock. The console lock can be ignored when debugging the console using printk, but this makes WARN_CONSOLE_UNLOCKED generate unnecessary warnings.
The variable ignore_console_lock_warning temporarily disables WARN_CONSOLE_UNLOCKED. Developers interested in debugging the console's critical sections should increment it before entering the CS and decrement it after leaving the CS. Setting ignore_console_lock_warning is only for debugging. Regular operation should not manipulate it.
Acknoledgements: This patch is based on an earlier version by Steven Rostedt. The use of atomic increment/decrement was suggested by Petr Mladek.
--- include/linux/console.h | 14 +++++++++----- kernel/printk/printk.c | 3 +++ 2 files changed, 12 insertions(+), 5 deletions(-)
include/linux/console.h +9 -5
@@ -14,6 +14,7 @@#ifndef _LINUX_CONSOLE_H_#define _LINUX_CONSOLE_H_ 1 +#include <asm/atomic.h> #include <linux/types.h> struct vc_data ;
@@ -201,11 +202,14 @@ void vcs_make_sysfs(int index);void vcs_remove_sysfs (int index);/* Some debug stub to catch some of the obvious races in the VT code */ -#if 1 -#define WARN_CONSOLE_UNLOCKED () WARN_ON(!is_console_locked() && !oops_in_progress) -#else -#define WARN_CONSOLE_UNLOCKED () -#endif +#define WARN_CONSOLE_UNLOCKED () \ + WARN_ON(!atomic_read(&ignore_console_lock_warning) && \ + !is_console_locked() && !oops_in_progress) +/* +* Increment ignore_console_lock_warning if you need to quiet +* WARN_CONSOLE_UNLOCKED() for debugging purposes. +*/ +extern atomic_t ignore_console_lock_warning;/* VESA Blanking Levels */ #define VESA_NO_BLANKING 0
kernel/printk/printk.c +3 -0
@@ -66,6 +66,9 @@ int console_printk[4] = { CONSOLE_LOGLEVEL_DEFAULT, /* default_console_loglevel */ }; +atomic_t ignore_console_lock_warning__read_mostly =ATOMIC_INIT (0 ); +EXPORT_SYMBOL (ignore_console_lock_warning); +/* * Low level drivers may need that to know if they can schedule in * their unblank() callback or not. So let's export it.
Signature · 1 line
2.18.0
Re: [PATCH v3 1/2] console: Replace #if 0 with atomic var 'ignore_console_lock_warning'
Quoted 12 lines · Thomas Zimmermann
The macro
WARN_CONSOLE_UNLOCKEDprints a warning when a thread enters the console's critical section without having acquired the console lock. The console lock can be ignored when debugging the console using printk, but this makesWARN_CONSOLE_UNLOCKEDgenerate unnecessary warnings.The variable
ignore_console_lock_warningtemporarily disablesWARN_CONSOLE_UNLOCKED. Developers interested in debugging the console's critical sections should increment it before entering the CS and decrement it after leaving the CS. Settingignore_console_lock_warningis only for debugging. Regular operation should not manipulate it.
Quoted 6 lines
Acknoledgements: This patch is based on an earlier version by Steven Rostedt. The use of atomic increment/decrement was suggested by Petr Mladek.
I have vacation the following two weeks. I prefer this version over the previous one but I could live with both.
Best Regards,
Petr
Re: [PATCH v3 1/2] console: Replace #if 0 with atomic var 'ignore_console_lock_warning'
In reply to Thomas ZimmermannQuoted 12 lines · Thomas Zimmermann
The macro
WARN_CONSOLE_UNLOCKEDprints a warning when a thread enters the console's critical section without having acquired the console lock. The console lock can be ignored when debugging the console using printk, but this makesWARN_CONSOLE_UNLOCKEDgenerate unnecessary warnings.The variable
ignore_console_lock_warningtemporarily disablesWARN_CONSOLE_UNLOCKED. Developers interested in debugging the console's critical sections should increment it before entering the CS and decrement it after leaving the CS. Settingignore_console_lock_warningis only for debugging. Regular operation should not manipulate it.
Quoted 6 lines
Acknoledgements: This patch is based on an earlier version by Steven Rostedt. The use of atomic increment/decrement was suggested by Petr Mladek.
Patch queued for 4.19 (w/ <asm/atomic.h> -> <linux/atomic.h> fixup), thanks.
Best regards,
--
Bartlomiej Zolnierkiewicz
Samsung R&D Institute Poland
Samsung Electronics
Steven Rostedt
reviewerRe: [PATCH v3 1/2] console: Replace #if 0 with atomic var 'ignore_console_lock_warning'
In reply to Thomas ZimmermannQuoted 12 lines · On Thu, 19 Jul 2018 12:16:00 +0200 Thomas Zimmermann <[email protected]>…
The macro
WARN_CONSOLE_UNLOCKEDprints a warning when a thread enters the console's critical section without having acquired the console lock. The console lock can be ignored when debugging the console using printk, but this makesWARN_CONSOLE_UNLOCKEDgenerate unnecessary warnings.The variable
ignore_console_lock_warningtemporarily disablesWARN_CONSOLE_UNLOCKED. Developers interested in debugging the console's critical sections should increment it before entering the CS and decrement it after leaving the CS. Settingignore_console_lock_warningis only for debugging. Regular operation should not manipulate it.
Quoted 3 lines
Acknoledgements: This patch is based on an earlier version by Steven Rostedt. The use of atomic increment/decrement was suggested by Petr Mladek.
You can also add a reference to that patch as well:
-- Steve
Quoted 54 lines
Signed-off-by Thomas Zimmermann <[email protected]>--- include/linux/console.h | 14 +++++++++----- kernel/printk/printk.c | 3 +++ 2 files changed, 12 insertions(+), 5 deletions(-)include/linux/console.h +9
-5@@ -14,6 +14,7 @@#ifndef _LINUX_CONSOLE_H_#define _LINUX_CONSOLE_H_ 1 +#include <asm/atomic.h> #include <linux/types.h> struct vc_data ;@@ -201,11 +202,14 @@ void vcs_make_sysfs(int index);void vcs_remove_sysfs (int index);/* Some debug stub to catch some of the obvious races in the VT code */ -#if 1 -#define WARN_CONSOLE_UNLOCKED () WARN_ON(!is_console_locked() && !oops_in_progress) -#else -#define WARN_CONSOLE_UNLOCKED () -#endif +#define WARN_CONSOLE_UNLOCKED () \ + WARN_ON(!atomic_read(&ignore_console_lock_warning) && \ + !is_console_locked() && !oops_in_progress) +/* +* Increment ignore_console_lock_warning if you need to quiet +* WARN_CONSOLE_UNLOCKED() for debugging purposes. +*/ +extern atomic_t ignore_console_lock_warning;/* VESA Blanking Levels */ #define VESA_NO_BLANKING 0kernel/printk/printk.c +3
-0@@ -66,6 +66,9 @@ int console_printk[4] = { CONSOLE_LOGLEVEL_DEFAULT, /* default_console_loglevel */ }; +atomic_t ignore_console_lock_warning__read_mostly =ATOMIC_INIT (0 ); +EXPORT_SYMBOL (ignore_console_lock_warning); +/* * Low level drivers may need that to know if they can schedule in * their unblank() callback or not. So let's export it.
PATCH v3 2/2 fbdev/core: Disable console-lock warnings when fb.lockless_register_fb is set
In reply to Thomas ZimmermannIf the console is unlocked during registration, the console subsystem generates significant amounts of warnings, which obfuscate actual debugging messages. Setting ignore_console_lock_warning while debugging console registration avoid the noise.
v3:
- manipulate ignore_console_lock_warning with atomic_{inc,dec}
v2:
- restore ignore_console_lock_warning if lock_fb_info() fails
--- drivers/video/fbdev/core/fbmem.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-)
drivers/video/fbdev/core/fbmem.c +9 -4
@@ -1691,17 +1691,22 @@ static int do_register_framebuffer(struct fb_info *fb_info) event.info = fb_info;if (!lockless_register_fb)console_lock (); +else +atomic_inc (&ignore_console_lock_warning);if (!lock_fb_info (fb_info)) { -if (!lockless_register_fb) -console_unlock (); -return -ENODEV ; + ret = -ENODEV ; + goto unlock_console; } + ret =0 ;fb_notifier_call_chain (FB_EVENT_FB_REGISTERED , &event);unlock_fb_info (fb_info); +unlock_console:if (!lockless_register_fb)console_unlock (); -return 0 ; +else +atomic_dec (&ignore_console_lock_warning); +return ret; }static int do_unregister_framebuffer (struct fb_info *fb_info)
Signature · 1 line
2.18.0
Quoted 11 lines · Thomas Zimmermann
If the console is unlocked during registration, the console subsystem generates significant amounts of warnings, which obfuscate actual debugging messages. Setting
ignore_console_lock_warningwhile debugging console registration avoid the noise.v3:
- manipulateignore_console_lock_warningwith atomic_{inc,dec}
v2:
- restoreignore_console_lock_warningiflock_fb_info()failsSigned-off-by Thomas Zimmermann <[email protected]>
I have vacation the following two weeks. Note that I am fine with v2 if anyone see the atomic as an overkill.
Best Regards,
Petr
Quoted 11 lines · Thomas Zimmermann
If the console is unlocked during registration, the console subsystem generates significant amounts of warnings, which obfuscate actual debugging messages. Setting
ignore_console_lock_warningwhile debugging console registration avoid the noise.v3:
- manipulateignore_console_lock_warningwith atomic_{inc,dec}
v2:
- restoreignore_console_lock_warningiflock_fb_info()failsSigned-off-by Thomas Zimmermann <[email protected]>
Patch queued for 4.19, thanks.
Best regards,
--
Bartlomiej Zolnierkiewicz
Samsung R&D Institute Poland
Samsung Electronics
Hi,
Quoted 24 lines · Thomas Zimmermann
Hi,
this is version 3 of the
WARN_CONSOLE_UNLOCKEDpatch set. The macro prints a warning if the console's critical sections are entered without holding the console lock. This patch set allows to disable the warnings while debugging the console.In the original approach,
WARN_CONSOLE_UNLOCKEDwas disabled by settingignore_console_lock_warningof type bool. As suggested by Petr Mladek, the new implementation is based onatomic_tand allows multiple threads to manipulate the warning state concurrently.With version 3, the patch set now includes the patch for introducing
ignore_console_lock_warning. This patch superseds all previous patches of the same purpose.Best regards
Thomasv3:
- implementignore_console_lock_warningwithatomic_t
v2:
- restoreignore_console_lock_warningiflock_fb_info()fails
Quoted 4 lines
Thomas Zimmermann (2):
console: Replace #if 0 with atomic var 'ignore_console_lock_warning' fbdev/core: Disable console-lock warnings when fb.lockless_register_fb
is set
I just saw this version after my comment on v2 that the race there was not really a problem.
This version is even better though :) :
Regards,
Hans
p.s. (without the lists in the Cc)
I'm on vacation starting tomorrow, back to work on Mon Jul 30th.
Quoted 14 lines · Thomas Zimmermann
this is version 3 of the
WARN_CONSOLE_UNLOCKEDpatch set. The macro prints a warning if the console's critical sections are entered without holding the console lock. This patch set allows to disable the warnings while debugging the console.In the original approach,
WARN_CONSOLE_UNLOCKEDwas disabled by settingignore_console_lock_warningof type bool. As suggested by Petr Mladek, the new implementation is based onatomic_tand allows multiple threads to manipulate the warning state concurrently.With version 3, the patch set now includes the patch for introducing
ignore_console_lock_warning. This patch superseds all previous patches of the same purpose.
Quoted 7 lines
Best regards
Thomasv3:
- implementignore_console_lock_warningwithatomic_t
v2:
- restoreignore_console_lock_warningiflock_fb_info()fails
-ss