]> Git Repo - linux.git/commit
sched/api: Introduce task_rcu_dereference() and try_get_task_struct()
authorOleg Nesterov <[email protected]>
Wed, 18 May 2016 17:02:18 +0000 (19:02 +0200)
committerIngo Molnar <[email protected]>
Fri, 3 Jun 2016 07:18:57 +0000 (09:18 +0200)
commit150593bf869393d10a79f6bd3df2585ecc20a9bb
treecbe9c8bbf903315c0b07397f18a6a97294bab0e7
parentdf55f462b905f3b2d40ec3fb865891382a6ebfb1
sched/api: Introduce task_rcu_dereference() and try_get_task_struct()

Generally task_struct is only protected by RCU if it was found on a
RCU protected list (say, for_each_process() or find_task_by_vpid()).

As Kirill pointed out rq->curr isn't protected by RCU, the scheduler
drops the (potentially) last reference without RCU gp, this means
that we need to fix the code which uses foreign_rq->curr under
rcu_read_lock().

Add a new helper which can be used to dereference rq->curr or any
other pointer to task_struct assuming that it should be cleared or
updated before the final put_task_struct(). It returns non-NULL
only if this task can't go away before rcu_read_unlock().

( Also add try_get_task_struct() to make it easier to use this API
  correctly. )

Suggested-by: Kirill Tkhai <[email protected]>
Signed-off-by: Oleg Nesterov <[email protected]>
[ Updated comments; added try_get_task_struct()]
Signed-off-by: Peter Zijlstra (Intel) <[email protected]>
Cc: Chris Metcalf <[email protected]>
Cc: Christoph Lameter <[email protected]>
Cc: Kirill Tkhai <[email protected]>
Cc: Linus Torvalds <[email protected]>
Cc: Mike Galbraith <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Thomas Gleixner <[email protected]>
Cc: Vladimir Davydov <[email protected]>
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Ingo Molnar <[email protected]>
include/linux/sched.h
kernel/exit.c
This page took 0.056963 seconds and 4 git commands to generate.