mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Arnd Bergmann" <arnd@arndb.de>
To: "Linus Torvalds" <torvalds@linux-foundation.org>
Cc: "Arnd Bergmann" <arnd@kernel.org>,
	linux-kernel@vger.kernel.org, x86@kernel.org,
	"Thomas Gleixner" <tglx@linutronix.de>,
	"Ingo Molnar" <mingo@redhat.com>,
	"Borislav Petkov" <bp@alien8.de>,
	"Dave Hansen" <dave.hansen@linux.intel.com>,
	"H. Peter Anvin" <hpa@zytor.com>,
	"Andy Shevchenko" <andy@kernel.org>,
	"Matthew Wilcox" <willy@infradead.org>,
	"Sean Christopherson" <seanjc@google.com>,
	"Davide Ciminaghi" <ciminaghi@gnudd.com>,
	"Paolo Bonzini" <pbonzini@redhat.com>,
	kvm@vger.kernel.org
Subject: Re: [PATCH 09/11] x86: rework CONFIG_GENERIC_CPU compiler flags
Date: Thu, 05 Dec 2024 10:46:25 +0100	[thread overview]
Message-ID: <66fefc5a-8cd9-4e6f-971d-0efc9810851b@app.fastmail.com> (raw)
In-Reply-To: <CAHk-=wji1sV93yKbc==Z7OSSHBiDE=LAdG_d5Y-zPBrnSs0k2A@mail.gmail.com>

On Thu, Dec 5, 2024, at 00:33, Linus Torvalds wrote:
> On Wed, 4 Dec 2024 at 11:44, Arnd Bergmann <arnd@arndb.de> wrote:
>>
>> I guess the other side of it is that the current selection
>> between pentium4/core2/k8/bonnell/generic is not much better,
>> given that in practice nobody has any of the
>> pentium4/core2/k8/bonnell variants any more.
>
> So I suspect:
>
>> A more radical solution would be to just drop the entire
>> menu for 64-bit kernels and always default to "-march=x86_64
>> -mtune=generic" and 64 byte L1 cachelines.
>
> would actually be perfectly acceptable. The non-generic choices are
> all entirely historical and not really very interesting.
>
> Absolutely nobody sane cares about instruction scheduling for the old P4 cores.

Ok, I'll do that instead then. This also means I can drop
the patch for CONFIG_MATOM.

> In the bad old 32-bit days, we had real code generation issues with
> basic instruction set, ie the whole "some CPU's are P6-class, but
> don't actually support the CMOVxx instruction". Those days are gone.

I did come across a remaining odd problem with this, as Crusoe and
GeodeLX both identify as Family 5 but have CMOV.  Trying to use
a CONFIG_M686+CONFIG_X86_GENERIC on these runs fails with a boot
error "This kernel requires a 686 CPU but only detected a 586 CPU".

As a result, the Debian 686 kernel binary gets built with
CONFIG_MGEODE_LX , which seems mildly wrong but harmful enough
to require a change in how we handle the levels.

> And yes, on x86-64, we still have the whole cmpxchg16b issue, which
> really is a slight annoyance. But the emphasis is on "slight" - we
> basically have one back for this in the SLAB code, and a couple of
> dynamic tests for one particular driver (iommu 128-bit IRTE mode).
>
> So yeah, the cmpxchg16b thing is annoying, but _realistically_ I don't
> think we care.
>
> And some day we will forget about it, notice that those (few) AMD
> early 64-bit CPU's can't possibly have been working for the last year
> or two, and we'll finally just kill that code, but in the meantime the
> cost of maintaining it is so slight that it's not worth actively going
> out to kill it.

Right, in particular my hope of turning the runtime detection into
always using compile-time configuration for cmpxchg16b is no longer
works as I noticed that risc-v has also gained a runtime detection
for system_has_cmpxchg128().

Besides cmpxchg16b, I can also see compile-time configuration
for some instructions (popcnt, tzcnt, movbe) and for 5-level
paging being useful, but not enough so to make up for the
configuration complexity.

I still think we will end up needing more compile time
configurability like this on arm64 to deal with small-memory
embedded systems, e.g. with a specialized cortex-a55 kernel
that leaves out support for other CPUs, but this is quite
different from the situation on x86-64.

> I do think that the *one* option we might have is "optimize for the
> current CPU" for people who just want to build their own kernel for
> their own machine. That's a nice easy choice to give people, and
> '-march=native' is kind of simple to use.
>
> Will that work when you cross-compile? No. Do we care? Also no. It's
> basically a simple "you want to optimize for your own local machine"
> switch.

Sure, I'll add that as a separate patch. Should it be -march=native
or -mtune=native though? Using -march= can be faster if it picks
up newer instructions, but it will eventually lead to users
running into a boot panic if it is accidentally turned on for
a kernel that runs on an older machine than it was built on.

> Maybe that could replace some of the 32-bit choices too?

Probably not. I spent hours looking through the 32-bit choices
in the hope of finding a way that is less of a mess. The current
menu mixes up instruction set level (486/586/686), optimization
(atom/k7/m3/pentiumm) and platform (elan/geode/pc) options.
This is needlessly confusing, but any change to the status quo
is going to cause more problems for existing users than it
solves. All the "interesting" embedded ones are likely to be
cross-compiled anyway, so mtune=native or -march=native wouldn't
help them either.

     Arnd

  parent reply	other threads:[~2024-12-05  9:46 UTC|newest]

