All of lore.kernel.org
 help / color / mirror / Atom feed
From: Bjorn Helgaas <bhelgaas@google.com>
To: Christoph Hellwig <hch@infradead.org>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	Ingo Molnar <mingo@kernel.org>,
	Thomas Gleixner <tglx@linutronix.de>,
	Tony Luck <tony.luck@intel.com>, Robert Richter <rric@kernel.org>,
	Aaro Koskinen <aaro.koskinen@iki.fi>,
	David Daney <david.daney@cavium.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: smp_call_function_single with wait=0 considered harmful
Date: Thu, 5 Dec 2013 14:43:03 -0700	[thread overview]
Message-ID: <CAErSpo49VvgpoRpS2+KHJe=zWhzR6sXdcrGdYQ5MGemi3m_Xuw@mail.gmail.com> (raw)
In-Reply-To: <20131204164627.GA27677@infradead.org>

On Wed, Dec 4, 2013 at 9:46 AM, Christoph Hellwig <hch@infradead.org> wrote:
> While doing my recent work on the generic smp function calls I noticed
> that smp_call_function_single without the wait flag can't work, as
> it allocates struct call_single_data on stack, and without the wait
> flag will happily return before the IPI has been executed.

I don't understand the problem yet.  With wait==0,
smp_call_function_single() sets "csd = &__get_cpu_var(csd_data)", so
it's not using a struct on the stack.  We'll queue up "func" and
likely will return before it is executed, but that should be fine
because nobody will overwrite csd_data until it *is* executed and
csd_unlock() has been called.

> This affects the following callers:
>
>   arch/ia64/kernel/mca.c:mca_cpu_callback()
>   arch/ia64/kernel/smpboot.c:ia64_sync_itc()
>   arch/x86/kernel/kvm.c:kvm_cpu_notify()
>   arch/x86/oprofile/nmi_int.c:oprofile_cpu_notifier()
>   arch/x86/pci/amd_bus.c:amd_cpu_notify()

I don't see any reason why amd_cpu_notify() needs to use wait==0.

>   drivers/staging/octeon/ethernet-rx.c:cvm_oct_enable_one_cpu()
>   kernel/stop_machine.c:stop_two_cpus()
>
> It would be good to get these fixed so that we could remove the
> parameter.  Either convert them to wait, or use a preallocated
> call_single_data and __smp_call_function_single.
>
> After that I'd like to remove the wait argument to prevent further
> abuses.

  reply	other threads:[~2013-12-05 21:43 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-04 16:46 smp_call_function_single with wait=0 considered harmful Christoph Hellwig
2013-12-05 21:43 ` Bjorn Helgaas [this message]
2013-12-06 10:56   ` Christoph Hellwig
2014-02-28 12:26 ` Peter Zijlstra
2014-02-28 12:39   ` Peter Zijlstra
2014-02-28 17:06     ` Rik van Riel
2014-02-28 17:34     ` Prarit Bhargava
2014-03-11 12:36     ` [tip:sched/core] stop_machine: Fix^2 race between stop_two_cpus() and stop_cpus() tip-bot for Peter Zijlstra

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='CAErSpo49VvgpoRpS2+KHJe=zWhzR6sXdcrGdYQ5MGemi3m_Xuw@mail.gmail.com' \
    --to=bhelgaas@google.com \
    --cc=aaro.koskinen@iki.fi \
    --cc=akpm@linux-foundation.org \
    --cc=david.daney@cavium.com \
    --cc=hch@infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=rric@kernel.org \
    --cc=tglx@linutronix.de \
    --cc=tony.luck@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 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.