Skip to content

Commit 77a0594

Browse files
committed
Merge branch 'sched-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull scheduler updates from Ingo Molnar: "The biggest changes in this cycle were: - Make kcpustat vtime aware (Frederic Weisbecker) - Rework the CFS load_balance() logic (Vincent Guittot) - Misc cleanups, smaller enhancements, fixes. The load-balancing rework is the most intrusive change: it replaces the old heuristics that have become less meaningful after the introduction of the PELT metrics, with a grounds-up load-balancing algorithm. As such it's not really an iterative series, but replaces the old load-balancing logic with the new one. We hope there are no performance regressions left - but statistically it's highly probable that there *is* going to be some workload that is hurting from these chnages. If so then we'd prefer to have a look at that workload and fix its scheduling, instead of reverting the changes" * 'sched-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: (46 commits) rackmeter: Use vtime aware kcpustat accessor leds: Use all-in-one vtime aware kcpustat accessor cpufreq: Use vtime aware kcpustat accessors for user time procfs: Use all-in-one vtime aware kcpustat accessor sched/vtime: Bring up complete kcpustat accessor sched/cputime: Support other fields on kcpustat_field() sched/cpufreq: Move the cfs_rq_util_change() call to cpufreq_update_util() sched/fair: Add comments for group_type and balancing at SD_NUMA level sched/fair: Fix rework of find_idlest_group() sched/uclamp: Fix overzealous type replacement sched/Kconfig: Fix spelling mistake in user-visible help text sched/core: Further clarify sched_class::set_next_task() sched/fair: Use mul_u32_u32() sched/core: Simplify sched_class::pick_next_task() sched/core: Optimize pick_next_task() sched/core: Make pick_next_task_idle() more consistent sched/fair: Better document newidle_balance() leds: Use vtime aware kcpustat accessor to fetch CPUTIME_SYSTEM cpufreq: Use vtime aware kcpustat accessor to fetch CPUTIME_SYSTEM procfs: Use vtime aware kcpustat accessor to fetch CPUTIME_SYSTEM ...
2 parents 3f59dbc + de881a3 commit 77a0594

File tree

28 files changed

+1331
-755
lines changed

28 files changed

+1331
-755
lines changed

arch/ia64/kernel/time.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ static __u64 vtime_delta(struct task_struct *tsk)
132132
return delta_stime;
133133
}
134134

135-
void vtime_account_system(struct task_struct *tsk)
135+
void vtime_account_kernel(struct task_struct *tsk)
136136
{
137137
struct thread_info *ti = task_thread_info(tsk);
138138
__u64 stime = vtime_delta(tsk);
@@ -146,7 +146,7 @@ void vtime_account_system(struct task_struct *tsk)
146146
else
147147
ti->stime += stime;
148148
}
149-
EXPORT_SYMBOL_GPL(vtime_account_system);
149+
EXPORT_SYMBOL_GPL(vtime_account_kernel);
150150

151151
void vtime_account_idle(struct task_struct *tsk)
152152
{

arch/powerpc/kernel/time.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ static unsigned long vtime_delta(struct task_struct *tsk,
338338
return stime;
339339
}
340340

341-
void vtime_account_system(struct task_struct *tsk)
341+
void vtime_account_kernel(struct task_struct *tsk)
342342
{
343343
unsigned long stime, stime_scaled, steal_time;
344344
struct cpu_accounting_data *acct = get_accounting(tsk);
@@ -366,7 +366,7 @@ void vtime_account_system(struct task_struct *tsk)
366366
#endif
367367
}
368368
}
369-
EXPORT_SYMBOL_GPL(vtime_account_system);
369+
EXPORT_SYMBOL_GPL(vtime_account_kernel);
370370

