* Re: [PATCH 1/4] task_work: make task_work_add() lockless
[not found] ` <20120826191209.GA4221@redhat.com>
@ 2012-09-24 19:27 ` Geert Uytterhoeven
2012-09-24 20:37 ` Oleg Nesterov
0 siblings, 1 reply; 2+ messages in thread
From: Geert Uytterhoeven @ 2012-09-24 19:27 UTC (permalink / raw)
To: Oleg Nesterov, Yoshinori Sato
Cc: Peter Zijlstra, Al Viro, Dave Jones, Linux Kernel,
Thomas Gleixner, rostedt, dhowells, Linus Torvalds, Linux-Next
On Sun, Aug 26, 2012 at 9:12 PM, Oleg Nesterov <oleg@redhat.com> wrote:
> Change task_works 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.
>
> Suggested-by: Peter Zijlstra <peterz@infradead.org>
> Signed-off-by: Oleg Nesterov <oleg@redhat.com>
> --- a/kernel/task_work.c
> +++ b/kernel/task_work.c
> @@ -30,52 +23,60 @@ task_work_add(struct task_struct *task, struct callback_head *twork, bool notify
> struct callback_head *
> task_work_cancel(struct task_struct *task, task_work_func_t func)
> {
> + struct callback_head **pprev = &task->task_works;
> + struct callback_head *work = NULL;
> unsigned long flags;
> - struct callback_head *last, *res = NULL;
> -
> + /*
> + * If cmpxchg() fails we continue without updating pprev.
> + * Either we raced with task_work_add() which added the
> + * new entry before this work, we will find it again. Or
> + * we raced with task_work_run(), *pprev == NULL.
> + */
> raw_spin_lock_irqsave(&task->pi_lock, flags);
> - last = task->task_works;
> - if (last) {
> - struct callback_head *q = last, *p = q->next;
> - while (1) {
> - if (p->func == func) {
> - q->next = p->next;
> - if (p == last)
> - task->task_works = q == p ? NULL : q;
> - res = p;
> - break;
> - }
> - if (p == last)
> - break;
> - q = p;
> - p = q->next;
> - }
> + while ((work = ACCESS_ONCE(*pprev))) {
> + read_barrier_depends();
Woops, h8300 doesn't have read_barrier_depends():
kernel/task_work.c:38:3: error: implicit declaration of function
'read_barrier_depends' [-Werror=implicit-function-declaration]
cc1: some warnings being treated as errors
make[2]: *** [kernel/task_work.o] Error 1
http://kisskb.ellerman.id.au/kisskb/buildresult/7238385/
Perhaps an empty definition is fine? Most architectures have:
#define read_barrier_depends() do { } while(0)
The same issue on c6x just got fixed in -next in commit
2c8c2366077da5645bf9063b3cf5c94ecb16f691 ("c6x: use
asm-generic/barrier.h")
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH 1/4] task_work: make task_work_add() lockless
2012-09-24 19:27 ` [PATCH 1/4] task_work: make task_work_add() lockless Geert Uytterhoeven
@ 2012-09-24 20:37 ` Oleg Nesterov
0 siblings, 0 replies; 2+ messages in thread
From: Oleg Nesterov @ 2012-09-24 20:37 UTC (permalink / raw)
To: Geert Uytterhoeven
Cc: Yoshinori Sato, Peter Zijlstra, Al Viro, Dave Jones, Linux Kernel,
Thomas Gleixner, rostedt, dhowells, Linus Torvalds, Linux-Next
On 09/24, Geert Uytterhoeven wrote:
>
> On Sun, Aug 26, 2012 at 9:12 PM, Oleg Nesterov <oleg@redhat.com> wrote:
> > + while ((work = ACCESS_ONCE(*pprev))) {
> > + read_barrier_depends();
Hmm. This should be smp_read_barrier_depends(), but this doesn't matter.
> Woops, h8300 doesn't have read_barrier_depends():
> kernel/task_work.c:38:3: error: implicit declaration of function
> 'read_barrier_depends' [-Werror=implicit-function-declaration]
> cc1: some warnings being treated as errors
> make[2]: *** [kernel/task_work.o] Error 1
Thanks...
> http://kisskb.ellerman.id.au/kisskb/buildresult/7238385/
>
> Perhaps an empty definition is fine? Most architectures have:
>
> #define read_barrier_depends() do { } while(0)
Yes. arch/h8300/include/asm/barrier.h has
#define smp_read_barrier_depends() read_barrier_depends()
so probably it should define read_barrier_depends() as well ?
Oleg.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2012-09-24 20:36 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20120826191132.GA3743@redhat.com>
[not found] ` <20120826191209.GA4221@redhat.com>
2012-09-24 19:27 ` [PATCH 1/4] task_work: make task_work_add() lockless Geert Uytterhoeven
2012-09-24 20:37 ` Oleg Nesterov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).