Skip to content

Commit 152e9b8

Browse files
author
Martin Schwidefsky
committed
s390/vtime: steal time exponential moving average
To be able to judge the current overcommitment ratio for a CPU add a lowcore field with the exponential moving average of the steal time. The average is updated every tick. Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
1 parent 01396a3 commit 152e9b8

File tree

3 files changed

+45
-38
lines changed

3 files changed

+45
-38
lines changed

arch/s390/include/asm/lowcore.h

Lines changed: 31 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -91,52 +91,53 @@ struct lowcore {
9191
__u64 hardirq_timer; /* 0x02e8 */
9292
__u64 softirq_timer; /* 0x02f0 */
9393
__u64 steal_timer; /* 0x02f8 */
94-
__u64 last_update_timer; /* 0x0300 */
95-
__u64 last_update_clock; /* 0x0308 */
96-
__u64 int_clock; /* 0x0310 */
97-
__u64 mcck_clock; /* 0x0318 */
98-
__u64 clock_comparator; /* 0x0320 */
99-
__u64 boot_clock[2]; /* 0x0328 */
94+
__u64 avg_steal_timer; /* 0x0300 */
95+
__u64 last_update_timer; /* 0x0308 */
96+
__u64 last_update_clock; /* 0x0310 */
97+
__u64 int_clock; /* 0x0318*/
98+
__u64 mcck_clock; /* 0x0320 */
99+
__u64 clock_comparator; /* 0x0328 */
100+
__u64 boot_clock[2]; /* 0x0330 */
100101

101102
/* Current process. */
102-
__u64 current_task; /* 0x0338 */
103-
__u64 kernel_stack; /* 0x0340 */
103+
__u64 current_task; /* 0x0340 */
104+
__u64 kernel_stack; /* 0x0348 */
104105

105106
/* Interrupt, DAT-off and restartstack. */
106-
__u64 async_stack; /* 0x0348 */
107-
__u64 nodat_stack; /* 0x0350 */
108-
__u64 restart_stack; /* 0x0358 */
107+
__u64 async_stack; /* 0x0350 */
108+
__u64 nodat_stack; /* 0x0358 */
109+
__u64 restart_stack; /* 0x0360 */
109110

110111
/* Restart function and parameter. */
111-
__u64 restart_fn; /* 0x0360 */
112-
__u64 restart_data; /* 0x0368 */
113-
__u64 restart_source; /* 0x0370 */
112+
__u64 restart_fn; /* 0x0368 */
113+
__u64 restart_data; /* 0x0370 */
114+
__u64 restart_source; /* 0x0378 */
114115

115116
/* Address space pointer. */
116-
__u64 kernel_asce; /* 0x0378 */
117-
__u64 user_asce; /* 0x0380 */
118-
__u64 vdso_asce; /* 0x0388 */
117+
__u64 kernel_asce; /* 0x0380 */
118+
__u64 user_asce; /* 0x0388 */
119+
__u64 vdso_asce; /* 0x0390 */
119120

120121
/*
121122
* The lpp and current_pid fields form a
122123
* 64-bit value that is set as program
123124
* parameter with the LPP instruction.
124125
*/
125-
__u32 lpp; /* 0x0390 */
126-
__u32 current_pid; /* 0x0394 */
126+
__u32 lpp; /* 0x0398 */
127+
__u32 current_pid; /* 0x039c */
127128

128129
/* SMP info area */
129-
__u32 cpu_nr; /* 0x0398 */
130-
__u32 softirq_pending; /* 0x039c */
131-
__u32 preempt_count; /* 0x03a0 */
132-
__u32 spinlock_lockval; /* 0x03a4 */
133-
__u32 spinlock_index; /* 0x03a8 */
134-
__u32 fpu_flags; /* 0x03ac */
135-
__u64 percpu_offset; /* 0x03b0 */
136-
__u64 vdso_per_cpu_data; /* 0x03b8 */
137-
__u64 machine_flags; /* 0x03c0 */
138-
__u64 gmap; /* 0x03c8 */
139-
__u8 pad_0x03d0[0x0400-0x03d0]; /* 0x03d0 */
130+
__u32 cpu_nr; /* 0x03a0 */
131+
__u32 softirq_pending; /* 0x03a4 */
132+
__u32 preempt_count; /* 0x03a8 */
133+
__u32 spinlock_lockval; /* 0x03ac */
134+
__u32 spinlock_index; /* 0x03b0 */
135+
__u32 fpu_flags; /* 0x03b4 */
136+
__u64 percpu_offset; /* 0x03b8 */
137+
__u64 vdso_per_cpu_data; /* 0x03c0 */
138+
__u64 machine_flags; /* 0x03c8 */
139+
__u64 gmap; /* 0x03d0 */
140+
__u8 pad_0x03d8[0x0400-0x03d8]; /* 0x03d8 */
140141

141142
/* br %r1 trampoline */
142143
__u16 br_r1_trampoline; /* 0x0400 */

arch/s390/kernel/smp.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,8 @@ static void pcpu_prepare_secondary(struct pcpu *pcpu, int cpu)
266266
lc->percpu_offset = __per_cpu_offset[cpu];
267267
lc->kernel_asce = S390_lowcore.kernel_asce;
268268
lc->machine_flags = S390_lowcore.machine_flags;
269-
lc->user_timer = lc->system_timer = lc->steal_timer = 0;
269+
lc->user_timer = lc->system_timer =
270+
lc->steal_timer = lc->avg_steal_timer = 0;
270271
__ctl_store(lc->cregs_save_area, 0, 15);
271272
save_access_regs((unsigned int *) lc->access_regs_save_area);
272273
memcpy(lc->stfle_fac_list, S390_lowcore.stfle_fac_list,

arch/s390/kernel/vtime.c

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ static void account_system_index_scaled(struct task_struct *p, u64 cputime,
124124
*/
125125
static int do_account_vtime(struct task_struct *tsk)
126126
{
127-
u64 timer, clock, user, guest, system, hardirq, softirq, steal;
127+
u64 timer, clock, user, guest, system, hardirq, softirq;
128128

129129
timer = S390_lowcore.last_update_timer;
130130
clock = S390_lowcore.last_update_clock;
@@ -182,12 +182,6 @@ static int do_account_vtime(struct task_struct *tsk)
182182
if (softirq)
183183
account_system_index_scaled(tsk, softirq, CPUTIME_SOFTIRQ);
184184

185-
steal = S390_lowcore.steal_timer;
186-
if ((s64) steal > 0) {
187-
S390_lowcore.steal_timer = 0;
188-
account_steal_time(cputime_to_nsecs(steal));
189-
}
190-
191185
return virt_timer_forward(user + guest + system + hardirq + softirq);
192186
}
193187

@@ -213,8 +207,19 @@ void vtime_task_switch(struct task_struct *prev)
213207
*/
214208
void vtime_flush(struct task_struct *tsk)
215209
{
210+
u64 steal, avg_steal;
211+
216212
if (do_account_vtime(tsk))
217213
virt_timer_expire();
214+
215+
steal = S390_lowcore.steal_timer;
216+
avg_steal = S390_lowcore.avg_steal_timer / 2;
217+
if ((s64) steal > 0) {
218+
S390_lowcore.steal_timer = 0;
219+
account_steal_time(steal);
220+
avg_steal += steal;
221+
}
222+
S390_lowcore.avg_steal_timer = avg_steal;
218223
}
219224

220225
/*

0 commit comments

Comments
 (0)