scheduler updates for v2.6.27, phase #2
Subsystems (5)
Linus,
Please pull the latest sched/for-linus git tree from:
git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip.git sched/for-linus
this includes the cpu_active_map changes (which cleans up scheduler and CPU hotplug interaction) and Peter's hrtick cleanup (which fixes the uvesafb regression) and assorted fixlets.
Thanks,
Ingo
------------------>
David Howells (1):
sched: fix warning in inc_rt_tasks() to not declare variable 'rq' if it's not needed
Dmitry Adamushko (1):
sched: rework of "prioritize non-migratable tasks over migratable ones"
Ingo Molnar (3):
Revert parts of "ftrace: do not trace scheduler functions"
sched: fix build error, provide partition_sched_domains() unconditionally
sched: hrtick_enabled() should use cpu_active()
Max Krasnyansky (2):
cpu hotplug, sched: Introduce cpu_active_map and redo sched domain managment (take 2) cpu hotplug: Make cpu_active_map synchronization dependency clear
Mike Travis (1):
sched: reduce stack size in isolated_cpu_setup()
Peter Zijlstra (1):
sched, x86: clean up hrtick implementation
arch/x86/kernel/signal_32.c | 3 - arch/x86/kernel/signal_64.c | 3 - include/asm-x86/thread_info.h | 4 +- include/linux/cpumask.h | 6 +- include/linux/cpuset.h | 7 + include/linux/sched.h | 11 ++- init/main.c | 7 + kernel/Kconfig.hz | 2 +- kernel/Makefile | 2 + kernel/cpu.c | 40 +++++- kernel/cpuset.c | 2 +- kernel/sched.c | 313 ++++++++++++++--------------------------- kernel/sched_fair.c | 8 +- kernel/sched_rt.c | 77 +++++++---- 14 files changed, 229 insertions(+), 256 deletions(-)
arch/x86/kernel/signal_32.c +0 -3
@@ -667,8 +667,5 @@ do_notify_resume(struct pt_regs *regs, void *unused, __u32 thread_info_flags)if (thread_info_flags & _TIF_SIGPENDING)do_signal (regs); -if (thread_info_flags & _TIF_HRTICK_RESCHED) -hrtick_resched (); -clear_thread_flag (TIF_IRET ); }
arch/x86/kernel/signal_64.c +0 -3
@@ -502,9 +502,6 @@ void do_notify_resume(struct pt_regs *regs, void *unused,/* deal with pending signal delivery */ if (thread_info_flags & _TIF_SIGPENDING)do_signal (regs); - -if (thread_info_flags & _TIF_HRTICK_RESCHED) -hrtick_resched (); }void signal_fault (struct pt_regs *regs,void __user *frame,char *where)
include/asm-x86/thread_info.h +1 -3
@@ -81,7 +81,6 @@ struct thread_info {#define TIF_SYSCALL_AUDIT 7/* syscall auditing active */ #define TIF_SECCOMP 8/* secure computing */ #define TIF_MCE_NOTIFY 10/* notify userspace of an MCE */ -#define TIF_HRTICK_RESCHED 11/* reprogram hrtick timer */ #define TIF_NOTSC 16/* TSC is not accessible in userland */ #define TIF_IA32 17/* 32bit process */ #define TIF_FORK 18/* ret_from_fork */
@@ -108,7 +107,6 @@ struct thread_info {#define _TIF_SYSCALL_AUDIT (1 << TIF_SYSCALL_AUDIT)#define _TIF_SECCOMP (1 << TIF_SECCOMP)#define _TIF_MCE_NOTIFY (1 << TIF_MCE_NOTIFY) -#define _TIF_HRTICK_RESCHED (1 << TIF_HRTICK_RESCHED)#define _TIF_NOTSC (1 << TIF_NOTSC)#define _TIF_IA32 (1 << TIF_IA32)#define _TIF_FORK (1 << TIF_FORK)
@@ -132,7 +130,7 @@ struct thread_info {/* Only used for 64 bit */ #define _TIF_DO_NOTIFY_MASK \ - (_TIF_SIGPENDING|_TIF_SINGLESTEP|_TIF_MCE_NOTIFY|_TIF_HRTICK_RESCHED) + (_TIF_SIGPENDING|_TIF_SINGLESTEP|_TIF_MCE_NOTIFY)/* flags to check in __switch_to() */ #define _TIF_WORK_CTXSW \
include/linux/cpumask.h +5 -1
@@ -359,13 +359,14 @@ static inline void __cpus_fold(cpumask_t *dstp, const cpumask_t *origp,/* * The following particular system cpumasks and operations manage -* possible, present and online cpus. Each of them is a fixed size +* possible, present, active and online cpus. Each of them is a fixed size * bitmap of size NR_CPUS. * * #ifdef CONFIG_HOTPLUG_CPU * cpu_possible_map - has bit 'cpu' set iff cpu is populatable * cpu_present_map - has bit 'cpu' set iff cpu is populated * cpu_online_map - has bit 'cpu' set iff cpu available to scheduler +* cpu_active_map - has bit 'cpu' set iff cpu available to migration * #else * cpu_possible_map - has bit 'cpu' set iff cpu is populated * cpu_present_map - copy of cpu_possible_map
@@ -416,6 +417,7 @@ static inline void __cpus_fold(cpumask_t *dstp, const cpumask_t *origp,extern cpumask_t cpu_possible_map;extern cpumask_t cpu_online_map;extern cpumask_t cpu_present_map; +extern cpumask_t cpu_active_map;#if NR_CPUS >1 #define num_online_cpus () cpus_weight(cpu_online_map)
@@ -424,6 +426,7 @@ extern cpumask_t cpu_present_map;#define cpu_online (cpu) cpu_isset((cpu), cpu_online_map)#define cpu_possible (cpu) cpu_isset((cpu), cpu_possible_map)#define cpu_present (cpu) cpu_isset((cpu), cpu_present_map) +#define cpu_active (cpu) cpu_isset((cpu), cpu_active_map)#else #define num_online_cpus () 1#define num_possible_cpus () 1
@@ -431,6 +434,7 @@ extern cpumask_t cpu_present_map;#define cpu_online (cpu) ((cpu) == 0)#define cpu_possible (cpu) ((cpu) == 0)#define cpu_present (cpu) ((cpu) == 0) +#define cpu_active (cpu) ((cpu) == 0)#endif #define cpu_is_offline (cpu) unlikely(!cpu_online(cpu))
include/linux/cpuset.h +7 -0
@@ -78,6 +78,8 @@ extern void cpuset_track_online_nodes(void);extern int current_cpuset_is_being_rebound (void ); +extern void rebuild_sched_domains (void ); +#else /* !CONFIG_CPUSETS */ static inline int cpuset_init_early (void ) {return 0 ; }
@@ -156,6 +158,11 @@ static inline int current_cpuset_is_being_rebound(void)return 0 ; } +static inline void rebuild_sched_domains (void ) +{ +partition_sched_domains (0 ,NULL ,NULL ); +} +#endif /* !CONFIG_CPUSETS */ #endif /* _LINUX_CPUSET_H */
include/linux/sched.h +10 -1
@@ -824,7 +824,16 @@ extern void partition_sched_domains(int ndoms_new, cpumask_t *doms_new, struct sched_domain_attr *dattr_new);extern int arch_reinit_sched_domains (void ); -#endif /* CONFIG_SMP */ +#else /* CONFIG_SMP */ + +struct sched_domain_attr ; + +static inline void +partition_sched_domains (int ndoms_new,cpumask_t *doms_new, +struct sched_domain_attr *dattr_new) +{ +} +#endif /* !CONFIG_SMP */ struct io_context ;/* See blkdev.h */ #define NGROUPS_SMALL 32
init/main.c +7 -0
@@ -415,6 +415,13 @@ static void __init smp_init(void) {unsigned int cpu; +/* +* Set up the current CPU as possible to migrate to. +* The other ones will be done by cpu_up/cpu_down() +*/ + cpu =smp_processor_id (); +cpu_set (cpu, cpu_active_map); +/* FIXME: This should be done in userspace --RR */ for_each_present_cpu (cpu) {if (num_online_cpus () >= setup_max_cpus)
kernel/Kconfig.hz +1 -1
@@ -55,4 +55,4 @@ config HZ default 1000 if HZ_1000 config SCHED_HRTICK - def_bool HIGH_RES_TIMERS && X86 + def_bool HIGH_RES_TIMERS
kernel/Makefile +2 -0
@@ -11,6 +11,8 @@ obj-y = sched.o fork.o exec_domain.o panic.o printk.o profile.o \ hrtimer.o rwsem.o nsproxy.o srcu.o semaphore.o \ notifier.o ksysfs.o pm_qos_params.o sched_clock.o +CFLAGS_REMOVE_sched.o = -mno-spe + ifdef CONFIG_FTRACE # Do not trace debug files and internal ftrace files CFLAGS_REMOVE_lockdep.o = -pg
kernel/cpu.c +34 -6
@@ -64,6 +64,8 @@ void __init cpu_hotplug_init(void) cpu_hotplug.refcount =0 ; } +cpumask_t cpu_active_map; +#ifdef CONFIG_HOTPLUG_CPU void get_online_cpus (void )
@@ -291,11 +293,30 @@ int __ref cpu_down(unsigned int cpu)int err =0 ;cpu_maps_update_begin (); -if (cpu_hotplug_disabled) + +if (cpu_hotplug_disabled) { err = -EBUSY ; -else - err =_cpu_down (cpu,0 ); + goto out; + } + +cpu_clear (cpu, cpu_active_map); + +/* +* Make sure the all cpus did the reschedule and are not +* using stale version of the cpu_active_map. +* This is not strictly necessary becuase stop_machine() +* that we run down the line already provides the required +* synchronization. But it's really a side effect and we do not +* want to depend on the innards of the stop_machine here. +*/ +synchronize_sched (); + + err =_cpu_down (cpu,0 ); +if (cpu_online (cpu)) +cpu_set (cpu, cpu_active_map); + +out:cpu_maps_update_done ();return err; }
@@ -355,11 +376,18 @@ int __cpuinit cpu_up(unsigned int cpu) }cpu_maps_update_begin (); -if (cpu_hotplug_disabled) + +if (cpu_hotplug_disabled) { err = -EBUSY ; -else - err =_cpu_up (cpu,0 ); + goto out; + } + + err =_cpu_up (cpu,0 ); +if (cpu_online (cpu)) +cpu_set (cpu, cpu_active_map); + +out:cpu_maps_update_done ();return err; }
kernel/cpuset.c +1 -1
@@ -564,7 +564,7 @@ update_domain_attr(struct sched_domain_attr *dattr, struct cpuset *c)* partition_sched_domains(). */ -static void rebuild_sched_domains (void ) +void rebuild_sched_domains (void ) {struct kfifo *q;/* queue of cpusets to be scanned */ struct cpuset *cp;/* scans q */
kernel/sched.c +107 -206
518 lines not on this page · raw message
kernel/sched_fair.c +5 -3
@@ -878,7 +878,6 @@ entity_tick(struct cfs_rq *cfs_rq, struct sched_entity *curr, int queued)#ifdef CONFIG_SCHED_HRTICK static void hrtick_start_fair (struct rq *rq,struct task_struct *p) { -int requeue = rq->curr == p;struct sched_entity *se = &p->se;struct cfs_rq *cfs_rq =cfs_rq_of (se);
@@ -899,10 +898,10 @@ static void hrtick_start_fair(struct rq *rq, struct task_struct *p)* Don't schedule slices shorter than 10000ns, that just * doesn't make sense. Rely on vruntime for fairness. */ -if (!requeue) +if (rq->curr != p) delta =max (10000LL , delta); - hrtick_start(rq, delta, requeue); + hrtick_start(rq, delta); } }#else /* !CONFIG_SCHED_HRTICK */
@@ -1004,6 +1003,8 @@ static void yield_task_fair(struct rq *rq)* not idle and an idle cpu is available. The span of cpus to * search starts with cpus closest then further out as needed, * so we always favor a closer, idle cpu. +* Domains may include CPUs that are not usable for migration, +* hence we need to mask them out (cpu_active_map) * * Returns the CPU we should wake onto. */
@@ -1031,6 +1032,7 @@ static int wake_idle(int cpu, struct task_struct *p) || ((sd->flags & SD_WAKE_IDLE_FAR) && !task_hot(p, task_rq(p)->clock, sd))) {cpus_and (tmp, sd->span, p->cpus_allowed); +cpus_and (tmp, tmp, cpu_active_map);for_each_cpu_mask (i, tmp) {if (idle_cpu (i)) {if (i !=task_cpu (p)) {
kernel/sched_rt.c +49 -28
136 lines not on this page · raw message
Quoted 9 lines · Ingo Molnar
Linus,
Please pull the latest sched/for-linus git tree from:
git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip.gitsched/for-linusthis includes the
cpu_active_mapchanges (which cleans up scheduler and CPU hotplug interaction) and Peter's hrtick cleanup (which fixes the uvesafb regression) and assorted fixlets.
I get this warning on powerpc builds (linus git as of a few days ago),
/localuser/dwalker/linus/kernel/sched_rt.c: In function ‘do_balance_runtime’:
/localuser/dwalker/linus/kernel/sched_rt.c:256: warning: comparison of distinct pointer types lacks a cast
I'm not exactly sure why .. Did this get fixed already?
Daniel
Quoted 12 lines · Daniel Walker
Quoted 9 lines · Ingo Molnar
Linus,
Please pull the latest sched/for-linus git tree from:
git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip.gitsched/for-linusthis includes the
cpu_active_mapchanges (which cleans up scheduler and CPU hotplug interaction) and Peter's hrtick cleanup (which fixes the uvesafb regression) and assorted fixlets.
Quoted 6 lines
I get this warning on powerpc builds (linus git as of a few days ago),
/localuser/dwalker/linus/kernel/sched_rt.c: In function ‘do_balance_runtime’:
/localuser/dwalker/linus/kernel/sched_rt.c:256: warning: comparison of distinct pointer types lacks a castI'm not exactly sure why .. Did this get fixed already?
Does this work for you?
---
shut up the type validation in asm-generic/div64.h:do_div()
its complaining diff isn't u64 - which is true, its s64. However we've already checked its >0, so its safe. However we can't sanely cast since do_div() is a macro.
Hence use an extra variable.
---
kernel/sched_rt.c +6 -4
@@ -253,11 +253,13 @@ static int do_balance_runtime(struct rt_rq *rt_rq) diff = iter->rt_runtime - iter->rt_time;if (diff >0 ) { -do_div (diff, weight); +u64 gain = diff; + +do_div (gain, weight);if (rt_rq->rt_runtime + diff > rt_period) - diff = rt_period - rt_rq->rt_runtime; - iter->rt_runtime -= diff; - rt_rq->rt_runtime += diff; + gain = rt_period - rt_rq->rt_runtime; + iter->rt_runtime -= gain; + rt_rq->rt_runtime += gain; more =1 ;if (rt_rq->rt_runtime == rt_period) {spin_unlock (&iter->rt_runtime_lock);
Quoted 2 lines · Peter Zijlstra
Does this work for you?
Yours removed the warning .. I made an alternate one below only compile tested, your choice..
kernel/sched_rt.c +2 -2
@@ -242,7 +242,7 @@ static int do_balance_runtime(struct rt_rq *rt_rq) rt_period =ktime_to_ns (rt_b->rt_period);for_each_cpu_mask (i, rd->span) {struct rt_rq *iter =sched_rt_period_rt_rq (rt_b, i); -s64 diff; +u64 diff;if (iter == rt_rq)continue ;
@@ -252,7 +252,7 @@ static int do_balance_runtime(struct rt_rq *rt_rq) goto next; diff = iter->rt_runtime - iter->rt_time; -if (diff >0 ) { +if ((s64)(diff) >0 ) {do_div (diff, weight);if (rt_rq->rt_runtime + diff > rt_period) diff = rt_period - rt_rq->rt_runtime;
Quoted 7 lines · Daniel Walker
Quoted 2 lines · Peter Zijlstra
Does this work for you?
Yours removed the warning .. I made an alternate one below only compile tested, your choice..
How about this one - it seems there is a whole scala of new division instructions these days... :-)
kernel/sched_rt.c +1 -1
@@ -253,7 +253,7 @@ static int do_balance_runtime(struct rt_rq *rt_rq) diff = iter->rt_runtime - iter->rt_time;if (diff >0 ) { -do_div (diff, weight); + diff =div_u64 ((u64 )diff, weight);if (rt_rq->rt_runtime + diff > rt_period) diff = rt_period - rt_rq->rt_runtime; iter->rt_runtime -= diff;
Quoted 12 lines · On Thu, 24 Jul 2008 12:43:13 +0200 Peter Zijlstra <[email protected]>…
Quoted 7 lines · Daniel Walker
Quoted 2 lines · Peter Zijlstra
Does this work for you?
Yours removed the warning .. I made an alternate one below only compile tested, your choice..
How about this one - it seems there is a whole scala of new division instructions these days... :-)
ain't life grand.
kernel/sched_rt.c static int do_balance_runtime(struct rt_rq *rt_rq) · line 256
Quoted 12 lines
kernel/sched_rt.c +1
-1@@ -253,7 +253,7 @@ static int do_balance_runtime(struct rt_rq *rt_rq) diff = iter->rt_runtime - iter->rt_time;if (diff >0 ) { -do_div (diff, weight); + diff =div_u64 ((u64 )diff, weight);
Can't use div_s64() here?
Quoted 4 lines
kernel/sched_rt.c +0
-0if (rt_rq->rt_runtime + diff > rt_period) diff = rt_period - rt_rq->rt_runtime; iter->rt_runtime -= diff;
Quoted 25 lines · Andrew Morton
Quoted 12 lines · On Thu, 24 Jul 2008 12:43:13 +0200 Peter Zijlstra <[email protected]>…
Quoted 7 lines · Daniel Walker
Quoted 2 lines · Peter Zijlstra
Does this work for you?
Yours removed the warning .. I made an alternate one below only compile tested, your choice..
How about this one - it seems there is a whole scala of new division instructions these days... :-)
ain't life grand.
Quoted 8 lines
kernel/sched_rt.c +0
-0@@ -253,7 +253,7 @@ static int do_balance_runtime(struct rt_rq *rt_rq)
Quoted 6 lines
kernel/sched_rt.c static int do_balance_runtime(struct rt_rq *rt_rq) · line 256
Quoted 4 lines
kernel/sched_rt.c +1
-1diff = iter->rt_runtime - iter->rt_time;if (diff >0 ) { -do_div (diff, weight); + diff =div_u64 ((u64 )diff, weight);Can't use
div_s64()here?
I guess we could, but since we already established >0, I thought using the u64 version might be slightly cheaper - but what do I know..
Quoted 4 lines
Quoted 4 lines
kernel/sched_rt.c +0
-0if (rt_rq->rt_runtime + diff > rt_period) diff = rt_period - rt_rq->rt_runtime; iter->rt_runtime -= diff;
Ingo Molnar
AppliedQuoted 20 lines · Peter Zijlstra
Quoted 7 lines · Daniel Walker
Quoted 2 lines · Peter Zijlstra
Does this work for you?
Yours removed the warning .. I made an alternate one below only compile tested, your choice..
How about this one - it seems there is a whole scala of new division instructions these days... :-)
Signed-off-by Peter Zijlstra <[email protected]>kernel/sched_rt.c +0
-0
kernel/sched_rt.c static int do_balance_runtime(struct rt_rq *rt_rq) · line 256
Quoted 5 lines
kernel/sched_rt.c +1
-1@@ -253,7 +253,7 @@ static int do_balance_runtime(struct rt_rq *rt_rq) diff = iter->rt_runtime - iter->rt_time;if (diff >0 ) { -do_div (diff, weight); + diff =div_u64 ((u64 )diff, weight);
/me likes.
applied to tip/sched/urgent, thanks guys.
Ingo
Quoted 3 lines · Ingo Molnar
/me likes.
applied to tip/sched/urgent, thanks guys.
Anyone for seconds?
kernel/sched.c:1107: warning: ‘init_hrtick’ defined but not used
and sched on ARM,
linus/kernel/sched.c:4227: warning: unsupported argument to ‘__builtin_return_address’ linus/kernel/sched.c:4206: warning: unsupported argument to ‘__builtin_return_address’
Also some ftrace on ARM,
linus/kernel/trace/trace_irqsoff.c:254: warning: unsupported argument to ‘__builtin_return_address’ linus/kernel/trace/trace_irqsoff.c:260: warning: unsupported argument to ‘__builtin_return_address’ linus/kernel/trace/trace_irqsoff.c:316: warning: unsupported argument to ‘__builtin_return_address’ linus/kernel/trace/trace_irqsoff.c:309: warning: unsupported argument to ‘__builtin_return_address’ linus/kernel/trace/trace_irqsoff.c:254: warning: unsupported argument to ‘__builtin_return_address’ linus/kernel/trace/trace_irqsoff.c:260: warning: unsupported argument to ‘__builtin_return_address’
The above also happens in trace_sched_wakeup.c .
Daniel