sched/core for v2.6.33
Subsystems (5)
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
Highlights:
- task_u/stime fixes that ought to (finally) resolve some of the time accounting bugs that were reported
- Less verbose scheduler messages during bootup.
- Various tweaks and small improvements.
Thanks,
Ingo
------------------>
Dhaval Giani (1):
sched: Add USER_SCHED to feature removal list
Heiko Carstens (1):
sched: Always show Cpus_allowed field in /proc/<pid>/status
Hidetoshi Seto (6):
sched: Fix granularity of task_u/stime()
sched: Introduce task_times() to replace task_{u,s}time() pair
sched: Remove task_{u,s,g}time()
sched, time: Define nsecs_to_jiffies()
sched, cputime: Cleanups related to task_times() sched, cputime: Introduce thread_group_times()
Hiroshi Shimamoto (3):
sched: Remove unused __schedule() declaration
sched: Remove unused time_sync_thresh declaration
sched: Remove unused cpu_nr_migrations()
Jan Blunck (1):
sched_feat_write(): Update ppos instead of file->f_pos
Jayson R. King (1):
sched: Remove obsolete comment in sched_init()
Lai Jiangshan (1):
sched, no_hz: Remove unused rq->last_tick_seen field
Mike Galbraith (5):
sched: Check for an idle shared cache in select_task_rq_fair()
sched: Rate-limit newidle
sched: Fix affinity logic in select_task_rq_fair()
sched: Fix and clean up rate-limit newidle code
sched: Fix/add missing update_rq_clock() calls
Mike Travis (1):
sched: Limit the number of scheduler debug messages
Peter Zijlstra (4):
sched: Make sure task has correct sched_class after policy change
sched: Cleanup select_task_rq_fair()
sched: More generic WAKE_AFFINE vs select_idle_sibling()
sched: Sched_rt_periodic_timer vs cpu hotplug
Rusty Russell (3):
cpumask: Simplify sched_rt.c
cpumask: Partition_sched_domains takes array of cpumask_var_t
sched: Fix isolcpus boot option
Ryota Ozaki (1):
sched, cpuacct: Fix niced guest time accounting
Shmulik Ladkani (1):
sched.c: Call debug_show_all_locks() when dumping all tasks
Tejun Heo (2):
sched, kvm: Fix race condition involving sched_in_preempt_notifers
sched: Revert 498657a478c60be092208422fefa9c7b248729c2
Tim Blechmann (4):
sched: Optimize branch hint in pick_next_task_fair()
sched: Optimize branch hint in context_switch() sched, x86: Optimize branch hint in __switch_to() Revert "sched, x86: Optimize branch hint in __switch_to()"
Documentation/feature-removal-schedule.txt | 15 ++ Documentation/filesystems/proc.txt | 3 +- Documentation/kernel-parameters.txt | 2 + fs/proc/array.c | 23 ++- fs/proc/stat.c | 19 ++- include/linux/jiffies.h | 1 + include/linux/kernel_stat.h | 1 + include/linux/preempt.h | 5 + include/linux/sched.h | 22 ++- kernel/cpuset.c | 27 +-- kernel/exit.c | 22 ++- kernel/fork.c | 5 + kernel/kgdb.c | 2 +- kernel/sched.c | 270 ++++++++++++++++++---------- kernel/sched_debug.c | 4 + kernel/sched_fair.c | 65 ++++++- kernel/sched_rt.c | 61 +++---- kernel/sys.c | 21 +-- kernel/time.c | 30 +++ 19 files changed, 397 insertions(+), 201 deletions(-)
Documentation/feature-removal-schedule.txt +15 -0
@@ -6,6 +6,21 @@ be removed from this file. --------------------------- +What: USER_SCHED +When: 2.6.34 + +Why: USER_SCHED was implemented as a proof of concept for group scheduling. + The effect of USER_SCHED can already be achieved from userspace with + the help of libcgroup. The removal of USER_SCHED will also simplify + the scheduler code with the removal of one major ifdef. There are also + issues USER_SCHED has with USER_NS. A decision was taken not to fix + those and instead remove USER_SCHED. Also new group scheduling + features will not be implemented for USER_SCHED. + +Who: Dhaval Giani <[email protected]> + +--------------------------- + What: PRISM54 When: 2.6.34
Documentation/filesystems/proc.txt +2 -1
@@ -1072,7 +1072,8 @@ second). The meanings of the columns are as follows, from left to right: - irq: servicing interrupts - softirq: servicing softirqs - steal: involuntary wait -- guest: running a guest +- guest: running a normal guest +- guest_nice: running a niced guest The "intr" line gives counts of interrupts serviced since boot time, for each of the possible system interrupts. The first column is the total of all
Documentation/kernel-parameters.txt +2 -0
@@ -2182,6 +2182,8 @@ and is between 256 and 4096 characters. It is defined in the file sbni= [NET] Granch SBNI12 leased line adapter + sched_debug [KNL] Enables verbose scheduler debug messages. + sc1200wdt= [HW,WDT] SC1200 WDT (watchdog) driver Format: <io>[,<timeout>[,<isapnp>]]
fs/proc/array.c +15 -8
@@ -410,6 +410,16 @@ static void task_show_stack_usage(struct seq_file *m, struct task_struct *task) }#endif /* CONFIG_MMU */ +static void task_cpus_allowed (struct seq_file *m,struct task_struct *task) +{ +seq_printf (m,"Cpus_allowed:\t" ); +seq_cpumask (m, &task->cpus_allowed); +seq_printf (m,"\n" ); +seq_printf (m,"Cpus_allowed_list:\t" ); +seq_cpumask_list (m, &task->cpus_allowed); +seq_printf (m,"\n" ); +} +int proc_pid_status (struct seq_file *m,struct pid_namespace *ns,struct pid *pid,struct task_struct *task) {
@@ -424,6 +434,7 @@ int proc_pid_status(struct seq_file *m, struct pid_namespace *ns, }task_sig (m, task);task_cap (m, task); +task_cpus_allowed (m, task);cpuset_task_status_allowed (m, task);#if defined(CONFIG_S390 )task_show_regs (m, task);
@@ -495,20 +506,17 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,/* add up live thread stats at the group level */ if (whole) { -struct task_cputime cputime;struct task_struct *t = task;do { min_flt += t->min_flt; maj_flt += t->maj_flt; - gtime =cputime_add (gtime,task_gtime (t)); + gtime =cputime_add (gtime, t->gtime); t =next_thread (t); }while (t != task); min_flt += sig->min_flt; maj_flt += sig->maj_flt; -thread_group_cputime (task, &cputime); - utime = cputime.utime; - stime = cputime.stime; +thread_group_times (task, &utime, &stime); gtime =cputime_add (gtime, sig->gtime); }
@@ -524,9 +532,8 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,if (!whole) { min_flt = task->min_flt; maj_flt = task->maj_flt; - utime =task_utime (task); - stime =task_stime (task); - gtime =task_gtime (task); +task_times (task, &utime, &stime); + gtime = task->gtime; }/* scale priority and nice values from timeslices to -20..20 */
fs/proc/stat.c +13 -6
@@ -27,7 +27,7 @@ static int show_stat(struct seq_file *p, void *v)int i, j;unsigned long jif;cputime64_t user, nice, system, idle, iowait, irq, softirq, steal; -cputime64_t guest; +cputime64_t guest, guest_nice;u64 sum =0 ;u64 sum_softirq =0 ;unsigned int per_softirq_sums[NR_SOFTIRQS ] = {0 };
@@ -36,7 +36,7 @@ static int show_stat(struct seq_file *p, void *v) user = nice = system = idle = iowait = irq = softirq = steal = cputime64_zero; - guest = cputime64_zero; + guest = guest_nice = cputime64_zero;getboottime (&boottime); jif = boottime.tv_sec;
@@ -51,6 +51,8 @@ static int show_stat(struct seq_file *p, void *v) softirq =cputime64_add (softirq,kstat_cpu (i).cpustat.softirq); steal =cputime64_add (steal,kstat_cpu (i).cpustat.steal); guest =cputime64_add (guest,kstat_cpu (i).cpustat.guest); + guest_nice =cputime64_add (guest_nice, +kstat_cpu (i).cpustat.guest_nice);for_each_irq_nr (j) { sum +=kstat_irqs_cpu (j, i); }
@@ -65,7 +67,8 @@ static int show_stat(struct seq_file *p, void *v) } sum +=arch_irq_stat (); - seq_printf(p, "cpu %llu %llu %llu %llu %llu %llu %llu %llu %llu\n", + seq_printf(p, "cpu %llu %llu %llu %llu %llu %llu %llu %llu %llu " + "%llu\n", (unsigned long long)cputime64_to_clock_t(user), (unsigned long long)cputime64_to_clock_t(nice), (unsigned long long)cputime64_to_clock_t(system),
@@ -74,7 +77,8 @@ static int show_stat(struct seq_file *p, void *v) (unsigned long long )cputime64_to_clock_t (irq), (unsigned long long )cputime64_to_clock_t (softirq), (unsigned long long )cputime64_to_clock_t (steal), - (unsigned long long)cputime64_to_clock_t(guest)); + (unsigned long long )cputime64_to_clock_t (guest), + (unsigned long long)cputime64_to_clock_t(guest_nice));for_each_online_cpu (i) {/* 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) softirq =kstat_cpu (i).cpustat.softirq; steal =kstat_cpu (i).cpustat.steal; guest =kstat_cpu (i).cpustat.guest; + guest_nice =kstat_cpu (i).cpustat.guest_nice; seq_printf(p, - "cpu%d %llu %llu %llu %llu %llu %llu %llu %llu %llu\n", + "cpu%d %llu %llu %llu %llu %llu %llu %llu %llu %llu " + "%llu\n", i, (unsigned long long)cputime64_to_clock_t(user), (unsigned long long)cputime64_to_clock_t(nice),
@@ -99,7 +105,8 @@ static int show_stat(struct seq_file *p, void *v) (unsigned long long )cputime64_to_clock_t (irq), (unsigned long long )cputime64_to_clock_t (softirq), (unsigned long long )cputime64_to_clock_t (steal), - (unsigned long long)cputime64_to_clock_t(guest)); + (unsigned long long )cputime64_to_clock_t (guest), + (unsigned long long)cputime64_to_clock_t(guest_nice)); }seq_printf (p,"intr %llu" , (unsigned long long )sum);
include/linux/jiffies.h +1 -0
@@ -307,6 +307,7 @@ extern clock_t jiffies_to_clock_t(long x);extern unsigned long clock_t_to_jiffies (unsigned long x);extern u64 jiffies_64_to_clock_t (u64 x);extern u64 nsec_to_clock_t (u64 x); +extern unsigned long nsecs_to_jiffies (u64 n);#define TIMESTAMP_SIZE 30
include/linux/kernel_stat.h +1 -0
@@ -25,6 +25,7 @@ struct cpu_usage_stat {cputime64_t iowait;cputime64_t steal;cputime64_t guest; +cputime64_t guest_nice; };struct kernel_stat {
include/linux/preempt.h +5 -0
@@ -105,6 +105,11 @@ struct preempt_notifier;* @sched_out: we've just been preempted * notifier: struct preempt_notifier for the task being preempted * next: the task that's kicking us out +* +* Please note that sched_in and out are called under different +* contexts. sched_out is called with rq lock held and irq disabled +* while sched_in is called without rq lock and irq enabled. This +* difference is intentional and depended upon by its users. */ struct preempt_ops {void (*sched_in)(struct preempt_notifier *notifier,int cpu);
include/linux/sched.h +13 -9
@@ -145,7 +145,6 @@ extern unsigned long this_cpu_load(void);extern void calc_global_load (void ); -extern u64 cpu_nr_migrations (int cpu);extern unsigned long get_parent_ip (unsigned long addr);
@@ -171,8 +170,6 @@ print_cfs_rq(struct seq_file *m, int cpu, struct cfs_rq *cfs_rq) }#endif -extern unsigned long long time_sync_thresh; -/* * Task state bitmask. NOTE! These bits are also * encoded in fs/proc/array.c: get_task_state().
@@ -349,7 +346,6 @@ extern signed long schedule_timeout(signed long timeout);extern signed long schedule_timeout_interruptible (signed long timeout);extern signed long schedule_timeout_killable (signed long timeout);extern signed long schedule_timeout_uninterruptible (signed long timeout); -asmlinkage void __schedule(void); asmlinkage void schedule(void);extern int mutex_spin_on_owner (struct mutex *lock,struct thread_info *owner);
@@ -628,6 +624,9 @@ struct signal_struct {cputime_t utime, stime, cutime, cstime;cputime_t gtime;cputime_t cgtime; +#ifndef CONFIG_VIRT_CPU_ACCOUNTING +cputime_t prev_utime, prev_stime; +#endif unsigned long nvcsw, nivcsw, cnvcsw, cnivcsw;unsigned long min_flt, maj_flt, cmin_flt, cmaj_flt;unsigned long inblock, oublock, cinblock, coublock;
@@ -1013,9 +1012,13 @@ static inline struct cpumask *sched_domain_span(struct sched_domain *sd)return to_cpumask (sd->span); } -extern void partition_sched_domains (int ndoms_new,struct cpumask *doms_new, +extern void partition_sched_domains (int ndoms_new,cpumask_var_t doms_new[],struct sched_domain_attr *dattr_new); +/* Allocate an array of sched domains, for partition_sched_domains(). */ +cpumask_var_t *alloc_sched_domains (unsigned int ndoms); +void free_sched_domains (cpumask_var_t doms[],unsigned int ndoms); +/* Test a flag in parent sched domain */ static inline int test_sd_parent (struct sched_domain *sd,int flag) {
@@ -1033,7 +1036,7 @@ unsigned long default_scale_smt_power(struct sched_domain *sd, int cpu);struct sched_domain_attr ;static inline void -partition_sched_domains (int ndoms_new,struct cpumask *doms_new, +partition_sched_domains (int ndoms_new,cpumask_var_t doms_new[],struct sched_domain_attr *dattr_new) { }
@@ -1331,7 +1334,9 @@ struct task_struct {cputime_t utime, stime, utimescaled, stimescaled;cputime_t gtime; +#ifndef CONFIG_VIRT_CPU_ACCOUNTING cputime_t prev_utime, prev_stime; +#endif unsigned long nvcsw, nivcsw;/* context switch counts */ struct timespec start_time;/* monotonic time */ struct timespec real_start_time;/* boot based time */
@@ -1720,9 +1725,8 @@ static inline void put_task_struct(struct task_struct *t)__put_task_struct (t); } -extern cputime_t task_utime (struct task_struct *p); -extern cputime_t task_stime (struct task_struct *p); -extern cputime_t task_gtime (struct task_struct *p); +extern void task_times (struct task_struct *p,cputime_t *ut,cputime_t *st); +extern void thread_group_times (struct task_struct *p,cputime_t *ut,cputime_t *st);/* * Per process flags
kernel/cpuset.c +10 -17
@@ -537,8 +537,7 @@ update_domain_attr_tree(struct sched_domain_attr *dattr, struct cpuset *c)* element of the partition (one sched domain) to be passed to * partition_sched_domains(). */ -/* FIXME: see the FIXME in partition_sched_domains() */ -static int generate_sched_domains (struct cpumask **domains, +static int generate_sched_domains (cpumask_var_t **domains,struct sched_domain_attr **attributes) {LIST_HEAD (q);/* queue of cpusets to be scanned */
@@ -546,7 +545,7 @@ static int generate_sched_domains(struct cpumask **domains,struct cpuset **csa;/* array of all cpuset ptrs */ int csn;/* how many cpuset ptrs in csa so far */ int i, j, k;/* indices for partition finding loops */ -struct cpumask *doms;/* resulting partition; i.e. sched domains */ +cpumask_var_t *doms;/* resulting partition; i.e. sched domains */ struct sched_domain_attr *dattr;/* attributes for custom domains */ int ndoms =0 ;/* number of sched domains in result */ int nslot;/* next empty doms[] struct cpumask slot */
@@ -557,7 +556,8 @@ static int generate_sched_domains(struct cpumask **domains,/* Special case for the 99% of systems with one, full, sched domain */ if (is_sched_load_balance (&top_cpuset)) { - doms =kmalloc (cpumask_size (),GFP_KERNEL ); + ndoms =1 ; + doms =alloc_sched_domains (ndoms);if (!doms) goto done;
@@ -566,9 +566,8 @@ static int generate_sched_domains(struct cpumask **domains, *dattr =SD_ATTR_INIT ;update_domain_attr_tree (dattr, &top_cpuset); } -cpumask_copy (doms, top_cpuset.cpus_allowed); +cpumask_copy (doms[0 ], top_cpuset.cpus_allowed); - ndoms =1 ; goto done; }
@@ -636,7 +635,7 @@ restart:* Now we know how many domains to create. * Convert <csn, csa> to <ndoms, doms> and populate cpu masks. */ - doms =kmalloc (ndoms *cpumask_size (),GFP_KERNEL ); + doms =alloc_sched_domains (ndoms);if (!doms) goto done;
@@ -656,7 +655,7 @@ restart:continue ; } - dp = doms + nslot; + dp = doms[nslot];if (nslot == ndoms) {static int warnings =10 ;
@@ -718,7 +717,7 @@ done:static void do_rebuild_sched_domains (struct work_struct *unused) {struct sched_domain_attr *attr; -struct cpumask *doms; +cpumask_var_t *doms;int ndoms;get_online_cpus ();
@@ -2052,7 +2051,7 @@ static int cpuset_track_online_cpus(struct notifier_block *unused_nb, unsigned long phase, void *unused_cpu) { struct sched_domain_attr *attr; -struct cpumask *doms; +cpumask_var_t *doms;int ndoms;switch (phase) {
@@ -2537,15 +2536,9 @@ const struct file_operations proc_cpuset_operations = { };#endif /* CONFIG_PROC_PID_CPUSET */ -/* Display task cpus_allowed, mems_allowed in /proc/<pid>/status file. */ +/* Display task mems_allowed in /proc/<pid>/status file. */ void cpuset_task_status_allowed (struct seq_file *m,struct task_struct *task) { -seq_printf (m,"Cpus_allowed:\t" ); -seq_cpumask (m, &task->cpus_allowed); -seq_printf (m,"\n" ); -seq_printf (m,"Cpus_allowed_list:\t" ); -seq_cpumask_list (m, &task->cpus_allowed); -seq_printf (m,"\n" );seq_printf (m,"Mems_allowed:\t" );seq_nodemask (m, &task->mems_allowed);seq_printf (m,"\n" );
kernel/exit.c +13 -9
@@ -110,9 +110,9 @@ static void __exit_signal(struct task_struct *tsk)* We won't ever get here for the group leader, since it * will have been the last reference on the signal_struct. */ - sig->utime =cputime_add (sig->utime,task_utime (tsk)); - sig->stime =cputime_add (sig->stime,task_stime (tsk)); - sig->gtime =cputime_add (sig->gtime,task_gtime (tsk)); + sig->utime =cputime_add (sig->utime, tsk->utime); + sig->stime =cputime_add (sig->stime, tsk->stime); + sig->gtime =cputime_add (sig->gtime, tsk->gtime); sig->min_flt += tsk->min_flt; sig->maj_flt += tsk->maj_flt; sig->nvcsw += tsk->nvcsw;
@@ -1205,6 +1205,7 @@ static int wait_task_zombie(struct wait_opts *wo, struct task_struct *p)struct signal_struct *psig;struct signal_struct *sig;unsigned long maxrss; +cputime_t tgutime, tgstime;/* * The resource counters for the group leader are in its
@@ -1220,20 +1221,23 @@ static int wait_task_zombie(struct wait_opts *wo, struct task_struct *p)* need to protect the access to parent->signal fields, * as other threads in the parent group can be right * here reaping other children at the same time. +* +* We use thread_group_times() to get times for the thread +* group, which consolidates times for all threads in the +* group including the group leader. */ +thread_group_times (p, &tgutime, &tgstime);spin_lock_irq (&p->real_parent->sighand->siglock); psig = p->real_parent->signal; sig = p->signal; psig->cutime =cputime_add (psig->cutime, -cputime_add (p->utime, -cputime_add (sig->utime, - sig->cutime))); +cputime_add (tgutime, + sig->cutime)); psig->cstime =cputime_add (psig->cstime, -cputime_add (p->stime, -cputime_add (sig->stime, - sig->cstime))); +cputime_add (tgstime, + sig->cstime)); psig->cgtime = cputime_add(psig->cgtime, cputime_add(p->gtime,
kernel/fork.c +5 -0
@@ -884,6 +884,9 @@ static int copy_signal(unsigned long clone_flags, struct task_struct *tsk) sig->utime = sig->stime = sig->cutime = sig->cstime = cputime_zero; sig->gtime = cputime_zero; sig->cgtime = cputime_zero; +#ifndef CONFIG_VIRT_CPU_ACCOUNTING + sig->prev_utime = sig->prev_stime = cputime_zero; +#endif sig->nvcsw = sig->nivcsw = sig->cnvcsw = sig->cnivcsw =0 ; sig->min_flt = sig->maj_flt = sig->cmin_flt = sig->cmaj_flt =0 ; sig->inblock = sig->oublock = sig->cinblock = sig->coublock =0 ;
@@ -1066,8 +1069,10 @@ static struct task_struct *copy_process(unsigned long clone_flags, p->gtime = cputime_zero; p->utimescaled = cputime_zero; p->stimescaled = cputime_zero; +#ifndef CONFIG_VIRT_CPU_ACCOUNTING p->prev_utime = cputime_zero; p->prev_stime = cputime_zero; +#endif p->default_timer_slack_ns = current->timer_slack_ns;
kernel/kgdb.c +1 -1
@@ -870,7 +870,7 @@ static void gdb_cmd_getregs(struct kgdb_state *ks)/* * All threads that don't have debuggerinfo should be -* in __schedule() sleeping, since all other CPUs +* in schedule() sleeping, since all other CPUs * are in kgdb_wait, and thus have debuggerinfo. */ if (local_debuggerinfo) {
kernel/sched.c +174 -96
546 lines not on this page · raw message
kernel/sched_debug.c +4 -0
@@ -285,12 +285,16 @@ static void print_cpu(struct seq_file *m, int cpu)#ifdef CONFIG_SCHEDSTATS #define P (n) SEQ_printf(m, " .%-30s: %d\n", #n, rq->n); +#define P64 (n) SEQ_printf(m, " .%-30s: %Ld\n", #n, rq->n);P (yld_count);P (sched_switch);P (sched_count);P (sched_goidle); +#ifdef CONFIG_SMP +P64 (avg_idle); +#endif P (ttwu_count);P (ttwu_local);
kernel/sched_fair.c +60 -5
84 lines not on this page · raw message
kernel/sched_rt.c +24 -37
88 lines not on this page · raw message
kernel/sys.c +9 -12
@@ -911,16 +911,15 @@ change_okay:void do_sys_times (struct tms *tms) { -struct task_cputime cputime; -cputime_t cutime, cstime; +cputime_t tgutime, tgstime, cutime, cstime; -thread_group_cputime (current, &cputime);spin_lock_irq (¤t->sighand->siglock); +thread_group_times (current, &tgutime, &tgstime); cutime = current->signal->cutime; cstime = current->signal->cstime;spin_unlock_irq (¤t->sighand->siglock); - tms->tms_utime =cputime_to_clock_t (cputime.utime); - tms->tms_stime =cputime_to_clock_t (cputime.stime); + tms->tms_utime =cputime_to_clock_t (tgutime); + tms->tms_stime =cputime_to_clock_t (tgstime); tms->tms_cutime =cputime_to_clock_t (cutime); tms->tms_cstime =cputime_to_clock_t (cstime); }
@@ -1338,16 +1337,14 @@ static void k_getrusage(struct task_struct *p, int who, struct rusage *r) {struct task_struct *t;unsigned long flags; -cputime_t utime, stime; -struct task_cputime cputime; +cputime_t tgutime, tgstime, utime, stime;unsigned long maxrss =0 ;memset ((char *) r,0 ,sizeof *r); utime = stime = cputime_zero;if (who ==RUSAGE_THREAD ) { - utime =task_utime (current); - stime =task_stime (current); +task_times (current, &utime, &stime);accumulate_thread_rusage (p, r); maxrss = p->signal->maxrss; goto out;
@@ -1373,9 +1370,9 @@ static void k_getrusage(struct task_struct *p, int who, struct rusage *r)break ;case RUSAGE_SELF : -thread_group_cputime (p, &cputime); - utime =cputime_add (utime, cputime.utime); - stime =cputime_add (stime, cputime.stime); +thread_group_times (p, &tgutime, &tgstime); + utime =cputime_add (utime, tgutime); + stime =cputime_add (stime, tgstime); r->ru_nvcsw += p->signal->nvcsw; r->ru_nivcsw += p->signal->nivcsw; r->ru_minflt += p->signal->min_flt;
kernel/time.c +30 -0
@@ -662,6 +662,36 @@ u64 nsec_to_clock_t(u64 x)#endif } +/** +* nsecs_to_jiffies - Convert nsecs in u64 to jiffies +* +* @n: nsecs in u64 +* +* Unlike {m,u}secs_to_jiffies, type of input is not unsigned int but u64. +* And this doesn't return MAX_JIFFY_OFFSET since this function is designed +* for scheduler, not for use in device drivers to calculate timeout value. +* +* note: +* NSEC_PER_SEC = 10^9 = (5^9 * 2^9) = (1953125 * 512) +* ULLONG_MAX ns = 18446744073.709551615 secs = about 584 years +*/ +unsigned long nsecs_to_jiffies (u64 n) +{ +#if (NSEC_PER_SEC %HZ ) ==0 +/* Common case, HZ = 100, 128, 200, 250, 256, 500, 512, 1000 etc. */ +return div_u64 (n,NSEC_PER_SEC /HZ ); +#elif (HZ %512 ) ==0 +/* overflow after 292 years if HZ = 1024 */ +return div_u64 (n *HZ /512 ,NSEC_PER_SEC /512 ); +#else +/* +* Generic case - optimized for cases where HZ is a multiple of 3. +* overflow after 64.99 years, exact for HZ = 60, 72, 90, 120 etc. +*/ +return div_u64 (n *9 , (9ull *NSEC_PER_SEC +HZ /2 ) /HZ ); +#endif +} +#if (BITS_PER_LONG <64 )u64 get_jiffies_64 (void ) {