Skip to contentSkip to conversation

cputime (4/6): introduce cputime.

PATCH New Martin Schwidefsky 1 participant 1 message Aug 5, 2004

Subsystems (11)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 cputime (4/6): introduce cputime.

[PATCH] cputime (4/6): introduce cputime.

From: Martin Schwidefsky <[email protected]>

This patch introduces the concept of (virtual) cputime. Each architecture can define its method to measure cputime. The main idea is to define a cputime_t type and a set of operations on it (see asm-generic/cputime.h). Then use the type for utime, stime, cutime, cstime, it_virt_value, it_virt_incr, it_prof_value and it_prof_incr and use the cputime operations for each access to these variables. The default implementation is jiffies based and the effect of this patch for architectures which use the default implementation should be neglectible.

There is a second type cputime64_t which is necessary for the kernel_stat cpu statistics. The default cputime_t is 32 bit and based on HZ, this will overflow after 49.7 days. This is not enough for kernel_stat (ihmo not enough for a processes too), so it is necessary to have a 64 bit type.

The third thing that gets introduced by this patch is an additional field for the /proc/stat interface: cpu steal time. An architecture can account cpu steal time by calls to the account_stealtime function. The cpu which backs a virtual processor doesn't spent all of its time for the virtual cpu. To get meaningful cpu usage numbers this involuntary wait time needs to be accounted and exported to user space.

diffstat:

 arch/parisc/kernel/binfmt_elf32.c  |    6 -
 arch/ppc64/kernel/binfmt_elf32.c   |    6 -
 arch/s390/kernel/binfmt_elf32.c    |    6 -
 arch/sparc64/kernel/binfmt_elf32.c |    6 -
 fs/binfmt_elf.c                    |    8 -
 fs/proc/array.c                    |    8 -
 fs/proc/proc_misc.c                |   60 ++++++++------
 include/asm-alpha/cputime.h        |    6 +
 include/asm-arm/cputime.h          |    6 +
 include/asm-arm26/cputime.h        |    6 +
 include/asm-cris/cputime.h         |    6 +
 include/asm-generic/cputime.h      |   63 +++++++++++++++
 include/asm-h8300/cputime.h        |    6 +
 include/asm-i386/cputime.h         |    6 +
 include/asm-ia64/cputime.h         |    6 +
 include/asm-m68k/cputime.h         |    6 +
 include/asm-m68knommu/cputime.h    |    6 +
 include/asm-mips/cputime.h         |    6 +
 include/asm-parisc/cputime.h       |    6 +
 include/asm-ppc/cputime.h          |    6 +
 include/asm-ppc64/cputime.h        |    6 +
 include/asm-s390/cputime.h         |    6 +
 include/asm-sh/cputime.h           |    6 +
 include/asm-sparc/cputime.h        |    6 +
 include/asm-sparc64/cputime.h      |    6 +
 include/asm-um/cputime.h           |    6 +
 include/asm-v850/cputime.h         |    6 +
 include/asm-x86_64/cputime.h       |    6 +
 include/linux/kernel_stat.h        |   19 ++--
 include/linux/sched.h              |   10 +-
 kernel/compat.c                    |    8 -
 kernel/cpu.c                       |    4 
 kernel/exit.c                      |   10 +-
 kernel/fork.c                      |    9 +-
 kernel/itimer.c                    |   55 +++++++------
 kernel/sched.c                     |  152 +++++++++++++++++++++++++++++++------
 kernel/signal.c                    |    8 -
 kernel/sys.c                       |   22 ++---
 kernel/timer.c                     |   63 +--------------
 mm/oom_kill.c                      |    3 
 40 files changed, 459 insertions(+), 187 deletions(-)
arch/parisc/kernel/binfmt_elf32.c +4 -2
diff -urN linux-2.6.8-rc3/arch/parisc/kernel/binfmt_elf32.c linux-2.6.8-s390/arch/parisc/kernel/binfmt_elf32.c
@@ -92,10 +92,12 @@
 	current->thread.map_base = DEFAULT_MAP_BASE32; \
 	current->thread.task_size = DEFAULT_TASK_SIZE32 \
 
-#define jiffies_to_timeval jiffies_to_compat_timeval 
+#undef cputime_to_timeval
+#define cputime_to_timeval cputime_to_compat_timeval 
 static __inline__ void
