Skip to contentSkip to conversation

itimers: merge ITIMER_VIRT and ITIMER_PROF common code

PATCH In review Stanislaw Gruszka 2 participants 3 messages May 22, 2009

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

PATCH 1/3 itimers: merge ITIMER_VIRT and ITIMER_PROF common code

Both cpu itimers have same data flow in the few places, this patch make unification of code related with VIRT and PROF itimers.

---
Compared to previous patch Thomas comments was applied (except one which goes to 3/3 patch).

 include/linux/posix-timers.h |    2 +
 include/linux/sched.h        |   14 +++-
 kernel/fork.c                |    8 +-
 kernel/itimer.c              |  146 +++++++++++++++++++----------------------
 kernel/posix-cpu-timers.c    |   98 +++++++++++++---------------
 5 files changed, 131 insertions(+), 137 deletions(-)
include/linux/posix-timers.h +2 -0
index 4f71bf4..71108e5 100644
@@ -23,6 +23,8 @@ struct cpu_timer_list {
 #define CPUCLOCK_PID_MASK	7
 #define CPUCLOCK_PERTHREAD_MASK	4
 #define CPUCLOCK_WHICH(clock)	((clock) & (clockid_t) CPUCLOCK_CLOCK_MASK)
+/* */
+
 #define CPUCLOCK_CLOCK_MASK	3
 #define CPUCLOCK_PROF		0
 #define CPUCLOCK_VIRT		1
include/linux/sched.h +11 -3
index b4c38bc..a29aab8 100644
@@ -454,6 +454,11 @@ struct pacct_struct {
 	unsigned long		ac_minflt, ac_majflt;
 };
 
+struct cpu_itimer {
+	cputime_t expires;
+	cputime_t incr;
+};
+
 /**
  * struct task_cputime - collected CPU time counts
  * @utime:		time spent in user mode, in &cputime_t units
@@ -539,9 +544,12 @@ struct signal_struct {
 	struct pid *leader_pid;
 	ktime_t it_real_incr;
 
-	/* ITIMER_PROF and ITIMER_VIRTUAL timers for the process */
-	cputime_t it_prof_expires, it_virt_expires;
-	cputime_t it_prof_incr, it_virt_incr;
+	/*
+	 * ITIMER_PROF and ITIMER_VIRTUAL timers for the process, mostly we
+	 * use CPUCLOCK_PROF and CPUCLOCK_VIRT for indexing this array as these
+	 * values are defined to 0 and 1 respectively
+	 */
+	struct cpu_itimer it[2];
 
 	/*
 	 * Thread group totals for process CPU timers.
kernel/fork.c +4 -4
index b9e2edd..fbde8e0 100644
@@ -790,10 +790,10 @@ static void posix_cpu_timers_init_group(struct signal_struct *sig)
 	thread_group_cputime_init(sig);
 
 	/* Expiration times and increments. */
-	sig->it_virt_expires = cputime_zero;
-	sig->it_virt_incr = cputime_zero;
-	sig->it_prof_expires = cputime_zero;
-	sig->it_prof_incr = cputime_zero;
+	sig->it[0].expires = cputime_zero;
+	sig->it[0].incr = cputime_zero;
+	sig->it[1].expires = cputime_zero;
+	sig->it[1].incr = cputime_zero;
 
 	/* Cached expiration times. */
 	sig->cputime_expires.prof_exp = cputime_zero;
kernel/itimer.c +68 -78

183 lines not on this page · raw message

kernel/posix-cpu-timers.c +46 -52

147 lines not on this page · raw message

Signature · 1 line
1.5.5.6
#1 lore raw

Stanislaw,

Quoted 4 lines · Stanislaw Gruszka
kernel/fork.c +0 -0
@@ -790,10 +790,10 @@ static void posix_cpu_timers_init_group(struct signal_struct *sig)
 	thread_group_cputime_init(sig);

kernel/fork.c static void posix_cpu_timers_init_group(struct signal_struct *sig) · line 796

Quoted 10 lines
kernel/fork.c +4 -4
 
 	/* Expiration times and increments. */
-	sig->it_virt_expires = cputime_zero;
-	sig->it_virt_incr = cputime_zero;
-	sig->it_prof_expires = cputime_zero;
-	sig->it_prof_incr = cputime_zero;
+	sig->it[0].expires = cputime_zero;
+	sig->it[0].incr = cputime_zero;
+	sig->it[1].expires = cputime_zero;
+	sig->it[1].incr = cputime_zero;

Nit, can we please use CPUCLOCK_PROF/VIRT instead of 0/1 ?

Thanks,

tglx

#2 lore raw

Hi.

Quoted 6 lines · On Fri, 22 May 2009 16:08:34 +0200 (CEST) Thomas Gleixner <[email protected]>…
Quoted 5 lines · Stanislaw Gruszka
kernel/fork.c +0 -0
@@ -790,10 +790,10 @@ static void posix_cpu_timers_init_group(struct signal_struct *sig)
 	thread_group_cputime_init(sig);
 
Quoted 11 lines

kernel/fork.c static void posix_cpu_timers_init_group(struct signal_struct *sig) · line 796

Quoted 9 lines
kernel/fork.c +4 -4
 	/* Expiration times and increments. */
-	sig->it_virt_expires = cputime_zero;
-	sig->it_virt_incr = cputime_zero;
-	sig->it_prof_expires = cputime_zero;
-	sig->it_prof_incr = cputime_zero;
+	sig->it[0].expires = cputime_zero;
+	sig->it[0].incr = cputime_zero;
+	sig->it[1].expires = cputime_zero;
+	sig->it[1].incr = cputime_zero;

Nit, can we please use CPUCLOCK_PROF/VIRT instead of 0/1 ?

I wanted to avoid including <linux/posix-timers.h> here.

Cheers
Stanislaw