tick: Emphasize tck_broadcast_on_off could only be called for host cpu
RFC PATCH 1/1 tick: Emphasize tck_broadcast_on_off could only be called for host cpu
With current tick_do_broadcast_on_off() and tick_broadcast_on_off(), it only cares host cpu, and doesn't really support to make the on/off for another target CPU as it seems to be. So remove the unneeded online check and add a WARN to notify user who doesn't know this new usage model.
Next step should be to remove those cases that sends the BROADCAST ON/OFF/FORCE msg on one cpu for another CPU, if this patch is reviewed to be ok.
--- kernel/time/tick-broadcast.c | 15 +-------------- kernel/time/tick-common.c | 6 +++++- kernel/time/tick-internal.h | 4 ++-- 3 files changed, 8 insertions(+), 17 deletions(-)
kernel/time/tick-broadcast.c +1 -14
@@ -204,7 +204,7 @@ static void tick_handle_periodic_broadcast(struct clock_event_device *dev)* Powerstate information: The system enters/leaves a state, where * affected devices might stop */ -static void tick_do_broadcast_on_off (unsigned long *reason) +void tick_broadcast_on_off (unsigned long *reason) {struct clock_event_device *bc, *dev;struct tick_device *td;
@@ -266,19 +266,6 @@ out: }/* -* Powerstate information: The system enters/leaves a state, where -* affected devices might stop. -*/ -void tick_broadcast_on_off (unsigned long reason,int *oncpu) -{ -if (!cpumask_test_cpu (*oncpu, cpu_online_mask)) -printk (KERN_ERR "tick-broadcast: ignoring broadcast for " -"offline CPU #%d\n" , *oncpu); -else -tick_do_broadcast_on_off (&reason); -} - -/* * Set the periodic handler depending on broadcast on/off */ void tick_set_periodic_handler (struct clock_event_device *dev,int broadcast)
kernel/time/tick-common.c +5 -1
@@ -362,6 +362,8 @@ static void tick_resume(void)static int tick_notify (struct notifier_block *nb,unsigned long reason,void *dev) { +int *cpu = dev; +switch (reason) {case CLOCK_EVT_NOTIFY_ADD :
@@ -370,7 +372,9 @@ static int tick_notify(struct notifier_block *nb, unsigned long reason,case CLOCK_EVT_NOTIFY_BROADCAST_ON :case CLOCK_EVT_NOTIFY_BROADCAST_OFF :case CLOCK_EVT_NOTIFY_BROADCAST_FORCE : -tick_broadcast_on_off (reason, dev); +WARN ((*cpu !=smp_processor_id ()), +"BROADCAST ON/OFF/FORCE should only be fired for host CPU\n" ); +tick_broadcast_on_off (&reason);break ;case CLOCK_EVT_NOTIFY_BROADCAST_ENTER :
kernel/time/tick-internal.h +2 -2
@@ -90,7 +90,7 @@ static inline bool tick_broadcast_oneshot_available(void) { return false; }extern int tick_device_uses_broadcast (struct clock_event_device *dev,int cpu);extern int tick_check_broadcast_device (struct clock_event_device *dev);extern int tick_is_broadcast_device (struct clock_event_device *dev); -extern void tick_broadcast_on_off (unsigned long reason,int *oncpu); +extern void tick_broadcast_on_off (unsigned long *reason);extern void tick_shutdown_broadcast (unsigned int *cpup);extern void tick_suspend_broadcast (void );extern int tick_resume_broadcast (void );
@@ -115,7 +115,7 @@ static inline int tick_device_uses_broadcast(struct clock_event_device *dev,return 0 ; }static inline void tick_do_periodic_broadcast (struct clock_event_device *d) { } -static inline void tick_broadcast_on_off (unsigned long reason,int *oncpu) { } +static inline void tick_broadcast_on_off (unsigned long *reason) { }static inline void tick_shutdown_broadcast (unsigned int *cpup) { }static inline void tick_suspend_broadcast (void ) { }static inline int tick_resume_broadcast (void ) {return 0 ; }
Signature · 1 line
1.7.1
Quoted 90 lines · On Tue, 31 Jul 2012 15:57:21 +0800 Feng Tang <[email protected]> wrote:
With current
tick_do_broadcast_on_off()andtick_broadcast_on_off(), it only cares host cpu, and doesn't really support to make the on/off for another target CPU as it seems to be. So remove the unneeded online check and add a WARN to notify user who doesn't know this new usage model.Next step should be to remove those cases that sends the BROADCAST ON/OFF/FORCE msg on one cpu for another CPU, if this patch is reviewed to be ok.
Signed-off-by Feng Tang <[email protected]>Cc Suresh Siddha <[email protected]>Cc Thomas Gleixner <[email protected]>--- kernel/time/tick-broadcast.c | 15 +-------------- kernel/time/tick-common.c | 6 +++++- kernel/time/tick-internal.h | 4 ++-- 3 files changed, 8 insertions(+), 17 deletions(-)kernel/time/tick-broadcast.c +1
-14@@ -204,7 +204,7 @@ static void tick_handle_periodic_broadcast(struct clock_event_device *dev)* Powerstate information: The system enters/leaves a state, where * affected devices might stop */ -static void tick_do_broadcast_on_off (unsigned long *reason) +void tick_broadcast_on_off (unsigned long *reason) {struct clock_event_device *bc, *dev;struct tick_device *td;@@ -266,19 +266,6 @@ out: }/* -* Powerstate information: The system enters/leaves a state, where -* affected devices might stop. -*/ -void tick_broadcast_on_off (unsigned long reason,int *oncpu) -{ -if (!cpumask_test_cpu (*oncpu, cpu_online_mask)) -printk (KERN_ERR "tick-broadcast: ignoring broadcast for " -"offline CPU #%d\n" , *oncpu); -else -tick_do_broadcast_on_off (&reason); -} - -/* * Set the periodic handler depending on broadcast on/off */ void tick_set_periodic_handler (struct clock_event_device *dev,int broadcast)kernel/time/tick-common.c +5
-1@@ -362,6 +362,8 @@ static void tick_resume(void)static int tick_notify (struct notifier_block *nb,unsigned long reason,void *dev) { +int *cpu = dev; +switch (reason) {case CLOCK_EVT_NOTIFY_ADD :@@ -370,7 +372,9 @@ static int tick_notify(struct notifier_block *nb, unsigned long reason,case CLOCK_EVT_NOTIFY_BROADCAST_ON :case CLOCK_EVT_NOTIFY_BROADCAST_OFF :case CLOCK_EVT_NOTIFY_BROADCAST_FORCE : -tick_broadcast_on_off (reason, dev); +WARN ((*cpu !=smp_processor_id ()), +"BROADCAST ON/OFF/FORCE should only be fired for host CPU\n" ); +tick_broadcast_on_off (&reason);break ;case CLOCK_EVT_NOTIFY_BROADCAST_ENTER :kernel/time/tick-internal.h +1
-1@@ -90,7 +90,7 @@ static inline bool tick_broadcast_oneshot_available(void) { return false; }extern int tick_device_uses_broadcast (struct clock_event_device *dev,int cpu);extern int tick_check_broadcast_device (struct clock_event_device *dev);extern int tick_is_broadcast_device (struct clock_event_device *dev); -extern void tick_broadcast_on_off (unsigned long reason,int *oncpu); +extern void tick_broadcast_on_off (unsigned long *reason);extern void tick_shutdown_broadcast (unsigned int *cpup);extern void tick_suspend_broadcast (void );extern int tick_resume_broadcast (void );
kernel/time/tick-internal.h static inline int tick_device_uses_broadcast(struct clock_event_device *dev, · line 121
Quoted 8 lines
kernel/time/tick-internal.h +1
-1@@ -115,7 +115,7 @@ static inline int tick_device_uses_broadcast(struct clock_event_device *dev,return 0 ; }static inline void tick_do_periodic_broadcast (struct clock_event_device *d) { } -static inline void tick_broadcast_on_off (unsigned long reason,int *oncpu) { } +static inline void tick_broadcast_on_off (unsigned long *reason) { }static inline void tick_shutdown_broadcast (unsigned int *cpup) { }static inline void tick_suspend_broadcast (void ) { }static inline int tick_resume_broadcast (void ) {return 0 ; }
Ping for comments.
Thanks,
Feng