All of lore.kernel.org
 help / color / mirror / Atom feed
From: Laurent Vivier <Laurent.Vivier@bull.net>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Fengguang Wu <wfg@mail.ustc.edu.cn>, Andi Kleen <ak@suse.de>,
	linux-kernel@vger.kernel.org
Subject: Re: WARNING: at arch/x86_64/kernel/smp.c:397 smp_call_function_mask()
Date: Fri, 28 Sep 2007 11:18:45 +0200	[thread overview]
Message-ID: <46FCC6F5.2030109@bull.net> (raw)
In-Reply-To: <20070928020950.bdcad2c2.akpm@linux-foundation.org>

[-- Attachment #1: Type: text/plain, Size: 4387 bytes --]

Andrew Morton wrote:
> On Fri, 28 Sep 2007 10:52:08 +0200 Laurent Vivier <Laurent.Vivier@bull.net> wrote:
> 
>> Fengguang Wu wrote:
>>> On Thu, Sep 27, 2007 at 02:22:20AM -0700, Andrew Morton wrote:
>>>> ftp://ftp.kernel.org/pub/linux/kernel/people/akpm/patches/2.6/2.6.23-rc8/2.6.23-rc8-mm2/
>>>  
>>> Laurent,
>>>
>>> It triggered a WARNING on first run in qemu:
>> Thank you to report it.
>>
>>> [    0.310000] WARNING: at arch/x86_64/kernel/smp.c:397 smp_call_function_mask()
>>> [    0.310000]
>>> [    0.310000] Call Trace:
>>> [    0.310000]  [<ffffffff8100dbde>] dump_trace+0x3ee/0x4a0
>>> [    0.310000]  [<ffffffff8100dcd3>] show_trace+0x43/0x70
>>> [    0.310000]  [<ffffffff8100dd15>] dump_stack+0x15/0x20
>>> [    0.310000]  [<ffffffff8101cd44>] smp_call_function_mask+0x94/0xa0
>>> [    0.310000]  [<ffffffff8101cd69>] smp_call_function+0x19/0x20
>>> [    0.310000]  [<ffffffff8104277f>] on_each_cpu+0x1f/0x50
>>> [    0.310000]  [<ffffffff81026eac>] global_flush_tlb+0x8c/0x110
>>> [    0.310000]  [<ffffffff81025c85>] free_init_pages+0xe5/0xf0
>>> [    0.310000]  [<ffffffff81549b5e>] alternative_instructions+0x7e/0x150
>>> [    0.310000]  [<ffffffff8154a2ea>] check_bugs+0x1a/0x20
>>> [    0.310000]  [<ffffffff81540c4a>] start_kernel+0x2da/0x380
>>> [    0.310000]  [<ffffffff81540132>] _sinittext+0x132/0x140
>>
>> the reason is the WARN_ON():
>>
>> 390 int smp_call_function_mask(cpumask_t mask,
>> 391                            void (*func)(void *), void *info,
>> 392                            int wait)
>> 393 {
>> 394         int ret;
>> 395
>> 396         /* Can deadlock when called with interrupts disabled */
>> 397         WARN_ON(irqs_disabled());
>> 398
>> 399         spin_lock(&call_lock);
>> 400         ret = __smp_call_function_mask(mask, func, info, wait);
>> 401         spin_unlock(&call_lock);
>> 402         return ret;
>> 403 }
>>
>> The patch I sent to Andi didn't include this WARN_ON() and it's why I didn't
>> find this issue. (see http://lkml.org/lkml/2007/8/24/101)
>>
>> smp_call_function_mask() is called by smp_call_function() which calls a function
>> on all CPU except current.
>> The comment of smp_call_function() specifies:
>> ...
>>  * You must not call this function with disabled interrupts or from a
>>  * hardware interrupt handler or from a bottom half handler.
>>  * Actually there are a few legal cases, like panic.
>>  */
>>
>> So this WARN_ON() is correct, and the caller (global_flush_tlb()) doesn't follow
>> this rule.
>>
>> I guess this WARN_ON() is only needed when we have current CPU in provided mask.
>> So I think we should change:
>>
>> int smp_call_function (void (*func) (void *info), void *info, int nonatomic,
>>                         int wait)
>> {
>>         return smp_call_function_mask(cpu_online_map, func, info, wait);
>> }
>> ("cpu_online_map" is a bad choice, comment also specifies: "run a function on
>> all other CPU")
>>
>> to
>>
>> int smp_call_function (void (*func) (void *info), void *info, int nonatomic,
>>                         int wait)
>> {
>>         int ret;
>> 	cpumask_t allbutself;
>>
>> 	allbutself = cpu_online_map;
>> 	cpu_clear(smp_processor_id(), allbutself);
>>
>>         spin_lock(&call_lock);
>>         ret = __smp_call_function_mask(allbutself, func, info, wait);
>>         spin_unlock(&call_lock);
>>         return ret;
>> }
>> (which is smp_call_function_mask() without the WARN_ON() and without current cpu
>> in the mask)
>>
>> Andi, is this correct ?
>> Andrew, should I send a patch implementing this change ?
> 
> umm, I think all the smp_call_function fucntions are deadlocky if called
> with local interrupts disabled, regardless of whether the calling CPU is in
> the mask.
> 
> If CPU A is sending a cross-cpu call to CPU B and CPU B is sending a
> cross-cpu call to CPU A, and they both have local interrupts disabled...

OK, so there are two errors:

1- one I introduce myself (without any help from anyone) where
smp_call_function() calls all online CPUs instead of calling all CPUs except itself.

2- one in global_flush_tlb() which calls smp_call_function() with irqs disabled.

I think I should at least correct #1 ?

Laurent
-- 
------------- Laurent.Vivier@bull.net  --------------
          "Software is hard" - Donald Knuth


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 189 bytes --]

  reply	other threads:[~2007-09-28  9:19 UTC|newest]

Thread overview: 61+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-09-27  9:22 2.6.23-rc8-mm2 Andrew Morton
2007-09-27 10:52 ` 2.6.23-rc8-mm2 - drivers/net/ibm_newemac/mal - broken Kamalesh Babulal
2007-09-27 15:19 ` 2.6.23-rc8-mm2: problems on HP nx6325 Rafael J. Wysocki
2007-09-27 15:59   ` Rafael J. Wysocki
2007-09-27 15:49     ` Thomas Gleixner
2007-09-28 21:31       ` Rafael J. Wysocki
2007-09-27 16:53     ` Sam Ravnborg
2007-09-27 17:33       ` Randy Dunlap
2007-09-27 19:19         ` Sam Ravnborg
2007-09-27 19:48           ` Rafael J. Wysocki
2007-09-27 19:37             ` Randy Dunlap
2007-09-27 20:01               ` Rafael J. Wysocki
2007-09-27 19:18 ` 2.6.23-rc8-mm2: BUG near reiserfs_xattr_set Laurent Riffard
2007-09-27 19:48   ` Andrew Morton
2007-09-27 19:48     ` Andrew Morton
2007-09-27 20:05     ` Dave Hansen
2007-09-27 20:26     ` Christoph Hellwig
2007-09-27 20:53       ` [RFC][PATCH] make reiserfs stop using 'struct file' for internal xattr operations Dave Hansen
2007-09-27 21:04         ` Christoph Hellwig
2007-09-27 21:27           ` Dave Hansen
2007-09-27 21:51             ` Andrew Morton
2007-09-27 21:54               ` Andrew Morton
2007-09-27 22:02               ` Peter Zijlstra
2007-09-28  7:16               ` Christoph Hellwig
2007-09-28  7:29                 ` [RFC][PATCH] stop abusing filp_open in reiserfs journal code Christoph Hellwig
2007-09-28  7:29                 ` Christoph Hellwig
2007-09-28  7:29                   ` Christoph Hellwig
2007-09-28  2:40 ` WARNING: at arch/x86_64/kernel/smp.c:397 smp_call_function_mask() Fengguang Wu
2007-09-28  2:40   ` Fengguang Wu
2007-09-28  8:52     ` Laurent Vivier
2007-09-28  9:09       ` Andrew Morton
2007-09-28  9:18         ` Laurent Vivier [this message]
2007-09-28  9:34           ` Andrew Morton
2007-09-28 12:07             ` Laurent Vivier
2007-09-29  6:59               ` Fengguang Wu
2007-09-29  6:59                 ` Fengguang Wu
2007-09-29  8:15               ` Fengguang Wu
2007-09-29  8:15                 ` Fengguang Wu
2007-10-02  9:11                 ` [PATCH][RESEND] call free_init_pages() with irqs enabled in alternative_instructions() Fengguang Wu
2007-10-02  9:11                   ` Fengguang Wu
2007-09-28 15:42 ` 2.6.23-rc8-mm2 - tcp_fastretrans_alert() WARNING Cedric Le Goater
2007-09-28 19:10   ` Ilpo Järvinen
2007-09-29 12:44     ` Ilpo Järvinen
2007-09-29 14:55       ` Cedric Le Goater
2007-09-29 20:49         ` Ilpo Järvinen
2007-10-01  9:26           ` Cedric Le Goater
2007-10-02 10:26             ` Ilpo Järvinen
2007-10-02 20:06               ` Ilpo Järvinen
2007-10-02 21:48                 ` Ilpo Järvinen
2007-09-28 16:30 ` /proc/net/ bad hard links count [Was: 2.6.23-rc8-mm2] Jiri Slaby
2007-09-28 17:03   ` Eric W. Biederman
2007-09-29  9:37 ` 2.6.23-rc8-mm2 Dave Young
2007-09-29 15:19   ` 2.6.23-rc8-mm2 Greg KH
2007-09-30  1:29     ` 2.6.23-rc8-mm2 Dave Young
2007-09-30  5:18     ` 2.6.23-rc8-mm2 thunder7
2007-10-08  6:43     ` 2.6.23-rc8-mm2 Dave Young
2007-09-30  2:26 ` 2.6.23-rc8-mm2 Valdis.Kletnieks
2007-09-30  8:50   ` 2.6.23-rc8-mm2 Andrew Morton
2007-09-30 20:01     ` 2.6.23-rc8-mm2 Rafael J. Wysocki
2007-10-01 17:12       ` 2.6.23-rc8-mm2 Valdis.Kletnieks
2007-10-01 16:12     ` 2.6.23-rc8-mm2 Valdis.Kletnieks
2007-09-30  4:10 ` 2.6.23-rc8-mm2 - PowerPC link failure at arch/powerpc/kernel/head_64.o Kamalesh Babulal
2007-09-30  9:37   ` Kamalesh Babulal
2007-09-30  9:37     ` Kamalesh Babulal
2007-10-09 17:49 ` 2.6.23-rc8-mm2 Matt Mackall

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=46FCC6F5.2030109@bull.net \
    --to=laurent.vivier@bull.net \
    --cc=ak@suse.de \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=wfg@mail.ustc.edu.cn \
    /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.