Skip to contentSkip to conversation

console: Replace #if 1 with a bool to ignore WARN_CONSOLE_UNLOCKED()

PATCH Superseded Steven Rostedt 4 participants 7 messages Jul 11, 2018 – Jul 12, 2018

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Steven Rostedt

author reviewer
#0 lore raw

PATCH 1/1 console: Replace #if 1 with a bool to ignore WARN_CONSOLE_UNLOCKED()

From: Steven Rostedt (VMware) <[email protected]>

There's been discussion on the fb list about the addition of WARN_CONSOLE_UNLOCKED() inside the fb code. The complaint is that when the fb module is loaded with lockless_register_fb the console lock is not taken for debugging reasons. With the addition of WARN_CONSOLE_UNLOCK() within the fb code, this causes the console to fill up with warnings when trying to debug the fb driver.

There's also a #if 1 that enables the warning which was added before git history, and we look down on constant #if's in the kernel nowadays anyway.

Remove the #if 1 and add a ignore_console_lock_warning boolean that can be set by drivers to ignore the warning in order to do debugging.

---

include/linux/console.h +3 -5
index dfd6b0e97855..9d4a6b985154 100644
@@ -200,11 +200,9 @@ 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
+extern bool ignore_console_lock_warning;
+#define WARN_CONSOLE_UNLOCKED()						\
+	WARN_ON(!ignore_console_lock_warning && !is_console_locked() && !oops_in_progress)
 
 /* VESA Blanking Levels */
 #define VESA_NO_BLANKING        0
kernel/printk/printk.c +3 -0
index 247808333ba4..d9056efc3739 100644
@@ -66,6 +66,9 @@ int console_printk[4] = {
 	CONSOLE_LOGLEVEL_DEFAULT,	/* default_console_loglevel */
 };
 
+bool ignore_console_lock_warning __read_mostly;
+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.
Reviewed-by on v1 1/1
#1 lore raw

Hi,

Quoted 14 lines · Steven Rostedt

From: Steven Rostedt (VMware) <[email protected]>

There's been discussion on the fb list about the addition of WARN_CONSOLE_UNLOCKED() inside the fb code. The complaint is that when the fb module is loaded with lockless_register_fb the console lock is not taken for debugging reasons. With the addition of WARN_CONSOLE_UNLOCK() within the fb code, this causes the console to fill up with warnings when trying to debug the fb driver.

There's also a #if 1 that enables the warning which was added before git history, and we look down on constant #if's in the kernel nowadays anyway.

Quoted 5 lines

Remove the #if 1 and add a ignore_console_lock_warning boolean that can be set by drivers to ignore the warning in order to do debugging.

Based on the fbdev discussion this seems a good idea to me and codewise this looks good to:

Regards,

Hans

Quoted 35 lines

---

include/linux/console.h +3 -5
index dfd6b0e97855..9d4a6b985154 100644
@@ -200,11 +200,9 @@ 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
+extern bool ignore_console_lock_warning;
+#define WARN_CONSOLE_UNLOCKED()						\
+	WARN_ON(!ignore_console_lock_warning && !is_console_locked() && !oops_in_progress)
 
  /* VESA Blanking Levels */
  #define VESA_NO_BLANKING        0
kernel/printk/printk.c +3 -0
index 247808333ba4..d9056efc3739 100644
@@ -66,6 +66,9 @@ int console_printk[4] = {
  	CONSOLE_LOGLEVEL_DEFAULT,	/* default_console_loglevel */
  };
 
+bool ignore_console_lock_warning __read_mostly;
+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.
#2 lore raw
In reply to Steven Rostedt

