All of lore.kernel.org
 help / color / mirror / Atom feed
From: Thomas Zimmermann <tzimmermann@suse.de>
To: rostedt@goodmis.org, pmladek@suse.com,
	linux-fbdev@vger.kernel.org, sergey.senozhatsky@gmail.com,
	b.zolnierkie@samsung.com, dri-devel@lists.freedesktop.org,
	hdegoede@redhat.com, akpm@linux-foundation.org,
	sergey.senozhatsky.work@gmail.com
Cc: Thomas Zimmermann <tzimmermann@suse.de>
Subject: [PATCH v3 1/2] console: Replace #if 0 with atomic var 'ignore_console_lock_warning'
Date: Thu, 19 Jul 2018 10:16:00 +0000	[thread overview]
Message-ID: <20180719101601.25076-2-tzimmermann@suse.de> (raw)
In-Reply-To: <20180719101601.25076-1-tzimmermann@suse.de>

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.

Link: http://lkml.kernel.org/r/717e6337-e7a6-7a92-1c1b-8929a25696b5@suse.de
Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
---
 include/linux/console.h | 14 +++++++++-----
 kernel/printk/printk.c  |  3 +++
 2 files changed, 12 insertions(+), 5 deletions(-)

diff --git a/include/linux/console.h b/include/linux/console.h
index f59f3dbca65c..a3307bcab947 100644
--- a/include/linux/console.h
+++ b/include/linux/console.h
@@ -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
diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
index 3f041e7cbfc9..7d32a86758cd 100644
--- a/kernel/printk/printk.c
+++ b/kernel/printk/printk.c
@@ -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.
-- 
2.18.0


WARNING: multiple messages have this Message-ID (diff)
From: Thomas Zimmermann <tzimmermann@suse.de>
To: rostedt@goodmis.org, pmladek@suse.com,
	linux-fbdev@vger.kernel.org, sergey.senozhatsky@gmail.com,
	b.zolnierkie@samsung.com, dri-devel@lists.freedesktop.org,
	hdegoede@redhat.com, akpm@linux-foundation.org,
	sergey.senozhatsky.work@gmail.com
Cc: Thomas Zimmermann <tzimmermann@suse.de>
Subject: [PATCH v3 1/2] console: Replace #if 0 with atomic var 'ignore_console_lock_warning'
Date: Thu, 19 Jul 2018 12:16:00 +0200	[thread overview]
Message-ID: <20180719101601.25076-2-tzimmermann@suse.de> (raw)
In-Reply-To: <20180719101601.25076-1-tzimmermann@suse.de>

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.

Link: http://lkml.kernel.org/r/717e6337-e7a6-7a92-1c1b-8929a25696b5@suse.de
Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
---
 include/linux/console.h | 14 +++++++++-----
 kernel/printk/printk.c  |  3 +++
 2 files changed, 12 insertions(+), 5 deletions(-)

diff --git a/include/linux/console.h b/include/linux/console.h
index f59f3dbca65c..a3307bcab947 100644
--- a/include/linux/console.h
+++ b/include/linux/console.h
@@ -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
diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
index 3f041e7cbfc9..7d32a86758cd 100644
--- a/kernel/printk/printk.c
+++ b/kernel/printk/printk.c
@@ -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.
-- 
2.18.0

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

  reply	other threads:[~2018-07-19 10:16 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-19 10:15 [PATCH v3 0/2] fbdev/core: Disable console-lock warnings when fb.lockless_register_fb is set Thomas Zimmermann
2018-07-19 10:15 ` Thomas Zimmermann
2018-07-19 10:16 ` Thomas Zimmermann [this message]
2018-07-19 10:16   ` [PATCH v3 1/2] console: Replace #if 0 with atomic var 'ignore_console_lock_warning' Thomas Zimmermann
2018-07-20  9:07   ` Petr Mladek
2018-07-20  9:07     ` Petr Mladek
2018-07-31 10:45   ` Bartlomiej Zolnierkiewicz
2018-07-31 10:45     ` Bartlomiej Zolnierkiewicz
2018-07-31 15:38   ` Steven Rostedt
2018-07-31 15:38     ` Steven Rostedt
2018-07-19 10:16 ` [PATCH v3 2/2] fbdev/core: Disable console-lock warnings when fb.lockless_register_fb is set Thomas Zimmermann
2018-07-19 10:16   ` Thomas Zimmermann
2018-07-20  9:10   ` Petr Mladek
2018-07-20  9:10     ` Petr Mladek
2018-07-31 10:45   ` Bartlomiej Zolnierkiewicz
2018-07-31 10:45     ` Bartlomiej Zolnierkiewicz
2018-07-19 11:45 ` [PATCH v3 0/2] " Hans de Goede
2018-07-19 11:45   ` Hans de Goede
2018-07-19 11:46 ` Hans de Goede
2018-07-20 12:08 ` Sergey Senozhatsky
2018-07-20 12:08   ` Sergey Senozhatsky

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180719101601.25076-2-tzimmermann@suse.de \
    --to=tzimmermann@suse.de \
    --cc=akpm@linux-foundation.org \
    --cc=b.zolnierkie@samsung.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=hdegoede@redhat.com \
    --cc=linux-fbdev@vger.kernel.org \
    --cc=pmladek@suse.com \
    --cc=rostedt@goodmis.org \
    --cc=sergey.senozhatsky.work@gmail.com \
    --cc=sergey.senozhatsky@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.