-jiffies_to_compat_timeval(unsigned long jiffies, struct compat_timeval *value)
+cputime_to_compat_timeval(const cputime_t cputime, struct compat_timeval *value)
 {
+	unsigned long jiffies = cputime_to_jiffies(cputime);
 	value->tv_usec = (jiffies % HZ) * (1000000L / HZ);
 	value->tv_sec = jiffies / HZ;
 }
arch/ppc64/kernel/binfmt_elf32.c +4 -2
diff -urN linux-2.6.8-rc3/arch/ppc64/kernel/binfmt_elf32.c linux-2.6.8-s390/arch/ppc64/kernel/binfmt_elf32.c
@@ -60,10 +60,12 @@
 
 #include <linux/time.h>
 
-#define jiffies_to_timeval jiffies_to_compat_timeval
+#undef cputime_to_timeval
+#define cputime_to_timeval cputime_to_compat_timeval
 static __inline__ void
-jiffies_to_compat_timeval(unsigned long jiffies, struct compat_timeval *value)
+cputime_to_compat_timeval(const cputime_t cputime, struct compat_timeval *value)
 {
+	unsigned long jiffies = cputime_to_jiffies(cputime);
 	value->tv_usec = (jiffies % HZ) * (1000000L / HZ);
 	value->tv_sec = jiffies / HZ;
 }
arch/s390/kernel/binfmt_elf32.c +4 -2
diff -urN linux-2.6.8-rc3/arch/s390/kernel/binfmt_elf32.c linux-2.6.8-s390/arch/s390/kernel/binfmt_elf32.c
@@ -173,10 +173,12 @@
 #undef MODULE_DESCRIPTION
 #undef MODULE_AUTHOR
 
-#define jiffies_to_timeval jiffies_to_compat_timeval
+#undef cputime_to_timeval
+#define cputime_to_timeval cputime_to_compat_timeval
 static __inline__ void
-jiffies_to_compat_timeval(unsigned long jiffies, struct compat_timeval *value)
+cputime_to_compat_timeval(const cputime_t cputime, struct compat_timeval *value)
 {
+	unsigned long jiffies = cputime_to_jiffies(cputime);
 	value->tv_usec = (jiffies % HZ) * (1000000L / HZ);
 	value->tv_sec = jiffies / HZ;
 }
arch/sparc64/kernel/binfmt_elf32.c +4 -2
diff -urN linux-2.6.8-rc3/arch/sparc64/kernel/binfmt_elf32.c linux-2.6.8-s390/arch/sparc64/kernel/binfmt_elf32.c
@@ -132,10 +132,12 @@
 
 #include <linux/time.h>
 
-#define jiffies_to_timeval jiffies_to_compat_timeval
+#undef cputime_to_timeval
+#define cputime_to_timeval cputime_to_compat_timeval
 static __inline__ void
-jiffies_to_compat_timeval(unsigned long jiffies, struct compat_timeval *value)
+cputime_to_compat_timeval(const cputime_t cputime, struct compat_timeval *value)
 {
+	unsigned long jiffies = cputime_to_jiffies(cputime);
 	value->tv_usec = (jiffies % HZ) * (1000000L / HZ);
 	value->tv_sec = jiffies / HZ;
 }
fs/binfmt_elf.c +4 -4
diff -urN linux-2.6.8-rc3/fs/binfmt_elf.c linux-2.6.8-s390/fs/binfmt_elf.c
@@ -1176,10 +1176,10 @@
 	prstatus->pr_ppid = p->parent->pid;
 	prstatus->pr_pgrp = process_group(p);
 	prstatus->pr_sid = p->signal->session;