371371
void vtime_account_idle(struct task_struct *tsk)
372372
{
@@ -395,7 +395,7 @@ static void vtime_flush_scaled(struct task_struct *tsk,
395395
/*
396396
* Account the whole cputime accumulated in the paca
397397
* Must be called with interrupts disabled.
398-
* Assumes that vtime_account_system/idle() has been called
398+
* Assumes that vtime_account_kernel/idle() has been called
399399
* recently (i.e. since the last entry from usermode) so that
400400
* get_paca()->user_time_scaled is up to date.
401401
*/

arch/s390/kernel/vtime.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -247,9 +247,9 @@ void vtime_account_irq_enter(struct task_struct *tsk)
247247
}
248248
EXPORT_SYMBOL_GPL(vtime_account_irq_enter);
249249

250-
void vtime_account_system(struct task_struct *tsk)
250+
void vtime_account_kernel(struct task_struct *tsk)
251251
__attribute__((alias("vtime_account_irq_enter")));
252-
EXPORT_SYMBOL_GPL(vtime_account_system);
252+
EXPORT_SYMBOL_GPL(vtime_account_kernel);
253253

254254
/*
255255
* Sorted add to a list. List is linear searched until first bigger

arch/x86/entry/calling.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ For 32-bit we have the following conventions - kernel is built with
354354
.macro CALL_enter_from_user_mode
355355
#ifdef CONFIG_CONTEXT_TRACKING
356356
#ifdef CONFIG_JUMP_LABEL
357-
STATIC_JUMP_IF_FALSE .Lafter_call_\@, context_tracking_enabled, def=0
357+
STATIC_JUMP_IF_FALSE .Lafter_call_\@, context_tracking_key, def=0
358358
#endif
359359
call enter_from_user_mode
360360
.Lafter_call_\@:

drivers/cpufreq/cpufreq.c

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -113,18 +113,21 @@ EXPORT_SYMBOL_GPL(get_governor_parent_kobj);
113113

114114
static inline u64 get_cpu_idle_time_jiffy(unsigned int cpu, u64 *wall)
115115
{
116-
u64 idle_time;
116+
struct kernel_cpustat kcpustat;
117117
u64 cur_wall_time;
118+
u64 idle_time;
118119
u64 busy_time;
119120

120121
cur_wall_time = jiffies64_to_nsecs(get_jiffies_64());
121122

122-
busy_time = kcpustat_cpu(cpu).cpustat[CPUTIME_USER];
123-
busy_time += kcpustat_cpu(cpu).cpustat[CPUTIME_SYSTEM];
124-
busy_time += kcpustat_cpu(cpu).cpustat[CPUTIME_IRQ];
125-
busy_time += kcpustat_cpu(cpu).cpustat[CPUTIME_SOFTIRQ];
126-
busy_time += kcpustat_cpu(cpu).cpustat[CPUTIME_STEAL];
127-
busy_time += kcpustat_cpu(cpu).cpustat[CPUTIME_NICE];
123+
kcpustat_cpu_fetch(&kcpustat, cpu);
124+
125+
busy_time = kcpustat.cpustat[CPUTIME_USER];
126+
busy_time += kcpustat.cpustat[CPUTIME_SYSTEM];
127+
busy_time += kcpustat.cpustat[CPUTIME_IRQ];
128+
busy_time += kcpustat.cpustat[CPUTIME_SOFTIRQ];
129+
busy_time += kcpustat.cpustat[CPUTIME_STEAL];
130+
busy_time += kcpustat.cpustat[CPUTIME_NICE];
128131

129132
idle_time = cur_wall_time - busy_time;
130133
if (wall)

drivers/cpufreq/cpufreq_governor.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ void gov_update_cpu_data(struct dbs_data *dbs_data)
105105
j_cdbs->prev_cpu_idle = get_cpu_idle_time(j, &j_cdbs->prev_update_time,
106106
dbs_data->io_is_busy);
107107
if (dbs_data->ignore_nice_load)
108-
j_cdbs->prev_cpu_nice = kcpustat_cpu(j).cpustat[CPUTIME_NICE];
108+
j_cdbs->prev_cpu_nice = kcpustat_field(&kcpustat_cpu(j), CPUTIME_NICE, j);
109109
}
110110
}
111111
}
@@ -149,7 +149,7 @@ unsigned int dbs_update(struct cpufreq_policy *policy)
149149
j_cdbs->prev_cpu_idle = cur_idle_time;
150150

151151
if (ignore_nice) {
152-
u64 cur_nice = kcpustat_cpu(j).cpustat[CPUTIME_NICE];
152+
u64 cur_nice = kcpustat_field(&kcpustat_cpu(j), CPUTIME_NICE, j);
153153

154154
idle_time += div_u64(cur_nice - j_cdbs->prev_cpu_nice, NSEC_PER_USEC);
155155
j_cdbs->prev_cpu_nice = cur_nice;
@@ -530,7 +530,7 @@ int cpufreq_dbs_governor_start(struct cpufreq_policy *policy)
530530
j_cdbs->prev_load = 0;
531531

532532
if (ignore_nice)
533-
j_cdbs->prev_cpu_nice = kcpustat_cpu(j).cpustat[CPUTIME_NICE];
533+
j_cdbs->prev_cpu_nice = kcpustat_field(&kcpustat_cpu(j), CPUTIME_NICE, j);
534534
}
535535

536536
gov->start(policy);

drivers/leds/trigger/ledtrig-activity.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,15 @@ static void led_activity_function(struct timer_list *t)
5757
curr_used = 0;
5858

5959
for_each_possible_cpu(i) {
60-
curr_used += kcpustat_cpu(i).cpustat[CPUTIME_USER]
61-
+ kcpustat_cpu(i).cpustat[CPUTIME_NICE]
62-
+ kcpustat_cpu(i).cpustat[CPUTIME_SYSTEM]
63-
+ kcpustat_cpu(i).cpustat[CPUTIME_SOFTIRQ]
64-
+ kcpustat_cpu(i).cpustat[CPUTIME_IRQ];
60+
struct kernel_cpustat kcpustat;
61+
62+
kcpustat_cpu_fetch(&kcpustat, i);
63+
64+
curr_used += kcpustat.cpustat[CPUTIME_USER]
65+
+ kcpustat.cpustat[CPUTIME_NICE]
66+
+ kcpustat.cpustat[CPUTIME_SYSTEM]
67+
+ kcpustat.cpustat[CPUTIME_SOFTIRQ]
68+
+ kcpustat.cpustat[CPUTIME_IRQ];
6569
cpus++;
6670
}
6771

drivers/macintosh/rack-meter.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,13 +81,14 @@ static int rackmeter_ignore_nice;
8181
*/
8282
static inline u64 get_cpu_idle_time(unsigned int cpu)
8383
{
84+
struct kernel_cpustat *kcpustat = &kcpustat_cpu(cpu);
8485
u64 retval;
8586

86-
retval = kcpustat_cpu(cpu).cpustat[CPUTIME_IDLE] +
87-
kcpustat_cpu(cpu).cpustat[CPUTIME_IOWAIT];
87+
retval = kcpustat->cpustat[CPUTIME_IDLE] +
88+
kcpustat->cpustat[CPUTIME_IOWAIT];
8889

8990
if (rackmeter_ignore_nice)
90-
retval += kcpustat_cpu(cpu).cpustat[CPUTIME_NICE];
91+
retval += kcpustat_field(kcpustat, CPUTIME_NICE, cpu);
9192

9293
return retval;
9394
}

fs/proc/stat.c

Lines changed: 31 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -120,20 +120,23 @@ static int show_stat(struct seq_file *p, void *v)
120120
getboottime64(&boottime);
121121

122122
for_each_possible_cpu(i) {
123-
struct kernel_cpustat *kcs = &kcpustat_cpu(i);
124-
125-
user += kcs->cpustat[CPUTIME_USER];
126-
nice += kcs->cpustat[CPUTIME_NICE];
127-
system += kcs->cpustat[CPUTIME_SYSTEM];
128-
idle += get_idle_time(kcs, i);
129-
iowait += get_iowait_time(kcs, i);
130-
irq += kcs->cpustat[CPUTIME_IRQ];
131-
softirq += kcs->cpustat[CPUTIME_SOFTIRQ];
132-
steal += kcs->cpustat[CPUTIME_STEAL];
133-
guest += kcs->cpustat[CPUTIME_GUEST];
134-
guest_nice += kcs->cpustat[CPUTIME_GUEST_NICE];
135-
sum += kstat_cpu_irqs_sum(i);
136-
sum += arch_irq_stat_cpu(i);
123+
struct kernel_cpustat kcpustat;
124+
u64 *cpustat = kcpustat.cpustat;
125+
126+
kcpustat_cpu_fetch(&kcpustat, i);
127+
128+
user += cpustat[CPUTIME_USER];
129+
nice += cpustat[CPUTIME_NICE];
130+
system += cpustat[CPUTIME_SYSTEM];
131+
idle += get_idle_time(&kcpustat, i);
132+
iowait += get_iowait_time(&kcpustat, i);
133+
irq += cpustat[CPUTIME_IRQ];
134+
softirq += cpustat[CPUTIME_SOFTIRQ];
135+
steal += cpustat[CPUTIME_STEAL];
136+
guest += cpustat[CPUTIME_GUEST];
137+
guest_nice += cpustat[CPUTIME_USER];
138+
sum += kstat_cpu_irqs_sum(i);
139+
sum += arch_irq_stat_cpu(i);
137140

138141
for (j = 0; j < NR_SOFTIRQS; j++) {
139142
unsigned int softirq_stat = kstat_softirqs_cpu(j, i);
@@ -157,19 +160,22 @@ static int show_stat(struct seq_file *p, void *v)
157160
seq_putc(p, '\n');
158161

159162
for_each_online_cpu(i) {
160-
struct kernel_cpustat *kcs = &kcpustat_cpu(i);
163+
struct kernel_cpustat kcpustat;
164+
u64 *cpustat = kcpustat.cpustat;
165+
166+
kcpustat_cpu_fetch(&kcpustat, i);
161167

162168
/* Copy values here to work around gcc-2.95.3, gcc-2.96 */
163-
user = kcs->cpustat[CPUTIME_USER];
164-
nice = kcs->cpustat[CPUTIME_NICE];
165-
system = kcs->cpustat[CPUTIME_SYSTEM];
166-
idle = get_idle_time(kcs, i);
167-
iowait = get_iowait_time(kcs, i);
168-
irq = kcs->cpustat[CPUTIME_IRQ];
169-
softirq = kcs->cpustat[CPUTIME_SOFTIRQ];
170-
steal = kcs->cpustat[CPUTIME_STEAL];
171-
guest = kcs->cpustat[CPUTIME_GUEST];
172-
guest_nice = kcs->cpustat[CPUTIME_GUEST_NICE];
169+
user = cpustat[CPUTIME_USER];
170+
nice = cpustat[CPUTIME_NICE];
171+
system = cpustat[CPUTIME_SYSTEM];
172+
idle = get_idle_time(&kcpustat, i);
173+
iowait = get_iowait_time(&kcpustat, i);
174+
irq = cpustat[CPUTIME_IRQ];
175+
softirq = cpustat[CPUTIME_SOFTIRQ];
176+
steal = cpustat[CPUTIME_STEAL];
177+
guest = cpustat[CPUTIME_GUEST];
178+
guest_nice = cpustat[CPUTIME_USER];
173179
seq_printf(p, "cpu%d", i);
174180
seq_put_decimal_ull(p, " ", nsec_to_clock_t(user));
175181
seq_put_decimal_ull(p, " ", nsec_to_clock_t(nice));

include/linux/context_tracking.h

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -22,34 +22,34 @@ extern void context_tracking_user_exit(void);
2222

2323
static inline void user_enter(void)
2424
{
25-
if (context_tracking_is_enabled())
25+
if (context_tracking_enabled())
2626
context_tracking_enter(CONTEXT_USER);
2727

2828
}
2929
static inline void user_exit(void)
3030
{
31-
if (context_tracking_is_enabled())
31+
if (context_tracking_enabled())
3232
context_tracking_exit(CONTEXT_USER);
3333
}
3434

3535
/* Called with interrupts disabled. */
3636
static inline void user_enter_irqoff(void)
3737
{
38-
if (context_tracking_is_enabled())
38+
if (context_tracking_enabled())
3939
__context_tracking_enter(CONTEXT_USER);
4040

4141
}
4242
static inline void user_exit_irqoff(void)
4343
{
44-
if (context_tracking_is_enabled())
44+
if (context_tracking_enabled())
4545
__context_tracking_exit(CONTEXT_USER);
4646
}
4747

4848
static inline enum ctx_state exception_enter(void)
4949
{
5050
enum ctx_state prev_ctx;
5151

52-
if (!context_tracking_is_enabled())
52+
if (!context_tracking_enabled())
5353
return 0;
5454

5555
prev_ctx = this_cpu_read(context_tracking.state);
@@ -61,7 +61,7 @@ static inline enum ctx_state exception_enter(void)
6161

6262
static inline void exception_exit(enum ctx_state prev_ctx)
6363
{
64-
if (context_tracking_is_enabled()) {
64+
if (context_tracking_enabled()) {
6565
if (prev_ctx != CONTEXT_KERNEL)
6666
context_tracking_enter(prev_ctx);
6767
}
@@ -77,7 +77,7 @@ static inline void exception_exit(enum ctx_state prev_ctx)
7777
*/
7878
static inline enum ctx_state ct_state(void)
7979
{
80-
return context_tracking_is_enabled() ?
80+
return context_tracking_enabled() ?
8181
this_cpu_read(context_tracking.state) : CONTEXT_DISABLED;
8282
}
8383
#else
@@ -90,7 +90,7 @@ static inline void exception_exit(enum ctx_state prev_ctx) { }
9090
static inline enum ctx_state ct_state(void) { return CONTEXT_DISABLED; }
9191
#endif /* !CONFIG_CONTEXT_TRACKING */
9292

93-
#define CT_WARN_ON(cond) WARN_ON(context_tracking_is_enabled() && (cond))
93+
#define CT_WARN_ON(cond) WARN_ON(context_tracking_enabled() && (cond))
9494

9595
#ifdef CONFIG_CONTEXT_TRACKING_FORCE
9696
extern void context_tracking_init(void);
@@ -103,12 +103,12 @@ static inline void context_tracking_init(void) { }
103103
/* must be called with irqs disabled */
104104
static inline void guest_enter_irqoff(void)
105105
{
106-
if (vtime_accounting_cpu_enabled())
106+
if (vtime_accounting_enabled_this_cpu())
107107
vtime_guest_enter(current);
108108
else
109109
current->flags |= PF_VCPU;
110110

111-
if (context_tracking_is_enabled())
111+
if (context_tracking_enabled())
112112
__context_tracking_enter(CONTEXT_GUEST);
113113

114114
/* KVM does not hold any references to rcu protected data when it
@@ -118,16 +118,16 @@ static inline void guest_enter_irqoff(void)
118118
* one time slice). Lets treat guest mode as quiescent state, just like
119119
* we do with user-mode execution.
120120
*/
121-
if (!context_tracking_cpu_is_enabled())
121+
if (!context_tracking_enabled_this_cpu())
122122
rcu_virt_note_context_switch(smp_processor_id());
123123
}
124124

125125
static inline void guest_exit_irqoff(void)
126126
{
127-
if (context_tracking_is_enabled())
127+
if (context_tracking_enabled())
128128
__context_tracking_exit(CONTEXT_GUEST);
129129

130-
if (vtime_accounting_cpu_enabled())
130+
if (vtime_accounting_enabled_this_cpu())
131131
vtime_guest_exit(current);
132132
else
133133
current->flags &= ~PF_VCPU;
@@ -141,15 +141,15 @@ static inline void guest_enter_irqoff(void)
141141
* to assume that it's the stime pending cputime
142142
* to flush.
143143
*/
144-
vtime_account_system(current);
144+
vtime_account_kernel(current);
145145
current->flags |= PF_VCPU;
146146
rcu_virt_note_context_switch(smp_processor_id());
147147
}
148148

149149
static inline void guest_exit_irqoff(void)
150150
{
151151
/* Flush the guest cputime we spent on the guest */
152-
vtime_account_system(current);
152+
vtime_account_kernel(current);
153153
current->flags &= ~PF_VCPU;
154154
}
155155
#endif /* CONFIG_VIRT_CPU_ACCOUNTING_GEN */

0 commit comments

Comments
 (0)