Re: [RFC PATCH] sched, timer: Use atomics for thread_group_cputimer stats

From: Peter Zijlstra
Date: Fri Jan 23 2015 - 04:25:17 EST


On Thu, Jan 22, 2015 at 07:31:53PM -0800, Jason Low wrote:
> +static void update_gt_cputime(struct thread_group_cputimer *a, struct task_cputime *b)
> {
> + if (b->utime > atomic64_read(&a->utime))
> + atomic64_set(&a->utime, b->utime);
>
> + if (b->stime > atomic64_read(&a->stime))
> + atomic64_set(&a->stime, b->stime);
>
> + if (b->sum_exec_runtime > atomic64_read(&a->sum_exec_runtime))
> + atomic64_set(&a->sum_exec_runtime, b->sum_exec_runtime);
> }

See something like this is not safe against concurrent adds.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/