-	jiffies_to_timeval(p->utime, &prstatus->pr_utime);
-	jiffies_to_timeval(p->stime, &prstatus->pr_stime);
-	jiffies_to_timeval(p->cutime, &prstatus->pr_cutime);
-	jiffies_to_timeval(p->cstime, &prstatus->pr_cstime);
+	cputime_to_timeval(p->utime, &prstatus->pr_utime);
+	cputime_to_timeval(p->stime, &prstatus->pr_stime);
+	cputime_to_timeval(p->cutime, &prstatus->pr_cutime);
+	cputime_to_timeval(p->cstime, &prstatus->pr_cstime);
 }
 
 static void fill_psinfo(struct elf_prpsinfo *psinfo, struct task_struct *p,
fs/proc/array.c +4 -4
diff -urN linux-2.6.8-rc3/fs/proc/array.c linux-2.6.8-s390/fs/proc/array.c
@@ -372,10 +372,10 @@
 		task->cmin_flt,
 		task->maj_flt,
 		task->cmaj_flt,
-		jiffies_to_clock_t(task->utime),
-		jiffies_to_clock_t(task->stime),
-		jiffies_to_clock_t(task->cutime),
-		jiffies_to_clock_t(task->cstime),
+		cputime_to_clock_t(task->utime),
+		cputime_to_clock_t(task->stime),
+		cputime_to_clock_t(task->cutime),
+		cputime_to_clock_t(task->cstime),
 		priority,
 		nice,
 		num_threads,
fs/proc/proc_misc.c +33 -27

93 lines not on this page · raw message

include/asm-alpha/cputime.h +6 -0
diff -urN linux-2.6.8-rc3/include/asm-alpha/cputime.h linux-2.6.8-s390/include/asm-alpha/cputime.h
@@ -0,0 +1,6 @@
+#ifndef __ALPHA_CPUTIME_H
+#define __ALPHA_CPUTIME_H
+
+#include <asm-generic/cputime.h>
+
+#endif /* __ALPHA_CPUTIME_H */
include/asm-arm/cputime.h +6 -0
diff -urN linux-2.6.8-rc3/include/asm-arm/cputime.h linux-2.6.8-s390/include/asm-arm/cputime.h
@@ -0,0 +1,6 @@
+#ifndef __ARM_CPUTIME_H
+#define __ARM_CPUTIME_H
+
+#include <asm-generic/cputime.h>
+
+#endif /* __ARM_CPUTIME_H */
include/asm-arm26/cputime.h +6 -0
diff -urN linux-2.6.8-rc3/include/asm-arm26/cputime.h linux-2.6.8-s390/include/asm-arm26/cputime.h
@@ -0,0 +1,6 @@
+#ifndef __ARM26_CPUTIME_H
+#define __ARM26_CPUTIME_H
+
+#include <asm-generic/cputime.h>
+
+#endif /* __ARM26_CPUTIME_H */
include/asm-cris/cputime.h +6 -0
diff -urN linux-2.6.8-rc3/include/asm-cris/cputime.h linux-2.6.8-s390/include/asm-cris/cputime.h
@@ -0,0 +1,6 @@
+#ifndef __CRIS_CPUTIME_H
+#define __CRIS_CPUTIME_H
+
+#include <asm-generic/cputime.h>
+
+#endif /* __CRIS_CPUTIME_H */
include/asm-generic/cputime.h +63 -0

63 lines not on this page · raw message

include/asm-h8300/cputime.h +6 -0
diff -urN linux-2.6.8-rc3/include/asm-h8300/cputime.h linux-2.6.8-s390/include/asm-h8300/cputime.h
@@ -0,0 +1,6 @@
+#ifndef __H8300_CPUTIME_H
+#define __H8300_CPUTIME_H
+
+#include <asm-generic/cputime.h>
+
+#endif /* __H8300_CPUTIME_H */
include/asm-i386/cputime.h +6 -0
diff -urN linux-2.6.8-rc3/include/asm-i386/cputime.h linux-2.6.8-s390/include/asm-i386/cputime.h
@@ -0,0 +1,6 @@
+#ifndef __I386_CPUTIME_H
+#define __I386_CPUTIME_H
+
+#include <asm-generic/cputime.h>
+
+#endif /* __I386_CPUTIME_H */
include/asm-ia64/cputime.h +6 -0
diff -urN linux-2.6.8-rc3/include/asm-ia64/cputime.h linux-2.6.8-s390/include/asm-ia64/cputime.h
@@ -0,0 +1,6 @@
+#ifndef __IA64_CPUTIME_H
+#define __IA64_CPUTIME_H
+
+#include <asm-generic/cputime.h>
+
+#endif /* __IA64_CPUTIME_H */
include/asm-m68k/cputime.h +6 -0
diff -urN linux-2.6.8-rc3/include/asm-m68k/cputime.h linux-2.6.8-s390/include/asm-m68k/cputime.h
@@ -0,0 +1,6 @@
+#ifndef __M68K_CPUTIME_H
+#define __M68K_CPUTIME_H
+
+#include <asm-generic/cputime.h>
+
+#endif /* __M68K_CPUTIME_H */
include/asm-m68knommu/cputime.h +6 -0
diff -urN linux-2.6.8-rc3/include/asm-m68knommu/cputime.h linux-2.6.8-s390/include/asm-m68knommu/cputime.h
@@ -0,0 +1,6 @@
+#ifndef __M68KNOMMU_CPUTIME_H
+#define __M68KNOMMU_CPUTIME_H
+
+#include <asm-generic/cputime.h>
+
+#endif /* __M68KNOMMU_CPUTIME_H */
include/asm-mips/cputime.h +6 -0
diff -urN linux-2.6.8-rc3/include/asm-mips/cputime.h linux-2.6.8-s390/include/asm-mips/cputime.h
@@ -0,0 +1,6 @@
+#ifndef __MIPS_CPUTIME_H
+#define __MIPS_CPUTIME_H
+
+#include <asm-generic/cputime.h>
+
+#endif /* __MIPS_CPUTIME_H */
include/asm-parisc/cputime.h +6 -0
diff -urN linux-2.6.8-rc3/include/asm-parisc/cputime.h linux-2.6.8-s390/include/asm-parisc/cputime.h
@@ -0,0 +1,6 @@
+#ifndef __PARISC_CPUTIME_H
+#define __PARISC_CPUTIME_H
+
+#include <asm-generic/cputime.h>
+
+#endif /* __PARISC_CPUTIME_H */
include/asm-ppc/cputime.h +6 -0
diff -urN linux-2.6.8-rc3/include/asm-ppc/cputime.h linux-2.6.8-s390/include/asm-ppc/cputime.h
@@ -0,0 +1,6 @@
+#ifndef __PPC_CPUTIME_H
+#define __PPC_CPUTIME_H
+
+#include <asm-generic/cputime.h>
+
+#endif /* __PPC_CPUTIME_H */
include/asm-ppc64/cputime.h +6 -0
diff -urN linux-2.6.8-rc3/include/asm-ppc64/cputime.h linux-2.6.8-s390/include/asm-ppc64/cputime.h
@@ -0,0 +1,6 @@
+#ifndef __PPC_CPUTIME_H
+#define __PPC_CPUTIME_H
+
+#include <asm-generic/cputime.h>
+
+#endif /* __PPC_CPUTIME_H */
include/asm-s390/cputime.h +6 -0
diff -urN linux-2.6.8-rc3/include/asm-s390/cputime.h linux-2.6.8-s390/include/asm-s390/cputime.h
@@ -0,0 +1,6 @@
+#ifndef __S390_CPUTIME_H
+#define __S390_CPUTIME_H
+
+#include <asm-generic/cputime.h>
+
+#endif /* __S390_CPUTIME_H */
include/asm-sh/cputime.h +6 -0
diff -urN linux-2.6.8-rc3/include/asm-sh/cputime.h linux-2.6.8-s390/include/asm-sh/cputime.h
@@ -0,0 +1,6 @@
+#ifndef __SH_CPUTIME_H
+#define __SH_CPUTIME_H
+
+#include <asm-generic/cputime.h>
+
+#endif /* __SH_CPUTIME_H */
include/asm-sparc/cputime.h +6 -0
diff -urN linux-2.6.8-rc3/include/asm-sparc/cputime.h linux-2.6.8-s390/include/asm-sparc/cputime.h
@@ -0,0 +1,6 @@
+#ifndef __SPARC_CPUTIME_H
+#define __SPARC_CPUTIME_H
+
+#include <asm-generic/cputime.h>
+
+#endif /* __SPARC_CPUTIME_H */
include/asm-sparc64/cputime.h +6 -0
diff -urN linux-2.6.8-rc3/include/asm-sparc64/cputime.h linux-2.6.8-s390/include/asm-sparc64/cputime.h
@@ -0,0 +1,6 @@
+#ifndef __SPARC64_CPUTIME_H
+#define __SPARC64_CPUTIME_H
+
+#include <asm-generic/cputime.h>
+
+#endif /* __SPARC64_CPUTIME_H */
include/asm-um/cputime.h +6 -0
diff -urN linux-2.6.8-rc3/include/asm-um/cputime.h linux-2.6.8-s390/include/asm-um/cputime.h
@@ -0,0 +1,6 @@
+#ifndef __UM_CPUTIME_H
+#define __UM_CPUTIME_H
+
+#include <asm-generic/cputime.h>
+
+#endif /* __UM_CPUTIME_H */
include/asm-v850/cputime.h +6 -0
diff -urN linux-2.6.8-rc3/include/asm-v850/cputime.h linux-2.6.8-s390/include/asm-v850/cputime.h
@@ -0,0 +1,6 @@
+#ifndef __V850_CPUTIME_H
+#define __V850_CPUTIME_H
+
+#include <asm-generic/cputime.h>
+
+#endif /* __V850_CPUTIME_H */
include/asm-x86_64/cputime.h +6 -0
diff -urN linux-2.6.8-rc3/include/asm-x86_64/cputime.h linux-2.6.8-s390/include/asm-x86_64/cputime.h
@@ -0,0 +1,6 @@
+#ifndef __X86_64_CPUTIME_H
+#define __X86_64_CPUTIME_H
+
+#include <asm-generic/cputime.h>
+
+#endif /* __X86_64_CPUTIME_H */
include/linux/kernel_stat.h +12 -7
diff -urN linux-2.6.8-rc3/include/linux/kernel_stat.h linux-2.6.8-s390/include/linux/kernel_stat.h
@@ -6,6 +6,7 @@
 #include <linux/smp.h>
 #include <linux/threads.h>
 #include <linux/percpu.h>
+#include <asm/cputime.h>
 
 /*
  * 'kernel_stat.h' contains the definitions needed for doing
@@ -14,13 +15,14 @@
  */
 
 struct cpu_usage_stat {
-	u64 user;
-	u64 nice;
-	u64 system;
-	u64 softirq;
-	u64 irq;
-	u64 idle;
-	u64 iowait;
+	cputime64_t user;
+	cputime64_t nice;
+	cputime64_t system;
+	cputime64_t softirq;
+	cputime64_t irq;
+	cputime64_t idle;
+	cputime64_t iowait;
+	cputime64_t steal;
 };
 
 struct kernel_stat {
@@ -50,4 +52,7 @@
 	return sum;
 }
 
+extern void account_cputime(struct task_struct *, int, cputime_t, cputime_t);
+extern void account_stealtime(struct task_struct *, cputime_t);
+
 #endif /* _LINUX_KERNEL_STAT_H */
include/linux/sched.h +6 -4
diff -urN linux-2.6.8-rc3/include/linux/sched.h linux-2.6.8-s390/include/linux/sched.h
@@ -19,6 +19,7 @@
 #include <asm/page.h>
 #include <asm/ptrace.h>
 #include <asm/mmu.h>
+#include <asm/cputime.h>
 
 #include <linux/smp.h>
 #include <linux/sem.h>
@@ -168,7 +169,7 @@
 extern void cpu_init (void);
 extern void trap_init(void);
 extern void update_process_times(int user);
-extern void scheduler_tick(int user_tick, int system);
+extern void scheduler_tick(void);
 extern unsigned long cache_decay_ticks;
 
 /* Attach to any functions which should be ignored in wchan output. */
@@ -452,10 +453,11 @@
 	int __user *clear_child_tid;		/* CLONE_CHILD_CLEARTID */
 
 	unsigned long rt_priority;
-	unsigned long it_real_value, it_prof_value, it_virt_value;
-	unsigned long it_real_incr, it_prof_incr, it_virt_incr;
+	unsigned long it_real_value, it_real_incr;
+	cputime_t it_virt_value, it_virt_incr;
+	cputime_t it_prof_value, it_prof_incr;
 	struct timer_list real_timer;
-	unsigned long utime, stime, cutime, cstime;
+	cputime_t utime, stime, cutime, cstime;
 	unsigned long nvcsw, nivcsw, cnvcsw, cnivcsw; /* context switch counts */
 	u64 start_time;
 /* mm fault and swap info: this can arguably be seen as either mm-specific or thread-specific */
kernel/compat.c +4 -4
diff -urN linux-2.6.8-rc3/kernel/compat.c linux-2.6.8-s390/kernel/compat.c
@@ -160,10 +160,10 @@
 	 */
 	if (tbuf) {
 		struct compat_tms tmp;
-		tmp.tms_utime = compat_jiffies_to_clock_t(current->utime);
-		tmp.tms_stime = compat_jiffies_to_clock_t(current->stime);
-		tmp.tms_cutime = compat_jiffies_to_clock_t(current->cutime);
-		tmp.tms_cstime = compat_jiffies_to_clock_t(current->cstime);
+		tmp.tms_utime = compat_jiffies_to_clock_t(cputime_to_jiffies(current->utime));
+		tmp.tms_stime = compat_jiffies_to_clock_t(cputime_to_jiffies(current->stime));
+		tmp.tms_cutime = compat_jiffies_to_clock_t(cputime_to_jiffies(current->cutime));
+		tmp.tms_cstime = compat_jiffies_to_clock_t(cputime_to_jiffies(current->cstime));
 		if (copy_to_user(tbuf, &tmp, sizeof(tmp)))
 			return -EFAULT;
 	}
kernel/cpu.c +3 -1
diff -urN linux-2.6.8-rc3/kernel/cpu.c linux-2.6.8-s390/kernel/cpu.c
@@ -49,7 +49,9 @@
 
 	write_lock_irq(&tasklist_lock);
 	for_each_process(p) {
-		if (task_cpu(p) == cpu && (p->utime != 0 || p->stime != 0))
+		if (task_cpu(p) == cpu &&
+		    (!cputime_eq(p->utime, cputime_zero) ||
+		     !cputime_eq(p->stime, cputime_zero)))
 			printk(KERN_WARNING "Task %s (pid = %d) is on cpu %d\
 				(state = %ld, flags = %lx) \n",
 				 p->comm, p->pid, cpu, p->state, p->flags);
kernel/exit.c +6 -4
diff -urN linux-2.6.8-rc3/kernel/exit.c linux-2.6.8-s390/kernel/exit.c
@@ -90,8 +90,10 @@
 		zap_leader = (leader->exit_signal == -1);
 	}
 
-	p->parent->cutime += p->utime + p->cutime;
-	p->parent->cstime += p->stime + p->cstime;
+	p->parent->cutime = cputime_add(p->parent->cutime, p->utime);
+	p->parent->cutime = cputime_add(p->parent->cutime, p->cutime);
+	p->parent->cstime = cputime_add(p->parent->cstime, p->stime);
+	p->parent->cstime = cputime_add(p->parent->cstime, p->cstime);
 	p->parent->cmin_flt += p->min_flt + p->cmin_flt;
 	p->parent->cmaj_flt += p->maj_flt + p->cmaj_flt;
 	p->parent->cnvcsw += p->nvcsw + p->cnvcsw;
@@ -762,8 +764,8 @@
 	 * Clear these here so that update_process_times() won't try to deliver
 	 * itimer, profile or rlimit signals to this task while it is in late exit.
 	 */
-	tsk->it_virt_value = 0;
-	tsk->it_prof_value = 0;
+	tsk->it_virt_value = cputime_zero;
+	tsk->it_prof_value = cputime_zero;
 	tsk->rlim[RLIMIT_CPU].rlim_cur = RLIM_INFINITY;
 
 	/*
kernel/fork.c +5 -4
diff -urN linux-2.6.8-rc3/kernel/fork.c linux-2.6.8-s390/kernel/fork.c
@@ -953,13 +953,14 @@
 	clear_tsk_thread_flag(p, TIF_SIGPENDING);
 	init_sigpending(&p->pending);
 
-	p->it_real_value = p->it_virt_value = p->it_prof_value = 0;
-	p->it_real_incr = p->it_virt_incr = p->it_prof_incr = 0;
+	p->it_real_value = p->it_real_incr = 0;
+	p->it_virt_value = p->it_virt_incr = cputime_zero;
+	p->it_prof_value = p->it_prof_incr = cputime_zero;
 	init_timer(&p->real_timer);
 	p->real_timer.data = (unsigned long) p;
 
-	p->utime = p->stime = 0;
-	p->cutime = p->cstime = 0;
+	p->utime = p->stime = cputime_zero;
+	p->cutime = p->cstime = cputime_zero;
 	p->lock_depth = -1;		/* -1 = no lock */
 	p->start_time = get_jiffies_64();
 	p->security = NULL;
kernel/itimer.c +29 -26

97 lines not on this page · raw message

kernel/sched.c +128 -24

183 lines not on this page · raw message

kernel/signal.c +4 -4
diff -urN linux-2.6.8-rc3/kernel/signal.c linux-2.6.8-s390/kernel/signal.c
@@ -1445,8 +1445,8 @@
 	info.si_uid = tsk->uid;
 
 	/* FIXME: find out whether or not this is supposed to be c*time. */
-	info.si_utime = tsk->utime;
-	info.si_stime = tsk->stime;
+	info.si_utime = cputime_to_jiffies(tsk->utime);
+	info.si_stime = cputime_to_jiffies(tsk->stime);
 
 	status = tsk->exit_code & 0x7f;
 	why = SI_KERNEL;	/* shouldn't happen */
@@ -1534,8 +1534,8 @@
 	info.si_uid = tsk->uid;
 
 	/* FIXME: find out whether or not this is supposed to be c*time. */
-	info.si_utime = tsk->utime;
-	info.si_stime = tsk->stime;
+	info.si_utime = cputime_to_jiffies(tsk->utime);
+	info.si_stime = cputime_to_jiffies(tsk->stime);
 
 	info.si_status = tsk->exit_code & 0x7f;
 	info.si_code = CLD_STOPPED;
kernel/sys.c +12 -10
diff -urN linux-2.6.8-rc3/kernel/sys.c linux-2.6.8-s390/kernel/sys.c
@@ -947,10 +947,10 @@
 	 */
 	if (tbuf) {
 		struct tms tmp;
-		tmp.tms_utime = jiffies_to_clock_t(current->utime);
-		tmp.tms_stime = jiffies_to_clock_t(current->stime);
-		tmp.tms_cutime = jiffies_to_clock_t(current->cutime);
-		tmp.tms_cstime = jiffies_to_clock_t(current->cstime);
+		tmp.tms_utime = cputime_to_clock_t(current->utime);
+		tmp.tms_stime = cputime_to_clock_t(current->stime);
+		tmp.tms_cutime = cputime_to_clock_t(current->cutime);
+		tmp.tms_cstime = cputime_to_clock_t(current->cstime);
 		if (copy_to_user(tbuf, &tmp, sizeof(struct tms)))
 			return -EFAULT;
 	}
@@ -1547,24 +1547,26 @@
 	memset((char *) &r, 0, sizeof(r));
 	switch (who) {
 		case RUSAGE_SELF:
-			jiffies_to_timeval(p->utime, &r.ru_utime);
-			jiffies_to_timeval(p->stime, &r.ru_stime);
+			cputime_to_timeval(p->utime, &r.ru_utime);
+			cputime_to_timeval(p->stime, &r.ru_stime);
 			r.ru_nvcsw = p->nvcsw;
 			r.ru_nivcsw = p->nivcsw;
 			r.ru_minflt = p->min_flt;
 			r.ru_majflt = p->maj_flt;
 			break;
 		case RUSAGE_CHILDREN:
-			jiffies_to_timeval(p->cutime, &r.ru_utime);
-			jiffies_to_timeval(p->cstime, &r.ru_stime);
+			cputime_to_timeval(p->cutime, &r.ru_utime);
+			cputime_to_timeval(p->cstime, &r.ru_stime);
 			r.ru_nvcsw = p->cnvcsw;
 			r.ru_nivcsw = p->cnivcsw;
 			r.ru_minflt = p->cmin_flt;
 			r.ru_majflt = p->cmaj_flt;
 			break;
 		default:
-			jiffies_to_timeval(p->utime + p->cutime, &r.ru_utime);
-			jiffies_to_timeval(p->stime + p->cstime, &r.ru_stime);
+			cputime_to_timeval(cputime_add(p->utime, p->cutime),
+					    &r.ru_utime);
+			cputime_to_timeval(cputime_add(p->stime, p->cstime),
+					    &r.ru_stime);
 			r.ru_nvcsw = p->nvcsw + p->cnvcsw;
 			r.ru_nivcsw = p->nivcsw + p->cnivcsw;
 			r.ru_minflt = p->min_flt + p->cmin_flt;
kernel/timer.c +8 -55

77 lines not on this page · raw message

mm/oom_kill.c +2 -1
diff -urN linux-2.6.8-rc3/mm/oom_kill.c linux-2.6.8-s390/mm/oom_kill.c
@@ -60,7 +60,8 @@
 	 * particular reason for this other than that it turned out to work
 	 * very well in practice.
 	 */
-	cpu_time = (p->utime + p->stime) >> (SHIFT_HZ + 3);
+	cpu_time = (cputime_to_jiffies(p->utime) + cputime_to_jiffies(p->stime))
+		>> (SHIFT_HZ + 3);
 	run_time = (get_jiffies_64() - p->start_time) >> (SHIFT_HZ + 10);
 
 	s = int_sqrt(cpu_time);