public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Peter Zijlstra <peterz@infradead.org>
To: Jens Axboe <jens.axboe@oracle.com>
Cc: linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org,
	npiggin@suse.de, torvalds@linux-foundation.org, sam@ravnborg.org
Subject: Re: [PATCH 1/11] Add generic helpers for arch IPI function calls
Date: Wed, 23 Apr 2008 09:50:19 +0200	[thread overview]
Message-ID: <1208937019.7115.326.camel@twins> (raw)
In-Reply-To: <20080423074933.GB12774@kernel.dk>

On Wed, 2008-04-23 at 09:49 +0200, Jens Axboe wrote:
> On Wed, Apr 23 2008, Peter Zijlstra wrote:
> > On Wed, 2008-04-23 at 08:07 +0200, Jens Axboe wrote:
> > > On Tue, Apr 22 2008, Peter Zijlstra wrote:
> > > > On Tue, 2008-04-22 at 20:50 +0200, Jens Axboe wrote:
> > > > 
> > > > > +int smp_call_function_single(int cpu, void (*func) (void *info), void *info,
> > > > > +			     int retry, int wait)
> > > > > +{
> > > > > +	unsigned long flags;
> > > > > +	/* prevent preemption and reschedule on another processor */
> > > > > +	int me = get_cpu();
> > > > > +
> > > > > +	/* Can deadlock when called with interrupts disabled */
> > > > > +	WARN_ON(wait && irqs_disabled());
> > > > 
> > > > With this fallback to wait the above condition isn't sufficient.
> > > 
> > > What deadlock are you concerned with here? Would making cfd_fallback
> > > per-cpu make you feel better?
> > 
> >   CPU0					  CPU1
> > 
> > local_irq_disable()			local_irq_disable()
> > 
> > 					smp_call_function_single(0,..,0)
> > 					  test_and_set_bit_lock()
> > 					  send IPI
> > smp_call_function_single(1,..,0)
> >   while(test_and_set_bit_lock())
> >     cpu_relax();
> > 
> > 
> > This will spin forever, because it needs to handle the IPI in order to
> > free the cfd_fallback thingy, but can't for its waiting for it.
> > 
> > That particular deadlock can indeed be solved by making cfd_fallback
> > per-cpu.
> 
> Right, that is the case I was thinking of. I added per-cpu fallbacks to
> cover that case.

Great, thanks!

> > But if you were to use multiple smp_call_function*() calls under a
> > single IRQ disabled, then that would not be sufficient. Now I can't
> > directly come up with a good reason to need to do that, but still.
> > 
> > You'd need somethine like:
> > 
> > local_irq_disable()
> > 
> > smp_call_function_single(n, func_a,..,0)
> > smp_call_function_single(m, func_b,..,0)
> > 
> > local_irq_enable()
> > 
> > And invite 3 cpus to the party while under memory pressure and you get
> > deadlock potential.
> > 
> > [ if it were both the same function, you'd want to use
> >   smp_call_function() and provide a mask; if it were the same cpu you'd
> >   want to call a function doing both ]
> 
> I think that is plenty far off into theoretical country that we can get
> by with just documenting this limitation. Nobody is doing that currently
> in the kernel, and I see no practical use case for it.

Agreed.


  reply	other threads:[~2008-04-23  7:50 UTC|newest]

Thread overview: 85+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-04-22 18:50 [PATCH 0/11] Generic smp_call_function() #2 Jens Axboe
2008-04-22 18:50 ` [PATCH 1/11] Add generic helpers for arch IPI function calls Jens Axboe
2008-04-22 20:17   ` Peter Zijlstra
2008-04-23  6:07     ` Jens Axboe
2008-04-23  6:32       ` Peter Zijlstra
2008-04-23  7:49         ` Jens Axboe
2008-04-23  7:50           ` Peter Zijlstra [this message]
2008-04-24 22:01   ` Russell King
2008-04-25  7:18     ` Jens Axboe
2008-04-26  6:28       ` Jeremy Fitzhardinge
2008-04-28  7:38         ` Jes Sorensen
2008-04-26  6:11   ` Andrew Morton
2008-04-26 14:13     ` James Bottomley
2008-04-28 14:25       ` David Howells
2008-04-28 14:43         ` James Bottomley
2008-04-27  0:58     ` Paul E. McKenney
2008-04-27 10:36       ` Jens Axboe
2008-04-27 10:30     ` Jens Axboe
2008-04-22 18:50 ` [PATCH 2/11] x86: convert to generic helpers for " Jens Axboe
2008-04-22 19:03   ` Linus Torvalds
2008-04-22 19:12     ` Ingo Molnar
2008-04-22 19:22       ` Linus Torvalds
2008-04-22 19:26         ` Ingo Molnar
2008-04-22 19:50           ` Linus Torvalds
2008-04-23  1:11             ` Nick Piggin
2008-04-23  1:22               ` Linus Torvalds
2008-04-23  1:36                 ` Nick Piggin
2008-04-23  7:08               ` Jens Axboe
2008-04-23 12:54     ` Jens Axboe
2008-04-26  6:44   ` Jeremy Fitzhardinge
2008-04-27 10:23     ` Jens Axboe
2008-04-27 15:18       ` Jeremy Fitzhardinge
2008-04-22 18:50 ` [PATCH 3/11] powerpc: " Jens Axboe
2008-04-22 18:50 ` [PATCH 4/11] ia64: " Jens Axboe
2008-04-22 18:50 ` [PATCH 5/11] alpha: " Jens Axboe
2008-04-22 18:50 ` [PATCH 6/11] arm: " Jens Axboe
2008-04-22 18:50 ` [PATCH 7/11] m32r: " Jens Axboe
2008-04-22 18:50 ` [PATCH 8/11] mips: " Jens Axboe
2008-04-22 23:18   ` Ralf Baechle
2008-04-23  7:18     ` Jens Axboe
2008-04-22 18:50 ` [PATCH 9/11] parisc: " Jens Axboe
2008-04-22 18:50 ` [PATCH 10/11] sh: " Jens Axboe
2008-04-25  8:56   ` Paul Mundt
2008-04-25  9:16     ` Jens Axboe
2008-04-22 18:50 ` [PATCH 11/11] s390: " Jens Axboe
2008-04-23  7:58   ` Heiko Carstens
2008-04-23  8:11     ` Jens Axboe
2008-04-23 11:21       ` Jens Axboe
2008-04-23 11:47         ` Heiko Carstens
2008-04-23 11:54           ` Jens Axboe
2008-04-23 12:42           ` Martin Schwidefsky
2008-04-23 15:56             ` Rusty Russell
  -- strict thread matches above, loose matches on Subject: below --
2008-04-22  7:57 [PATCH 0/11] Generic smp_call_function() and friends Jens Axboe
2008-04-22  7:57 ` [PATCH 1/11] Add generic helpers for arch IPI function calls Jens Axboe
2008-04-22  9:16   ` Avi Kivity
2008-04-22  9:22     ` Jens Axboe
2008-04-22 11:14       ` Jens Axboe
2008-04-22 13:00         ` Peter Zijlstra
2008-04-22 14:25           ` Jens Axboe
2008-04-22 14:38             ` Avi Kivity
2008-04-22 14:43               ` Peter Zijlstra
2008-04-22 14:47                 ` Avi Kivity
2008-04-22 14:53               ` Jens Axboe
2008-04-22 14:43   ` Linus Torvalds
2008-04-22 14:51     ` Jens Axboe
2008-04-22 15:01       ` Linus Torvalds
2008-04-22 16:49         ` Jens Axboe
2008-04-22 17:04           ` Jens Axboe
2008-04-22 17:13             ` Jens Axboe
2008-04-22 17:29               ` Linus Torvalds
2008-04-22 18:23                 ` Jens Axboe
2008-04-22 18:39                   ` Linus Torvalds
2008-04-22 14:58     ` Linus Torvalds
2008-04-22 15:07       ` Jens Axboe
2008-04-22 23:12   ` Mark Lord
2008-04-23  7:24     ` Jens Axboe
2008-04-23 13:42       ` Mark Lord
2008-04-23 13:51         ` Jens Axboe
2008-04-23 14:46           ` Mark Lord
2008-04-24 10:59             ` Jens Axboe
2008-04-24 12:44               ` Mark Lord
2008-04-24 21:30                 ` Rafael J. Wysocki
2008-04-25 11:08                 ` Pavel Machek
2008-04-26  8:04               ` Pavel Machek
2008-04-28 15:13                 ` Mark Lord
2008-05-01 16:23                   ` Pavel Machek

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=1208937019.7115.326.camel@twins \
    --to=peterz@infradead.org \
    --cc=jens.axboe@oracle.com \
    --cc=linux-arch@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=npiggin@suse.de \
    --cc=sam@ravnborg.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox