From: David Howells <dhowells@redhat.com>
To: Oleg Nesterov <oleg@redhat.com>
Cc: dhowells@redhat.com, Andrew Morton <akpm@linux-foundation.org>,
Linus Torvalds <torvalds@linux-foundation.org>,
Thomas Gleixner <tglx@linutronix.de>,
Alexander Gordeev <agordeev@redhat.com>,
Chris Zankel <chris@zankel.net>, David Smith <dsmith@redhat.com>,
"Frank Ch. Eigler" <fche@redhat.com>,
Geert Uytterhoeven <geert@linux-m68k.org>,
Larry Woodman <lwoodman@redhat.com>,
Peter Zijlstra <peterz@infradead.org>,
Richard Kuo <rkuo@codeaurora.org>, Tejun Heo <tj@kernel.org>,
linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v6 1/6] task_work_add: generic process-context callbacks
Date: Fri, 20 Apr 2012 09:48:58 +0100 [thread overview]
Message-ID: <10341.1334911738@redhat.com> (raw)
In-Reply-To: <20120419231455.GA15828@redhat.com>
Oleg Nesterov <oleg@redhat.com> wrote:
> 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.
>
> v2:
> - implement task_work_cancel(func), it removes the first
> task_work with the same callback.
> v3:
> - task_work_add() gets the new arg, "bool notify" to
> conditionalize set_notify_resume(), this makes it useable
> for kthreads and task_work_add(notify => false) can
> work without TIF_NOTIFY_RESUME.
>
> - don't add the dummy "ifndef TIF_NOTIFY_RESUME" inlines,
> just add the simple check in task_work_add().
> v4:
> - s/task_work_queue/task_work_add/
> v5:
> - task_work_run() uses current explicitely
>
> Todo:
> - move clear_thread_flag(TIF_NOTIFY_RESUME) from arch/
> to tracehook_notify_resume()
>
> - rename tracehook_notify_resume() and move it into
> linux/task_work.h
>
> - m68k and xtensa don't have TIF_NOTIFY_RESUME and thus
> task_work_add(notify => true) fails with -ENOTSUPP.
>
> However, ->replacement_session_keyring equally needs
> this flag, task_work_add() is not worse.
>
> Signed-off-by: Oleg Nesterov <oleg@redhat.com>
Acked-by: David Howells <dhowells@redhat.com>
next prev parent reply other threads:[~2012-04-20 8:48 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-04-19 23:14 [PATCH v6 0/6] task_work_add: generic process-context callbacks Oleg Nesterov
2012-04-19 23:14 ` [PATCH v6 1/6] " Oleg Nesterov
2012-04-20 8:48 ` David Howells [this message]
2012-04-19 23:15 ` [PATCH v6 2/6] genirq: reimplement exit_irq_thread() hook via task_work_add() Oleg Nesterov
2012-04-19 23:15 ` [PATCH v6 3/6] hexagon: do_notify_resume() needs tracehook_notify_resume() Oleg Nesterov
2012-04-20 0:24 ` Richard Kuo
2012-04-19 23:15 ` [PATCH v6 4/6] keys: change keyctl_session_to_parent() to use task_work_add() Oleg Nesterov
2012-04-20 8:45 ` David Howells
2012-04-19 23:16 ` [PATCH v6 5/6] keys: kill the dummy key_replace_session_keyring() Oleg Nesterov
2012-04-20 8:45 ` David Howells
2012-04-19 23:16 ` [PATCH v6 6/6] keys: kill task_struct->replacement_session_keyring Oleg Nesterov
2012-04-20 8:45 ` David Howells
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=10341.1334911738@redhat.com \
--to=dhowells@redhat.com \
--cc=agordeev@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=chris@zankel.net \
--cc=dsmith@redhat.com \
--cc=fche@redhat.com \
--cc=geert@linux-m68k.org \
--cc=linux-arch@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lwoodman@redhat.com \
--cc=oleg@redhat.com \
--cc=peterz@infradead.org \
--cc=rkuo@codeaurora.org \
--cc=tglx@linutronix.de \
--cc=tj@kernel.org \
--cc=torvalds@linux-foundation.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.