Skip to content

Commit 897e81b

Browse files
committed
Merge branch 'sched-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip
* 'sched-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip: (35 commits) sched, cputime: Introduce thread_group_times() sched, cputime: Cleanups related to task_times() Revert "sched, x86: Optimize branch hint in __switch_to()" sched: Fix isolcpus boot option sched: Revert 498657a sched, time: Define nsecs_to_jiffies() sched: Remove task_{u,s,g}time() sched: Introduce task_times() to replace task_{u,s}time() pair sched: Limit the number of scheduler debug messages sched.c: Call debug_show_all_locks() when dumping all tasks sched, x86: Optimize branch hint in __switch_to() sched: Optimize branch hint in context_switch() sched: Optimize branch hint in pick_next_task_fair() sched_feat_write(): Update ppos instead of file->f_pos sched: Sched_rt_periodic_timer vs cpu hotplug sched, kvm: Fix race condition involving sched_in_preempt_notifers sched: More generic WAKE_AFFINE vs select_idle_sibling() sched: Cleanup select_task_rq_fair() sched: Fix granularity of task_u/stime() sched: Fix/add missing update_rq_clock() calls ...
2 parents c3fa27d + 0cf55e1 commit 897e81b

19 files changed

Lines changed: 397 additions & 201 deletions

File tree

‎Documentation/feature-removal-schedule.txt‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,21 @@ be removed from this file.
66

77
---------------------------
88

9+
What: USER_SCHED
10+
When: 2.6.34
11+
12+
Why: USER_SCHED was implemented as a proof of concept for group scheduling.
13+
The effect of USER_SCHED can already be achieved from userspace with
14+
the help of libcgroup. The removal of USER_SCHED will also simplify
15+
the scheduler code with the removal of one major ifdef. There are also
16+
issues USER_SCHED has with USER_NS. A decision was taken not to fix
17+
those and instead remove USER_SCHED. Also new group scheduling
18+
features will not be implemented for USER_SCHED.
19+
20+
Who: Dhaval Giani <dhaval@linux.vnet.ibm.com>
21+
22+
---------------------------
23+
924
What: PRISM54
1025
When: 2.6.34
1126

‎Documentation/filesystems/proc.txt‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1072,7 +1072,8 @@ second). The meanings of the columns are as follows, from left to right:
10721072
- irq: servicing interrupts
10731073
- softirq: servicing softirqs
10741074
- steal: involuntary wait
1075-
- guest: running a guest
1075+
- guest: running a normal guest
1076+
- guest_nice: running a niced guest
10761077

10771078
The "intr" line gives counts of interrupts serviced since boot time, for each
10781079
of the possible system interrupts. The first column is the total of all

‎Documentation/kernel-parameters.txt‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2186,6 +2186,8 @@ and is between 256 and 4096 characters. It is defined in the file
21862186

21872187
sbni= [NET] Granch SBNI12 leased line adapter
21882188

2189+
sched_debug [KNL] Enables verbose scheduler debug messages.
2190+
21892191
sc1200wdt= [HW,WDT] SC1200 WDT (watchdog) driver
21902192
Format: <io>[,<timeout>[,<isapnp>]]
21912193

‎fs/proc/array.c‎

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -410,6 +410,16 @@ static void task_show_stack_usage(struct seq_file *m, struct task_struct *task)
410410
}
411411
#endif /* CONFIG_MMU */
412412

