From: Catalin Marinas <catalin.marinas@arm.com>
To: Nick Piggin <npiggin@suse.de>
Cc: paulmck@linux.vnet.ibm.com, Jens Axboe <jens.axboe@oracle.com>,
linux-kernel@vger.kernel.org, peterz@infradead.org,
linux-arch@vger.kernel.org, jeremy@goop.org, mingo@elte.hu,
Russell King <rmk+lkml@arm.linux.org.uk>
Subject: Re: [PATCH 1/10] Add generic helpers for arch IPI function calls
Date: Wed, 11 Jun 2008 11:13:35 +0100 [thread overview]
Message-ID: <1213179215.19224.61.camel@pc1117.cambridge.arm.com> (raw)
In-Reply-To: <20080611032531.GC8228@wotan.suse.de>
On Wed, 2008-06-11 at 05:25 +0200, Nick Piggin wrote:
> On Tue, Jun 10, 2008 at 05:53:08PM +0100, Catalin Marinas wrote:
> > On Tue, 2008-06-10 at 08:47 -0700, Paul E. McKenney wrote:
> > > On Tue, Jun 10, 2008 at 03:51:25PM +0100, Catalin Marinas wrote:
> > > > I was thinking whether this condition can be removed and allow the
> > > > smp_call_function*() to be called with IRQs disabled. At a quick look,
> > > > it seems to be possible if the csd_flag_wait() function calls the IPI
> > > > handlers directly when the IRQs are disabled (see the patch below).
> > [...]
> > > There were objections last month: http://lkml.org/lkml/2008/5/3/167
> >
> > Thanks, I missed this discussion.
> >
> > > The issue was that this permits some interrupts to arrive despite
> > > interrupts being disabled. There seemed to be less resistance to
> > > doing this in the wait==1 case, however.
> >
> > The "(wait == 1) && irqs_disabled()" case is what I would be interested
> > in. In the patch you proposed, this doesn't seem to be allowed (at least
> > from the use of WARN_ON). However, from your post in May:
> >
> > > 5. If you call smp_call_function() with irqs disabled, then you
> > > are guaranteed that no other CPU's smp_call_function() handler
> > > will be invoked while smp_call_function() is executing.
> >
> > this would be possible but no one need this functionality yet.
> >
> > Would one use-case (ARM SMP and DMA cache maintenance) be enough to
> > implement this or I should add it to the ARM-specific code?
>
> How will you implement it? You have to be able to wait *somewhere*
> (either before or after the smp_call_function call) with interrupts
> enabled. It is not enough just to eg. use a spinlock around
> smp_call_function, because other CPUs might also be trying to call
> down the same path also with interrupts disabled, and they'll wait
> forever on the spinlock.
With the generic IPI patches, I think it is just a matter of polling for
incoming IPIs in the csd_flag_wait() if interrupts are disabled since no
spinlock is held when issuing the IPI (smp_call_function can be called
concurrently).
If I do it in the ARM-specific code, I would duplicate the
smp_call_function (but avoid the call_single_queue, maybe just like the
current ARM implementation) and use a spinlock around the IPI
invocation. If interrupts are allowed to be disabled, the spin_lock()
would actually be a spin_trylock() (or spin_trylock_irqsave()),
something like below (untested). It can be improved for the IRQs-enabled
case to reduce the latency.
smp_call_function(...)
{
...
/*
* disable IRQs so that we can call this function from
* interrupt context
*/
local_irq_save(flags)
while (!spin_trylock(&call_function_lock)) {
/* other CPU is sending an IPI, just poll for it */
smp_call_function_interrupt();
}
/* acquired the lock, do the IPI stuff */
...
/*
* wait for the other CPUs to complete the IPI. No other CPU
* is waiting for completion because of the call_function_lock
*/
...
spin_unlock(&call_function_lock);
local_irq_restore(flags);
}
One issue I saw raised with the polling loop is that it calls an
interrupt handler outside an interrupt context and with IRQs disabled.
There shouldn't be any issue with the existing code since
smp_call_function assumes interrupts enabled anyway. Whoever needs this
functionality should take greater care with IRQs disabled (in my case,
only calling some cache maintenance operations is OK).
Regarding the interrupt latency, it would be higher since the IPI is not
that cheap but (in ARM SMP case) calling dma_map_single/sg (especially
with TO_DEVICE) with interrupts disabled I think is pretty bad already
as it involves flushing the caches for that range and time-consuming.
If dma_map_single/sg would be disallowed with interrupts disabled or
from interrupt context, we would no longer need the above workarounds
for smp_call_function on ARM.
Regards.
--
Catalin
next prev parent reply other threads:[~2008-06-11 10:23 UTC|newest]
Thread overview: 60+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-05-29 8:58 [PATCH 0/10] Add generic helpers for arch IPI function calls #4 Jens Axboe
2008-05-29 8:58 ` [PATCH 1/10] Add generic helpers for arch IPI function calls Jens Axboe
2008-05-30 11:24 ` Paul E. McKenney
2008-06-06 8:44 ` Jens Axboe
2008-06-10 14:51 ` Catalin Marinas
2008-06-10 15:44 ` James Bottomley
2008-06-10 16:04 ` Catalin Marinas
2008-06-10 15:47 ` Paul E. McKenney
2008-06-10 16:53 ` Catalin Marinas
2008-06-11 3:25 ` Nick Piggin
2008-06-11 10:13 ` Catalin Marinas [this message]
2008-07-06 17:21 ` Jeremy Fitzhardinge
2008-05-29 8:58 ` [PATCH 2/10] x86: convert to generic helpers for " Jens Axboe
2008-05-29 12:12 ` Jeremy Fitzhardinge
2008-05-29 12:17 ` Jens Axboe
2008-05-29 13:47 ` Jeremy Fitzhardinge
2008-05-29 8:58 ` [PATCH 3/10] powerpc: " Jens Axboe
2008-05-29 8:58 ` [PATCH 4/10] ia64: " Jens Axboe
2008-05-29 8:58 ` [PATCH 5/10] alpha: " Jens Axboe
2008-05-29 8:58 ` [PATCH 6/10] arm: " Jens Axboe
2008-06-02 12:29 ` Russell King
2008-06-06 8:47 ` Jens Axboe
2008-05-29 8:58 ` [PATCH 7/10] m32r: " Jens Axboe
2008-05-29 8:58 ` [PATCH 8/10] mips: " Jens Axboe
2008-05-29 14:20 ` Ralf Baechle
2008-05-30 7:23 ` Jens Axboe
2008-05-29 8:58 ` [PATCH 9/10] parisc: " Jens Axboe
2008-05-31 7:00 ` Kyle McMartin
2008-06-02 8:17 ` Jens Axboe
2008-06-02 16:09 ` Kyle McMartin
2008-06-06 8:47 ` Jens Axboe
2008-06-06 21:11 ` Kyle McMartin
2008-06-09 8:47 ` Jens Axboe
2008-05-29 8:58 ` [PATCH 10/10] sh: " Jens Axboe
2008-06-01 8:57 ` [PATCH 0/10] Add generic helpers for arch IPI function calls #4 Andrew Morton
2008-06-01 9:52 ` Jeremy Fitzhardinge
-- strict thread matches above, loose matches on Subject: below --
2008-04-29 7:26 [PATCH 0/10] Add generic helpers for arch IPI function calls #3 Jens Axboe
2008-04-29 7:26 ` [PATCH 1/10] Add generic helpers for arch IPI function calls Jens Axboe
2008-04-29 13:59 ` Paul E. McKenney
2008-04-30 11:29 ` Paul E. McKenney
2008-04-30 11:34 ` Jens Axboe
2008-04-30 12:17 ` Paul E. McKenney
2008-04-30 12:37 ` Jens Axboe
2008-05-01 2:44 ` Paul E. McKenney
2008-05-02 2:02 ` Paul E. McKenney
2008-05-02 2:12 ` Nick Piggin
2008-05-02 12:29 ` Paul E. McKenney
2008-05-02 12:42 ` Paul E. McKenney
2008-05-02 12:59 ` Peter Zijlstra
2008-05-02 14:21 ` Paul E. McKenney
2008-05-03 2:30 ` Paul E. McKenney
2008-05-03 5:49 ` Nick Piggin
2008-05-03 18:11 ` Paul E. McKenney
2008-05-04 22:04 ` Paul E. McKenney
2008-05-05 4:15 ` Nick Piggin
2008-05-05 17:43 ` Paul E. McKenney
2008-05-07 20:42 ` Jens Axboe
2008-05-08 4:36 ` Paul E. McKenney
2008-05-02 12:50 ` Keith Owens
2008-05-02 13:09 ` Paul E. McKenney
2008-04-30 22:56 ` Jeremy Fitzhardinge
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=1213179215.19224.61.camel@pc1117.cambridge.arm.com \
--to=catalin.marinas@arm.com \
--cc=jens.axboe@oracle.com \
--cc=jeremy@goop.org \
--cc=linux-arch@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=npiggin@suse.de \
--cc=paulmck@linux.vnet.ibm.com \
--cc=peterz@infradead.org \
--cc=rmk+lkml@arm.linux.org.uk \
/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
all inboxes | Powered by JetHome®