LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Dmitry Vyukov <dvyukov@google.com>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Dexuan Cui <decui@microsoft.com>, Ingo Molnar <mingo@kernel.org>,
Alexey Dobriyan <adobriyan@gmail.com>,
Andrew Morton <akpm@linux-foundation.org>,
Peter Zijlstra <peterz@infradead.org>,
Thomas Gleixner <tglx@linutronix.de>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Rakib Mullick <rakib.mullick@gmail.com>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
Kostya Serebryany <kcc@google.com>
Subject: Re: for_each_cpu() is buggy for UP kernel?
Date: Mon, 14 May 2018 09:28:19 +0200 [thread overview]
Message-ID: <CACT4Y+aUV5XoynuhCnNTUNveQQGBhD8iHeYSMXbp7U6SVBAckw@mail.gmail.com> (raw)
In-Reply-To: <CA+55aFx5_qcUHBQ50RfOnH+pS=jqA_Wg2YYCcm=fTXRFJjs3rg@mail.gmail.com>
On Sun, May 13, 2018 at 8:21 PM, Linus Torvalds
<torvalds@linux-foundation.org> wrote:
> On Tue, May 8, 2018 at 11:24 PM Dexuan Cui <decui@microsoft.com> wrote:
>
>> Should we fix the for_each_cpu() in include/linux/cpumask.h for UP?
>
> As Thomas points out, this has come up before.
>
> One of the issues is historical - we tried very hard to make the SMP code
> not cause code generation problems for UP, and part of that was just that
> all these loops were literally designed to entirely go away under UP. It
> still *looks* syntactically like a loop, but an optimizing compiler will
> see that there's nothing there, and "for_each_cpu(...) x" essentially just
> turns into "x" on UP. An empty mask simply generally doesn't make sense,
> since opn UP you also don't have any masking of CPU ops, so the mask is
> ignored, and that helps the code generation immensely.
>
> If you have to load and test the mask, you immediately lose out badly in
> code generation.
>
> So honestly, I'd really prefer to keep our current behavior. Perhaps with a
> debug option that actually tests (on SMP - because that's what every
> developer is actually _using_ these days) that the mask isn't empty. But
> I'm not sure that would find this case, since presumably on SMP it might
> never be empty.
This looks like the problem automated testing traditionally and
effectively solves. If UP is an important config, there must be
automated pre/post commit checks for this.
next prev parent reply other threads:[~2018-05-14 7:28 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-05-09 6:24 Dexuan Cui
2018-05-09 23:20 ` Andrew Morton
2018-05-13 13:35 ` Thomas Gleixner
2018-05-13 18:21 ` Linus Torvalds
2018-05-14 7:28 ` Dmitry Vyukov [this message]
2018-05-15 3:02 ` Dexuan Cui
2018-05-15 17:21 ` Linus Torvalds
2018-05-15 20:10 ` Dexuan Cui
2018-05-15 19:52 ` [PATCH] tick/broadcast: Use for_each_cpu() specially on UP kernels Dexuan Cui
2018-05-15 20:48 ` [tip:timers/urgent] " tip-bot for Dexuan Cui
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=CACT4Y+aUV5XoynuhCnNTUNveQQGBhD8iHeYSMXbp7U6SVBAckw@mail.gmail.com \
--to=dvyukov@google.com \
--cc=adobriyan@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=decui@microsoft.com \
--cc=gregkh@linuxfoundation.org \
--cc=kcc@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=peterz@infradead.org \
--cc=rakib.mullick@gmail.com \
--cc=tglx@linutronix.de \
--cc=torvalds@linux-foundation.org \
--subject='Re: for_each_cpu() is buggy for UP kernel?' \
/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
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).