Thread overview: 77+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-12-04 10:30 [PATCH 00/11] x86: 32-bit cleanups Arnd Bergmann
2024-12-04 10:30 ` [PATCH 01/11] x86/Kconfig: Geode CPU has cmpxchg8b Arnd Bergmann
2024-12-04 10:30 ` [PATCH 02/11] x86: drop 32-bit "bigsmp" machine support Arnd Bergmann
2024-12-04 10:30 ` [PATCH 03/11] x86: Kconfig.cpu: split out 64-bit atom Arnd Bergmann
2024-12-04 13:16   ` Thomas Gleixner
2024-12-04 15:55     ` H. Peter Anvin
2024-12-04 18:21       ` Andy Shevchenko
2024-12-04 10:30 ` [PATCH 04/11] x86: split CPU selection into 32-bit and 64-bit Arnd Bergmann
2024-12-04 18:31   ` Andy Shevchenko
2024-12-04 21:18     ` Arnd Bergmann
2024-12-04 10:30 ` [PATCH 05/11] x86: remove HIGHMEM64G support Arnd Bergmann
2024-12-04 13:29   ` Brian Gerst
2024-12-04 13:43     ` Arnd Bergmann
2024-12-04 14:02       ` Brian Gerst
2024-12-04 15:00         ` Brian Gerst
2024-12-04 15:58         ` H. Peter Anvin
2024-12-04 15:53       ` H. Peter Anvin
2024-12-04 16:37     ` H. Peter Anvin
2024-12-04 16:55       ` Arnd Bergmann
2024-12-04 18:37         ` Andy Shevchenko
2024-12-04 21:14           ` Arnd Bergmann
2025-04-11 23:44   ` Dave Hansen
2025-04-12  8:39     ` Ingo Molnar
2025-04-12 10:05     ` Mike Rapoport
2025-04-12 10:44       ` Arnd Bergmann
2025-04-12 19:48       ` Ingo Molnar
2025-04-13  8:08         ` [PATCH] x86/e820: discard high memory that can't be addressed by 32-bit systems Mike Rapoport
2025-04-13  9:23           ` [tip: x86/urgent] x86/e820: Discard " tip-bot2 for Mike Rapoport (Microsoft)
2025-04-14 14:19             ` Dave Hansen
2025-04-15  7:18               ` Mike Rapoport
2025-04-15 13:43                 ` Dave Hansen
2025-04-16  7:17                   ` Ingo Molnar
2025-04-16  7:51                     ` Ingo Molnar
2025-04-16  7:24           ` tip-bot2 for Mike Rapoport (Microsoft)
2025-04-16  8:16           ` tip-bot2 for Mike Rapoport (Microsoft)
2025-04-17 16:22           ` [PATCH] x86/e820: discard " Nathan Chancellor
2025-04-18  6:33             ` Ingo Molnar
2025-04-18  9:01               ` Mike Rapoport
2025-04-18 12:59                 ` Ingo Molnar
2025-04-18 19:25                   ` Mike Rapoport
2025-04-18 19:29                     ` Dave Hansen
2025-04-18 19:49           ` Guenter Roeck
2025-04-12 10:40     ` [PATCH 05/11] x86: remove HIGHMEM64G support Arnd Bergmann
2024-12-04 10:30 ` [PATCH 06/11] x86: drop SWIOTLB and PHYS_ADDR_T_64BIT for PAE Arnd Bergmann
2024-12-04 18:41   ` Andy Shevchenko
2024-12-04 20:52     ` Arnd Bergmann
2024-12-05  7:59       ` Andy Shevchenko
2024-12-04 10:30 ` [PATCH 07/11] x86: drop support for CONFIG_HIGHPTE Arnd Bergmann
2024-12-04 10:30 ` [PATCH 08/11] x86: document X86_INTEL_MID as 64-bit-only Arnd Bergmann
2024-12-04 18:55   ` Andy Shevchenko
2024-12-04 20:38     ` Arnd Bergmann
2024-12-05  8:03       ` Andy Shevchenko
2024-12-06 11:23     ` Ferry Toth
2024-12-06 14:27       ` Arnd Bergmann
2024-12-04 10:30 ` [PATCH 09/11] x86: rework CONFIG_GENERIC_CPU compiler flags Arnd Bergmann
2024-12-04 15:36   ` Tor Vic
2024-12-04 17:51     ` Arnd Bergmann
2024-12-04 17:09   ` Nathan Chancellor
2024-12-04 17:52     ` Arnd Bergmann
2024-12-04 18:10   ` Linus Torvalds
2024-12-04 19:43     ` Arnd Bergmann
2024-12-04 23:33       ` Linus Torvalds
2024-12-05  8:13         ` Andy Shevchenko
2024-12-05 10:09           ` Arnd Bergmann
2024-12-05 11:17             ` Andy Shevchenko
2024-12-05 11:58               ` Arnd Bergmann
2024-12-05 12:35                 ` Jason A. Donenfeld
2024-12-05  9:46         ` Arnd Bergmann [this message]
2024-12-05 10:01           ` Andy Shevchenko
2024-12-05 10:47             ` Arnd Bergmann
2024-12-05  8:07       ` Andy Shevchenko
2024-12-06 13:56   ` David Laight
2024-12-04 10:30 ` [PATCH 10/11] x86: remove old STA2x11 support Arnd Bergmann
2024-12-05  7:35   ` Davide Ciminaghi
2024-12-04 10:30 ` [PATCH 11/11] x86: drop 32-bit KVM host support Arnd Bergmann
2024-12-04 15:30   ` Sean Christopherson
2024-12-04 16:33     ` Arnd Bergmann

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=66fefc5a-8cd9-4e6f-971d-0efc9810851b@app.fastmail.com \
    --to=arnd@arndb.de \
    --cc=andy@kernel.org \
    --cc=arnd@kernel.org \
    --cc=bp@alien8.de \
    --cc=ciminaghi@gnudd.com \
    --cc=dave.hansen@linux.intel.com \
    --cc=hpa@zytor.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=seanjc@google.com \
    --cc=tglx@linutronix.de \
    --cc=torvalds@linux-foundation.org \
    --cc=willy@infradead.org \
    --cc=x86@kernel.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

all inboxes | Powered by JetHome®