From: Andrzej Hajda <andrzej.hajda@intel.com>
To: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: Arnd Bergmann <arnd@arndb.de>,
intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org,
dri-devel@lists.freedesktop.org,
Rodrigo Vivi <rodrigo.vivi@intel.com>,
Andrew Morton <akpm@linux-foundation.org>
Subject: Re: [Intel-gfx] [PATCH 1/5] linux/minmax.h: add non-atomic version of xchg
Date: Tue, 13 Dec 2022 11:09:12 +0100 [thread overview]
Message-ID: <398d55d0-3256-238e-132a-195baaf7f4a6@intel.com> (raw)
In-Reply-To: <Y5OE3AX7DS/DfClX@smile.fi.intel.com>
On 09.12.2022 19:56, Andy Shevchenko wrote:
> On Fri, Dec 09, 2022 at 04:48:39PM +0100, Andrzej Hajda wrote:
>> The pattern of setting variable with new value and returning old
>> one is very common in kernel. Usually atomicity of the operation
>> is not required, so xchg seems to be suboptimal and confusing in
>> such cases. Since name xchg is already in use and __xchg is used
>> in architecture code, proposition is to name the macro exchange.
>>
>> Signed-off-by: Andrzej Hajda <andrzej.hajda@intel.com>
>> ---
>> Hi,
>>
>> I hope there will be place for such tiny helper in kernel.
>> Quick cocci analyze shows there is probably few thousands places
>> where it could be used, of course I do not intend to do it :).
>>
>> I was not sure where to put this macro, I hope near swap definition
>> is the most suitable place.
>
> Ah, swap() in this context is not the same. minmax.h hosts it because
> it's often related to the swap function in the sort-type algorithms. > >> Moreover sorry if to/cc is not correct - get_maintainers.pl was
>> more confused than me, to who address this patch.
>
> ...
>
>> include/linux/minmax.h | 14 ++++++++++++++
>
> Does it really suit this header? I would expect something else.
> Maybe include/linux/non-atomic/xchg.h, dunno.
non-atomic seems quite strange for me, I would assume everything not in
atomic is non-atomic, unless explicitly specified.
>
> Btw, have you looked if Ingo's gigantic series have done anything to cmpxchg.h
> and related headers? Maybe some ideas can be taken from there?
>
Grepping it didn't give any clue.
Looking at 'near' languages just to get an idea (they name the function
differently):
C++ [1]: exchange and swap are in utility header
Rust[2]: replace and swap are in std::mem module
This is some argument to put them together.
[1]: https://en.cppreference.com/w/cpp/header/utility
[2]: https://doc.rust-lang.org/std/mem/index.html
Regards
Andrzej
next prev parent reply other threads:[~2022-12-13 10:09 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-09 15:48 Andrzej Hajda
2022-12-09 15:48 ` [PATCH 2/5] drm/i915/display: kill fetch_and_zero usage Andrzej Hajda
2022-12-09 15:48 ` [PATCH 3/5] drm/i915/gt: " Andrzej Hajda
2022-12-12 9:14 ` [Intel-gfx] " Upadhyay, Tejas
2022-12-12 9:23 ` Andrzej Hajda
2022-12-09 15:48 ` [PATCH 4/5] drm/i915/gvt: " Andrzej Hajda
2022-12-09 15:48 ` [PATCH 5/5] drm/i915: kill fetch_and_zero Andrzej Hajda
2022-12-09 17:16 ` [PATCH 1/5] linux/minmax.h: add non-atomic version of xchg Arnd Bergmann
2022-12-13 9:28 ` [Intel-gfx] " Andrzej Hajda
2022-12-13 9:35 ` Arnd Bergmann
2022-12-09 18:56 ` Andy Shevchenko
2022-12-09 18:58 ` Andy Shevchenko
2022-12-13 10:09 ` Andrzej Hajda [this message]
2022-12-13 10:27 ` [Intel-gfx] " Andy Shevchenko
2022-12-12 9:38 ` David Laight
2023-01-05 13:04 ` Daniel Vetter
2023-01-05 13:28 ` [Intel-gfx] " Jani Nikula
2023-01-05 13:34 ` David Laight
2023-01-05 14:13 ` Daniel Vetter
2023-01-05 14:41 ` David Laight
2023-01-05 14:57 ` Daniel Vetter
2023-01-05 16:16 ` Mark Rutland
2023-01-05 14:13 ` Tvrtko Ursulin
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=398d55d0-3256-238e-132a-195baaf7f4a6@intel.com \
--to=andrzej.hajda@intel.com \
--cc=akpm@linux-foundation.org \
--cc=andriy.shevchenko@linux.intel.com \
--cc=arnd@arndb.de \
--cc=dri-devel@lists.freedesktop.org \
--cc=intel-gfx@lists.freedesktop.org \
--cc=linux-kernel@vger.kernel.org \
--cc=rodrigo.vivi@intel.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®