mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Tzu-Ching Yang <shingekinocore@gmail.com>
To: "Maciej W. Rozycki" <macro@orcam.me.uk>
Cc: "Thomas Bogendoerfer" <tsbogend@alpha.franken.de>,
	linux-mips@vger.kernel.org, "Arnd Bergmann" <arnd@arndb.de>,
	"Yury Norov" <yury.norov@gmail.com>,
	"Rasmus Villemoes" <linux@rasmusvillemoes.dk>,
	linux-kernel@vger.kernel.org,
	"Gregory CLEMENT" <gregory.clement@bootlin.com>,
	"Théo Lebrun" <theo.lebrun@bootlin.com>,
	"Benoît Monin" <benoit.monin@bootlin.com>,
	"Jiaxun Yang" <jiaxun.yang@flygoat.com>
Subject: Re: [PATCH] MIPS: Make cpu_has_mips64r6 constant on 64-bit r6 kernels
Date: Mon, 23 Nov 2026 11:57:32 +0800	[thread overview]
Message-ID: <20261123035732.728281-1-shingekinocore@gmail.com> (raw)
In-Reply-To: <alpine.DEB.2.21.2610301515350.42255@angie.orcam.me.uk>

Sorry for the late reply: your mail did not reach my mailbox, and I did
not check the list archive until now.

On Fri, 30 Oct 2026, Maciej W. Rozycki wrote:
>  Umm, the wrong fix.  You want __isa_ge_or_flag() instead, plus obviously
> `cpu_has_64bits' is also needed (and __isa_ge_and_flag() can be discarded;
> I guess it was meant to take care of what `cpu_has_64bits' does and broke
> the whole idea by mistake).

Your form and v1 differ only on pre-r6 kernels. I built both on
mips-next (bfe97f12a0a6), and this is what cpu_has_mips64r6 folds to:

  kernel       mainline        v1              your form
  ---------    -------------   -------------   -------------
  64-bit r6    run-time test   1               1
  32-bit r6    run-time test   run-time test   run-time test
  pre-r6       0               0               run-time test

On r6 kernels the two give the same vmlinux, byte for byte
(64r6el_defconfig and 32r6el_defconfig, GCC 8.1 and 16.2, Clang 23).
On pre-r6 kernels your form compiles the r6 paths in behind the test,
for example the dmfc0 and dmtc0 of c0_ebase in decode_configs(), and
on 32-bit kernels every cpu_has_mips_r6 check also tests cpu_has_64bits
and MIPS_CPU_ISA_M64R6. In bloat-o-meter -t that is +264 bytes for
64r2el_defconfig and +3352 for 32r2el_defconfig with GCC 16.2, and
+168 and -2500 with Clang 23, which on 32r2el_defconfig no longer
inlines two prefetch helpers in mm/page.c.

> Your proposal precludes the use of R6 stuff
> with pre-R6 compilations -- not sure if that makes sense, but let's stay
> consistent with these macro definitions.

In mainline cpu_has_mips64r6 is already 0 on pre-r6 kernels, and I do
not think a pre-r6 kernel gets as far as cpu_probe() on an r6 CPU.
The comment above __isa_ge_and_ase() in cpu-features.h says that
"a kernel built for an older ISA cannot run on a MIPSr6 CPU", and
under QEMU -cpu I6400 (an r6 CPU) a 64-bit malta kernel built for r2
takes a Reserved Instruction exception at the first jr in head.S.

That leaves three ways, and I will send whichever you prefer as v2:

1. v1 with the unused __isa_ge_and_flag() removed, and in the same
   series a patch that defines cpu_has_mips32r6 as (MIPS_ISA_REV >= 6)
   to match, like cpu_has_mips_1 (MIPS_ISA_REV < 6) in that header.
   cpu_has_mips_r6 is then 0 on pre-r6 kernels and the code that it
   guards is dropped: in bloat-o-meter -t, -11524 bytes for
   64r2el_defconfig and -11156 for 32r2el_defconfig with GCC 16.2,
   -18704 and -14140 with Clang 23, with no new W=1 warnings in these
   vmlinux builds. r6 kernels stay byte-identical to v1.
2. v1 with __isa_ge_and_flag() removed: pre-r6 kernels do not change.
3. Your form, with the sizes above.

I would suggest 1.

Thanks,
Tzu-Ching

      reply	other threads:[~2026-11-23  3:57 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-30 14:04 Tzu-Ching Yang
2026-10-30 15:27 ` Maciej W. Rozycki
2026-11-23  3:57   ` Tzu-Ching Yang [this message]

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=20261123035732.728281-1-shingekinocore@gmail.com \
    --to=shingekinocore@gmail.com \
    --cc=arnd@arndb.de \
    --cc=benoit.monin@bootlin.com \
    --cc=gregory.clement@bootlin.com \
    --cc=jiaxun.yang@flygoat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mips@vger.kernel.org \
    --cc=linux@rasmusvillemoes.dk \
    --cc=macro@orcam.me.uk \
    --cc=theo.lebrun@bootlin.com \
    --cc=tsbogend@alpha.franken.de \
    --cc=yury.norov@gmail.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 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®