[PATCHv2 2/4] kernel/watchdog_hld: clarify the condition in hardlockup_detector_event_create()
Pingfan Liu
kernelfans at gmail.com
Thu Sep 23 07:09:49 PDT 2021
As for the context, there are two arguments to change
debug_smp_processor_id() to is_percpu_thread().
-1. watchdog_ev is percpu, and migration will frustrate the attempt
which try to bind a watchdog_ev to a cpu by protecting this func inside
the pair of preempt_disable()/preempt_enable().
-2. hardlockup_detector_event_create() indirectly calls
kmem_cache_alloc_node(), which is blockable.
So here, spelling out the really planned context "is_percpu_thread()".
Signed-off-by: Pingfan Liu <kernelfans at gmail.com>
Cc: Petr Mladek <pmladek at suse.com>
Cc: Andrew Morton <akpm at linux-foundation.org>
Cc: Wang Qing <wangqing at vivo.com>
Cc: "Peter Zijlstra (Intel)" <peterz at infradead.org>
Cc: Santosh Sivaraj <santosh at fossix.org>
Cc: linux-arm-kernel at lists.infradead.org
To: linux-kernel at vger.kernel.org
---
kernel/watchdog_hld.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/kernel/watchdog_hld.c b/kernel/watchdog_hld.c
index 247bf0b1582c..df010df76576 100644
--- a/kernel/watchdog_hld.c
+++ b/kernel/watchdog_hld.c
@@ -165,10 +165,13 @@ static void watchdog_overflow_callback(struct perf_event *event,
static int hardlockup_detector_event_create(void)
{
- unsigned int cpu = smp_processor_id();
+ unsigned int cpu;
struct perf_event_attr *wd_attr;
struct perf_event *evt;
+ /* This function plans to execute in cpu bound kthread */
+ WARN_ON(!is_percpu_thread());
+ cpu = raw_smp_processor_id();
wd_attr = &wd_hw_attr;
wd_attr->sample_period = hw_nmi_get_sample_period(watchdog_thresh);
--
2.31.1
More information about the linux-arm-kernel
mailing list