413+
static void task_cpus_allowed(struct seq_file *m, struct task_struct *task)
414+
{
415+
seq_printf(m, "Cpus_allowed:\t");
416+
seq_cpumask(m, &task->cpus_allowed);
417+
seq_printf(m, "\n");
418+
seq_printf(m, "Cpus_allowed_list:\t");
419+
seq_cpumask_list(m, &task->cpus_allowed);
420+
seq_printf(m, "\n");
421+
}
422+
413423
int proc_pid_status(struct seq_file *m, struct pid_namespace *ns,
414424
struct pid *pid, struct task_struct *task)
415425
{
@@ -424,6 +434,7 @@ int proc_pid_status(struct seq_file *m, struct pid_namespace *ns,
424434
}
425435
task_sig(m, task);
426436
task_cap(m, task);
437+
task_cpus_allowed(m, task);
427438
cpuset_task_status_allowed(m, task);
428439
#if defined(CONFIG_S390)
429440
task_show_regs(m, task);
@@ -495,20 +506,17 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
495506

496507
/* add up live thread stats at the group level */
497508
if (whole) {
498-
struct task_cputime cputime;
499509
struct task_struct *t = task;
500510
do {
501511
min_flt += t->min_flt;
502512
maj_flt += t->maj_flt;
503-
gtime = cputime_add(gtime, task_gtime(t));
513+
gtime = cputime_add(gtime, t->gtime);
504514
t = next_thread(t);
505515
} while (t != task);
506516

507517
min_flt += sig->min_flt;
508518
maj_flt += sig->maj_flt;
509-
thread_group_cputime(task, &cputime);
510-
utime = cputime.utime;
511-
stime = cputime.stime;
519+
thread_group_times(task, &utime, &stime);
512520
gtime = cputime_add(gtime, sig->gtime);
513521
}
514522

@@ -524,9 +532,8 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
524532
if (!whole) {
525533
min_flt = task->min_flt;
526534
maj_flt = task->maj_flt;
527-
utime = task_utime(task);
528-
stime = task_stime(task);
529-
gtime = task_gtime(task);
535+
task_times(task, &utime, &stime);
536+
gtime = task->gtime;
530537
}
531538

532539
/* scale priority and nice values from timeslices to -20..20 */

‎fs/proc/stat.c‎

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ static int show_stat(struct seq_file *p, void *v)
2727
int i, j;
2828
unsigned long jif;
2929
cputime64_t user, nice, system, idle, iowait, irq, softirq, steal;
30-
cputime64_t guest;
30+
cputime64_t guest, guest_nice;
3131
u64 sum = 0;
3232
u64 sum_softirq = 0;
3333
unsigned int per_softirq_sums[NR_SOFTIRQS] = {0};
@@ -36,7 +36,7 @@ static int show_stat(struct seq_file *p, void *v)
3636

3737
user = nice = system = idle = iowait =
3838
irq = softirq = steal = cputime64_zero;
39-
guest = cputime64_zero;
39+
guest = guest_nice = cputime64_zero;
4040
getboottime(&boottime);
4141
jif = boottime.tv_sec;
4242

@@ -51,6 +51,8 @@ static int show_stat(struct seq_file *p, void *v)
5151
softirq = cputime64_add(softirq, kstat_cpu(i).cpustat.softirq);
5252
steal = cputime64_add(steal, kstat_cpu(i).cpustat.steal);
5353
guest = cputime64_add(guest, kstat_cpu(i).cpustat.guest);
54+
guest_nice = cputime64_add(guest_nice,
55+
kstat_cpu(i).cpustat.guest_nice);
5456
for_each_irq_nr(j) {
5557
sum += kstat_irqs_cpu(j, i);
5658
}
@@ -65,7 +67,8 @@ static int show_stat(struct seq_file *p, void *v)
6567
}
6668
sum += arch_irq_stat();
6769

