Skip to content

Commit 257c14e

Browse files
hcahcaVasily Gorbik
authored andcommitted
s390/idle: Inline update_timer_idle()
Inline update_timer_idle() again to avoid an extra function call. This way the generated code is close to old assembler version again. Reviewed-by: Sven Schnelle <svens@linux.ibm.com> Signed-off-by: Heiko Carstens <hca@linux.ibm.com> Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
1 parent 00d8b03 commit 257c14e

4 files changed

Lines changed: 38 additions & 35 deletions

File tree

arch/s390/include/asm/idle.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,11 @@ struct s390_idle_data {
1919
unsigned long mt_cycles_enter[8];
2020
};
2121

22+
DECLARE_PER_CPU(struct s390_idle_data, s390_idle);
23+
2224
extern struct device_attribute dev_attr_idle_count;
2325
extern struct device_attribute dev_attr_idle_time_us;
2426

2527
void psw_idle(struct s390_idle_data *data, unsigned long psw_mask);
26-
void update_timer_idle(void);
2728

2829
#endif /* _S390_IDLE_H */

arch/s390/include/asm/vtime.h

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22
#ifndef _S390_VTIME_H
33
#define _S390_VTIME_H
44

5+
#include <asm/lowcore.h>
6+
#include <asm/cpu_mf.h>
7+
#include <asm/idle.h>
8+
9+
DECLARE_PER_CPU(u64, mt_cycles[8]);
10+
511
static inline void update_timer_sys(void)
612
{
713
struct lowcore *lc = get_lowcore();
@@ -20,4 +26,32 @@ static inline void update_timer_mcck(void)
2026
lc->last_update_timer = lc->mcck_enter_timer;
2127
}
2228

29+
static inline void update_timer_idle(void)
30+
{
31+
struct s390_idle_data *idle = this_cpu_ptr(&s390_idle);
32+
struct lowcore *lc = get_lowcore();
33+
u64 cycles_new[8];
34+
int i, mtid;
35+
36+
mtid = smp_cpu_mtid;
37+
if (mtid) {
38+
stcctm(MT_DIAG, mtid, cycles_new);
39+
for (i = 0; i < mtid; i++)
40+
__this_cpu_add(mt_cycles[i], cycles_new[i] - idle->mt_cycles_enter[i]);
41+
}
42+
/*
43+
* This is a bit subtle: Forward last_update_clock so it excludes idle
44+
* time. For correct steal time calculation in do_account_vtime() add
45+
* passed wall time before idle_enter to steal_timer:
46+
* During the passed wall time before idle_enter CPU time may have
47+
* been accounted to system, hardirq, softirq, etc. lowcore fields.
48+
* The accounted CPU times will be subtracted again from steal_timer
49+
* when accumulated steal time is calculated in do_account_vtime().
50+
*/
51+
lc->steal_timer += idle->clock_idle_enter - lc->last_update_clock;
52+
lc->last_update_clock = lc->int_clock;
53+
lc->system_timer += lc->last_update_timer - idle->timer_idle_enter;
54+
lc->last_update_timer = lc->sys_enter_timer;
55+
}
56+
2357
#endif /* _S390_VTIME_H */

arch/s390/kernel/entry.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,6 @@ long sys_s390_pci_mmio_write(unsigned long, const void __user *, size_t);
5656
long sys_s390_pci_mmio_read(unsigned long, void __user *, size_t);
5757
long sys_s390_sthyi(unsigned long function_code, void __user *buffer, u64 __user *return_code, unsigned long flags);
5858

59-
DECLARE_PER_CPU(u64, mt_cycles[8]);
60-
6159
unsigned long stack_alloc(void);
6260
void stack_free(unsigned long stack);
6361

arch/s390/kernel/idle.c

Lines changed: 2 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -15,41 +15,11 @@
1515
#include <trace/events/power.h>
1616
#include <asm/cpu_mf.h>
1717
#include <asm/cputime.h>
18+
#include <asm/idle.h>
1819
#include <asm/nmi.h>
1920
#include <asm/smp.h>
20-
#include "entry.h"
2121

22-
static DEFINE_PER_CPU(struct s390_idle_data, s390_idle);
23-
24-
void update_timer_idle(void)
25-
{
26-
struct s390_idle_data *idle = this_cpu_ptr(&s390_idle);
27-
struct lowcore *lc = get_lowcore();
28-
u64 cycles_new[8];
29-
int i, mtid;
30-
31-
mtid = smp_cpu_mtid;
32-
if (mtid) {
33-
stcctm(MT_DIAG, mtid, cycles_new);
34-
for (i = 0; i < mtid; i++)
35-
__this_cpu_add(mt_cycles[i], cycles_new[i] - idle->mt_cycles_enter[i]);
36-
}
37-
38-
/*
39-
* This is a bit subtle: Forward last_update_clock so it excludes idle
40-
* time. For correct steal time calculation in do_account_vtime() add
41-
* passed wall time before idle_enter to steal_timer:
42-
* During the passed wall time before idle_enter CPU time may have
43-
* been accounted to system, hardirq, softirq, etc. lowcore fields.
44-
* The accounted CPU times will be subtracted again from steal_timer
45-
* when accumulated steal time is calculated in do_account_vtime().
46-
*/
47-
lc->steal_timer += idle->clock_idle_enter - lc->last_update_clock;
48-
lc->last_update_clock = lc->int_clock;
49-
50-
lc->system_timer += lc->last_update_timer - idle->timer_idle_enter;
51-
lc->last_update_timer = lc->sys_enter_timer;
52-
}
22+
DEFINE_PER_CPU(struct s390_idle_data, s390_idle);
5323

5424
void account_idle_time_irq(void)
5525
{

0 commit comments

Comments
 (0)