[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <828437e5-ba9c-4062-a086-1d69aace5d14@app.fastmail.com>
Date: Wed, 31 Jul 2024 12:50:02 +0200
From: "Arnd Bergmann" <arnd@...nel.org>
To: "David Laight" <David.Laight@...lab.com>,
"Linus Torvalds" <torvalds@...uxfoundation.org>
Cc: "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
"Jens Axboe" <axboe@...nel.dk>, "Matthew Wilcox" <willy@...radead.org>,
"Christoph Hellwig" <hch@...radead.org>,
"Andrew Morton" <akpm@...ux-foundation.org>,
"Andy Shevchenko" <andriy.shevchenko@...ux.intel.com>,
"Dan Carpenter" <dan.carpenter@...aro.org>,
"Jason A . Donenfeld" <Jason@...c4.com>,
"pedro.falcato@...il.com" <pedro.falcato@...il.com>,
"Mateusz Guzik" <mjguzik@...il.com>,
"linux-mm@...ck.org" <linux-mm@...ck.org>,
"Lorenzo Stoakes" <lorenzo.stoakes@...cle.com>
Subject: Re: [PATCH v2 1/8] minmax: Put all the clamp() definitions together
On Wed, Jul 31, 2024, at 10:09, David Laight wrote:
> From: Linus Torvalds
>> Sent: 31 July 2024 00:04
>>
>> On Tue, 30 Jul 2024 at 15:44, Linus Torvalds
>> <torvalds@...uxfoundation.org> wrote:
>> >
>> > Does this work for you?
>>
>> It seems to at least build cleanly here, but I'm not claiming it's all
>> that great.
>>
>> The nested __cmp() is still rather less than optimal from an expansion
>> standpoint, but at least it expands only those unique temporaries.
>
> That is the main gain, IIRC Arnd did suggest splitting it but that is
> a relatively small gain.
Right, I suggested a split version earlier, but that was without
the __careful_op3, something like
#define min3(x, y, z) ({ __auto_type __xy = min(x, y); min(__xy, z); })
I think Linus' approach with __careful_op3() is better here because
it handles more corner cases with constant arguments, otherwise
the two approaches are equivalent in how they expand the arguments.
Doing both __careful_op3() and another temporary won't add any
advantages that I can see either.
Arnd
Powered by blists - more mailing lists