Re: [PATCH 2/3] task: RCU protect tasks on the runqueue
From: Peter Zijlstra
Date: Tue Sep 03 2019 - 03:41:32 EST
On Mon, Sep 02, 2019 at 11:52:01PM -0500, Eric W. Biederman wrote:
> diff --git a/kernel/sched/core.c b/kernel/sched/core.c
> index 2b037f195473..802958407369 100644
> --- a/kernel/sched/core.c
> +++ b/kernel/sched/core.c
> @@ -3857,7 +3857,7 @@ static void __sched notrace __schedule(bool preempt)
>
> if (likely(prev != next)) {
> rq->nr_switches++;
> - rq->curr = next;
> + rcu_assign_pointer(rq->curr, next);
> /*
> * The membarrier system call requires each architecture
> * to have a full memory barrier after updating
This one is sad; it puts a (potentially) expensive barrier in here. And
I'm not sure I can explain the need for it. That is, we've not changed
@next before this and don't need to 'publish' it as such.
Can we use RCU_INIT_POINTER() or simply WRITE_ONCE(), here?