From: Ingo Molnar <mingo@elte.hu>
To: Hidetoshi Seto <seto.hidetoshi@jp.fujitsu.com>
Cc: linux-kernel@vger.kernel.org
Subject: Re: [PATCH] posix-cpu-timers: clock_gettime(CLOCK_THREAD_CPUTIME_ID) goes backward
Date: Thu, 25 Dec 2008 09:24:56 +0100 [thread overview]
Message-ID: <20081225082456.GA28479@elte.hu> (raw)
In-Reply-To: <4951F7E6.2080805@jp.fujitsu.com>
* Hidetoshi Seto <seto.hidetoshi@jp.fujitsu.com> wrote:
> --- a/kernel/sched.c
> +++ b/kernel/sched.c
> @@ -4064,6 +4064,33 @@ DEFINE_PER_CPU(struct kernel_stat, kstat);
> EXPORT_PER_CPU_SYMBOL(kstat);
>
> /*
> + * Return total of runtime which already banked and which not yet
> + * @p in case that task is currently running.
> + */
> +unsigned long long task_total_exec(struct task_struct *p)
> +{
> + unsigned long flags;
> + struct rq *rq;
> + u64 ns = 0;
> +
> + rq = task_rq_lock(p, &flags);
> +
> + if (task_current(rq, p)) {
> + u64 delta_exec;
> +
> + update_rq_clock(rq);
> + delta_exec = rq->clock - p->se.exec_start;
> + if ((s64)delta_exec > 0)
> + ns = delta_exec;
> + }
> + ns += p->se.sum_exec_runtime;
> +
> + task_rq_unlock(rq, &flags);
> +
> + return ns;
> +}
> +
ok - the issue is real, but there's a few implementational details. Did
you know about task_delta_exec()? This new function duplicates that
function's behavior - and task_delta_exec() is already used by posix
task/cpu timers.
I find your new task_total_exec() interface better (it's easier to use),
could you have a look at eliminating task_delta_exec() users and migrating
them over to task_total_exec()?
Maybe even change the name of sum_exec_runtime over to __sum_exec_runtime,
to make sure nobody uses the 'raw' value - which is always stale up to one
tick's worth of execution. Accessing that raw value would only make sense
after the task has finished executing. (i.e. at cutime/cstime collection
time)
Ingo
next prev parent reply other threads:[~2008-12-25 8:25 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-12-24 8:50 [PATCH] posix-cpu-timers: clock_gettime(CLOCK_THREAD_CPUTIME_ID) goes backward Hidetoshi Seto
2008-12-25 8:24 ` Ingo Molnar [this message]
2008-12-26 0:07 ` 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=20081225082456.GA28479@elte.hu \
--to=mingo@elte.hu \
--cc=linux-kernel@vger.kernel.org \
--cc=seto.hidetoshi@jp.fujitsu.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