linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH next 00/11] minmax: Optimise to reduce .i line length.
@ 2024-01-28 19:24 David Laight
  2024-01-28 19:26 ` [PATCH next 01/11] minmax: Put all the clamp() definitions together David Laight
                   ` (10 more replies)
  0 siblings, 11 replies; 20+ messages in thread
From: David Laight @ 2024-01-28 19:24 UTC (permalink / raw)
  To: linux-kernel, 'Linus Torvalds', Netdev, dri-devel
  Cc: 'Andy Shevchenko', 'Andrew Morton',
	'Matthew Wilcox (Oracle)', 'Christoph Hellwig',
	'Dan Carpenter',
	Linus Walleij, David S . Miller, linux-btrfs,
	'Jens Axboe'

The changes to minmax.h that changed the type check to a signedness
check significantly increased the length of the expansion.
In some cases it has also significantly increased compile type.
This is particularly noticeable for nested expansions.

The fact that _Static_assert() only requires a compile time constant
not a constant expression allows a lot of simplification.

The other thing that complicates the expansion is the necessity of
returning a constant expression from constant arguments (for VLA).
I can only find a handful of places this is done.
Penalising most of the code for these few cases seems 'suboptimal'.
Instead I've added min_const() and max_const() for VLA and static
initialisers, these check the arguments are constant to avoid misuse.

Patch [9] is dependent on the earlier patches.
Patch [10] isn't dependant on them.
Patch [11] depends on both 9 and 10.

David Laight (11):
  [1] minmax: Put all the clamp() definitions together
  [2] minmax: Use _Static_assert() instead of static_assert()
  [3] minmax: Simplify signedness check
  [4] minmax: Replace multiple __UNIQUE_ID() by directly using __COUNTER__
  [5] minmax: Move the signedness check out of __cmp_once() and
    __clamp_once()
  [6] minmax: Remove 'constexpr' check from __careful_clamp()
  [7] minmax: minmax: Add __types_ok3() and optimise defines with 3
    arguments
  [8] minmax: Add min_const() and max_const()
  [9] tree-wide: minmax: Replace all the uses of max() for array sizes with
    max_const().
  [10] block: Use a boolean expression instead of max() on booleans
  [11] minmax: min() and max() don't need to return constant expressions

 block/blk-settings.c                          |   2 +-
 drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c        |   2 +-
 drivers/gpu/drm/drm_color_mgmt.c              |   4 +-
 drivers/input/touchscreen/cyttsp4_core.c      |   2 +-
 .../net/can/usb/etas_es58x/es58x_devlink.c    |   2 +-
 fs/btrfs/tree-checker.c                       |   2 +-
 include/linux/minmax.h                        | 211 ++++++++++--------
 lib/vsprintf.c                                |   4 +-
 net/ipv4/proc.c                               |   2 +-
 net/ipv6/proc.c                               |   2 +-
 10 files changed, 127 insertions(+), 106 deletions(-)

-- 
2.17.1

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)


^ permalink raw reply	[flat|nested] 20+ messages in thread

end of thread, other threads:[~2024-01-29 10:16 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-28 19:24 [PATCH next 00/11] minmax: Optimise to reduce .i line length David Laight
2024-01-28 19:26 ` [PATCH next 01/11] minmax: Put all the clamp() definitions together David Laight
2024-01-28 19:27 ` [PATCH next 02/11] minmax: Use _Static_assert() instead of static_assert() David Laight
2024-01-28 19:27 ` [PATCH next 03/11] minmax: Simplify signedness check David Laight
2024-01-28 19:28 ` [PATCH next 04/11] minmax: Replace multiple __UNIQUE_ID() by directly using __COUNTER__ David Laight
2024-01-28 19:29 ` [PATCH next 05/11] minmax: Move the signedness check out of __cmp_once() and __clamp_once() David Laight
2024-01-28 19:30 ` [PATCH next 00611] minmax: Remove 'constexpr' check from __careful_clamp() David Laight
2024-01-28 19:31 ` [PATCH next 0711] minmax: minmax: Add __types_ok3() and optimise defines with 3 arguments David Laight
2024-01-28 19:32 ` [PATCH next 08/11 minmax: Add min_const() and max_const() David Laight
2024-01-28 19:34 ` [PATCH next 09/11] tree-wide: minmax: Replace all the uses of max() for array sizes with max_const() David Laight
2024-01-29  7:54   ` David Sterba
2024-01-28 19:35 ` [PATCH next 10/11] block: Use a boolean expression instead of max() on booleans David Laight
2024-01-28 19:59   ` Linus Torvalds
2024-01-28 22:21     ` David Laight
2024-01-28 22:32       ` Linus Torvalds
2024-01-29  9:07   ` Jani Nikula
2024-01-29  9:22     ` David Laight
2024-01-29  9:47       ` Jani Nikula
2024-01-29 10:16       ` Dan Carpenter
2024-01-28 19:36 ` [PATCH next 11/11] minmax: min() and max() don't need to return constant expressions David Laight

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).