[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20140813172230.GA6296@redhat.com>
Date: Wed, 13 Aug 2014 19:22:30 +0200
From: Oleg Nesterov <oleg@...hat.com>
To: Rik van Riel <riel@...hat.com>
Cc: linux-kernel@...r.kernel.org,
Peter Zijlstra <peterz@...radead.org>,
Hidetoshi Seto <seto.hidetoshi@...fujitsu.com>,
Frank Mayhar <fmayhar@...gle.com>,
Frederic Weisbecker <fweisbec@...hat.com>,
Andrew Morton <akpm@...ux-foundation.org>,
Sanjay Rao <srao@...hat.com>,
Larry Woodman <lwoodman@...hat.com>
Subject: Re: [PATCH RFC] time: drop do_sys_times spinlock
On 08/12, Rik van Riel wrote:
>
> Any other ideas?
To simplify, lets suppose that we only need sum_exec_runtime.
Perhaps we can do something like this
u64 thread_group_sched_runtime(void)
{
struct task_struct *tsk = current;
spinlock_t *siglock = &tsk->sighand->siglock; /* stable */
struct task_struct *t;
u64 x1, x2;
retry:
x1 = tsk->signal->sum_sched_runtime;
rmb();
spin_unlock_wait(siglock);
rmb();
x2 = 0;
rcu_read_lock();
for_each_thread(tsk, t)
x2 += task_sched_runtime(t);
rcu_read_unlock();
rmb();
spin_unlock_wait(siglock);
rmb();
if (x1 != tsk->signal->sum_sched_runtime)
goto retry;
return x1 + x2;
}
?
We do not care if for_each_thread() misses the new thread, we can pretend
thread_group_sched_runtime() was called before clone.
We do not care if a thread with sum_sched_runtime == 0 exits, obviously.
Otherwise "x1 != tsk->signal->sum_sched_runtime" should tell us that we
raced with __exit_signal().
Oleg.
--
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