Skip to content

Commit 16fa94b

Browse files
committed
Merge branch 'sched-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull scheduler changes from Ingo Molnar: "The main changes in this development cycle were: - full dynticks preparatory work by Frederic Weisbecker - factor out the cpu time accounting code better, by Li Zefan - multi-CPU load balancer cleanups and improvements by Joonsoo Kim - various smaller fixes and cleanups" * 'sched-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: (45 commits) sched: Fix init NOHZ_IDLE flag sched: Prevent to re-select dst-cpu in load_balance() sched: Rename load_balance_tmpmask to load_balance_mask sched: Move up affinity check to mitigate useless redoing overhead sched: Don't consider other cpus in our group in case of NEWLY_IDLE sched: Explicitly cpu_idle_type checking in rebalance_domains() sched: Change position of resched_cpu() in load_balance() sched: Fix wrong rq's runnable_avg update with rt tasks sched: Document task_struct::personality field sched/cpuacct/UML: Fix header file dependency bug on the UML build cgroup: Kill subsys.active flag sched/cpuacct: No need to check subsys active state sched/cpuacct: Initialize cpuacct subsystem earlier sched/cpuacct: Initialize root cpuacct earlier sched/cpuacct: Allocate per_cpu cpuusage for root cpuacct statically sched/cpuacct: Clean up cpuacct.h sched/cpuacct: Remove redundant NULL checks in cpuacct_acount_field() sched/cpuacct: Remove redundant NULL checks in cpuacct_charge() sched/cpuacct: Add cpuacct_acount_field() sched/cpuacct: Add cpuacct_init() ...
2 parents e097291 + 25f55d9 commit 16fa94b

20 files changed

Lines changed: 834 additions & 709 deletions

File tree

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,10 @@
11
#ifndef _ASM_X86_CONTEXT_TRACKING_H
22
#define _ASM_X86_CONTEXT_TRACKING_H
33

4-
#ifndef __ASSEMBLY__
5-
#include <linux/context_tracking.h>
6-
#include <asm/ptrace.h>
7-
8-
static inline void exception_enter(struct pt_regs *regs)
9-
{
10-
user_exit();
11-
}
12-
13-
static inline void exception_exit(struct pt_regs *regs)
14-
{
15-
#ifdef CONFIG_CONTEXT_TRACKING
16-
if (user_mode(regs))
17-
user_enter();
18-
#endif
19-
}
20-
21-
#else /* __ASSEMBLY__ */
22-
234
#ifdef CONFIG_CONTEXT_TRACKING
245
# define SCHEDULE_USER call schedule_user
256
#else
267
# define SCHEDULE_USER call schedule
278
#endif
289

29-
#endif /* !__ASSEMBLY__ */
30-
3110
#endif

‎arch/x86/kernel/kvm.c‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
* Authors: Anthony Liguori <aliguori@us.ibm.com>
2121
*/
2222

23+
#include <linux/context_tracking.h>
2324
#include <linux/module.h>
2425
#include <linux/kernel.h>
2526
#include <linux/kvm_para.h>
@@ -43,7 +44,6 @@
4344
#include <asm/apicdef.h>
4445
#include <asm/hypervisor.h>
4546
#include <asm/kvm_guest.h>
46-
#include <asm/context_tracking.h>
4747

4848
static int kvmapf = 1;
4949

@@ -254,16 +254,18 @@ EXPORT_SYMBOL_GPL(kvm_read_and_reset_pf_reason);
254254
dotraplinkage void __kprobes
255255
do_async_page_fault(struct pt_regs *regs, unsigned long error_code)
256256
{
257+
enum ctx_state prev_state;
258+
257259
switch (kvm_read_and_reset_pf_reason()) {
258260
default:
259261
do_page_fault(regs, error_code);
260262
break;
261263
case KVM_PV_REASON_PAGE_NOT_PRESENT:
262264
/* page is swapped out by the host. */
263-
exception_enter(regs);
265+
prev_state = exception_enter();
264266
exit_idle();
265267
kvm_async_pf_task_wait((u32)read_cr2());
266-
exception_exit(regs);
268+
exception_exit(prev_state);
267269
break;
268270
case KVM_PV_REASON_PAGE_READY:
269271
rcu_irq_enter();

‎arch/x86/kernel/traps.c‎

Lines changed: 42 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
1414

15+
#include <linux/context_tracking.h>
1516
#include <linux/interrupt.h>
1617
#include <linux/kallsyms.h>
1718
#include <linux/spinlock.h>
@@ -55,8 +56,6 @@
5556
#include <asm/i387.h>
5657
#include <asm/fpu-internal.h>
5758
#include <asm/mce.h>
58-
#include <asm/context_tracking.h>
59-
6059
#include <asm/mach_traps.h>
6160

6261
#ifdef CONFIG_X86_64
@@ -176,34 +175,38 @@ do_trap(int trapnr, int signr, char *str, struct pt_regs *regs,
176175
#define DO_ERROR(trapnr, signr, str, name) \
177176
dotraplinkage void do_##name(struct pt_regs *regs, long error_code) \
178177
{ \
179-
exception_enter(regs); \
178+
enum ctx_state prev_state; \
179+
\
180+
prev_state = exception_enter(); \
180181
if (notify_die(DIE_TRAP, str, regs, error_code, \
181182
trapnr, signr) == NOTIFY_STOP) { \
182-
exception_exit(regs); \
183+
exception_exit(prev_state); \
183184
return; \
184185
} \
185186
conditional_sti(regs); \
186187
do_trap(trapnr, signr, str, regs, error_code, NULL); \
187-
exception_exit(regs); \
188+
exception_exit(prev_state); \
188189
}
189190

190191
#define DO_ERROR_INFO(trapnr, signr, str, name, sicode, siaddr) \
191192
dotraplinkage void do_##name(struct pt_regs *regs, long error_code) \
192193
{ \
193194
siginfo_t info; \
195+
enum ctx_state prev_state; \
196+
\
194197
info.si_signo = signr; \
195198
info.si_errno = 0; \
196199
info.si_code = sicode; \
197200
info.si_addr = (void __user *)siaddr; \
198-
exception_enter(regs); \
201+
prev_state = exception_enter(); \
199202
if (notify_die(DIE_TRAP, str, regs, error_code, \
200203
trapnr, signr) == NOTIFY_STOP) { \
201-
exception_exit(regs); \
204+
exception_exit(prev_state); \
202205
return; \
203206
} \
204207
conditional_sti(regs); \
205208
do_trap(trapnr, signr, str, regs, error_code, &info); \
206-
exception_exit(regs); \
209+
exception_exit(prev_state); \
207210
}
208211

209212
DO_ERROR_INFO(X86_TRAP_DE, SIGFPE, "divide error", divide_error, FPE_INTDIV,
@@ -226,22 +229,24 @@ DO_ERROR_INFO(X86_TRAP_AC, SIGBUS, "alignment check", alignment_check,
226229
/* Runs on IST stack */
227230
dotraplinkage void do_stack_segment(struct pt_regs *regs, long error_code)
228231
{
229-
exception_enter(regs);
232+
enum ctx_state prev_state;
233+
234+
prev_state = exception_enter();
230235
if (notify_die(DIE_TRAP, "stack segment", regs, error_code,
231236
X86_TRAP_SS, SIGBUS) != NOTIFY_STOP) {
232237
preempt_conditional_sti(regs);
233238
do_trap(X86_TRAP_SS, SIGBUS, "stack segment", regs, error_code, NULL);
234239
preempt_conditional_cli(regs);
235240
}
236-
exception_exit(regs);
241+
exception_exit(prev_state);
237242
}
238243

239244
dotraplinkage void do_double_fault(struct pt_regs *regs, long error_code)
240245
{
241246
static const char str[] = "double fault";
242247
struct task_struct *tsk = current;
243248

244-
exception_enter(regs);
249+
exception_enter();
245250
/* Return not checked because double check cannot be ignored */
246251
notify_die(DIE_TRAP, str, regs, error_code, X86_TRAP_DF, SIGSEGV);
247252

@@ -261,8 +266,9 @@ dotraplinkage void __kprobes
261266
do_general_protection(struct pt_regs *regs, long error_code)
262267
{
263268
struct task_struct *tsk;
269+
enum ctx_state prev_state;
264270

265-
exception_enter(regs);
271+
prev_state = exception_enter();
266272
conditional_sti(regs);
267273

268274
#ifdef CONFIG_X86_32
@@ -300,12 +306,14 @@ do_general_protection(struct pt_regs *regs, long error_code)
300306

301307
force_sig(SIGSEGV, tsk);
302308
exit:
303-
exception_exit(regs);
309+
exception_exit(prev_state);
304310
}
305311

306312
/* May run on IST stack. */
307313
dotraplinkage void __kprobes notrace do_int3(struct pt_regs *regs, long error_code)
308314
{
315+
enum ctx_state prev_state;
316+
309317
#ifdef CONFIG_DYNAMIC_FTRACE
310318
/*
311319
* ftrace must be first, everything else may cause a recursive crash.
@@ -315,7 +323,7 @@ dotraplinkage void __kprobes notrace do_int3(struct pt_regs *regs, long error_co
315323
ftrace_int3_handler(regs))
316324
return;
317325
#endif
318-
exception_enter(regs);
326+
prev_state = exception_enter();
319327
#ifdef CONFIG_KGDB_LOW_LEVEL_TRAP
320328
if (kgdb_ll_trap(DIE_INT3, "int3", regs, error_code, X86_TRAP_BP,
321329
SIGTRAP) == NOTIFY_STOP)
@@ -336,7 +344,7 @@ dotraplinkage void __kprobes notrace do_int3(struct pt_regs *regs, long error_co
336344
preempt_conditional_cli(regs);
337345
debug_stack_usage_dec();
338346
exit:
339-
exception_exit(regs);
347+
exception_exit(prev_state);
340348
}
341349

342350
#ifdef CONFIG_X86_64
@@ -393,11 +401,12 @@ asmlinkage __kprobes struct pt_regs *sync_regs(struct pt_regs *eregs)
393401
dotraplinkage void __kprobes do_debug(struct pt_regs *regs, long error_code)
394402
{
395403
struct task_struct *tsk = current;
404+
enum ctx_state prev_state;
396405
int user_icebp = 0;
397406
unsigned long dr6;
398407
int si_code;
399408

400-
exception_enter(regs);
409+
prev_state = exception_enter();
401410

402411
get_debugreg(dr6, 6);
403412

@@ -467,7 +476,7 @@ dotraplinkage void __kprobes do_debug(struct pt_regs *regs, long error_code)
467476
debug_stack_usage_dec();
468477

469478
exit:
470-
exception_exit(regs);
479+
exception_exit(prev_state);
471480
}
472481

473482
/*
@@ -561,17 +570,21 @@ void math_error(struct pt_regs *regs, int error_code, int trapnr)
561570

562571
dotraplinkage void do_coprocessor_error(struct pt_regs *regs, long error_code)
563572
{
564-
exception_enter(regs);
573+
enum ctx_state prev_state;
574+
575+
prev_state = exception_enter();
565576
math_error(regs, error_code, X86_TRAP_MF);
566-
exception_exit(regs);
577+
exception_exit(prev_state);
567578
}
568579

569580
dotraplinkage void
570581
do_simd_coprocessor_error(struct pt_regs *regs, long error_code)
571582
{
572-
exception_enter(regs);
583+
enum ctx_state prev_state;
584+
585+
prev_state = exception_enter();
573586
math_error(regs, error_code, X86_TRAP_XF);
574-
exception_exit(regs);
587+
exception_exit(prev_state);
575588
}
576589

577590
dotraplinkage void
@@ -639,7 +652,9 @@ EXPORT_SYMBOL_GPL(math_state_restore);
639652
dotraplinkage void __kprobes
640653
do_device_not_available(struct pt_regs *regs, long error_code)
641654
{
642-
exception_enter(regs);
655+
enum ctx_state prev_state;
656+
657+
prev_state = exception_enter();
643658
BUG_ON(use_eager_fpu());
644659

645660
#ifdef CONFIG_MATH_EMULATION
@@ -650,23 +665,24 @@ do_device_not_available(struct pt_regs *regs, long error_code)
650665

651666
info.regs = regs;
652667
math_emulate(&info);
653-
exception_exit(regs);
668+
exception_exit(prev_state);
654669
return;
655670
}
656671
#endif
657672
math_state_restore(); /* interrupts still off */
658673
#ifdef CONFIG_X86_32
659674
conditional_sti(regs);
660675
#endif
661-
exception_exit(regs);
676+
exception_exit(prev_state);
662677
}
663678

664679
#ifdef CONFIG_X86_32
665680
dotraplinkage void do_iret_error(struct pt_regs *regs, long error_code)
666681
{
667682
siginfo_t info;
683+
enum ctx_state prev_state;
668684

669-
exception_enter(regs);
685+
prev_state = exception_enter();
670686
local_irq_enable();
671687

672688
info.si_signo = SIGILL;
@@ -678,7 +694,7 @@ dotraplinkage void do_iret_error(struct pt_regs *regs, long error_code)
678694
do_trap(X86_TRAP_IRET, SIGILL, "iret exception", regs, error_code,
679695
&info);
680696
}
681-
exception_exit(regs);
697+
exception_exit(prev_state);
682698
}
683699
#endif
684700

‎arch/x86/mm/fault.c‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@
1313
#include <linux/perf_event.h> /* perf_sw_event */
1414
#include <linux/hugetlb.h> /* hstate_index_to_shift */
1515
#include <linux/prefetch.h> /* prefetchw */
16+
#include <linux/context_tracking.h> /* exception_enter(), ... */
1617

1718
#include <asm/traps.h> /* dotraplinkage, ... */
1819
#include <asm/pgalloc.h> /* pgd_*(), ... */
1920
#include <asm/kmemcheck.h> /* kmemcheck_*(), ... */
2021
#include <asm/fixmap.h> /* VSYSCALL_START */
21-
#include <asm/context_tracking.h> /* exception_enter(), ... */
2222

2323
/*
2424
* Page fault error code bits:
@@ -1224,7 +1224,9 @@ __do_page_fault(struct pt_regs *regs, unsigned long error_code)
12241224
dotraplinkage void __kprobes
12251225
do_page_fault(struct pt_regs *regs, unsigned long error_code)
12261226
{
1227-
exception_enter(regs);
1227+
enum ctx_state prev_state;
1228+
1229+
prev_state = exception_enter();
12281230
__do_page_fault(regs, error_code);
1229-
exception_exit(regs);
1231+
exception_exit(prev_state);
12301232
}

‎include/linux/cgroup.h‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -586,7 +586,6 @@ struct cgroup_subsys {
586586
void (*bind)(struct cgroup *root);
587587

588588
int subsys_id;
589-
int active;
590589
int disabled;
591590
int early_init;
592591
/*

‎include/linux/context_tracking.h‎

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
#ifndef _LINUX_CONTEXT_TRACKING_H
22
#define _LINUX_CONTEXT_TRACKING_H
33

4-
#ifdef CONFIG_CONTEXT_TRACKING
54
#include <linux/sched.h>
65
#include <linux/percpu.h>
6+
#include <asm/ptrace.h>
77

88
struct context_tracking {
99
/*
@@ -13,12 +13,13 @@ struct context_tracking {
1313
* may be further optimized using static keys.
1414
*/
1515
bool active;
16-
enum {
16+
enum ctx_state {
1717
IN_KERNEL = 0,
1818
IN_USER,
1919
} state;
2020
};
2121

22+
#ifdef CONFIG_CONTEXT_TRACKING
2223
DECLARE_PER_CPU(struct context_tracking, context_tracking);
2324

2425
static inline bool context_tracking_in_user(void)
@@ -33,12 +34,31 @@ static inline bool context_tracking_active(void)
3334

3435
extern void user_enter(void);
3536
extern void user_exit(void);
37+
38+
static inline enum ctx_state exception_enter(void)
39+
{
40+
enum ctx_state prev_ctx;
41+
42+
prev_ctx = this_cpu_read(context_tracking.state);
43+
user_exit();
44+
45+
return prev_ctx;
46+
}
47+
48+
static inline void exception_exit(enum ctx_state prev_ctx)
49+
{
50+
if (prev_ctx == IN_USER)
51+
user_enter();
52+
}
53+
3654
extern void context_tracking_task_switch(struct task_struct *prev,
3755
struct task_struct *next);
3856
#else
3957
static inline bool context_tracking_in_user(void) { return false; }
4058
static inline void user_enter(void) { }
4159
static inline void user_exit(void) { }
60+
static inline enum ctx_state exception_enter(void) { return 0; }
61+
static inline void exception_exit(enum ctx_state prev_ctx) { }
4262
static inline void context_tracking_task_switch(struct task_struct *prev,
4363
struct task_struct *next) { }
4464
#endif /* !CONFIG_CONTEXT_TRACKING */

0 commit comments

Comments
 (0)