From: David Laight <David.Laight@ACULAB.COM>
To: 'Aurelien Jarno' <aurelien@aurel32.net>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
Bluecherry Maintainers <maintainers@bluecherrydvr.com>,
Anton Sviridenko <anton@corp.bluecherry.net>,
Andrey Utkin <andrey_utkin@fastmail.com>,
"Ismael Luceno" <ismael@iodev.co.uk>,
Mauro Carvalho Chehab <mchehab@kernel.org>,
"open list:SOFTLOGIC 6x10 MPEG CODEC"
<linux-media@vger.kernel.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>,
Andy Shevchenko' <andriy.shevchenko@linux.intel.com>,
Andrew Morton' <akpm@linux-foundation.org>,
Matthew Wilcox <willy@infradead.org>,
"Christoph Hellwig'" <hch@infradead.org>,
"Jason A . Donenfeld" <Jason@zx2c4.com>,
"Jiri Slaby" <jirislaby@gmail.com>,
"stable@vger.kernel.org" <stable@vger.kernel.org>
Subject: RE: [PATCH] media: solo6x10: replace max(a, min(b, c)) by clamp(b, a, c)
Date: Sat, 13 Jan 2024 22:42:10 +0000 [thread overview]
Message-ID: <3c85f81d1b944d4c9ec1cd07504f45db@AcuMS.aculab.com> (raw)
In-Reply-To: <20240113183334.1690740-1-aurelien@aurel32.net>
From: Aurelien Jarno
> Sent: 13 January 2024 18:34
>
> This patch replaces max(a, min(b, c)) by clamp(b, a, c) in the solo6x10
> driver. This improves the readability and more importantly, for the
> solo6x10-p2m.c file, this reduces on my system (x86-64, gcc 13):
> - the preprocessed size from 121 MiB to 4.5 MiB;
> - the build CPU time from 46.8 s to 1.6 s;
> - the build memory from 2786 MiB to 98MiB.
>
> In fine, this allows this relatively simple C file to be built on a
> 32-bit system.
>
> Reported-by: Jiri Slaby <jirislaby@gmail.com>
> Closes: https://lore.kernel.org/lkml/18c6df0d-45ed-450c-9eda-95160a2bbb8e@gmail.com/
> Cc: stable@vger.kernel.org # v6.7+
> Suggested-by: David Laight <David.Laight@ACULAB.COM>
> Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
Reviewed-by: David Laight <David.Laight@ACULAB.COM>
I was about to send the same patch.
Although I'm not sure why the cpu time is so large.
It compiles pretty immediately on my system.
I do have some patches to minmax.h that reduce the .i for the nested
clamp() to around 200k.
Mostly obtained be adding min/max_const() for the few places
that need a constant and min/max_ptr() for pointer types.
Supporting both causes the expansion to be a lot larger.
David
> ---
> drivers/media/pci/solo6x10/solo6x10-offsets.h | 10 +++++-----
> 1 file changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/media/pci/solo6x10/solo6x10-offsets.h b/drivers/media/pci/solo6x10/solo6x10-
> offsets.h
> index f414ee1316f2..fdbb817e6360 100644
> --- a/drivers/media/pci/solo6x10/solo6x10-offsets.h
> +++ b/drivers/media/pci/solo6x10/solo6x10-offsets.h
> @@ -57,16 +57,16 @@
> #define SOLO_MP4E_EXT_ADDR(__solo) \
> (SOLO_EREF_EXT_ADDR(__solo) + SOLO_EREF_EXT_AREA(__solo))
> #define SOLO_MP4E_EXT_SIZE(__solo) \
> - max((__solo->nr_chans * 0x00080000), \
> - min(((__solo->sdram_size - SOLO_MP4E_EXT_ADDR(__solo)) - \
> - __SOLO_JPEG_MIN_SIZE(__solo)), 0x00ff0000))
> + clamp(__solo->sdram_size - SOLO_MP4E_EXT_ADDR(__solo) - \
> + __SOLO_JPEG_MIN_SIZE(__solo), \
> + __solo->nr_chans * 0x00080000, 0x00ff0000)
>
> #define __SOLO_JPEG_MIN_SIZE(__solo) (__solo->nr_chans * 0x00080000)
> #define SOLO_JPEG_EXT_ADDR(__solo) \
> (SOLO_MP4E_EXT_ADDR(__solo) + SOLO_MP4E_EXT_SIZE(__solo))
> #define SOLO_JPEG_EXT_SIZE(__solo) \
> - max(__SOLO_JPEG_MIN_SIZE(__solo), \
> - min((__solo->sdram_size - SOLO_JPEG_EXT_ADDR(__solo)), 0x00ff0000))
> + clamp(__solo->sdram_size - SOLO_JPEG_EXT_ADDR(__solo), \
> + __SOLO_JPEG_MIN_SIZE(__solo), 0x00ff0000)
>
> #define SOLO_SDRAM_END(__solo) \
> (SOLO_JPEG_EXT_ADDR(__solo) + SOLO_JPEG_EXT_SIZE(__solo))
> --
> 2.42.0
-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)
next prev parent reply other threads:[~2024-01-13 22:42 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-13 18:33 Aurelien Jarno
2024-01-13 22:42 ` David Laight [this message]
2024-01-14 11:04 ` Hans Verkuil
2024-01-21 19:57 ` Linus Torvalds
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=3c85f81d1b944d4c9ec1cd07504f45db@AcuMS.aculab.com \
--to=david.laight@aculab.com \
--cc=Jason@zx2c4.com \
--cc=akpm@linux-foundation.org \
--cc=andrey_utkin@fastmail.com \
--cc=andriy.shevchenko@linux.intel.com \
--cc=anton@corp.bluecherry.net \
--cc=aurelien@aurel32.net \
--cc=hch@infradead.org \
--cc=ismael@iodev.co.uk \
--cc=jirislaby@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=maintainers@bluecherrydvr.com \
--cc=mchehab@kernel.org \
--cc=stable@vger.kernel.org \
--cc=torvalds@linux-foundation.org \
--cc=willy@infradead.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®