Skip to contentSkip to conversation

timers: Remove duplicate setting of new_base in __mod_timer()

RFC In review Simon Horman 2 participants 3 messages Dec 16, 2009 – Dec 17, 2009

lore
Share & tools
lore
#0 lore raw

RFC 1/1 timers: Remove duplicate setting of new_base in __mod_timer()

Hi,

I am wondering if the first line of the following snippet of __mod_timer() can be removed as new_base always seems to be reset.

Alternatively perhaps smp_processor_id() and per_cpu() could be moved to inside the #if and the call to __get_cpu_var() moved to inside #else ?

        new_base = __get_cpu_var(tvec_bases);

        cpu = smp_processor_id();
#if defined(CONFIG_NO_HZ) && defined(CONFIG_SMP)
        if (!pinned && get_sysctl_timer_migration() && idle_cpu(cpu)) {
                int preferred_cpu = get_nohz_load_balancer();
                        
                if (preferred_cpu >= 0)
                        cpu = preferred_cpu;
        }
#endif
        new_base = per_cpu(tvec_bases, cpu);
kernel/timer.c +0 -2
Index: linux-2.6/kernel/timer.c
===================================================================
@@ -656,8 +656,6 @@ __mod_timer(struct timer_list *timer, un
 
 	debug_activate(timer, expires);
 
-	new_base = __get_cpu_var(tvec_bases);
-
 	cpu = smp_processor_id();
 
 #if defined(CONFIG_NO_HZ) && defined(CONFIG_SMP)
#1 lore raw

B1;2005;0cSimon,

Quoted 2 lines · Simon Horman

I am wondering if the first line of the following snippet of __mod_timer() can be removed as new_base always seems to be reset.

Good catch.

Quoted 3 lines

Alternatively perhaps smp_processor_id() and per_cpu() could be moved to inside the #if and the call to __get_cpu_var() moved to inside #else ?

Nah, __get_cpu_var does a smp_processor_id() anyway. Removing that first new_base assignment is the right thing to do.

Quoted 21 lines
        new_base = __get_cpu_var(tvec_bases);

        cpu = smp_processor_id();
#if defined(CONFIG_NO_HZ) && defined(CONFIG_SMP)
        if (!pinned && get_sysctl_timer_migration() && idle_cpu(cpu)) {
                int preferred_cpu = get_nohz_load_balancer();
                        
                if (preferred_cpu >= 0)
                        cpu = preferred_cpu;
        }
#endif
        new_base = per_cpu(tvec_bases, cpu);

Index: linux-2.6/kernel/timer.c
===================================================================

kernel/timer.c __mod_timer(struct timer_list *timer, un · line 661

Quoted 8 lines
kernel/timer.c +0 -2
@@ -656,8 +656,6 @@ __mod_timer(struct timer_list *timer, un
 
 	debug_activate(timer, expires);
 
-	new_base = __get_cpu_var(tvec_bases);
-
 	cpu = smp_processor_id();
 
 #if defined(CONFIG_NO_HZ) && defined(CONFIG_SMP)

Could you please resend the patch with a proper change log ?

Thanks,

tglx

#2 lore raw
Quoted 40 lines · Thomas Gleixner

B1;2005;0cSimon,

Quoted 2 lines · Simon Horman

I am wondering if the first line of the following snippet of __mod_timer() can be removed as new_base always seems to be reset.

Good catch.

Quoted 3 lines

Alternatively perhaps smp_processor_id() and per_cpu() could be moved to inside the #if and the call to __get_cpu_var() moved to inside #else ?

Nah, __get_cpu_var does a smp_processor_id() anyway. Removing that first new_base assignment is the right thing to do.

Quoted 24 lines
        new_base = __get_cpu_var(tvec_bases);

        cpu = smp_processor_id();
#if defined(CONFIG_NO_HZ) && defined(CONFIG_SMP)
        if (!pinned && get_sysctl_timer_migration() && idle_cpu(cpu)) {
                int preferred_cpu = get_nohz_load_balancer();
                        
                if (preferred_cpu >= 0)
                        cpu = preferred_cpu;
        }
#endif
        new_base = per_cpu(tvec_bases, cpu);

Index: linux-2.6/kernel/timer.c
===================================================================

kernel/timer.c +0 -0
@@ -656,8 +656,6 @@ __mod_timer(struct timer_list *timer, un
 
 	debug_activate(timer, expires);
 
Quoted 7 lines

kernel/timer.c __mod_timer(struct timer_list *timer, un · line 661

Quoted 5 lines
kernel/timer.c +0 -2
-	new_base = __get_cpu_var(tvec_bases);
-
 	cpu = smp_processor_id();
 
 #if defined(CONFIG_NO_HZ) && defined(CONFIG_SMP)

Could you please resend the patch with a proper change log ?

Will do.