Skip to content

Commit

Permalink
parisc: Find a new timesync master if current CPU is removed
Browse files Browse the repository at this point in the history
When CPU hotplugging is enabled, the user may want to remove the
current CPU which is providing the timer ticks. If this happens
we need to find a new timesync master.

Signed-off-by: Helge Deller <deller@gmx.de>
  • Loading branch information
hdeller committed Mar 29, 2022
1 parent ca45ec3 commit 1afde47
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
1 change: 1 addition & 0 deletions arch/parisc/include/asm/processor.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ struct cpuinfo_parisc {

extern struct system_cpuinfo_parisc boot_cpu_data;
DECLARE_PER_CPU(struct cpuinfo_parisc, cpu_data);
extern int time_keeper_id; /* CPU used for timekeeping */

#define CPU_HVERSION ((boot_cpu_data.hversion >> 4) & 0x0FFF)

Expand Down
6 changes: 6 additions & 0 deletions arch/parisc/kernel/smp.c
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,12 @@ int __cpu_disable(void)
*/
set_cpu_online(cpu, false);

/* Find a new timesync master */
if (cpu == time_keeper_id) {
time_keeper_id = cpumask_first(cpu_online_mask);
pr_info("CPU %d is now promoted to time-keeper master\n", time_keeper_id);
}

disable_percpu_irq(IPI_IRQ);

irq_migrate_all_off_this_cpu();
Expand Down
4 changes: 3 additions & 1 deletion arch/parisc/kernel/time.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@

#include <linux/timex.h>

int time_keeper_id __read_mostly; /* CPU used for timekeeping. */

static unsigned long clocktick __ro_after_init; /* timer cycles per tick */

/*
Expand Down Expand Up @@ -84,7 +86,7 @@ irqreturn_t __irq_entry timer_interrupt(int irq, void *dev_id)
cpuinfo->it_value = next_tick;

/* Go do system house keeping. */
if (cpu != 0)
if (IS_ENABLED(CONFIG_SMP) && (cpu != time_keeper_id))
ticks_elapsed = 0;
legacy_timer_tick(ticks_elapsed);

Expand Down

0 comments on commit 1afde47

Please sign in to comment.