lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Thu, 25 Dec 2008 09:24:56 +0100
From:	Ingo Molnar <mingo@...e.hu>
To:	Hidetoshi Seto <seto.hidetoshi@...fujitsu.com>
Cc:	linux-kernel@...r.kernel.org
Subject: Re: [PATCH] posix-cpu-timers:
	clock_gettime(CLOCK_THREAD_CPUTIME_ID) goes backward


* Hidetoshi Seto <seto.hidetoshi@...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
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists