[Devel] [PATCH v2 2/2] sched/core: Fix unserialized r-m-w scribbling stuff

Vladimir Davydov vdavydov at virtuozzo.com
Mon Jan 18 03:06:19 PST 2016


On Fri, Jan 15, 2016 at 07:57:03PM +0300, Kirill Tkhai wrote:
> Port commit be958bdc96f18bc1356177bbb79d46ea0c037b96 from mainstream.
> 
> Some of the sched bitfieds (notably sched_reset_on_fork) can be set
> on other than current, this can cause the r-m-w to race with other
> updates.
> 
> Since all the sched bits are serialized by scheduler locks, pull them
> in a separate word.
> 
> Reported-by: Tejun Heo <tj at kernel.org>
> Signed-off-by: Peter Zijlstra (Intel) <peterz at infradead.org>
> Cc: Dmitry Vyukov <dvyukov at google.com>
> Cc: Linus Torvalds <torvalds at linux-foundation.org>
> Cc: Peter Zijlstra <peterz at infradead.org>
> Cc: Sasha Levin <sasha.levin at oracle.com>
> Cc: Thomas Gleixner <tglx at linutronix.de>
> Cc: akpm at linux-foundation.org
> Cc: hannes at cmpxchg.org
> Cc: mhocko at kernel.org
> Cc: Dmitry Vyukov <dvyukov at google.com>
> Cc: Linus Torvalds <torvalds at linux-foundation.org>
> Cc: Peter Zijlstra <peterz at infradead.org>
> 
> Really the below 4 bits are protected by different locks:
> 
> unsigned sched_reset_on_fork:1; rq pi
> unsigned sched_contributes_to_load:1; pi
> unsigned sched_interruptible_sleep:1; pi
> unsigned woken_while_running:1; rq
> 
> But we may say, all of them are protected by rq lock,
> because sched_contributes_to_load and sched_interruptible_sleep
> are modified in try_to_wake_up(), when task is not on rq,
> so nobody can modify sched_reset_on_fork and woken_while_running
> this moment.
> 
> Thus we won't use one more bitfield and save a memory of one word.
> 
> Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>

Reviewed-by: Vladimir Davydov <vdavydov at virtuozzo.com>


More information about the Devel mailing list