* [PATCH 1/3] timer: Optimize fastpath_timer_check()
2015-08-26 3:17 [PATCH 0/3] timer: Improve itimers scalability Jason Low
@ 2015-08-26 3:17 ` Jason Low
2015-08-26 21:57 ` Frederic Weisbecker
2015-08-31 15:15 ` Davidlohr Bueso
0 siblings, 2 replies; 6+ messages in thread
From: Jason Low @ 2015-08-26 3:17 UTC (permalink / raw)
To: Peter Zijlstra, Ingo Molnar, Thomas Gleixner, Oleg Nesterov,
Paul E. McKenney
Cc: linux-kernel, Frederic Weisbecker, Linus Torvalds,
Davidlohr Bueso, Steven Rostedt, Andrew Morton, Terry Rudd,
Rik van Riel, Scott J Norton, Jason Low
In fastpath_timer_check(), the task_cputime() function is always
called to compute the utime and stime values. However, this is not
necessary if there are no per-thread timers to check for. This patch
modifies the code such that we compute the task_cputime values only
when there are per-thread timers set.
Signed-off-by: Jason Low <jason.low2@hp.com>
---
kernel/time/posix-cpu-timers.c | 15 +++++++--------
1 files changed, 7 insertions(+), 8 deletions(-)
diff --git a/kernel/time/posix-cpu-timers.c b/kernel/time/posix-cpu-timers.c
index 892e3da..02596ff 100644
--- a/kernel/time/posix-cpu-timers.c
+++ b/kernel/time/posix-cpu-timers.c
@@ -1117,16 +1117,15 @@ static inline int task_cputime_expired(const struct task_cputime *sample,
static inline int fastpath_timer_check(struct task_struct *tsk)
{
struct signal_struct *sig;
- cputime_t utime, stime;
-
- task_cputime(tsk, &utime, &stime);
if (!task_cputime_zero(&tsk->cputime_expires)) {
- struct task_cputime task_sample = {
- .utime = utime,
- .stime = stime,
- .sum_exec_runtime = tsk->se.sum_exec_runtime
- };
+ struct task_cputime task_sample;
+ cputime_t utime, stime;
+
+ task_cputime(tsk, &utime, &stime);
+ task_sample.utime = utime;
+ task_sample.stime = stime;
+ task_sample.sum_exec_runtime = tsk->se.sum_exec_runtime;
if (task_cputime_expired(&task_sample, &tsk->cputime_expires))
return 1;
--
1.7.2.5
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 1/3] timer: Optimize fastpath_timer_check()
@ 2015-08-26 16:57 George Spelvin
2015-08-26 17:31 ` Jason Low
0 siblings, 1 reply; 6+ messages in thread
From: George Spelvin @ 2015-08-26 16:57 UTC (permalink / raw)
To: jason.low2; +Cc: akpm, linux, linux-kernel
> if (!task_cputime_zero(&tsk->cputime_expires)) {
>+ struct task_cputime task_sample;
>+ cputime_t utime, stime;
>+
>+ task_cputime(tsk, &utime, &stime);
>+ task_sample.utime = utime;
>+ task_sample.stime = stime;
>+ task_sample.sum_exec_runtime = tsk->se.sum_exec_runtime;
Er, task_sample.[us]time are already the correct types.
Whay are the local variables necessary? How about:
if (!task_cputime_zero(&tsk->cputime_expires)) {
+ struct task_cputime task_sample;
+
+ task_cputime(tsk, &task_simple.utime, &task_simple.stime);
+ task_sample.sum_exec_runtime = tsk->se.sum_exec_runtime;
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 1/3] timer: Optimize fastpath_timer_check()
2015-08-26 16:57 [PATCH 1/3] timer: Optimize fastpath_timer_check() George Spelvin
@ 2015-08-26 17:31 ` Jason Low
0 siblings, 0 replies; 6+ messages in thread
From: Jason Low @ 2015-08-26 17:31 UTC (permalink / raw)
To: George Spelvin; +Cc: akpm, linux-kernel, jason.low2
On Wed, 2015-08-26 at 12:57 -0400, George Spelvin wrote:
> > if (!task_cputime_zero(&tsk->cputime_expires)) {
> >+ struct task_cputime task_sample;
> >+ cputime_t utime, stime;
> >+
> >+ task_cputime(tsk, &utime, &stime);
> >+ task_sample.utime = utime;
> >+ task_sample.stime = stime;
> >+ task_sample.sum_exec_runtime = tsk->se.sum_exec_runtime;
>
> Er, task_sample.[us]time are already the correct types.
> Whay are the local variables necessary? How about:
>
> if (!task_cputime_zero(&tsk->cputime_expires)) {
> + struct task_cputime task_sample;
> +
> + task_cputime(tsk, &task_simple.utime, &task_simple.stime);
> + task_sample.sum_exec_runtime = tsk->se.sum_exec_runtime;
Yes, good point. Now that we're moving the task_cputime() call to after
the task_sample structure is declared, the utime and stime local
variables are not required anymore.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 1/3] timer: Optimize fastpath_timer_check()
2015-08-26 3:17 ` [PATCH 1/3] timer: Optimize fastpath_timer_check() Jason Low
@ 2015-08-26 21:57 ` Frederic Weisbecker
2015-08-31 15:15 ` Davidlohr Bueso
1 sibling, 0 replies; 6+ messages in thread
From: Frederic Weisbecker @ 2015-08-26 21:57 UTC (permalink / raw)
To: Jason Low
Cc: Peter Zijlstra, Ingo Molnar, Thomas Gleixner, Oleg Nesterov,
Paul E. McKenney, linux-kernel, Linus Torvalds, Davidlohr Bueso,
Steven Rostedt, Andrew Morton, Terry Rudd, Rik van Riel,
Scott J Norton
On Tue, Aug 25, 2015 at 08:17:46PM -0700, Jason Low wrote:
> In fastpath_timer_check(), the task_cputime() function is always
> called to compute the utime and stime values. However, this is not
> necessary if there are no per-thread timers to check for. This patch
> modifies the code such that we compute the task_cputime values only
> when there are per-thread timers set.
>
> Signed-off-by: Jason Low <jason.low2@hp.com>
Reviewed-by: Frederic Weisbecker <fweisbec@gmail.com>
Thanks.
> ---
> kernel/time/posix-cpu-timers.c | 15 +++++++--------
> 1 files changed, 7 insertions(+), 8 deletions(-)
>
> diff --git a/kernel/time/posix-cpu-timers.c b/kernel/time/posix-cpu-timers.c
> index 892e3da..02596ff 100644
> --- a/kernel/time/posix-cpu-timers.c
> +++ b/kernel/time/posix-cpu-timers.c
> @@ -1117,16 +1117,15 @@ static inline int task_cputime_expired(const struct task_cputime *sample,
> static inline int fastpath_timer_check(struct task_struct *tsk)
> {
> struct signal_struct *sig;
> - cputime_t utime, stime;
> -
> - task_cputime(tsk, &utime, &stime);
>
> if (!task_cputime_zero(&tsk->cputime_expires)) {
> - struct task_cputime task_sample = {
> - .utime = utime,
> - .stime = stime,
> - .sum_exec_runtime = tsk->se.sum_exec_runtime
> - };
> + struct task_cputime task_sample;
> + cputime_t utime, stime;
> +
> + task_cputime(tsk, &utime, &stime);
> + task_sample.utime = utime;
> + task_sample.stime = stime;
> + task_sample.sum_exec_runtime = tsk->se.sum_exec_runtime;
>
> if (task_cputime_expired(&task_sample, &tsk->cputime_expires))
> return 1;
> --
> 1.7.2.5
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 1/3] timer: Optimize fastpath_timer_check()
2015-08-26 3:17 ` [PATCH 1/3] timer: Optimize fastpath_timer_check() Jason Low
2015-08-26 21:57 ` Frederic Weisbecker
@ 2015-08-31 15:15 ` Davidlohr Bueso
2015-08-31 19:40 ` Jason Low
1 sibling, 1 reply; 6+ messages in thread
From: Davidlohr Bueso @ 2015-08-31 15:15 UTC (permalink / raw)
To: Jason Low
Cc: Peter Zijlstra, Ingo Molnar, Thomas Gleixner, Oleg Nesterov,
Paul E. McKenney, linux-kernel, Frederic Weisbecker,
Linus Torvalds, Steven Rostedt, Andrew Morton, Terry Rudd,
Rik van Riel, Scott J Norton
On Tue, 2015-08-25 at 20:17 -0700, Jason Low wrote:
> In fastpath_timer_check(), the task_cputime() function is always
> called to compute the utime and stime values. However, this is not
> necessary if there are no per-thread timers to check for. This patch
> modifies the code such that we compute the task_cputime values only
> when there are per-thread timers set.
>
> Signed-off-by: Jason Low <jason.low2@hp.com>
Reviewed-by: Davidlohr Bueso <dave@stgolabs.net>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 1/3] timer: Optimize fastpath_timer_check()
2015-08-31 15:15 ` Davidlohr Bueso
@ 2015-08-31 19:40 ` Jason Low
0 siblings, 0 replies; 6+ messages in thread
From: Jason Low @ 2015-08-31 19:40 UTC (permalink / raw)
To: Davidlohr Bueso
Cc: Peter Zijlstra, Ingo Molnar, Thomas Gleixner, Oleg Nesterov,
Paul E. McKenney, linux-kernel, Frederic Weisbecker,
Steven Rostedt, Andrew Morton, Terry Rudd, Rik van Riel,
Scott J Norton, jason.low2
On Mon, 2015-08-31 at 08:15 -0700, Davidlohr Bueso wrote:
> On Tue, 2015-08-25 at 20:17 -0700, Jason Low wrote:
> > In fastpath_timer_check(), the task_cputime() function is always
> > called to compute the utime and stime values. However, this is not
> > necessary if there are no per-thread timers to check for. This patch
> > modifies the code such that we compute the task_cputime values only
> > when there are per-thread timers set.
> >
> > Signed-off-by: Jason Low <jason.low2@hp.com>
>
> Reviewed-by: Davidlohr Bueso <dave@stgolabs.net>
Thanks David and Frederic.
I want to mention that this patch has been slightly changed. As
suggested by George, those extra utime, stime local variables are not
needed anymore, and we should be able to directly call:
task_cputime(tsk, &task_sample.utime, &task_sample.stime);
---
diff --git a/kernel/time/posix-cpu-timers.c b/kernel/time/posix-cpu-timers.c
index 892e3da..3a8c5b4 100644
--- a/kernel/time/posix-cpu-timers.c
+++ b/kernel/time/posix-cpu-timers.c
@@ -1117,16 +1117,13 @@ static inline int task_cputime_expired(const struct task_cputime *sample,
static inline int fastpath_timer_check(struct task_struct *tsk)
{
struct signal_struct *sig;
- cputime_t utime, stime;
-
- task_cputime(tsk, &utime, &stime);
if (!task_cputime_zero(&tsk->cputime_expires)) {
- struct task_cputime task_sample = {
- .utime = utime,
- .stime = stime,
- .sum_exec_runtime = tsk->se.sum_exec_runtime
- };
+ struct task_cputime task_sample;
+
+ task_cputime(tsk, &task_sample.utime, &task_sample.stime);
+
+ task_sample.sum_exec_runtime = tsk->se.sum_exec_runtime;
if (task_cputime_expired(&task_sample, &tsk->cputime_expires))
return 1;
^ permalink raw reply related [flat|nested] 6+ messages in thread
end of thread, other threads:[~2015-08-31 19:44 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-08-26 16:57 [PATCH 1/3] timer: Optimize fastpath_timer_check() George Spelvin
2015-08-26 17:31 ` Jason Low
-- strict thread matches above, loose matches on Subject: below --
2015-08-26 3:17 [PATCH 0/3] timer: Improve itimers scalability Jason Low
2015-08-26 3:17 ` [PATCH 1/3] timer: Optimize fastpath_timer_check() Jason Low
2015-08-26 21:57 ` Frederic Weisbecker
2015-08-31 15:15 ` Davidlohr Bueso
2015-08-31 19:40 ` Jason Low
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox