From: Stanislaw Gruszka <sgruszka@redhat.com>
To: Frederic Weisbecker <fweisbec@gmail.com>
Cc: LKML <linux-kernel@vger.kernel.org>,
Steven Rostedt <rostedt@goodmis.org>,
Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@kernel.org>,
Andrew Morton <akpm@linux-foundation.org>
Subject: Re: [PATCH 2/2] sched: Lower chances of cputime scaling overflow
Date: Thu, 7 Mar 2013 15:32:46 +0100 [thread overview]
Message-ID: <20130307143246.GB1859@redhat.com> (raw)
In-Reply-To: <1362586015-27951-3-git-send-email-fweisbec@gmail.com>
On Wed, Mar 06, 2013 at 05:06:55PM +0100, Frederic Weisbecker wrote:
> If this solution appears not to be enough in the end, we'll
> need to partly revert back to the behaviour prior to commit
> 0cf55e1ec08bb5a22e068309e2d8ba1180ab4239
> ("sched, cputime: Introduce thread_group_times()")
>
> Back then, the scaling was done on exit() time before adding the cputime
> of an exiting thread to the signal struct. And then we'll need to
> scale one-by-one the live threads cputime in thread_group_cputime(). The
> drawback may be a slightly slower code on exit time.
I do not see this part in the patch ? What I can see is just scaling
algorithm change.
> -static cputime_t scale_stime(cputime_t stime, cputime_t rtime, cputime_t total)
> +static cputime_t scale_stime(u64 stime, u64 rtime, u64 total)
> {
> - u64 temp = (__force u64) rtime;
> + u64 rem, res, scaled;
>
> - temp *= (__force u64) stime;
> -
> - if (sizeof(cputime_t) == 4)
> - temp = div_u64(temp, (__force u32) total);
> - else
> - temp = div64_u64(temp, (__force u64) total);
> + if (rtime >= total) {
> + res = div64_u64_rem(rtime, total, &rem);
> + scaled = stime * res;
> + scaled += div64_u64(stime * rem, total);
> + } else {
> + res = div64_u64_rem(total, rtime, &rem);
> + scaled = div64_u64(stime, res);
> + scaled -= div64_u64(scaled * rem, total);
Those calculus are not obvious. Perhaps it should be commented, how
they evolved from scaled = (rtime*stime)/total ?
> + } else if (!total) {
> stime = rtime;
I would prefer stime = rtime/2 (hence utime will be rtime/2 too), but this
is not so important.
Other than that, patch looks great.
Stanislaw
next prev parent reply other threads:[~2013-03-07 14:32 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-03-06 16:06 [RFC PATCH 0/2] sched: Lower chances of cputime scaling overflow v2 Frederic Weisbecker
2013-03-06 16:06 ` [PATCH 1/2] math64: New div64_u64_rem helper Frederic Weisbecker
2013-03-06 16:06 ` [PATCH 2/2] sched: Lower chances of cputime scaling overflow Frederic Weisbecker
2013-03-07 14:32 ` Stanislaw Gruszka [this message]
2013-03-12 17:52 ` Frederic Weisbecker
2013-03-13 17:53 ` Frederic Weisbecker
-- strict thread matches above, loose matches on Subject: below --
2013-03-13 17:44 [GIT PULL] sched: Cputime update for 3.10 Frederic Weisbecker
2013-03-13 17:44 ` [PATCH 2/2] sched: Lower chances of cputime scaling overflow Frederic Weisbecker
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=20130307143246.GB1859@redhat.com \
--to=sgruszka@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=fweisbec@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=peterz@infradead.org \
--cc=rostedt@goodmis.org \
/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