From: Peter Zijlstra <peterz@infradead.org>
To: Huang Ying <ying.huang@intel.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH -mm 1/2] irq_work, Use llist in irq_work
Date: Thu, 01 Sep 2011 09:57:08 +0200 [thread overview]
Message-ID: <1314863829.7945.9.camel@twins> (raw)
In-Reply-To: <4E5EE409.3060102@intel.com>
On Thu, 2011-09-01 at 09:46 +0800, Huang Ying wrote:
> You mean we should not use cpu_relax before the first cmpxchg?
Yeah, that's just wasting time for no reason..
> You suggest something as follow?
>
> void llist_add(struct llist_node *new, struct llist_head *head)
> {
> struct llist_node *entry, *old_entry;
>
> #ifndef CONFIG_ARCH_HAVE_NMI_SAFE_CMPXCHG
> BUG_ON(in_nmi());
> #endif
>
> entry = head->first;
> for (;;) {
> old_entry = entry;
> new->next = entry;
> entry = cmpxchg(&head->first, old_entry, new);
> if (entry == old_entry)
> break;
> cpu_relax();
> }
> }
If you insist on having cpu_relax(), then yes that's lots better. Also
avoids the assignment in your conditional. Thing with cpu_relax() is
that its only beneficial in the highly contended case and degrade
light/un-contended loads.
Also, just noticed, why do you have different list_head/list_node
structures? They're the same, a single pointer.
> > and loose the get/put
> > cpu muck? The existing preempt_disable/enable() are already superfluous
> > and could be removed, you just made all this way more horrid than need
> > be.
>
> Will it cause race condition to remove preempt_disable/enable?
> Considering something as follow:
>
> - get irq_work_list of CPU A
> - queue irq_work into irq_work_list of CPU A
> - preempted and resumed execution on CPU B
> - arch_irq_work_raise on CPU B
>
> irq_work_run on CPU B will do nothing. While irq_work need to wait for
> next timer interrupt. Isn't it an issue?
Yes that's unfortunate, the current version would work just fine without
preempt but that's because of the this_cpu_* ops foo.
Not sure it would make sense to add a special this_cpu_llist_add() or
so.. esp seeing that this_cpu_* is basically x86-only.
next prev parent reply other threads:[~2011-09-01 7:57 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-08-30 5:16 [PATCH -mm 0/2] Use llist in irq_work and xlist Huang Ying
2011-08-30 5:16 ` [PATCH -mm 1/2] irq_work, Use llist in irq_work Huang Ying
2011-08-31 10:10 ` Peter Zijlstra
2011-09-01 1:46 ` Huang Ying
2011-09-01 3:20 ` Huang Ying
2011-09-01 7:58 ` Peter Zijlstra
2011-09-01 8:56 ` Huang Ying
2011-09-01 9:57 ` Peter Zijlstra
2011-09-02 1:14 ` Huang Ying
2011-09-03 17:35 ` Mathieu Desnoyers
2011-09-01 12:51 ` Mathieu Desnoyers
2011-09-01 13:00 ` Mathieu Desnoyers
2011-09-02 1:08 ` Huang Ying
2011-09-03 16:33 ` Mathieu Desnoyers
2011-09-01 7:57 ` Peter Zijlstra [this message]
2011-09-01 8:44 ` Huang Ying
2011-09-01 10:00 ` Peter Zijlstra
2011-09-02 1:18 ` Huang Ying
2011-09-02 13:26 ` Peter Zijlstra
2011-08-30 5:16 ` [PATCH -mm 2/2] net, rds, Replace xlist in net/rds/xlist.h with llist Huang Ying
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=1314863829.7945.9.camel@twins \
--to=peterz@infradead.org \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=ying.huang@intel.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox