scheduler changes for v2.6.37
Subsystems (9)
Linus,
Please pull the latest sched-core-for-linus git tree from:
git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip.git sched-core-for-linus
Thanks,
Ingo
------------------>
Christian Dietrich (1):
sched: Remove unnecessary #ifdef CONFIG_SMP
Dave Young (1):
sched: Remove unused PF_ALIGNWARN flag
Heiko Carstens (5):
sched: Merge cpu_to_core_group functions
sched: Add book scheduling domain topology/sysfs: Provide book id and siblings attributes topology, s390: Add z11 cpu topology support
sched: Remove branch hints within context_switch()
Ingo Molnar (1):
sched: Export account_system_vtime()
Linus Walleij (1):
sched: Drop all load weight manipulation for RT tasks
Mathieu Desnoyers (1):
sched: Fix string comparison in /proc/sched_features
Nikhil Rao (4):
sched: Do not consider SCHED_IDLE tasks to be cache hot
sched: Set group_imb only a task can be pulled from the busiest cpu
sched: Force balancing on newidle balance if local group has capacity
sched: Drop group_capacity to 1 only if local group has extra capacity
Peter Zijlstra (2):
sched: Unindent labels
sched: Create special class for stop/migrate work
Steven Rostedt (3):
sched: Try not to migrate higher priority RT tasks
sched: Give CPU bound RT tasks preference tracing/sched: Add sched_pi_setprio tracepoint
Takuya Yoshikawa (1):
sched: Comment updates: fix default latency and granularity numbers
Venkatesh Pallipadi (9):
sched: Increment cache_nice_tries only on periodic lb
sched: Fix softirq time accounting
sched: Consolidate account_system_vtime extern declaration
sched: Add a PF flag for ksoftirqd identification
sched: Add IRQ_TIME_ACCOUNTING, finer accounting of irq time
x86: Add IRQ_TIME_ACCOUNTING
sched: Do not account irq time to current task
sched: Remove irq time from available CPU power
sched: Call tick_check_idle before __irq_enter
Documentation/cputopology.txt | 23 +++- Documentation/kernel-parameters.txt | 4 + arch/ia64/include/asm/system.h | 4 - arch/powerpc/include/asm/system.h | 4 - arch/s390/Kconfig | 7 + arch/s390/include/asm/system.h | 1 - arch/s390/include/asm/topology.h | 27 +++- arch/s390/kernel/topology.c | 150 +++++++++++------- arch/x86/Kconfig | 11 ++ arch/x86/kernel/tsc.c | 8 + drivers/base/topology.c | 16 ++- include/linux/hardirq.h | 9 +- include/linux/sched.h | 23 ++- include/linux/topology.h | 6 + include/trace/events/sched.h | 29 ++++ kernel/sched.c | 291 +++++++++++++++++++++++++++++------ kernel/sched_fair.c | 76 +++++++-- kernel/sched_features.h | 5 + kernel/sched_rt.c | 40 +++-- kernel/sched_stoptask.c | 108 +++++++++++++ kernel/softirq.c | 64 ++++++--- kernel/stop_machine.c | 8 +- net/sched/cls_cgroup.c | 2 +- 23 files changed, 732 insertions(+), 184 deletions(-) create mode 100644 kernel/sched_stoptask.c
Documentation/cputopology.txt +20 -3
@@ -14,25 +14,39 @@ to /proc/cpuinfo. identifier (rather than the kernel's). The actual value is architecture and platform dependent. -3) /sys/devices/system/cpu/cpuX/topology/thread_siblings: +3) /sys/devices/system/cpu/cpuX/topology/book_id: + + the book ID of cpuX. Typically it is the hardware platform's + identifier (rather than the kernel's). The actual value is + architecture and platform dependent. + +4) /sys/devices/system/cpu/cpuX/topology/thread_siblings: internel kernel map of cpuX's hardware threads within the same core as cpuX -4) /sys/devices/system/cpu/cpuX/topology/core_siblings: +5) /sys/devices/system/cpu/cpuX/topology/core_siblings: internal kernel map of cpuX's hardware threads within the same physical_package_id. +6) /sys/devices/system/cpu/cpuX/topology/book_siblings: + + internal kernel map of cpuX's hardware threads within the same + book_id. + To implement it in an architecture-neutral way, a new source file, -drivers/base/topology.c, is to export the 4 attributes. +drivers/base/topology.c, is to export the 4 or 6 attributes. The two book +related sysfs files will only be created if CONFIG_SCHED_BOOK is selected. For an architecture to support this feature, it must define some of these macros in include/asm-XXX/topology.h: #define topology_physical_package_id(cpu) #define topology_core_id(cpu) +#define topology_book_id(cpu) #define topology_thread_cpumask(cpu) #define topology_core_cpumask(cpu) +#define topology_book_cpumask(cpu) The type of **_id is int. The type of siblings is (const) struct cpumask *.
@@ -45,6 +59,9 @@ not defined by include/asm-XXX/topology.h: 3) thread_siblings: just the given CPU 4) core_siblings: just the given CPU +For architectures that don't support books (CONFIG_SCHED_BOOK) there are no +default definitions for topology_book_id() and topology_book_cpumask(). + Additionally, CPU topology information is provided under /sys/devices/system/cpu and includes these files. The internal source for the output is in brackets ("[]").
Documentation/kernel-parameters.txt +4 -0
@@ -2435,6 +2435,10 @@ and is between 256 and 4096 characters. It is defined in the file disables clocksource verification at runtime. Used to enable high-resolution timer mode on older hardware, and in virtualized environment. + [x86] noirqtime: Do not use TSC to do irq accounting. + Used to run time disable IRQ_TIME_ACCOUNTING on any + platforms where RDTSC is slow and this accounting + can add overhead. turbografx.map[2|3]= [HW,JOY] TurboGraFX parallel port interface
arch/ia64/include/asm/system.h +0 -4
@@ -272,10 +272,6 @@ void cpu_idle_wait(void);void default_idle (void ); -#ifdef CONFIG_VIRT_CPU_ACCOUNTING -extern void account_system_vtime (struct task_struct *); -#endif -#endif /* __KERNEL__ */ #endif /* __ASSEMBLY__ */
arch/powerpc/include/asm/system.h +0 -4
@@ -542,10 +542,6 @@ extern void reloc_got2(unsigned long);#define PTRRELOC (x) ((typeof(x)) add_reloc_offset((unsigned long)(x))) -#ifdef CONFIG_VIRT_CPU_ACCOUNTING -extern void account_system_vtime (struct task_struct *); -#endif -extern struct dentry *powerpc_debugfs_root;#endif /* __KERNEL__ */
arch/s390/Kconfig +7 -0
@@ -198,6 +198,13 @@ config HOTPLUG_CPU can be controlled through /sys/devices/system/cpu/cpu#. Say N if you want to disable CPU hotplug. +config SCHED_BOOK + bool "Book scheduler support" + depends on SMP + help + Book scheduler support improves the CPU scheduler's decision making + when dealing with machines that have several books. + config MATHEMU bool "IEEE FPU emulation" depends on MARCH_G5
arch/s390/include/asm/system.h +0 -1
@@ -97,7 +97,6 @@ static inline void restore_access_regs(unsigned int *acrs)extern void account_vtime (struct task_struct *,struct task_struct *);extern void account_tick_vtime (struct task_struct *); -extern void account_system_vtime (struct task_struct *);#ifdef CONFIG_PFAULT extern void pfault_irq_init (void );
arch/s390/include/asm/topology.h +23 -4
@@ -3,15 +3,32 @@#include <linux/cpumask.h> -#define mc_capable () (1) - -const struct cpumask *cpu_coregroup_mask (unsigned int cpu); -extern unsigned char cpu_core_id[NR_CPUS ];extern cpumask_t cpu_core_map[NR_CPUS ]; +static inline const struct cpumask *cpu_coregroup_mask (unsigned int cpu) +{ +return &cpu_core_map[cpu]; +} +#define topology_core_id (cpu) (cpu_core_id[cpu])#define topology_core_cpumask (cpu) (&cpu_core_map[cpu]) +#define mc_capable () (1) + +#ifdef CONFIG_SCHED_BOOK + +extern unsigned char cpu_book_id[NR_CPUS ]; +extern cpumask_t cpu_book_map[NR_CPUS ]; + +static inline const struct cpumask *cpu_book_mask (unsigned int cpu) +{ +return &cpu_book_map[cpu]; +} + +#define topology_book_id (cpu) (cpu_book_id[cpu]) +#define topology_book_cpumask (cpu) (&cpu_book_map[cpu]) + +#endif /* CONFIG_SCHED_BOOK */ int topology_set_cpu_management (int fc);void topology_schedule_update (void );
@@ -30,6 +47,8 @@ static inline void s390_init_cpu_topology(void) };#endif +#define SD_BOOK_INIT SD_CPU_INIT +#include <asm-generic/topology.h> #endif /* _ASM_S390_TOPOLOGY_H */
arch/s390/kernel/topology.c +93 -57
252 lines not on this page · raw message
arch/x86/Kconfig +11 -0
@@ -795,6 +795,17 @@ config SCHED_MC making when dealing with multi-core CPU chips at a cost of slightly increased overhead in some places. If unsure say N here. +config IRQ_TIME_ACCOUNTING + bool "Fine granularity task level IRQ time accounting" + default n + ---help--- + Select this option to enable fine granularity task irq time + accounting. This is done by reading a timestamp on each + transitions between softirq and hardirq state, so there can be a + small performance impact. + + If in doubt, say N here. + source "kernel/Kconfig.preempt" config X86_UP_APIC
arch/x86/kernel/tsc.c +8 -0
@@ -104,10 +104,14 @@ int __init notsc_setup(char *str)__setup ("notsc" , notsc_setup); +static int no_sched_irq_time; +static int __init tsc_setup (char *str) {if (!strcmp (str,"reliable" )) tsc_clocksource_reliable =1 ; +if (!strncmp (str,"noirqtime" ,9 )) + no_sched_irq_time =1 ;return 1 ; }
@@ -801,6 +805,7 @@ void mark_tsc_unstable(char *reason)if (!tsc_unstable) { tsc_unstable =1 ; sched_clock_stable =0 ; +disable_sched_clock_irqtime ();printk (KERN_INFO "Marking TSC unstable due to %s\n" , reason);/* Change only the rating, when not registered */ if (clocksource_tsc.mult)
@@ -987,6 +992,9 @@ void __init tsc_init(void)/* now allow native_sched_clock() to use rdtsc */ tsc_disabled =0 ; +if (!no_sched_irq_time) +enable_sched_clock_irqtime (); + lpj = ((u64 )tsc_khz *1000 );do_div (lpj,HZ ); lpj_fine = lpj;
drivers/base/topology.c +15 -1
@@ -45,7 +45,8 @@ static ssize_t show_##name(struct sys_device *dev, \ return sprintf(buf, "%d\n", topology_##name(cpu)); \ } -#if defined(topology_thread_cpumask) || defined(topology_core_cpumask) +#if defined(topology_thread_cpumask) || defined(topology_core_cpumask) || \ + defined(topology_book_cpumask)static ssize_t show_cpumap (int type,const struct cpumask *mask,char *buf) {ptrdiff_t len =PTR_ALIGN (buf +PAGE_SIZE -1 ,PAGE_SIZE ) - buf;
@@ -114,6 +115,14 @@ define_siblings_show_func(core_cpumask);define_one_ro_named (core_siblings, show_core_cpumask);define_one_ro_named (core_siblings_list, show_core_cpumask_list); +#ifdef CONFIG_SCHED_BOOK +define_id_show_func (book_id); +define_one_ro (book_id); +define_siblings_show_func (book_cpumask); +define_one_ro_named (book_siblings, show_book_cpumask); +define_one_ro_named (book_siblings_list, show_book_cpumask_list); +#endif +static struct attribute *default_attrs[] = { &attr_physical_package_id.attr, &attr_core_id.attr,
@@ -121,6 +130,11 @@ static struct attribute *default_attrs[] = { &attr_thread_siblings_list.attr, &attr_core_siblings.attr, &attr_core_siblings_list.attr, +#ifdef CONFIG_SCHED_BOOK + &attr_book_id.attr, + &attr_book_siblings.attr, + &attr_book_siblings_list.attr, +#endif NULL };
include/linux/hardirq.h +8 -1
@@ -64,6 +64,8 @@#define HARDIRQ_OFFSET (1UL << HARDIRQ_SHIFT)#define NMI_OFFSET (1UL << NMI_SHIFT) +#define SOFTIRQ_DISABLE_OFFSET (2 * SOFTIRQ_OFFSET) +#ifndef PREEMPT_ACTIVE #define PREEMPT_ACTIVE_BITS 1#define PREEMPT_ACTIVE_SHIFT (NMI_SHIFT + NMI_BITS)
@@ -82,10 +84,13 @@/* * Are we doing bottom half or hardware interrupt processing? * Are we in a softirq context? Interrupt context? +* in_softirq - Are we currently processing softirq or have bh disabled? +* in_serving_softirq - Are we currently processing softirq? */ #define in_irq () (hardirq_count())#define in_softirq () (softirq_count())#define in_interrupt () (irq_count()) +#define in_serving_softirq () (softirq_count() & SOFTIRQ_OFFSET)/* * Are we in NMI context?
@@ -132,10 +137,12 @@ extern void synchronize_irq(unsigned int irq);struct task_struct ; -#ifndef CONFIG_VIRT_CPU_ACCOUNTING +#if !defined(CONFIG_VIRT_CPU_ACCOUNTING ) && !defined(CONFIG_IRQ_TIME_ACCOUNTING )static inline void account_system_vtime (struct task_struct *tsk) { } +#else +extern void account_system_vtime (struct task_struct *tsk);#endif #if defined(CONFIG_NO_HZ )
include/linux/sched.h +18 -5
@@ -875,6 +875,7 @@ enum sched_domain_level {SD_LV_NONE =0 ,SD_LV_SIBLING ,SD_LV_MC , +SD_LV_BOOK ,SD_LV_CPU ,SD_LV_NODE , SD_LV_ALLNODES,
@@ -1681,8 +1682,7 @@ extern void thread_group_times(struct task_struct *p, cputime_t *ut, cputime_t */* * Per process flags */ -#define PF_ALIGNWARN 0x00000001/* Print alignment warning msgs */ -/* Not implemented yet, only for 486*/ +#define PF_KSOFTIRQD 0x00000001/* I am ksoftirqd */ #define PF_STARTING 0x00000002/* being created */ #define PF_EXITING 0x00000004/* getting shut down */ #define PF_EXITPIDONE 0x00000008/* pi exit done on shut down */
@@ -1826,6 +1826,19 @@ extern void sched_clock_idle_sleep_event(void);extern void sched_clock_idle_wakeup_event (u64 delta_ns);#endif +#ifdef CONFIG_IRQ_TIME_ACCOUNTING +/* +* An i/f to runtime opt-in for irq time accounting based off of sched_clock. +* The reason for this explicit opt-in is not to have perf penalty with +* slow sched_clocks. +*/ +extern void enable_sched_clock_irqtime (void ); +extern void disable_sched_clock_irqtime (void ); +#else +static inline void enable_sched_clock_irqtime (void ) {} +static inline void disable_sched_clock_irqtime (void ) {} +#endif +extern unsigned long long task_sched_runtime (struct task_struct *task);extern unsigned long long thread_group_sched_runtime (struct task_struct *task);
@@ -2367,9 +2380,9 @@ extern int __cond_resched_lock(spinlock_t *lock);extern int __cond_resched_softirq (void ); -#define cond_resched_softirq () ({ \ - __might_sleep(__FILE__, __LINE__, SOFTIRQ_OFFSET); \ - __cond_resched_softirq(); \ +#define cond_resched_softirq () ({ \ + __might_sleep(__FILE__, __LINE__, SOFTIRQ_DISABLE_OFFSET); \ + __cond_resched_softirq(); \ })/*
include/linux/topology.h +6 -0
@@ -201,6 +201,12 @@ int arch_update_cpu_topology(void); .balance_interval = 64, \ } +#ifdef CONFIG_SCHED_BOOK +#ifndef SD_BOOK_INIT +#error Please define an appropriate SD_BOOK_INIT in include/asm/topology.h!!! +#endif +#endif /* CONFIG_SCHED_BOOK */ +#ifdef CONFIG_NUMA #ifndef SD_NODE_INIT #error Please define an appropriate SD_NODE_INIT in include/asm/topology.h!!!
include/trace/events/sched.h +29 -0
@@ -362,6 +362,35 @@ TRACE_EVENT(sched_stat_runtime, (unsigned long long)__entry->vruntime) ); +/* +* Tracepoint for showing priority inheritance modifying a tasks +* priority. +*/ +TRACE_EVENT (sched_pi_setprio, + + TP_PROTO(struct task_struct *tsk, int newprio), + +TP_ARGS (tsk, newprio), + +TP_STRUCT__entry ( + __array( char, comm, TASK_COMM_LEN ) + __field( pid_t, pid ) + __field( int, oldprio ) +__field ( int, newprio ) + ), + +TP_fast_assign ( + memcpy(__entry->comm, tsk->comm, TASK_COMM_LEN); + __entry->pid = tsk->pid; + __entry->oldprio = tsk->prio; + __entry->newprio = newprio; + ), + +TP_printk ("comm=%s pid=%d oldprio=%d newprio=%d" , + __entry->comm, __entry->pid, + __entry->oldprio, __entry->newprio) +); +#endif /* _TRACE_SCHED_H */ /* This part must be outside protection */
kernel/sched.c +246 -45
544 lines not on this page · raw message
kernel/sched_fair.c +59 -17
221 lines not on this page · raw message
kernel/sched_features.h +5 -0
@@ -61,3 +61,8 @@ SCHED_FEAT(ASYM_EFF_LOAD, 1)* release the lock. Decreases scheduling overhead. */ SCHED_FEAT (OWNER_SPIN ,1 ) + +/* +* Decrement CPU power based on irq activity + */ +SCHED_FEAT (NONIRQ_POWER ,1 )
kernel/sched_rt.c +22 -18
@@ -609,7 +609,7 @@ static void update_curr_rt(struct rq *rq)if (!task_has_rt_policy (curr))return ; - delta_exec = rq->clock - curr->se.exec_start; + delta_exec = rq->clock_task - curr->se.exec_start;if (unlikely ((s64 )delta_exec <0 )) delta_exec =0 ;
@@ -618,7 +618,7 @@ static void update_curr_rt(struct rq *rq) curr->se.sum_exec_runtime += delta_exec;account_group_exec_runtime (curr, delta_exec); - curr->se.exec_start = rq->clock; + curr->se.exec_start = rq->clock_task;cpuacct_charge (curr, delta_exec);sched_rt_avg_update (rq, delta_exec);
@@ -960,18 +960,19 @@ select_task_rq_rt(struct rq *rq, struct task_struct *p, int sd_flag, int flags)* runqueue. Otherwise simply start this RT task * on its current runqueue. * -* We want to avoid overloading runqueues. Even if -* the RT task is of higher priority than the current RT task. -* RT tasks behave differently than other tasks. If -* one gets preempted, we try to push it off to another queue. -* So trying to keep a preempting RT task on the same -* cache hot CPU will force the running RT task to -* a cold CPU. So we waste all the cache for the lower -* RT task in hopes of saving some of a RT task -* that is just being woken and probably will have -* cold cache anyway. +* We want to avoid overloading runqueues. If the woken +* task is a higher priority, then it will stay on this CPU +* and the lower prio task should be moved to another CPU. +* Even though this will probably make the lower prio task +* lose its cache, we do not want to bounce a higher task +* around just because it gave up its CPU, perhaps for a +* lock? +* +* For equal prio tasks, we just let the scheduler sort it out. */ if (unlikely (rt_task (rq->curr)) && + (rq->curr->rt.nr_cpus_allowed <2 || + rq->curr->prio < p->prio) && (p->rt.nr_cpus_allowed >1 )) {int cpu =find_lowest_rq (p);
@@ -1074,7 +1075,7 @@ static struct task_struct *_pick_next_task_rt(struct rq *rq) }while (rt_rq); p =rt_task_of (rt_se); - p->se.exec_start = rq->clock; + p->se.exec_start = rq->clock_task;return p; }
@@ -1139,7 +1140,7 @@ static struct task_struct *pick_next_highest_task_rt(struct rq *rq, int cpu)for_each_leaf_rt_rq (rt_rq, rq) { array = &rt_rq->active; idx =sched_find_first_bit (array->bitmap); - next_idx: +next_idx:if (idx >=MAX_RT_PRIO )continue ;if (next && next->prio < idx)
@@ -1315,7 +1316,7 @@ static int push_rt_task(struct rq *rq)if (!next_task)return 0 ; - retry: +retry:if (unlikely (next_task == rq->curr)) {WARN_ON (1 );return 0 ;
@@ -1463,7 +1464,7 @@ static int pull_rt_task(struct rq *this_rq)* but possible) */ } - skip: +skip:double_unlock_balance (this_rq, src_rq); }
@@ -1491,7 +1492,10 @@ static void task_woken_rt(struct rq *rq, struct task_struct *p)if (!task_running (rq, p) && !test_tsk_need_resched (rq->curr) &&has_pushable_tasks (rq) && - p->rt.nr_cpus_allowed >1 ) + p->rt.nr_cpus_allowed >1 && +rt_task (rq->curr) && + (rq->curr->rt.nr_cpus_allowed <2 || + rq->curr->prio < p->prio))push_rt_tasks (rq); }
@@ -1709,7 +1713,7 @@ static void set_curr_task_rt(struct rq *rq) {struct task_struct *p = rq->curr; - p->se.exec_start = rq->clock; + p->se.exec_start = rq->clock_task;/* The running task is never eligible for pushing */ dequeue_pushable_task (rq, p);
kernel/sched_stoptask.c new file +108 -0
108 lines not on this page · raw message
kernel/softirq.c +44 -20
142 lines not on this page · raw message
kernel/stop_machine.c +5 -3
@@ -287,11 +287,12 @@ repeat: goto repeat; } +extern void sched_set_stop_task (int cpu,struct task_struct *stop); +/* manage stopper for a cpu, mostly lifted from sched migration thread mgmt */ static int __cpuinit cpu_stop_cpu_callback (struct notifier_block *nfb,unsigned long action,void *hcpu) { -struct sched_param param = { .sched_priority =MAX_RT_PRIO -1 };unsigned int cpu = (unsigned long )hcpu;struct cpu_stopper *stopper = &per_cpu (cpu_stopper, cpu);struct task_struct *p;
@@ -304,13 +305,13 @@ static int __cpuinit cpu_stop_cpu_callback(struct notifier_block *nfb, cpu);if (IS_ERR (p))return NOTIFY_BAD ; -sched_setscheduler_nocheck (p,SCHED_FIFO , ¶m);get_task_struct (p); +kthread_bind (p, cpu); +sched_set_stop_task (cpu, p); stopper->thread = p;break ;case CPU_ONLINE : -kthread_bind (stopper->thread, cpu);/* strictly unnecessary, as first user will wake it */ wake_up_process (stopper->thread);/* mark enabled */
@@ -325,6 +326,7 @@ static int __cpuinit cpu_stop_cpu_callback(struct notifier_block *nfb, {struct cpu_stop_work *work; +sched_set_stop_task (cpu,NULL );/* kill the stopper */ kthread_stop (stopper->thread);/* drain remaining works */
net/sched/cls_cgroup.c +1 -1
@@ -123,7 +123,7 @@ static int cls_cgroup_classify(struct sk_buff *skb, struct tcf_proto *tp,* calls by looking at the number of nested bh disable calls because * softirqs always disables bh. */ -if (softirq_count () !=SOFTIRQ_OFFSET ) { +if (in_serving_softirq ()) {/* If there is an sk_classid we'll use that. */ if (!skb->sk)return -1 ;