Skip to contentSkip to conversation

itimers: merge ITIMER_VIRT and ITIMER_PROF common code

PATCH RESEND New Stanislaw Gruszka 1 participant 2 messages May 12, 2009 – May 13, 2009

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

PATCH RESEND 1/2 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.

---
 include/linux/sched.h     |   11 +++-
 kernel/fork.c             |    8 +-
 kernel/itimer.c           |  142 ++++++++++++++++++++-------------------------
 kernel/posix-cpu-timers.c |   74 +++++++++++-------------
 4 files changed, 111 insertions(+), 124 deletions(-)
include/linux/sched.h +9 -2
index b4c38bc..58430e7 100644
@@ -454,6 +454,14 @@ struct pacct_struct {
 	unsigned long		ac_minflt, ac_majflt;
 };
 
+struct cpu_itimer {
+	cputime_t expires;
+	cputime_t incr;
+};
+
+#define IT_PROF 0
+#define IT_VIRT 1
+
 /**
  * struct task_cputime - collected CPU time counts
  * @utime:		time spent in user mode, in &cputime_t units
@@ -540,8 +548,7 @@ struct signal_struct {
 	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;
+	struct cpu_itimer it[2];
 
 	/*
 	 * Thread group totals for process CPU timers.
kernel/fork.c +4 -4
index b9e2edd..a6225d3 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[IT_PROF].expires = cputime_zero;
+	sig->it[IT_PROF].incr = cputime_zero;
+	sig->it[IT_VIRT].expires = cputime_zero;
+	sig->it[IT_VIRT].incr = cputime_zero;
 
 	/* Cached expiration times. */
 	sig->cputime_expires.prof_exp = cputime_zero;
kernel/itimer.c +64 -78

179 lines not on this page · raw message

kernel/posix-cpu-timers.c +33 -40

110 lines not on this page · raw message

#1 lore raw

PATCH 1/2 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.

---
I resend again as previous patch was truncated, thanks to Andrew for pointing this.

 include/linux/sched.h     |   11 +++-
 kernel/fork.c             |    8 +-
 kernel/itimer.c           |  142 ++++++++++++++++++++-------------------------
 kernel/posix-cpu-timers.c |   74 +++++++++++-------------
 4 files changed, 111 insertions(+), 124 deletions(-)
include/linux/sched.h +9 -2
index b4c38bc..58430e7 100644
@@ -454,6 +454,14 @@ struct pacct_struct {
 	unsigned long		ac_minflt, ac_majflt;
 };
 
+struct cpu_itimer {
+	cputime_t expires;
+	cputime_t incr;
+};
+
+#define IT_PROF 0
+#define IT_VIRT 1
+
 /**
  * struct task_cputime - collected CPU time counts
  * @utime:		time spent in user mode, in &cputime_t units
@@ -540,8 +548,7 @@ struct signal_struct {
 	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;
+	struct cpu_itimer it[2];
 
 	/*
 	 * Thread group totals for process CPU timers.
kernel/fork.c +4 -4
index b9e2edd..a6225d3 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[IT_PROF].expires = cputime_zero;
+	sig->it[IT_PROF].incr = cputime_zero;
+	sig->it[IT_VIRT].expires = cputime_zero;
+	sig->it[IT_VIRT].incr = cputime_zero;
 
 	/* Cached expiration times. */
 	sig->cputime_expires.prof_exp = cputime_zero;
kernel/itimer.c +64 -78

179 lines not on this page · raw message

kernel/posix-cpu-timers.c +34 -40

114 lines not on this page · raw message

Signature · 1 line
1.6.0.6