kernel/printk/printk.c int console_printk[4] = { · line 70

Quoted 2 lines · Steven Rostedt
kernel/printk/printk.c +2 -0
+bool ignore_console_lock_warning __read_mostly;
+EXPORT_SYMBOL(ignore_console_lock_warning);

OK. So, to recap,
We made is_console_locked() EXPORT_SYMBOL recently [it's still in linux-next], so people could use WARN_CONSOLE_UNLOCKED in more places; this made other people unhappy, so now we add another EXPORT_SYMBOL to the picture, which will disable those newly added WARN_CONSOLE_UNLOCKED and make other people happy again.

This makes me wonder - do we want to add more WARN_CONSOLE_UNLOCKED in the first place? :)

Other than that, the patch looks OK to me I guess. I'm not super happy with more printk EXPORT_SYMBOL-s, frankly speaking, I'm not entirely in love with the "add a bool flag to suppress warn print outs which we added in the previous patch" direction, but if you guys want/need it... Probably I'm just dramatizing it, as usual ;)
The removal of "#if 1" is definitely nice.

Let's hear from Petr.

	-ss
author reviewer
#3 lore raw
Quoted 10 lines · On Thu, 12 Jul 2018 10:58:48 +0900 Sergey Senozhatsky…

kernel/printk/printk.c int console_printk[4] = { · line 70

Quoted 2 lines · Steven Rostedt
kernel/printk/printk.c +2 -0
+bool ignore_console_lock_warning __read_mostly;
+EXPORT_SYMBOL(ignore_console_lock_warning);  

OK. So, to recap,
We made is_console_locked() EXPORT_SYMBOL recently [it's still in linux-next], so people could use WARN_CONSOLE_UNLOCKED in more places; this made other people unhappy, so now we add another EXPORT_SYMBOL to the picture, which will disable those newly added WARN_CONSOLE_UNLOCKED and make other people happy again.

Note, it only made people that added a module parameter that disables grabbing the console lock in the first place for debugging purposes only. The added WARN_CONSOLE_UNLOCKED() are good. Nobody complaining that they exist. They are complaining that it breaks one of their debugging work flows, and need to disable it when they are doing so.

Quoted 3 lines

This makes me wonder - do we want to add more WARN_CONSOLE_UNLOCKED in the first place? :)

I would say yes.

Quoted 5 lines

Other than that, the patch looks OK to me I guess. I'm not super happy with more printk EXPORT_SYMBOL-s, frankly speaking, I'm not entirely in love with the "add a bool flag to suppress warn print outs which we added in the previous patch" direction, but if you guys want/need it...

I could add a comment explaining why it exists. Something like:

/*
* Set this is you need to quiet WARN_CONSOLE_UNLOCKED() for debugging
* purposes.
*/

Quoted 2 lines

Probably I'm just dramatizing it, as usual ;)
The removal of "#if 1" is definitely nice.

Yeah, that had to go regardless.

Quoted 2 lines

Let's hear from Petr.

Sure.

-- Steve

#4 lore raw
Quoted 11 lines · Steven Rostedt
Quoted 10 lines · Steven Rostedt

kernel/printk/printk.c int console_printk[4] = { · line 70

Quoted 2 lines
kernel/printk/printk.c +2 -0
+bool ignore_console_lock_warning __read_mostly;
+EXPORT_SYMBOL(ignore_console_lock_warning);  

OK. So, to recap,
We made is_console_locked() EXPORT_SYMBOL recently [it's still in linux-next], so people could use WARN_CONSOLE_UNLOCKED in more places; this made other people unhappy, so now we add another EXPORT_SYMBOL to the picture, which will disable those newly added WARN_CONSOLE_UNLOCKED and make other people happy again.

Quoted 5 lines

Note, it only made people that added a module parameter that disables grabbing the console lock in the first place for debugging purposes only. The added WARN_CONSOLE_UNLOCKED() are good. Nobody complaining that they exist. They are complaining that it breaks one of their debugging work flows, and need to disable it when they are doing so.

True, but at the same time nobody complained that we didn't have those extra WARN_CONSOLE_UNLOCKED()-s. Just saying. Over all I agree that there is probably some value in those extra WARN-s.

Quoted 6 lines

I could add a comment explaining why it exists. Something like:

/*
* Set this is you need to quiet WARN_CONSOLE_UNLOCKED() for debugging
* purposes.
*/

s/is you/if you/

	-ss
maintainer
#5 lore raw
Quoted 18 lines · Sergey Senozhatsky
Quoted 11 lines · Steven Rostedt
Quoted 10 lines · Steven Rostedt

kernel/printk/printk.c int console_printk[4] = { · line 70

Quoted 2 lines
kernel/printk/printk.c +2 -0
+bool ignore_console_lock_warning __read_mostly;
+EXPORT_SYMBOL(ignore_console_lock_warning);  

OK. So, to recap,
We made is_console_locked() EXPORT_SYMBOL recently [it's still in linux-next], so people could use WARN_CONSOLE_UNLOCKED in more places; this made other people unhappy, so now we add another EXPORT_SYMBOL to the picture, which will disable those newly added WARN_CONSOLE_UNLOCKED and make other people happy again.

Quoted 5 lines

Note, it only made people that added a module parameter that disables grabbing the console lock in the first place for debugging purposes only. The added WARN_CONSOLE_UNLOCKED() are good. Nobody complaining that they exist. They are complaining that it breaks one of their debugging work flows, and need to disable it when they are doing so.

Quoted 3 lines

True, but at the same time nobody complained that we didn't have those extra WARN_CONSOLE_UNLOCKED()-s. Just saying. Over all I agree that there is probably some value in those extra WARN-s.

I agree that there is some value in the extra WARN's. Also it seems that it is useful to disable them for debugging purposes. I do not see a better solution. Therefore I am fine with this one.

Quoted 8 lines
Quoted 6 lines

I could add a comment explaining why it exists. Something like:

/*
* Set this is you need to quiet WARN_CONSOLE_UNLOCKED() for debugging
* purposes.
*/

s/is you/if you/

Yes, this extra comment would be appreciated.

If you send v2, please, break also the WARN definition to 80-chars's per line ;-)

Quoted 1 line

AFAIK, the change was actually suggested by Steven. The inspiration is described by the line:

Link:
http://lkml.kernel.org/r/[email protected]

Finally, IMHO, it would make sense to push this change together with the fbcon/vt side.

Best Regards,
Petr

#6 lore raw
Quoted 8 lines · Petr Mladek
Quoted 4 lines

True, but at the same time nobody complained that we didn't have those extra WARN_CONSOLE_UNLOCKED()-s. Just saying. Over all I agree that there is probably some value in those extra WARN-s.

I agree that there is some value in the extra WARN's. Also it seems that it is useful to disable them for debugging purposes. I do not see a better solution. Therefore I am fine with this one.

Good.

Quoted 1 line

Yes, this extra comment would be appreciated.

Yep.

Quoted 2 lines

If you send v2, please, break also the WARN definition to 80-chars's per line ;-)

Yeah, I noticed that too.

	-ss