From: Stanislaw Gruszka <sgruszka@redhat.com>
To: Hidetoshi Seto <seto.hidetoshi@jp.fujitsu.com>
Cc: linux-kernel@vger.kernel.org, "Ingo Molnar" <mingo@elte.hu>,
"Peter Zijlstra" <peterz@infradead.org>,
"Spencer Candland" <spencer@bluehost.com>,
"Oleg Nesterov" <oleg@redhat.com>,
"Balbir Singh" <balbir@in.ibm.com>,
"Américo Wang" <xiyou.wangcong@gmail.com>
Subject: Re: [PATCH tip/sched/core] introduce task_times() to replace task_[us]time() pair
Date: Mon, 23 Nov 2009 11:28:07 +0100 [thread overview]
Message-ID: <20091123102806.GD25978@dhcp-lab-161.englab.brq.redhat.com> (raw)
In-Reply-To: <4B061E9A.8040100@jp.fujitsu.com>
On Fri, Nov 20, 2009 at 01:44:10PM +0900, Hidetoshi Seto wrote:
> Function task_[us]times() are called consecutively in almost all
> cases. However task_stime() is implemented to call task_utime()
> from its inside, so such paired calls run task_utime() twice.
>
> It means we do heavy divisions (div_u64 + do_div) twice to get
> stime and utime which can be obtained at same time by one set
> of divisions.
>
> This patch introduces task_times(*tsk, *utime, *stime) to get
> stime and utime at once, in better, optimized way.
>
> Signed-off-by: Hidetoshi Seto <seto.hidetoshi@jp.fujitsu.com>
[snip]
> @@ -5155,6 +5155,14 @@ cputime_t task_stime(struct task_struct *p)
> {
> return p->stime;
> }
> +
> +void task_times(struct task_struct *p, cputime_t *ut, cputime_t *st)
> +{
> + if (ut)
> + *ut = task_utime(p);
> + if (st)
> + *st = task_stime(p);
> +}
> #else
I think task_{u,s}time are not needed anymore. Can we just fully get
rid of them and only use task_times() ?
> #ifndef nsecs_to_cputime
> @@ -5162,41 +5170,48 @@ cputime_t task_stime(struct task_struct *p)
> msecs_to_cputime(div_u64((__nsecs), NSEC_PER_MSEC))
> #endif
Could we furhter optimize this? Perhaps we can use below code
(taken from timespec_to_jiffies()):
cputime = (nsec * NSEC_CONVERSION) >>
(NSEC_JIFFIE_SC - SEC_JIFFIE_SC))) >> SEC_JIFFIE_SC;
Stanislaw
next prev parent reply other threads:[~2009-11-23 10:30 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-11-20 4:44 Hidetoshi Seto
2009-11-23 10:28 ` Stanislaw Gruszka [this message]
2009-11-24 5:38 ` Hidetoshi Seto
2009-11-24 7:08 ` Hidetoshi Seto
2009-11-26 5:48 ` [PATCH -tip 1/3] introduce task_times() to replace task_{u,s}time() pair Hidetoshi Seto
2009-11-26 10:25 ` Peter Zijlstra
2009-11-27 0:37 ` Hidetoshi Seto
2009-11-26 12:33 ` [tip:sched/core] sched: Introduce " tip-bot for Hidetoshi Seto
2009-11-26 5:49 ` [PATCH -tip 2/3] remove task_{u,s,g}time() Hidetoshi Seto
2009-11-26 10:26 ` Peter Zijlstra
2009-11-26 12:33 ` [tip:sched/core] sched: Remove task_{u,s,g}time() tip-bot for Hidetoshi Seto
2009-11-26 5:49 ` [PATCH -tip 3/3] define nsecs_to_jiffies() Hidetoshi Seto
2009-11-26 10:27 ` Peter Zijlstra
2009-11-26 12:34 ` [tip:sched/core] sched, time: Define nsecs_to_jiffies() tip-bot for Hidetoshi Seto
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20091123102806.GD25978@dhcp-lab-161.englab.brq.redhat.com \
--to=sgruszka@redhat.com \
--cc=balbir@in.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=oleg@redhat.com \
--cc=peterz@infradead.org \
--cc=seto.hidetoshi@jp.fujitsu.com \
--cc=spencer@bluehost.com \
--cc=xiyou.wangcong@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®