scheduler fixes
Subsystems (4)
Linus,
Please pull the latest sched-urgent-for-linus git tree from:
git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git sched-urgent-for-linus
# HEAD: f3a7e1a9c464a32ee186ab91388313c82e7ce018 sched/dl: Fix preemption checks
Various scheduler fixes all over the place: three SCHED_DL fixes, three sched/numa fixes, two generic race fixes and a comment fix.
Thanks,
Ingo
------------------>
Chen Hanxiao (1):
sched: Update comments for CLONE_NEWNS
Juri Lelli (2):
sched/deadline: Don't replenish from a !SCHED_DEADLINE entity sched/deadline: Fix races between rt_mutex_setprio() and dl_task_timer()
Kirill Tkhai (4):
sched: Fix race between task_group and sched_task_group sched/numa: Fix unsafe get_task_struct() in task_numa_assign() sched/fair: Fix division by zero sysctl_numa_balancing_scan_size sched/dl: Fix preemption checks
Oleg Nesterov (1):
sched: stop the unbound recursion in preempt_schedule_context()
Yasuaki Ishimatsu (1):
sched/fair: Care divide error in update_task_scan_period()
arch/x86/include/asm/preempt.h | 1 + include/uapi/linux/sched.h | 2 +- kernel/context_tracking.c | 40 ----------------------------------- kernel/sched/core.c | 47 ++++++++++++++++++++++++++++++++++++++++++ kernel/sched/deadline.c | 41 ++++++++++++++++++++++++++++-------- kernel/sched/fair.c | 21 ++++++++++++++----- kernel/sysctl.c | 3 ++- 7 files changed, 99 insertions(+), 56 deletions(-)
arch/x86/include/asm/preempt.h +1 -0
@@ -105,6 +105,7 @@ static __always_inline bool should_resched(void)# ifdef CONFIG_CONTEXT_TRACKING extern asmlinkage void ___preempt_schedule_context(void);# define __preempt_schedule_context () asm ("call ___preempt_schedule_context") + extern asmlinkage void preempt_schedule_context(void);# endif #endif
include/uapi/linux/sched.h +1 -1
@@ -13,7 +13,7 @@#define CLONE_VFORK 0x00004000/* set if the parent wants the child to wake it up on mm_release */ #define CLONE_PARENT 0x00008000/* set if we want to have the same parent as the cloner */ #define CLONE_THREAD 0x00010000/* Same thread group? */ -#define CLONE_NEWNS 0x00020000/* New namespace group? */ +#define CLONE_NEWNS 0x00020000/* New mount namespace group */ #define CLONE_SYSVSEM 0x00040000/* share system V SEM_UNDO semantics */ #define CLONE_SETTLS 0x00080000/* create a new TLS for the child */ #define CLONE_PARENT_SETTID 0x00100000/* set the TID in the parent */
kernel/context_tracking.c +0 -40
@@ -107,46 +107,6 @@ void context_tracking_user_enter(void) }NOKPROBE_SYMBOL (context_tracking_user_enter); -#ifdef CONFIG_PREEMPT -/** -* preempt_schedule_context - preempt_schedule called by tracing -* -* The tracing infrastructure uses preempt_enable_notrace to prevent -* recursion and tracing preempt enabling caused by the tracing -* infrastructure itself. But as tracing can happen in areas coming -* from userspace or just about to enter userspace, a preempt enable -* can occur before user_exit() is called. This will cause the scheduler -* to be called when the system is still in usermode. -* -* To prevent this, the preempt_enable_notrace will use this function -* instead of preempt_schedule() to exit user context if needed before -* calling the scheduler. -*/ -asmlinkage __visible void __sched notrace preempt_schedule_context(void) -{ -enum ctx_state prev_ctx; - -if (likely (!preemptible ())) -return ; - -/* -* Need to disable preemption in case user_exit() is traced -* and the tracer calls preempt_enable_notrace() causing -* an infinite recursion. -*/ -preempt_disable_notrace (); - prev_ctx =exception_enter (); -preempt_enable_no_resched_notrace (); - -preempt_schedule (); - -preempt_disable_notrace (); -exception_exit (prev_ctx); -preempt_enable_notrace (); -} -EXPORT_SYMBOL_GPL (preempt_schedule_context); -#endif /* CONFIG_PREEMPT */ -/** * context_tracking_user_exit - Inform the context tracking that the CPU is * exiting userspace mode and entering the kernel.
kernel/sched/core.c +47 -0
65 lines not on this page · raw message
kernel/sched/deadline.c +32 -9
67 lines not on this page · raw message
kernel/sched/fair.c +16 -5
@@ -828,11 +828,12 @@ static unsigned int task_nr_scan_windows(struct task_struct *p)static unsigned int task_scan_min (struct task_struct *p) { +unsigned int scan_size =ACCESS_ONCE (sysctl_numa_balancing_scan_size);unsigned int scan, floor;unsigned int windows =1 ; -if (sysctl_numa_balancing_scan_size <MAX_SCAN_WINDOW ) - windows =MAX_SCAN_WINDOW / sysctl_numa_balancing_scan_size; +if (scan_size <MAX_SCAN_WINDOW ) + windows =MAX_SCAN_WINDOW / scan_size; floor =1000 / windows; scan = sysctl_numa_balancing_scan_period_min /task_nr_scan_windows (p);
@@ -1164,9 +1165,19 @@ static void task_numa_compare(struct task_numa_env *env,long moveimp = imp;rcu_read_lock (); - cur =ACCESS_ONCE (dst_rq->curr); -if (cur->pid ==0 )/* idle */ + +raw_spin_lock_irq (&dst_rq->lock); + cur = dst_rq->curr; +/* +* No need to move the exiting task, and this ensures that ->curr +* wasn't reaped and thus get_task_struct() in task_numa_assign() +* is safe under RCU read lock. +* Note that rcu_read_lock() itself can't protect from the final +* put_task_struct() after the last schedule(). +*/ +if ((cur->flags &PF_EXITING ) ||is_idle_task (cur)) cur =NULL ; +raw_spin_unlock_irq (&dst_rq->lock);/* * "imp" is the fault differential for the source task between the
@@ -1520,7 +1531,7 @@ static void update_task_scan_period(struct task_struct *p,* scanning faster if shared accesses dominate as it may * simply bounce migrations uselessly */ - ratio =DIV_ROUND_UP (private *NUMA_PERIOD_SLOTS , (private + shared)); + ratio =DIV_ROUND_UP (private *NUMA_PERIOD_SLOTS , (private + shared +1 )); diff = (diff * ratio) /NUMA_PERIOD_SLOTS ; }
kernel/sysctl.c +2 -1
@@ -387,7 +387,8 @@ static struct ctl_table kern_table[] = { .data = &sysctl_numa_balancing_scan_size, .maxlen = sizeof(unsigned int), .mode = 0644, - .proc_handler = proc_dointvec, + .proc_handler = proc_dointvec_minmax, + .extra1 = &one, }, { .procname = "numa_balancing",