All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andi Kleen <andi@firstfloor.org>
To: akpm@linux-foundation.org
Cc: linux-kernel@vger.kernel.org, Andi Kleen <ak@linux.intel.com>,
	mpe@ellerman.id.au
Subject: [PATCH] Support resetting WARN_ONCE for all architectures
Date: Thu, 19 Oct 2017 13:46:42 -0700	[thread overview]
Message-ID: <20171019204642.7404-1-andi@firstfloor.org> (raw)

From: Andi Kleen <ak@linux.intel.com>

Some architectures store the WARN_ONCE state in the flags
field of the bug_entry. Clear that one too when resetting
once state through /sys/kernel/debug/clear_warn_once

Pointed out by Michael Ellerman

Improves the earlier patch that add clear_warn_once.

Cc: mpe@ellerman.id.au
Signed-off-by: Andi Kleen <ak@linux.intel.com>
---
 include/linux/bug.h |  5 +++++
 kernel/panic.c      |  1 +
 lib/bug.c           | 21 +++++++++++++++++++++
 3 files changed, 27 insertions(+)

diff --git a/include/linux/bug.h b/include/linux/bug.h
index 5d5554c874fd..b8666ee88086 100644
--- a/include/linux/bug.h
+++ b/include/linux/bug.h
@@ -42,6 +42,8 @@ enum bug_trap_type report_bug(unsigned long bug_addr, struct pt_regs *regs);
 /* These are defined by the architecture */
 int is_valid_bugaddr(unsigned long addr);
 
+void generic_bug_clear_once(void);
+
 #else	/* !CONFIG_GENERIC_BUG */
 
 static inline enum bug_trap_type report_bug(unsigned long bug_addr,
@@ -50,6 +52,9 @@ static inline enum bug_trap_type report_bug(unsigned long bug_addr,
 	return BUG_TRAP_TYPE_BUG;
 }
 
+
+static inline void generic_bug_clear_once(void) {}
+
 #endif	/* CONFIG_GENERIC_BUG */
 
 /*
diff --git a/kernel/panic.c b/kernel/panic.c
index 49dbdb231a77..840a98fa4963 100644
--- a/kernel/panic.c
+++ b/kernel/panic.c
@@ -595,6 +595,7 @@ EXPORT_SYMBOL(warn_slowpath_null);
 
 static int clear_warn_once_set(void *data, u64 val)
 {
+	generic_bug_clear_once();
 	memset(__start_once, 0, __end_once - __start_once);
 	return 0;
 }
diff --git a/lib/bug.c b/lib/bug.c
index a6a1137d06db..7cb2d41845f7 100644
--- a/lib/bug.c
+++ b/lib/bug.c
@@ -195,3 +195,24 @@ enum bug_trap_type report_bug(unsigned long bugaddr, struct pt_regs *regs)
 
 	return BUG_TRAP_TYPE_BUG;
 }
+
+static void clear_once_table(struct bug_entry *start, struct bug_entry *end)
+{
+	struct bug_entry *bug;
+
+	for (bug = start; bug < end; bug++)
+		bug->flags &= ~BUGFLAG_ONCE;
+}
+
+void generic_bug_clear_once(void)
+{
+	struct module *mod;
+
+	rcu_read_lock_sched();
+	list_for_each_entry_rcu(mod, &module_bug_list, bug_list)
+		clear_once_table(mod->bug_table,
+				 mod->bug_table + mod->num_bugs);
+	rcu_read_unlock_sched();
+
+	clear_once_table(__start___bug_table, __stop___bug_table);
+}
-- 
2.13.6

             reply	other threads:[~2017-10-19 20:46 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-19 20:46 Andi Kleen [this message]
2017-11-03  9:38 ` [PATCH] Support resetting WARN_ONCE for all architectures Michael Ellerman
2017-11-03 17:47   ` Andrew Morton
2017-11-06  0:18     ` Michael Ellerman
2017-11-06 21:36     ` Andi Kleen
2017-11-08  9:40       ` Michael Ellerman
2017-10-20 17:06 Andi Kleen

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=20171019204642.7404-1-andi@firstfloor.org \
    --to=andi@firstfloor.org \
    --cc=ak@linux.intel.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mpe@ellerman.id.au \
    /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.