68-
seq_printf(p, "cpu %llu %llu %llu %llu %llu %llu %llu %llu %llu\n",
70+
seq_printf(p, "cpu %llu %llu %llu %llu %llu %llu %llu %llu %llu "
71+
"%llu\n",
6972
(unsigned long long)cputime64_to_clock_t(user),
7073
(unsigned long long)cputime64_to_clock_t(nice),
7174
(unsigned long long)cputime64_to_clock_t(system),
@@ -74,7 +77,8 @@ static int show_stat(struct seq_file *p, void *v)
7477
(unsigned long long)cputime64_to_clock_t(irq),
7578
(unsigned long long)cputime64_to_clock_t(softirq),
7679
(unsigned long long)cputime64_to_clock_t(steal),
77-
(unsigned long long)cputime64_to_clock_t(guest));
80+
(unsigned long long)cputime64_to_clock_t(guest),
81+
(unsigned long long)cputime64_to_clock_t(guest_nice));
7882
for_each_online_cpu(i) {
7983

8084
/* Copy values here to work around gcc-2.95.3, gcc-2.96 */
@@ -88,8 +92,10 @@ static int show_stat(struct seq_file *p, void *v)
8892
softirq = kstat_cpu(i).cpustat.softirq;
8993
steal = kstat_cpu(i).cpustat.steal;
9094
guest = kstat_cpu(i).cpustat.guest;
95+
guest_nice = kstat_cpu(i).cpustat.guest_nice;
9196
seq_printf(p,
92-
"cpu%d %llu %llu %llu %llu %llu %llu %llu %llu %llu\n",
97+
"cpu%d %llu %llu %llu %llu %llu %llu %llu %llu %llu "
98+
"%llu\n",
9399
i,
94100
(unsigned long long)cputime64_to_clock_t(user),
95101
(unsigned long long)cputime64_to_clock_t(nice),
@@ -99,7 +105,8 @@ static int show_stat(struct seq_file *p, void *v)
99105
(unsigned long long)cputime64_to_clock_t(irq),
100106
(unsigned long long)cputime64_to_clock_t(softirq),
101107
(unsigned long long)cputime64_to_clock_t(steal),
102-
(unsigned long long)cputime64_to_clock_t(guest));
108+
(unsigned long long)cputime64_to_clock_t(guest),
109+
(unsigned long long)cputime64_to_clock_t(guest_nice));
103110
}
104111
seq_printf(p, "intr %llu", (unsigned long long)sum);
105112

‎include/linux/jiffies.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,7 @@ extern clock_t jiffies_to_clock_t(long x);
307307
extern unsigned long clock_t_to_jiffies(unsigned long x);
308308
extern u64 jiffies_64_to_clock_t(u64 x);
309309
extern u64 nsec_to_clock_t(u64 x);
310+
extern unsigned long nsecs_to_jiffies(u64 n);
310311

311312
#define TIMESTAMP_SIZE 30
312313

‎include/linux/kernel_stat.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ struct cpu_usage_stat {
2525
cputime64_t iowait;
2626
cputime64_t steal;
2727
cputime64_t guest;
28+
cputime64_t guest_nice;
2829
};
2930

