BFS backport to 2.6.27
Subsystems (18)
PATCH 3/4 sched: account system time properly
In reply to Jayson R. KingFrom: Eric Dumazet <[email protected]>
[upstream commit f5f293a4e3d0a0c52cec31de6762c95050156516] [this is not actually necessary for applying BFS, but is included for the sake of completeness since it is mirrored in BFS]
Andrew Gallatin reported that IRQ and SOFTIRQ times were sometime not reported correctly on recent kernels, and even bisected to commit 457533a7d3402d1d91fbc125c8bd1bd16dcd3cd4 ([PATCH] fix scaled & unscaled cputime accounting) as the first bad commit.
Further analysis pointed that commit 79741dd35713ff4f6fd0eafd59fa94e8a4ba922d ([PATCH] idle cputime accounting) was the real cause of the problem.
account_process_tick() was not taking into account timer IRQ interrupting the idle task servicing a hard or soft irq.
On mostly idle cpu, irqs were thus not accounted and top or mpstat could tell user/admin that cpu was 100 % idle, 0.00 % irq, 0.00 % softirq, while it was not.
[ Impact: fix occasionally incorrect CPU statistics in top/mpstat ]
LKML-Reference: <[email protected]>
--- kernel/sched.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/sched.c +1 -1
@@ -4187,7 +4187,7 @@ void account_process_tick(struct task_stif (user_tick)account_user_time (p, one_jiffy, one_jiffy_scaled); -else if (p != rq->idle) +else if ((p != rq->idle) || (irq_count () !=HARDIRQ_OFFSET ))account_system_time (p,HARDIRQ_OFFSET , one_jiffy, one_jiffy_scaled);else
PATCH 4/4 BFS backport to 2.6.27
In reply to Jayson R. KingThe Brain Fuck Scheduler v0.302 by Con Kolivas.
Backported to kernel 2.6.27.35 by Jayson R. King <[email protected]> Prereqs to apply: mainline patches 457533a7, 79741dd3 and f5f293a4. Known issues for 2.6.27:
- microcode update does not work
- others? please email me ([email protected]) if you have problems with this port
--- Documentation/sysctl/kernel.txt | 26 Makefile | 2 fs/pipe.c | 4 fs/proc/base.c | 2 include/linux/init_task.h | 15 include/linux/ioprio.h | 2 include/linux/sched.h | 184 init/Kconfig | 56 init/main.c | 2 kernel/Makefile | 4 kernel/delayacct.c | 2 kernel/exit.c | 3 kernel/fork.c | 1 kernel/kthread.c | 3 kernel/posix-cpu-timers.c | 20 kernel/sched_bfs.c | 5811 ++++++++++++++++++++++++++++++ kernel/sysctl.c | 139 kernel/timer.c | 3 kernel/trace/trace.c | 4 kernel/workqueue.c | 2 mm/oom_kill.c | 2 21 files changed, 5918 insertions(+), 369 deletions(-)
Documentation/sysctl/kernel.txt +26 -0
@@ -25,6 +25,7 @@ show up in /proc/sys/kernel: - domainname - hostname - hotplug +- iso_cpu - java-appletviewer [ binfmt_java, obsolete ] - java-interpreter [ binfmt_java, obsolete ] - kstack_depth_to_print [ X86 only ]
@@ -44,6 +45,7 @@ show up in /proc/sys/kernel: - randomize_va_space - real-root-dev ==> Documentation/initrd.txt - reboot-cmd [ SPARC only ] +- rr_interval - rtsig-max - rtsig-nr - sem
@@ -165,6 +167,16 @@ Default value is "/sbin/hotplug". ============================================================== +iso_cpu: + +This sets the percentage cpu that the unprivileged SCHED_ISO tasks can +run effectively at realtime priority, averaged over a rolling five +seconds over the -whole- system, meaning all cpus. + +Set to 70 (percent) by default. + +============================================================== + l2cr: (PPC only) This flag controls the L2 cache of G3 processor boards. If
@@ -317,6 +329,20 @@ rebooting. ??? ============================================================== +rr_interval: + +This is the smallest duration that any cpu process scheduling unit +will run for. Increasing this value can increase throughput of cpu +bound tasks substantially but at the expense of increased latencies +overall. Conversely decreasing it will decrease average and maximum +latencies but at the expense of throughput. This value is in +milliseconds and the default value chosen depends on the number of +cpus available at scheduler initialisation with a minimum of 6. + +Valid values are from 1-5000. + +============================================================== + rtsig-max & rtsig-nr: The file rtsig-max can be used to tune the maximum number
fs/pipe.c +0 -4
@@ -42,10 +42,6 @@ void pipe_wait(struct pipe_inode_info *p {DEFINE_WAIT (wait); -/* -* Pipes are system-local resources, so sleeping on them -* is considered a noninteractive wait: -*/ prepare_to_wait (&pipe->wait, &wait,TASK_INTERRUPTIBLE );if (pipe->inode)mutex_unlock (&pipe->inode->i_mutex);
fs/proc/base.c +1 -1
@@ -340,7 +340,7 @@ static int proc_pid_wchan(struct task_ststatic int proc_pid_schedstat (struct task_struct *task,char *buffer) {return sprintf (buffer,"%llu %llu %lu\n" , - task->sched_info.cpu_time, + task->sched_time, task->sched_info.run_delay, task->sched_info.pcount); }
include/linux/init_task.h +5 -10
@@ -124,21 +124,16 @@ extern struct group_info init_groups; .usage = ATOMIC_INIT(2), \ .flags = PF_KTHREAD, \ .lock_depth = -1, \ - .prio = MAX_PRIO-20, \ + .prio = NORMAL_PRIO, \ .static_prio = MAX_PRIO-20, \ - .normal_prio = MAX_PRIO-20, \ + .normal_prio = NORMAL_PRIO, \ + .deadline = 0, \ .policy = SCHED_NORMAL, \ .cpus_allowed = CPU_MASK_ALL, \ .mm = NULL, \ .active_mm = &init_mm, \ - .se = { \ - .group_node = LIST_HEAD_INIT(tsk.se.group_node), \ - }, \ - .rt = { \ - .run_list = LIST_HEAD_INIT(tsk.rt.run_list), \ - .time_slice = HZ, \ - .nr_cpus_allowed = NR_CPUS, \ - }, \ + .run_list = LIST_HEAD_INIT(tsk.run_list), \ + .time_slice = HZ, \ .tasks = LIST_HEAD_INIT(tsk.tasks), \ .ptraced = LIST_HEAD_INIT(tsk.ptraced), \ .ptrace_entry = LIST_HEAD_INIT(tsk.ptrace_entry), \
include/linux/ioprio.h +1 -1
@@ -73,7 +73,7 @@ static inline int task_nice_ioprio(struc*/ static inline int task_nice_ioclass (struct task_struct *task) { -if (task->policy ==SCHED_IDLE ) +if (task->policy ==SCHED_IDLEPRIO )return IOPRIO_CLASS_IDLE ;else if (task->policy ==SCHED_FIFO || task->policy ==SCHED_RR )return IOPRIO_CLASS_RT ;
include/linux/sched.h +24 -160
260 lines not on this page · raw message
init/Kconfig +0 -56
62 lines not on this page · raw message
init/main.c +2 -0
@@ -800,6 +800,8 @@ static int noinline init_post(void) system_state =SYSTEM_RUNNING ;numa_default_policy (); +printk (KERN_INFO "Running BFS CPU scheduler v0.302 by Con Kolivas.\n" ); +if (sys_open ((const char __user *)"/dev/console" ,O_RDWR ,0 ) <0 )printk (KERN_WARNING "Warning: unable to open an initial console.\n" );
kernel/delayacct.c +1 -1
@@ -127,7 +127,7 @@ int __delayacct_add_tsk(struct taskstats*/ t1 = tsk->sched_info.pcount; t2 = tsk->sched_info.run_delay; - t3 = tsk->sched_info.cpu_time; + t3 = tsk->sched_time; d->cpu_count += t1;
kernel/exit.c +2 -1
@@ -122,7 +122,7 @@ static void __exit_signal(struct task_st sig->inblock +=task_io_get_inblock (tsk); sig->oublock +=task_io_get_oublock (tsk);task_io_accounting_add (&sig->ioac, &tsk->ioac); - sig->sum_sched_runtime += tsk->se.sum_exec_runtime; + sig->sum_sched_runtime += tsk->sched_time; sig =NULL ;/* Marker for below. */ }
@@ -193,6 +193,7 @@ repeat: leader->exit_state =EXIT_DEAD ; } +sched_exit (p);write_unlock_irq (&tasklist_lock);release_thread (p);call_rcu (&p->rcu, delayed_put_task_struct);
kernel/fork.c +0 -1
@@ -1156,7 +1156,6 @@ static struct task_struct *copy_process(* parent's CPU). This avoids alot of nasty races. */ p->cpus_allowed = current->cpus_allowed; - p->rt.nr_cpus_allowed = current->rt.nr_cpus_allowed;if (unlikely (!cpu_isset (task_cpu (p), p->cpus_allowed) || !cpu_online (task_cpu (p))))set_task_cpu (p,smp_processor_id ());
kernel/kthread.c +1 -2
@@ -14,7 +14,7 @@#include <linux/module.h> #include <linux/mutex.h> -#define KTHREAD_NICE_LEVEL (-5) +#define KTHREAD_NICE_LEVEL (0)static DEFINE_SPINLOCK (kthread_create_lock);static LIST_HEAD (kthread_create_list);
@@ -179,7 +179,6 @@ void kthread_bind(struct task_struct *k,wait_task_inactive (k,0 );set_task_cpu (k, cpu); k->cpus_allowed =cpumask_of_cpu (cpu); - k->rt.nr_cpus_allowed =1 ; k->flags |=PF_THREAD_BOUND ; }EXPORT_SYMBOL (kthread_bind);
kernel/Makefile +2 -2
@@ -2,7 +2,7 @@ # Makefile for the linux kernel. # -obj-y = sched.o fork.o exec_domain.o panic.o printk.o \ +obj-y = sched_bfs.o fork.o exec_domain.o panic.o printk.o \ cpu.o exit.o itimer.o time.o softirq.o resource.o \ sysctl.o capability.o ptrace.o timer.o user.o \ signal.o sys.o kmod.o workqueue.o pid.o \
@@ -93,7 +93,7 @@ ifneq ($(CONFIG_SCHED_NO_NO_OMIT_FRAME_P # me. I suspect most platforms don't need this, but until we know that for sure # I turn this off for IA-64 only. Andreas Schwab says it's also needed on m68k # to get a correct value for the wait-channel (WCHAN in ps). --davidm -CFLAGS_sched.o := $(PROFILING) -fno-omit-frame-pointer +CFLAGS_sched_bfs.o := $(PROFILING) -fno-omit-frame-pointer endif $(obj)/configs.o: $(obj)/config_data.h
kernel/posix-cpu-timers.c +10 -10
@@ -248,7 +248,7 @@ static int cpu_clock_sample_group_locked cpu->sched = p->signal->sum_sched_runtime;/* Add in each other live thread. */ while ((t =next_thread (t)) != p) { - cpu->sched += t->se.sum_exec_runtime; + cpu->sched += t->sched_time; } cpu->sched +=sched_ns (p);break ;
@@ -466,7 +466,7 @@ static void cleanup_timers(struct list_hvoid posix_cpu_timers_exit (struct task_struct *tsk) {cleanup_timers (tsk->cpu_timers, - tsk->utime, tsk->stime, tsk->se.sum_exec_runtime); + tsk->utime, tsk->stime, tsk->sched_time); }void posix_cpu_timers_exit_group (struct task_struct *tsk)
@@ -474,7 +474,7 @@ void posix_cpu_timers_exit_group(structcleanup_timers (tsk->signal->cpu_timers,cputime_add (tsk->utime, tsk->signal->utime),cputime_add (tsk->stime, tsk->signal->stime), - tsk->se.sum_exec_runtime + tsk->signal->sum_sched_runtime); + tsk->sched_time + tsk->signal->sum_sched_runtime); }
@@ -535,7 +535,7 @@ static void process_timer_rebalance(stru nsleft = max_t(unsigned long long, nsleft, 1); do { if (likely(!(t->flags & PF_EXITING))) { - ns = t->se.sum_exec_runtime + nsleft; + ns = t->sched_time + nsleft; if (t->it_sched_expires == 0 || t->it_sched_expires > ns) { t->it_sched_expires = ns;
@@ -1004,7 +1004,7 @@ static void check_thread_timers(struct tstruct cpu_timer_list *t =list_first_entry (timers, struct cpu_timer_list, entry); -if (!--maxfire || tsk->se.sum_exec_runtime < t->expires.sched) { +if (!--maxfire || tsk->sched_time < t->expires.sched) { tsk->it_sched_expires = t->expires.sched;break ; }
@@ -1020,7 +1020,7 @@ static void check_thread_timers(struct tunsigned long *soft = &sig->rlim[RLIMIT_RTTIME ].rlim_cur;if (hard !=RLIM_INFINITY && - tsk->rt.timeout >DIV_ROUND_UP (hard,USEC_PER_SEC /HZ )) { + tsk->rt_timeout >DIV_ROUND_UP (hard,USEC_PER_SEC /HZ )) {/* * At the hard limit, we just die. * No need to calculate anything else now.
@@ -1028,7 +1028,7 @@ static void check_thread_timers(struct t__group_send_sig_info (SIGKILL ,SEND_SIG_PRIV , tsk);return ; } -if (tsk->rt.timeout >DIV_ROUND_UP (*soft,USEC_PER_SEC /HZ )) { +if (tsk->rt_timeout >DIV_ROUND_UP (*soft,USEC_PER_SEC /HZ )) {/* * At the soft limit, send a SIGXCPU every second. */
@@ -1081,7 +1081,7 @@ static void check_process_timers(structdo { utime =cputime_add (utime, t->utime); stime =cputime_add (stime, t->stime); - sum_sched_runtime += t->se.sum_exec_runtime; + sum_sched_runtime += t->sched_time; t =next_thread (t); }while (t != tsk); ptime =cputime_add (utime, stime);
@@ -1240,7 +1240,7 @@ static void check_process_timers(struct t->it_virt_expires = ticks; } - sched = t->se.sum_exec_runtime + sched_left; + sched = t->sched_time + sched_left;if (sched_expires && (t->it_sched_expires ==0 || t->it_sched_expires > sched)) { t->it_sched_expires = sched;
@@ -1332,7 +1332,7 @@ void run_posix_cpu_timers(struct task_stif (UNEXPIRED (prof) &&UNEXPIRED (virt) && (tsk->it_sched_expires ==0 || - tsk->se.sum_exec_runtime < tsk->it_sched_expires)) + tsk->sched_time < tsk->it_sched_expires))return ;#undef UNEXPIRED
kernel/sched_bfs.c +5811 -0
2,427 lines not on this page · raw message
kernel/sysctl.c +27 -112
139 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Part of the diff is not shown here. View the raw message.
cover BFS backport to 2.6.27
Here is the finished backport of Con Kolivas' BFS to kernel 2.6.27.35.
There are four patches in this series that will be sent as replies to this email. The first three patches are mainline patches that change some scheduler accounting behavior. The fourth patch is the BFS backport. All patches should be applied in order on top of 2.6.27.35.
This port has been build- & run-tested on x86_64 only. If anyone finds problems related to this port, please let me know.
Jayson
Nuts. Thunderbird mangled my patches (and I would have known that if I read email-clients.txt first!). Anyway, the un-mangled patches are at
http://jaysonking.com/bfs-2.6.27-backport/ as I wrote earlier.
Jayson
PATCH 1/4 fix scaled & unscaled cputime accounting
In reply to Jayson R. KingFrom: Martin Schwidefsky <[email protected]>
[upstream commit 457533a7d3402d1d91fbc125c8bd1bd16dcd3cd4]
The utimescaled / stimescaled fields in the task structure and the global cpustat should be set on all architectures. On s390 the calls to account_user_time_scaled and account_system_time_scaled never have been added. In addition system time that is accounted as guest time to the user time of a process is accounted to the scaled system time instead of the scaled user time.
To fix the bugs and to prevent future forgetfulness this patch merges account_system_time_scaled into account_system_time and account_user_time_scaled into account_user_time.
--- arch/ia64/kernel/time.c | 12 +++------ arch/powerpc/kernel/time.c | 7 +---- arch/s390/kernel/vtime.c | 10 ++++---- include/linux/kernel_stat.h | 6 +--- kernel/sched.c | 41 +++++++++++++--------------------- kernel/time/tick-sched.c | 5 ++-- kernel/timer.c | 12 ++++----- 7 files changed, 37 insertions(+), 56 deletions(-)
arch/ia64/kernel/time.c +4 -8
@@ -93,13 +93,11 @@ void ia64_account_on_switch(struct task_ now =ia64_get_itc (); delta_stime =cycle_to_cputime (pi->ac_stime + (now - pi->ac_stamp)); -account_system_time (prev,0 , delta_stime); -account_system_time_scaled (prev, delta_stime); +account_system_time (prev,0 , delta_stime, delta_stime);if (pi->ac_utime) { delta_utime =cycle_to_cputime (pi->ac_utime); -account_user_time (prev, delta_utime); -account_user_time_scaled (prev, delta_utime); +account_user_time (prev, delta_utime, delta_utime); } pi->ac_stamp = ni->ac_stamp = now;
@@ -122,8 +120,7 @@ void account_system_vtime(struct task_st now =ia64_get_itc (); delta_stime =cycle_to_cputime (ti->ac_stime + (now - ti->ac_stamp)); -account_system_time (tsk,0 , delta_stime); -account_system_time_scaled (tsk, delta_stime); +account_system_time (tsk,0 , delta_stime, delta_stime); ti->ac_stime =0 ; ti->ac_stamp = now;
@@ -143,8 +140,7 @@ void account_process_tick(struct task_stif (ti->ac_utime) { delta_utime =cycle_to_cputime (ti->ac_utime); -account_user_time (p, delta_utime); -account_user_time_scaled (p, delta_utime); +account_user_time (p, delta_utime, delta_utime); ti->ac_utime =0 ; } }
arch/powerpc/kernel/time.c +2 -5
@@ -258,8 +258,7 @@ void account_system_vtime(struct task_st delta += sys_time;get_paca ()->system_time =0 ; } -account_system_time (tsk,0 , delta); -account_system_time_scaled (tsk, deltascaled); +account_system_time (tsk,0 , delta, deltascaled);per_cpu (cputime_last_delta,smp_processor_id ()) = delta;per_cpu (cputime_scaled_last_delta,smp_processor_id ()) = deltascaled;local_irq_restore (flags);
@@ -277,10 +276,8 @@ void account_process_tick(struct task_st utime =get_paca ()->user_time;get_paca ()->user_time =0 ; -account_user_time (tsk, utime); - utimescaled =cputime_to_scaled (utime); -account_user_time_scaled (tsk, utimescaled); +account_user_time (tsk, utime, utimescaled); }/*
arch/s390/kernel/vtime.c +5 -5
@@ -51,12 +51,12 @@ void account_process_tick(struct task_st rcu_user_flag = cputime !=0 ; S390_lowcore.user_timer -= cputime <<12 ; S390_lowcore.steal_clock -= cputime <<12 ; -account_user_time (tsk, cputime); +account_user_time (tsk, cputime, cputime); cputime = S390_lowcore.system_timer >>12 ; S390_lowcore.system_timer -= cputime <<12 ; S390_lowcore.steal_clock -= cputime <<12 ; -account_system_time (tsk,HARDIRQ_OFFSET , cputime); +account_system_time (tsk,HARDIRQ_OFFSET , cputime, cputime); cputime = S390_lowcore.steal_clock;if ((__s64 ) cputime >0 ) {
@@ -83,12 +83,12 @@ void account_vtime(struct task_struct *t cputime = S390_lowcore.user_timer >>12 ; S390_lowcore.user_timer -= cputime <<12 ; S390_lowcore.steal_clock -= cputime <<12 ; -account_user_time (tsk, cputime); +account_user_time (tsk, cputime, cputime); cputime = S390_lowcore.system_timer >>12 ; S390_lowcore.system_timer -= cputime <<12 ; S390_lowcore.steal_clock -= cputime <<12 ; -account_system_time (tsk,0 , cputime); +account_system_time (tsk,0 , cputime, cputime); }/*
@@ -108,7 +108,7 @@ void account_system_vtime(struct task_st cputime = S390_lowcore.system_timer >>12 ; S390_lowcore.system_timer -= cputime <<12 ; S390_lowcore.steal_clock -= cputime <<12 ; -account_system_time (tsk,0 , cputime); +account_system_time (tsk,0 , cputime, cputime); }EXPORT_SYMBOL_GPL (account_system_vtime);
include/linux/kernel_stat.h +2 -4
@@ -52,10 +52,8 @@ static inline int kstat_irqs(int irq) return sum; } -extern void account_user_time (struct task_struct *,cputime_t ); -extern void account_user_time_scaled (struct task_struct *,cputime_t ); -extern void account_system_time (struct task_struct *,int ,cputime_t ); -extern void account_system_time_scaled (struct task_struct *,cputime_t ); +extern void account_user_time (struct task_struct *,cputime_t ,cputime_t ); +extern void account_system_time (struct task_struct *,int ,cputime_t ,cputime_t );extern void account_steal_time (struct task_struct *,cputime_t );#endif /* _LINUX_KERNEL_STAT_H */
kernel/sched.c +16 -25
96 lines not on this page · raw message
kernel/time/tick-sched.c +3 -2
@@ -378,6 +378,7 @@ void tick_nohz_restart_sched_tick(void)int cpu =smp_processor_id ();struct tick_sched *ts = &per_cpu (tick_cpu_sched, cpu);unsigned long ticks; +cputime_t cputime;ktime_t now;local_irq_disable ();
@@ -410,8 +411,8 @@ void tick_nohz_restart_sched_tick(void)*/ if (ticks && ticks <LONG_MAX ) {add_preempt_count (HARDIRQ_OFFSET ); -account_system_time (current,HARDIRQ_OFFSET , -jiffies_to_cputime (ticks)); + cputime =jiffies_to_cputime (ticks); +account_system_time (current,HARDIRQ_OFFSET , cputime, cputime);sub_preempt_count (HARDIRQ_OFFSET ); }
kernel/timer.c +5 -7
@@ -954,13 +954,11 @@ void account_process_tick(struct task_st {cputime_t one_jiffy =jiffies_to_cputime (1 ); -if (user_tick) { -account_user_time (p, one_jiffy); -account_user_time_scaled (p,cputime_to_scaled (one_jiffy)); - }else { -account_system_time (p,HARDIRQ_OFFSET , one_jiffy); -account_system_time_scaled (p,cputime_to_scaled (one_jiffy)); - } +if (user_tick) +account_user_time (p, one_jiffy,cputime_to_scaled (one_jiffy)); +else +account_system_time (p,HARDIRQ_OFFSET , one_jiffy, +cputime_to_scaled (one_jiffy)); }#endif
PATCH 2/4 idle cputime accounting
In reply to Jayson R. KingFrom: Martin Schwidefsky <[email protected]>
[upstream commit 79741dd35713ff4f6fd0eafd59fa94e8a4ba922d]
The cpu time spent by the idle process actually doing something is currently accounted as idle time. This is plain wrong, the architectures that support VIRT_CPU_ACCOUNTING=y can do better: distinguish between the time spent doing nothing and the time spent by idle doing work. The first is accounted with account_idle_time and the second with account_system_time. The architectures that use the account_xxx_time interface directly and not the account_xxx_ticks interface now need to do the check for the idle process in their arch code. In particular to improve the system vs true idle time accounting the arch code needs to measure the true idle time instead of just testing for the idle process.
To improve the tick based accounting as well we would need an architecture primitive that can tell us if the pt_regs of the interrupted context points to the magic instruction that halts the cpu.
In addition idle time is no more added to the stime of the idle process. This field now contains the system time of the idle process as it should be. On systems without VIRT_CPU_ACCOUNTING this will always be zero as every tick that occurs while idle is running will be accounted as idle time.
This patch contains the necessary common code changes to be able to distinguish idle system time and true idle time. The architectures with support for VIRT_CPU_ACCOUNTING need some changes to exploit this.
--- arch/ia64/kernel/time.c | 10 +++- arch/powerpc/kernel/process.c | 1 arch/powerpc/kernel/time.c | 13 ++++- arch/s390/kernel/vtime.c | 20 ++++++-- arch/x86/xen/time.c | 10 +--- include/linux/kernel_stat.h | 7 ++ include/linux/sched.h | 1 kernel/sched.c | 80 +++++++++++++++++++++++++------- kernel/time/tick-sched.c | 13 ++--- kernel/timer.c | 13 ----- 10 files changed, 114 insertions(+), 54 deletions(-)
arch/ia64/kernel/time.c +8 -2
@@ -93,7 +93,10 @@ void ia64_account_on_switch(struct task_ now =ia64_get_itc (); delta_stime =cycle_to_cputime (pi->ac_stime + (now - pi->ac_stamp)); -account_system_time (prev,0 , delta_stime, delta_stime); +if (idle_task (smp_processor_id ()) != prev) +account_system_time (prev,0 , delta_stime, delta_stime); +else +account_idle_time (delta_stime);if (pi->ac_utime) { delta_utime =cycle_to_cputime (pi->ac_utime);
@@ -120,7 +123,10 @@ void account_system_vtime(struct task_st now =ia64_get_itc (); delta_stime =cycle_to_cputime (ti->ac_stime + (now - ti->ac_stamp)); -account_system_time (tsk,0 , delta_stime, delta_stime); +if (irq_count () ||idle_task (smp_processor_id ()) != tsk) +account_system_time (tsk,0 , delta_stime, delta_stime); +else +account_idle_time (delta_stime); ti->ac_stime =0 ; ti->ac_stamp = now;
arch/powerpc/kernel/process.c +1 -0
@@ -33,6 +33,7 @@#include <linux/mqueue.h> #include <linux/hardirq.h> #include <linux/utsname.h> +#include <linux/kernel_stat.h> #include <asm/pgtable.h> #include <asm/uaccess.h>
arch/powerpc/kernel/time.c +10 -3
@@ -258,7 +258,10 @@ void account_system_vtime(struct task_st delta += sys_time;get_paca ()->system_time =0 ; } -account_system_time (tsk,0 , delta, deltascaled); +if (in_irq () ||idle_task (smp_processor_id ()) != tsk) +account_system_time (tsk,0 , delta, deltascaled); +else +account_idle_time (delta);per_cpu (cputime_last_delta,smp_processor_id ()) = delta;per_cpu (cputime_scaled_last_delta,smp_processor_id ()) = deltascaled;local_irq_restore (flags);
@@ -337,8 +340,12 @@ void calculate_steal_time(void) tb =mftb (); purr =mfspr (SPRN_PURR ); stolen = (tb - pme->tb) - (purr - pme->purr); -if (stolen >0 ) -account_steal_time (current, stolen); +if (stolen >0 ) { +if (idle_task (smp_processor_id ()) != current) +account_steal_time (stolen); +else +account_idle_time (stolen); + } pme->tb = tb; pme->purr = purr; }
arch/s390/kernel/vtime.c +16 -4
@@ -56,13 +56,19 @@ void account_process_tick(struct task_st cputime = S390_lowcore.system_timer >>12 ; S390_lowcore.system_timer -= cputime <<12 ; S390_lowcore.steal_clock -= cputime <<12 ; -account_system_time (tsk,HARDIRQ_OFFSET , cputime, cputime); +if (idle_task (smp_processor_id ()) != current) +account_system_time (tsk,HARDIRQ_OFFSET , cputime, cputime); +else +account_idle_time (cputime); cputime = S390_lowcore.steal_clock;if ((__s64 ) cputime >0 ) { cputime >>=12 ; S390_lowcore.steal_clock -= cputime <<12 ; -account_steal_time (tsk, cputime); +if (idle_task (smp_processor_id ()) != current) +account_steal_time (cputime); +else +account_idle_time (cputime); } }
@@ -88,7 +94,10 @@ void account_vtime(struct task_struct *t cputime = S390_lowcore.system_timer >>12 ; S390_lowcore.system_timer -= cputime <<12 ; S390_lowcore.steal_clock -= cputime <<12 ; -account_system_time (tsk,0 , cputime, cputime); +if (idle_task (smp_processor_id ()) != current) +account_system_time (tsk,0 , cputime, cputime); +else +account_idle_time (cputime); }/*
@@ -108,7 +117,10 @@ void account_system_vtime(struct task_st cputime = S390_lowcore.system_timer >>12 ; S390_lowcore.system_timer -= cputime <<12 ; S390_lowcore.steal_clock -= cputime <<12 ; -account_system_time (tsk,0 , cputime, cputime); +if (in_irq () ||idle_task (smp_processor_id ()) != current) +account_system_time (tsk,0 , cputime, cputime); +else +account_idle_time (cputime); }EXPORT_SYMBOL_GPL (account_system_vtime);
arch/x86/xen/time.c +4 -6
@@ -134,8 +134,7 @@ static void do_stolen_accounting(void) *snap = state;/* Add the appropriate number of ticks of stolen time, -including any left-overs from last time. Passing NULL to -account_steal_time accounts the time as stolen. */ +including any left-overs from last time. */ stolen = runnable + offline +__get_cpu_var (residual_stolen);if (stolen <0 )
@@ -143,11 +142,10 @@ static void do_stolen_accounting(void) ticks =iter_div_u64_rem (stolen,NS_PER_TICK , &stolen);__get_cpu_var (residual_stolen) = stolen; -account_steal_time (NULL , ticks); +account_steal_ticks (ticks);/* Add the appropriate number of ticks of blocked time, -including any left-overs from last time. Passing idle to -account_steal_time accounts the time as idle/wait. */ +including any left-overs from last time. */ blocked +=__get_cpu_var (residual_blocked);if (blocked <0 )
@@ -155,7 +153,7 @@ static void do_stolen_accounting(void) ticks =iter_div_u64_rem (blocked,NS_PER_TICK , &blocked);__get_cpu_var (residual_blocked) = blocked; -account_steal_time (idle_task (smp_processor_id ()), ticks); +account_idle_ticks (ticks); }/*
include/linux/kernel_stat.h +6 -1
@@ -54,6 +54,11 @@ static inline int kstat_irqs(int irq)extern void account_user_time (struct task_struct *,cputime_t ,cputime_t );extern void account_system_time (struct task_struct *,int ,cputime_t ,cputime_t ); -extern void account_steal_time (struct task_struct *,cputime_t ); +extern void account_steal_time (cputime_t ); +extern void account_idle_time (cputime_t ); + +extern void account_process_tick (struct task_struct *,int user); +extern void account_steal_ticks (unsigned long ticks); +extern void account_idle_ticks (unsigned long ticks);#endif /* _LINUX_KERNEL_STAT_H */
include/linux/sched.h +0 -1
@@ -285,7 +285,6 @@ long io_schedule_timeout(long timeout);extern void cpu_init (void );extern void trap_init (void ); -extern void account_process_tick (struct task_struct *task,int user);extern void update_process_times (int user);extern void scheduler_tick (void );extern void hrtick_resched (void );
kernel/sched.c +63 -17
107 lines not on this page · raw message
kernel/time/tick-sched.c +6 -7
@@ -377,8 +377,9 @@ void tick_nohz_restart_sched_tick(void) {int cpu =smp_processor_id ();struct tick_sched *ts = &per_cpu (tick_cpu_sched, cpu); +#ifndef CONFIG_VIRT_CPU_ACCOUNTING unsigned long ticks; -cputime_t cputime; +#endif ktime_t now;local_irq_disable ();
@@ -400,6 +401,7 @@ void tick_nohz_restart_sched_tick(void)tick_do_update_jiffies64 (now);cpu_clear (cpu, nohz_cpu_mask); +#ifndef CONFIG_VIRT_CPU_ACCOUNTING /* * We stopped the tick in idle. Update process times would miss the * time we slept as update_process_times does only a 1 tick
@@ -409,12 +411,9 @@ void tick_nohz_restart_sched_tick(void)/* * We might be one off. Do not randomly account a huge number of ticks! */ -if (ticks && ticks <LONG_MAX ) { -add_preempt_count (HARDIRQ_OFFSET ); - cputime =jiffies_to_cputime (ticks); -account_system_time (current,HARDIRQ_OFFSET , cputime, cputime); -sub_preempt_count (HARDIRQ_OFFSET ); - } +if (ticks && ticks <LONG_MAX ) +account_idle_ticks (ticks); +#endif touch_softlockup_watchdog ();/*
kernel/timer.c +0 -13
@@ -949,19 +949,6 @@ unsigned long get_next_timer_interrupt(u }#endif -#ifndef CONFIG_VIRT_CPU_ACCOUNTING -void account_process_tick (struct task_struct *p,int user_tick) -{ -cputime_t one_jiffy =jiffies_to_cputime (1 ); - -if (user_tick) -account_user_time (p, one_jiffy,cputime_to_scaled (one_jiffy)); -else -account_system_time (p,HARDIRQ_OFFSET , one_jiffy, -cputime_to_scaled (one_jiffy)); -} -#endif -/* * Called from the timer interrupt handler to charge one tick to the current * process. user_tick is 1 if the tick is user time, 0 for system.
The patch files are also now available for download here:
http://jaysonking.com/bfs-2.6.27-backport/
Jayson
Quoted 1 line · Jayson R. King
Nuts. Thunderbird mangled my patches
Shouldn't patches be sent as attachments?
Quoted 1 line · David Newall
Shouldn't patches be sent as attachments?
Not according to Documentation/SubmittingPatches
Jayson
Quoted 6 lines · Jayson R. King
Quoted 2 lines · David Newall
Shouldn't patches be sent as attachments?
Not according to
Documentation/SubmittingPatches
Yes, I was trying for irony. Mime has been around for many decades and anybody claiming that they can't cope with them is probably very stupid or lying to make some strange point. Anyway, I'm not trying to change the policy, but was only have a snide dig, en passant, at the crufty, old, has-been attitude that it represents.
Quoted 5 lines · David Newall
Yes, I was trying for irony. Mime has been around for many decades and anybody claiming that they can't cope with them is probably very stupid or lying to make some strange point. Anyway, I'm not trying to change the policy, but was only have a snide dig, en passant, at the crufty, old, has-been attitude that it represents.
The problem is that with most MUAs, if you do a 'reply and quote text', it only operates correctly on the first/main body part - doing a 'reply and quote' to an *attachment* is usually a lot harder, and doing a 'reply and quote text from both main body and attachment' is usually convoluted enough that 'Just Hit Delete' becomes tempting...
I've submitted my share of one-liner patches, and they've all been PGP-signed, so they show up as MIME multiparts - and yet I've never ONCE been asked to change it. I have to conclude that it's because although it's a multipart, it's a multipart that DTRT when a maintainer hits 'reply' - and that production MUAs still DTWT when dealing with replying to the attachments rather than the main body....