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 majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to