3031
struct kernel_stat {

‎include/linux/preempt.h‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,11 @@ struct preempt_notifier;
105105
* @sched_out: we've just been preempted
106106
* notifier: struct preempt_notifier for the task being preempted
107107
* next: the task that's kicking us out
108+
*
109+
* Please note that sched_in and out are called under different
110+
* contexts. sched_out is called with rq lock held and irq disabled
111+
* while sched_in is called without rq lock and irq enabled. This
112+
* difference is intentional and depended upon by its users.
108113
*/
109114
struct preempt_ops {
110115
void (*sched_in)(struct preempt_notifier *notifier, int cpu);

‎include/linux/sched.h‎

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,6 @@ extern unsigned long this_cpu_load(void);
145145

146146

147147
extern void calc_global_load(void);
148-
extern u64 cpu_nr_migrations(int cpu);
149148

150149
extern unsigned long get_parent_ip(unsigned long addr);
151150

@@ -171,8 +170,6 @@ print_cfs_rq(struct seq_file *m, int cpu, struct cfs_rq *cfs_rq)
171170
}
172171
#endif
173172

174-
extern unsigned long long time_sync_thresh;
175-
176173
/*
177174
* Task state bitmask. NOTE! These bits are also
178175
* encoded in fs/proc/array.c: get_task_state().
@@ -349,7 +346,6 @@ extern signed long schedule_timeout(signed long timeout);
349346
extern signed long schedule_timeout_interruptible(signed long timeout);
350347
extern signed long schedule_timeout_killable(signed long timeout);
351348
extern signed long schedule_timeout_uninterruptible(signed long timeout);
352-
asmlinkage void __schedule(void);
353349
asmlinkage void schedule(void);
354350
extern int mutex_spin_on_owner(struct mutex *lock, struct thread_info *owner);
355351

@@ -628,6 +624,9 @@ struct signal_struct {
628624
cputime_t utime, stime, cutime, cstime;
629625
cputime_t gtime;
630626
cputime_t cgtime;
627+
#ifndef CONFIG_VIRT_CPU_ACCOUNTING
628+
cputime_t prev_utime, prev_stime;
629+
#endif
631630
unsigned long nvcsw, nivcsw, cnvcsw, cnivcsw;
632631
unsigned long min_flt, maj_flt, cmin_flt, cmaj_flt;
633632
unsigned long inblock, oublock, cinblock, coublock;
@@ -1013,9 +1012,13 @@ static inline struct cpumask *sched_domain_span(struct sched_domain *sd)
10131012
return to_cpumask(sd->span);
10141013
}
10151014

1016-
extern void partition_sched_domains(int ndoms_new, struct cpumask *doms_new,
1015+
extern void partition_sched_domains(int ndoms_new, cpumask_var_t doms_new[],
10171016
struct sched_domain_attr *dattr_new);
10181017

1018+
/* Allocate an array of sched domains, for partition_sched_domains(). */
1019+
cpumask_var_t *alloc_sched_domains(unsigned int ndoms);
1020+
void free_sched_domains(cpumask_var_t doms[], unsigned int ndoms);
1021+
10191022
/* Test a flag in parent sched domain */
10201023
static inline int test_sd_parent(struct sched_domain *sd, int flag)
10211024
{
@@ -1033,7 +1036,7 @@ unsigned long default_scale_smt_power(struct sched_domain *sd, int cpu);
10331036
struct sched_domain_attr;
10341037

10351038
static inline void
1036-
partition_sched_domains(int ndoms_new, struct cpumask *doms_new,
1039+
partition_sched_domains(int ndoms_new, cpumask_var_t doms_new[],
10371040
struct sched_domain_attr *dattr_new)
10381041
{
10391042
}
@@ -1331,7 +1334,9 @@ struct task_struct {
13311334

13321335
cputime_t utime, stime, utimescaled, stimescaled;
13331336
cputime_t gtime;
1337+
#ifndef CONFIG_VIRT_CPU_ACCOUNTING
13341338
cputime_t prev_utime, prev_stime;
1339+
#endif
13351340
unsigned long nvcsw, nivcsw; /* context switch counts */
13361341
struct timespec start_time; /* monotonic time */
13371342
struct timespec real_start_time; /* boot based time */
@@ -1720,9 +1725,8 @@ static inline void put_task_struct(struct task_struct *t)
17201725
__put_task_struct(t);
17211726
}
17221727

1723-
extern cputime_t task_utime(struct task_struct *p);
1724-
extern cputime_t task_stime(struct task_struct *p);
1725-
extern cputime_t task_gtime(struct task_struct *p);
1728+
extern void task_times(struct task_struct *p, cputime_t *ut, cputime_t *st);
1729+
extern void thread_group_times(struct task_struct *p, cputime_t *ut, cputime_t *st);
17261730

17271731
/*
17281732
* Per process flags

‎kernel/cpuset.c‎

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -537,16 +537,15 @@ update_domain_attr_tree(struct sched_domain_attr *dattr, struct cpuset *c)
537537
* element of the partition (one sched domain) to be passed to
538538
* partition_sched_domains().
539539
*/
540-
/* FIXME: see the FIXME in partition_sched_domains() */
541-
static int generate_sched_domains(struct cpumask **domains,
540+
static int generate_sched_domains(cpumask_var_t **domains,
542541
struct sched_domain_attr **attributes)
543542
{
544543
LIST_HEAD(q); /* queue of cpusets to be scanned */
545544
struct cpuset *cp; /* scans q */
546545
struct cpuset **csa; /* array of all cpuset ptrs */
547546
int csn; /* how many cpuset ptrs in csa so far */
548547
int i, j, k; /* indices for partition finding loops */
549-
struct cpumask *doms; /* resulting partition; i.e. sched domains */
548+
cpumask_var_t *doms; /* resulting partition; i.e. sched domains */
550549
struct sched_domain_attr *dattr; /* attributes for custom domains */
551550
int ndoms = 0; /* number of sched domains in result */
552551
int nslot; /* next empty doms[] struct cpumask slot */
@@ -557,7 +556,8 @@ static int generate_sched_domains(struct cpumask **domains,
557556

558557
/* Special case for the 99% of systems with one, full, sched domain */
559558
if (is_sched_load_balance(&top_cpuset)) {
560-
doms = kmalloc(cpumask_size(), GFP_KERNEL);
559+
ndoms = 1;
560+
doms = alloc_sched_domains(ndoms);
561561
if (!doms)
562562
goto done;
563563

@@ -566,9 +566,8 @@ static int generate_sched_domains(struct cpumask **domains,
566566
*dattr = SD_ATTR_INIT;
567567
update_domain_attr_tree(dattr, &top_cpuset);
568568
}
569-
cpumask_copy(doms, top_cpuset.cpus_allowed);
569+
cpumask_copy(doms[0], top_cpuset.cpus_allowed);
570570

571-
ndoms = 1;
572571
goto done;
573572
}
574573

@@ -636,7 +635,7 @@ static int generate_sched_domains(struct cpumask **domains,
636635
* Now we know how many domains to create.
637636
* Convert <csn, csa> to <ndoms, doms> and populate cpu masks.
638637
*/
639-
doms = kmalloc(ndoms * cpumask_size(), GFP_KERNEL);
638+
doms = alloc_sched_domains(ndoms);
640639
if (!doms)
641640
goto done;
642641

@@ -656,7 +655,7 @@ static int generate_sched_domains(struct cpumask **domains,
656655
continue;
657656
}
658657

659-
dp = doms + nslot;
658+
dp = doms[nslot];
660659

661660
if (nslot == ndoms) {
662661
static int warnings = 10;
@@ -718,7 +717,7 @@ static int generate_sched_domains(struct cpumask **domains,
718717
static void do_rebuild_sched_domains(struct work_struct *unused)
719718
{
720719
struct sched_domain_attr *attr;
721-
struct cpumask *doms;
720+
cpumask_var_t *doms;
722721
int ndoms;
723722

724723
get_online_cpus();
@@ -2052,7 +2051,7 @@ static int cpuset_track_online_cpus(struct notifier_block *unused_nb,
20522051
unsigned long phase, void *unused_cpu)
20532052
{
20542053
struct sched_domain_attr *attr;
2055-
struct cpumask *doms;
2054+
cpumask_var_t *doms;
20562055
int ndoms;
20572056

20582057
switch (phase) {
@@ -2537,15 +2536,9 @@ const struct file_operations proc_cpuset_operations = {
25372536
};
25382537
#endif /* CONFIG_PROC_PID_CPUSET */
25392538

2540-
/* Display task cpus_allowed, mems_allowed in /proc/<pid>/status file. */
2539+
/* Display task mems_allowed in /proc/<pid>/status file. */
25412540
void cpuset_task_status_allowed(struct seq_file *m, struct task_struct *task)
25422541
{
2543-
seq_printf(m, "Cpus_allowed:\t");
2544-
seq_cpumask(m, &task->cpus_allowed);
2545-
seq_printf(m, "\n");
2546-
seq_printf(m, "Cpus_allowed_list:\t");
2547-
seq_cpumask_list(m, &task->cpus_allowed);
2548-
seq_printf(m, "\n");
25492542
seq_printf(m, "Mems_allowed:\t");
25502543
seq_nodemask(m, &task->mems_allowed);
25512544
seq_printf(m, "\n");

0 commit comments

Comments
 (0)