Skip to content

Commit 6881e75

Browse files
committed
tick/broadcast: Move per CPU pointer access into the atomic section
The recent fix for making the take over of the broadcast timer more reliable retrieves a per CPU pointer in preemptible context. This went unnoticed as compilers hoist the access into the non-preemptible region where the pointer is actually used. But of course it's valid that the compiler keeps it at the place where the code puts it which rightfully triggers: BUG: using smp_processor_id() in preemptible [00000000] code: caller is hotplug_cpu__broadcast_tick_pull+0x1c/0xc0 Move it to the actual usage site which is in a non-preemptible region. Fixes: f7d43dd ("tick/broadcast: Make takeover of broadcast hrtimer reliable") Reported-by: David Wang <00107082@163.com> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Tested-by: Yu Liao <liaoyu15@huawei.com> Cc: stable@vger.kernel.org Link: https://lore.kernel.org/all/87ttg56ers.ffs@tglx
1 parent 8400291 commit 6881e75

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

kernel/time/tick-broadcast.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1141,7 +1141,6 @@ void tick_broadcast_switch_to_oneshot(void)
11411141
#ifdef CONFIG_HOTPLUG_CPU
11421142
void hotplug_cpu__broadcast_tick_pull(int deadcpu)
11431143
{
1144-
struct tick_device *td = this_cpu_ptr(&tick_cpu_device);
11451144
struct clock_event_device *bc;
11461145
unsigned long flags;
11471146

@@ -1167,6 +1166,8 @@ void hotplug_cpu__broadcast_tick_pull(int deadcpu)
11671166
* device to avoid the starvation.
11681167
*/
11691168
if (tick_check_broadcast_expired()) {
1169+
struct tick_device *td = this_cpu_ptr(&tick_cpu_device);
1170+
11701171
cpumask_clear_cpu(smp_processor_id(), tick_broadcast_force_mask);
11711172
tick_program_event(td->evtdev->next_event, 1);
11721173
}

0 commit comments

Comments
 (0)