[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20220420140521.45361-8-kernelfans@gmail.com>
Date: Wed, 20 Apr 2022 22:05:19 +0800
From: Pingfan Liu <kernelfans@...il.com>
To: linux-kernel@...r.kernel.org
Cc: Pingfan Liu <kernelfans@...il.com>,
Thomas Gleixner <tglx@...utronix.de>,
Valentin Schneider <valentin.schneider@....com>,
Peter Zijlstra <peterz@...radead.org>,
Frederic Weisbecker <frederic@...nel.org>,
Baokun Li <libaokun1@...wei.com>,
Mark Rutland <mark.rutland@....com>,
Steven Price <steven.price@....com>,
"Jason A. Donenfeld" <Jason@...c4.com>,
Yuan ZhaoXiong <yuanzhaoxiong@...du.com>,
YueHaibing <yuehaibing@...wei.com>,
Randy Dunlap <rdunlap@...radead.org>
Subject: [PATCH 7/9] irq: remove needless lock in takedown_cpu()
Any allocation or release of irq_desc should fall into the interface of
__irq_alloc_descs() or irq_free_descs(). And both of them hold the mutex
sparse_irq_lock. This preemptability contradicts the preempt-disabled
context when dispatching fn in cpu_stopper_thread(). So allocation or
free of irq_desc can not be demanded in cpu_stopper_thread().
On the other hand, for the safety of access to irq_desc, rcu still keeps
watching the dying cpu until the last minute rcu_report_dead(), so each
cpu_stop_fn_t can safely access irq_desc.
As a result, in takedown_cpu() irq_lock_sparse()/irq_unlock_sparse() can
be safely removed.
Signed-off-by: Pingfan Liu <kernelfans@...il.com>
Cc: Thomas Gleixner <tglx@...utronix.de>
Cc: Valentin Schneider <valentin.schneider@....com>
Cc: Peter Zijlstra <peterz@...radead.org>
Cc: Frederic Weisbecker <frederic@...nel.org>
Cc: Baokun Li <libaokun1@...wei.com>
Cc: Mark Rutland <mark.rutland@....com>
Cc: Steven Price <steven.price@....com>
Cc: "Jason A. Donenfeld" <Jason@...c4.com>
Cc: Yuan ZhaoXiong <yuanzhaoxiong@...du.com>
Cc: YueHaibing <yuehaibing@...wei.com>
Cc: Randy Dunlap <rdunlap@...radead.org>
To: linux-kernel@...r.kernel.org
---
kernel/cpu.c | 11 +++--------
1 file changed, 3 insertions(+), 8 deletions(-)
diff --git a/kernel/cpu.c b/kernel/cpu.c
index d0a9aa0b42e8..94a6b512c26d 100644
--- a/kernel/cpu.c
+++ b/kernel/cpu.c
@@ -1033,18 +1033,16 @@ static int takedown_cpu(unsigned int cpu)
kthread_park(st->thread);
/*
- * Prevent irq alloc/free while the dying cpu reorganizes the
- * interrupt affinities.
+ * RCU keeps watching 'cpu' until do_idle()->rcu_report_dead().
+ * And cpu_stopper's fn is dispatched with preemption disabled.
+ * So it can not occur to release a irq_desc.
*/
- irq_lock_sparse();
/*
* So now all preempt/rcu users must observe !cpu_active().
*/
err = stop_machine_cpuslocked(take_cpu_down, NULL, cpumask_of(cpu));
if (err) {
- /* CPU refused to die */
- irq_unlock_sparse();
/* Unpark the hotplug thread so we can rollback there */
kthread_unpark(st->thread);
return err;
@@ -1061,9 +1059,6 @@ static int takedown_cpu(unsigned int cpu)
wait_for_ap_thread(st, false);
BUG_ON(st->state != CPUHP_AP_IDLE_DEAD);
- /* Interrupts are moved away from the dying cpu, reenable alloc/free */
- irq_unlock_sparse();
-
hotplug_cpu__broadcast_tick_pull(cpu);
/* This actually kills the CPU. */
__cpu_die(cpu);
--
2.31.1
Powered by blists - more mailing lists