]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
s390/vtime: limit MT scaling value updates
authorMartin Schwidefsky <schwidefsky@de.ibm.com>
Mon, 3 Aug 2015 14:16:40 +0000 (16:16 +0200)
committerMartin Schwidefsky <schwidefsky@de.ibm.com>
Tue, 4 Aug 2015 12:26:17 +0000 (14:26 +0200)
The MT scaling values are updated on each calll to do_account_vtime.
This function is called for each HZ interrupt and for each context
switch. Context switch can happen often, the STCCTM instruction
on this path is noticeable. Limit the updates to once per jiffy.

Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
arch/s390/kernel/vtime.c

index e53d3595a7c8c1a54400d5fb3e984004cd864219..b9ce650e9e992065aa611f5bc654f59b5b8bf40f 100644 (file)
@@ -28,6 +28,7 @@ static atomic64_t virt_timer_elapsed;
 static DEFINE_PER_CPU(u64, mt_cycles[32]);
 static DEFINE_PER_CPU(u64, mt_scaling_mult) = { 1 };
 static DEFINE_PER_CPU(u64, mt_scaling_div) = { 1 };
+static DEFINE_PER_CPU(u64, mt_scaling_jiffies);
 
 static inline u64 get_vtimer(void)
 {
@@ -85,7 +86,8 @@ static int do_account_vtime(struct task_struct *tsk, int hardirq_offset)
        S390_lowcore.steal_timer += S390_lowcore.last_update_clock - clock;
 
        /* Do MT utilization calculation */
-       if (smp_cpu_mtid) {
+       if (smp_cpu_mtid &&
+           time_after64(jiffies_64, __this_cpu_read(mt_scaling_jiffies))) {
                u64 cycles_new[32], *cycles_old;
                u64 delta, mult, div;
 
@@ -105,6 +107,7 @@ static int do_account_vtime(struct task_struct *tsk, int hardirq_offset)
                                       sizeof(u64) * (smp_cpu_mtid + 1));
                        }
                }
+               __this_cpu_write(mt_scaling_jiffies, jiffies_64);
        }
 
        user = S390_lowcore.user_timer - ti->user_timer;
@@ -376,4 +379,11 @@ void vtime_init(void)
 {
        /* set initial cpu timer */
        set_vtimer(VTIMER_MAX_SLICE);
+       /* Setup initial MT scaling values */
+       if (smp_cpu_mtid) {
+               __this_cpu_write(mt_scaling_jiffies, jiffies);
+               __this_cpu_write(mt_scaling_mult, 1);
+               __this_cpu_write(mt_scaling_div, 1);
+               stcctm5(smp_cpu_mtid + 1, this_cpu_ptr(mt_cycles));
+       }
 }