linux/arch/x86
Linus Torvalds 3d1169785a minmax: add a few more MIN_T/MAX_T users
[ Upstream commit 4477b39c32 ]

Commit 3a7e02c040 ("minmax: avoid overly complicated constant
expressions in VM code") added the simpler MIN_T/MAX_T macros in order
to avoid some excessive expansion from the rather complicated regular
min/max macros.

The complexity of those macros stems from two issues:

 (a) trying to use them in situations that require a C constant
     expression (in static initializers and for array sizes)

 (b) the type sanity checking

and MIN_T/MAX_T avoids both of these issues.

Now, in the whole (long) discussion about all this, it was pointed out
that the whole type sanity checking is entirely unnecessary for
min_t/max_t which get a fixed type that the comparison is done in.

But that still leaves min_t/max_t unnecessarily complicated due to
worries about the C constant expression case.

However, it turns out that there really aren't very many cases that use
min_t/max_t for this, and we can just force-convert those.

This does exactly that.

Which in turn will then allow for much simpler implementations of
min_t()/max_t().  All the usual "macros in all upper case will evaluate
the arguments multiple times" rules apply.

We should do all the same things for the regular min/max() vs MIN/MAX()
cases, but that has the added complexity of various drivers defining
their own local versions of MIN/MAX, so that needs another level of
fixes first.

Link: https://lore.kernel.org/all/b47fad1d0cf8449886ad148f8c013dae@AcuMS.aculab.com/
Cc: David Laight <David.Laight@aculab.com>
Cc: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Eliav Farber <farbere@amazon.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
History 2025-10-19 16:21:52 +02:00
..
boot x86/boot/compressed: prefer cc-option for CFLAGS additions 2025-06-27 11:05:21 +01:00
configs x86/kbuild: Enable CONFIG_KALLSYMS_ALL=y in the defconfigs 2022-01-27 11:04:56 +01:00
crypto crypto: x86/aegis128 - access 32-bit arguments as 32-bit 2024-12-14 19:51:13 +01:00
entry x86/bugs: Rename MDS machinery to something more generic 2025-07-10 15:57:50 +02:00
events perf/amd/ibs: Fix perf_ibs_op.cnt_mask for CurCnt 2025-06-04 14:38:04 +02:00
hyperv x86/hyperv: Remove unregister syscore call from Hyper-V cleanup 2022-12-31 13:14:39 +01:00
ia32 binfmt: remove in-tree usage of MAP_DENYWRITE 2021-09-03 18:42:01 +02:00
include x86/vdso: Fix output operand size of RDPID 2025-10-19 16:21:29 +02:00
kernel x86/umip: Fix decoding of register forms of 0F 01 (SGDT and SIDT aliases) 2025-10-19 16:21:48 +02:00
kvm KVM: x86: Don't (re)check L1 intercepts when completing userspace I/O 2025-10-19 16:21:49 +02:00
lib x86/its: Add support for ITS-safe return thunk 2025-05-22 14:08:23 +02:00
math-emu x86: Prepare asm files for straight-line-speculation 2022-05-15 20:18:49 +02:00
mm minmax: add a few more MIN_T/MAX_T users 2025-10-19 16:21:52 +02:00
net x86/its: FineIBT-paranoid vs ITS 2025-05-22 14:08:24 +02:00
pci PCI: Detect and trust built-in Thunderbolt chips 2024-12-14 19:51:42 +01:00
platform x86/pvh: Call C code via the kernel virtual mapping 2025-05-02 07:44:18 +02:00
power x86/pm: Add enumeration check before spec MSRs save/restore setup 2022-12-02 17:41:09 +01:00
purgatory x86/purgatory: Switch to the position-independent small code model 2024-06-16 13:39:22 +02:00
ras treewide: replace '---help---' in Kconfig files with 'help' 2020-06-14 01:57:21 +09:00
realmode x86/mm: Flush global TLB when switching to trampoline page-table 2022-01-27 11:04:35 +01:00
tools x86/boot: Ignore relocations in .notes sections in walk_relocs() too 2024-06-16 13:39:18 +02:00
um um: Add cmpxchg8b_emu and checksum functions to asm-prototypes.h 2025-07-10 15:57:33 +02:00
video treewide: Add SPDX license identifier - Makefile/Kconfig 2019-05-21 10:50:46 +02:00
xen Grab mm lock before grabbing pt lock 2025-03-13 12:50:36 +01:00
.gitignore .gitignore: add SPDX License Identifier 2020-03-25 11:50:48 +01:00
Kbuild treewide: Add SPDX license identifier - Kbuild 2019-05-30 11:32:33 -07:00
Kconfig x86/vmscape: Enable the mitigation 2025-09-11 17:17:17 +02:00
Kconfig.assembler x86/delay: Introduce TPAUSE delay 2020-05-07 16:06:20 +02:00
Kconfig.cpu x86/Kconfig: Transmeta Crusoe is CPU family 5, not 6 2024-02-23 08:55:08 +01:00
Kconfig.debug x86/kconfig: Select ARCH_WANT_FRAME_POINTERS again when UNWINDER_FRAME_POINTER=y 2024-06-16 13:39:46 +02:00
Makefile x86/realmode: build with -D__DISABLE_EXPORTS 2022-07-23 12:53:56 +02:00
Makefile.um um: allow not setting extra rpaths in the linux binary 2021-06-17 21:54:15 +02:00
Makefile_32.cpu x86/build: Do not add -falign flags unconditionally for clang 2021-09-19 10:35:53 +09:00