Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Commits on Sep 13, 2012
  1. @utrace

    task_work: task_work_add() should not succeed after exit_task_work()

    utrace authored Ingo Molnar committed
    ed3e694 "move exit_task_work() past exit_files()" destroyed
    the add/exit synchronization we had, the caller itself should ensure
    task_work_add() can't race with the exiting task.
    However, this is not convenient/simple, and the only user which tries
    to do this is buggy (see the next patch). Unless the task is current,
    there is simply no way to do this in general.
    Change exit_task_work()->task_work_run() to use the dummy "work_exited"
    entry to let task_work_add() know it should fail.
    Signed-off-by: Oleg Nesterov <>
    Signed-off-by: Peter Zijlstra <>
    Cc: Al Viro <>
    Cc: Linus Torvalds <>
    Cc: Andrew Morton <>
    Cc: Thomas Gleixner <>
    Signed-off-by: Ingo Molnar <>
  2. @utrace

    task_work: Make task_work_add() lockless

    utrace authored Ingo Molnar committed
    Change task_work's to use llist-like code to avoid pi_lock
    in task_work_add(), this makes it useable under rq->lock.
    task_work_cancel() and task_work_run() still use pi_lock
    to synchronize with each other.
    (This is in preparation for a deadlock fix.)
    Suggested-by: Peter Zijlstra <>
    Signed-off-by: Oleg Nesterov <>
    Signed-off-by: Peter Zijlstra <>
    Cc: Al Viro <>
    Cc: Linus Torvalds <>
    Cc: Andrew Morton <>
    Cc: Thomas Gleixner <>
    Signed-off-by: Ingo Molnar <>
Commits on Aug 21, 2012
  1. task_work: add a scheduling point in task_work_run()

    Eric Dumazet authored committed
    It seems commit 4a9d4b0 ("switch fput to task_work_add") re-
    introduced the problem addressed in 944be0b ("close_files(): add
    scheduling point")
    If a server process with a lot of files (say 2 million tcp sockets) is
    killed, we can spend a lot of time in task_work_run() and trigger a soft
    Signed-off-by: Eric Dumazet <>
    Signed-off-by: Linus Torvalds <>
Commits on Jul 22, 2012
  1. deal with task_work callbacks adding more work

    Al Viro authored
    It doesn't matter on normal return to userland path (we'll recheck the
    NOTIFY_RESUME flag anyway), but in case of exit_task_work() we'll
    need that as soon as we get callbacks capable of triggering more
    Signed-off-by: Al Viro <>
  2. move exit_task_work() past exit_files()

    Al Viro authored
    ... and get rid of PF_EXITING check in task_work_add().
    Signed-off-by: Al Viro <>
  3. merge task_work and rcu_head, get rid of separate allocation for keyr…

    Al Viro authored
    …ing case
    task_work and rcu_head are identical now; merge them (calling the result
    struct callback_head, rcu_head #define'd to it), kill separate allocation
    in security/keys since we can just use cred->rcu now.
    Signed-off-by: Al Viro <>
  4. trim task_work: get rid of hlist

    Al Viro authored
    layout based on Oleg's suggestion; single-linked list,
    task->task_works points to the last element, forward pointer
    from said last element points to head.  I'd still prefer
    much more regular scheme with two pointers in task_work,
    Signed-off-by: Al Viro <>
Commits on May 24, 2012
  1. @utrace

    task_work_add: generic process-context callbacks

    utrace authored Al Viro committed
    Provide a simple mechanism that allows running code in the (nonatomic)
    context of the arbitrary task.
    The caller does task_work_add(task, task_work) and this task executes
    task_work->func() either from do_notify_resume() or from do_exit().  The
    callback can rely on PF_EXITING to detect the latter case.
    "struct task_work" can be embedded in another struct, still it has "void
    *data" to handle the most common/simple case.
    This allows us to kill the ->replacement_session_keyring hack, and
    potentially this can have more users.
    Performance-wise, this adds 2 "unlikely(!hlist_empty())" checks into
    tracehook_notify_resume() and do_exit().  But at the same time we can
    remove the "replacement_session_keyring != NULL" checks from
    arch/*/signal.c and exit_creds().
    Note: task_work_add/task_work_run abuses ->pi_lock.  This is only because
    this lock is already used by lookup_pi_state() to synchronize with
    do_exit() setting PF_EXITING.  Fortunately the scope of this lock in
    task_work.c is really tiny, and the code is unlikely anyway.
    Signed-off-by: Oleg Nesterov <>
    Acked-by: David Howells <>
    Cc: Thomas Gleixner <>
    Cc: Richard Kuo <>
    Cc: Linus Torvalds <>
    Cc: Alexander Gordeev <>
    Cc: Chris Zankel <>
    Cc: David Smith <>
    Cc: "Frank Ch. Eigler" <>
    Cc: Geert Uytterhoeven <>
    Cc: Larry Woodman <>
    Cc: Peter Zijlstra <>
    Cc: Tejun Heo <>
    Cc: Ingo Molnar <>
    Signed-off-by: Andrew Morton <>
    Signed-off-by: Al Viro <>
Something went wrong with that request. Please try again.