Re: [Intel-gfx] [PATCH 1/5] linux/minmax.h: add non-atomic version of xchg

2023-01-10 Thread Mark Rutland
On Thu, Jan 05, 2023 at 03:57:25PM +0100, Daniel Vetter wrote: > It's more fun, for the atomic functions which don't have the atomic_ > prefix in their names, the __ prefixed versions provide the non-atomic > implementation. This pattern was started with the long * bitops stuff for > managing

Re: [Intel-gfx] [PATCH 1/5] linux/minmax.h: add non-atomic version of xchg

2023-01-05 Thread Daniel Vetter
On Thu, Jan 05, 2023 at 02:41:43PM +, David Laight wrote: > From: Daniel Vetter > > Sent: 05 January 2023 14:13 > ... > > > > So here we are, with Andrzej looking to add the common helper. And the > > > > same concerns crop up. What should it be called to make it clear that > > > > it's not

Re: [Intel-gfx] [PATCH 1/5] linux/minmax.h: add non-atomic version of xchg

2023-01-05 Thread David Laight
From: Daniel Vetter > Sent: 05 January 2023 14:13 ... > > > So here we are, with Andrzej looking to add the common helper. And the > > > same concerns crop up. What should it be called to make it clear that > > > it's not atomic? Is that possible? > > > > old_value = read_write(variable,

Re: [Intel-gfx] [PATCH 1/5] linux/minmax.h: add non-atomic version of xchg

2023-01-05 Thread Tvrtko Ursulin
On 05/01/2023 13:34, David Laight wrote: From: Jani Nikula Sent: 05 January 2023 13:28 On Thu, 05 Jan 2023, Daniel Vetter wrote: On Mon, Dec 12, 2022 at 09:38:12AM +, David Laight wrote: From: Andrzej Hajda Sent: 09 December 2022 15:49 The pattern of setting variable with new value

Re: [Intel-gfx] [PATCH 1/5] linux/minmax.h: add non-atomic version of xchg

2023-01-05 Thread Daniel Vetter
On Thu, Jan 05, 2023 at 01:34:33PM +, David Laight wrote: > From: Jani Nikula > > Sent: 05 January 2023 13:28 > > > > On Thu, 05 Jan 2023, Daniel Vetter wrote: > > > On Mon, Dec 12, 2022 at 09:38:12AM +, David Laight wrote: > > >> From: Andrzej Hajda > > >> > Sent: 09 December 2022

Re: [Intel-gfx] [PATCH 1/5] linux/minmax.h: add non-atomic version of xchg

2023-01-05 Thread David Laight
From: Jani Nikula > Sent: 05 January 2023 13:28 > > On Thu, 05 Jan 2023, Daniel Vetter wrote: > > On Mon, Dec 12, 2022 at 09:38:12AM +, David Laight wrote: > >> From: Andrzej Hajda > >> > Sent: 09 December 2022 15:49 > >> > > >> > The pattern of setting variable with new value and returning

Re: [Intel-gfx] [PATCH 1/5] linux/minmax.h: add non-atomic version of xchg

2023-01-05 Thread Jani Nikula
On Thu, 05 Jan 2023, Daniel Vetter wrote: > On Mon, Dec 12, 2022 at 09:38:12AM +, David Laight wrote: >> From: Andrzej Hajda >> > Sent: 09 December 2022 15:49 >> > >> > The pattern of setting variable with new value and returning old >> > one is very common in kernel. Usually atomicity of

Re: [Intel-gfx] [PATCH 1/5] linux/minmax.h: add non-atomic version of xchg

2023-01-05 Thread Daniel Vetter
On Mon, Dec 12, 2022 at 09:38:12AM +, David Laight wrote: > From: Andrzej Hajda > > Sent: 09 December 2022 15:49 > > > > 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

Re: [Intel-gfx] [PATCH 1/5] linux/minmax.h: add non-atomic version of xchg

2022-12-13 Thread Andy Shevchenko
On Tue, Dec 13, 2022 at 11:09:12AM +0100, Andrzej Hajda wrote: > On 09.12.2022 19:56, Andy Shevchenko wrote: > > On Fri, Dec 09, 2022 at 04:48:39PM +0100, Andrzej Hajda wrote: ... > > > I hope there will be place for such tiny helper in kernel. > > > Quick cocci analyze shows there is probably

Re: [Intel-gfx] [PATCH 1/5] linux/minmax.h: add non-atomic version of xchg

2022-12-13 Thread Andrzej Hajda
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

Re: [Intel-gfx] [PATCH 1/5] linux/minmax.h: add non-atomic version of xchg

2022-12-13 Thread Arnd Bergmann
On Tue, Dec 13, 2022, at 10:28, Andrzej Hajda wrote: > On 09.12.2022 18:16, Arnd Bergmann wrote: >> name for the backing of arch_xchg() or arch_xchg_relaxed(), >> maybe we can instead rename those to __arch_xchg() and use the >> __xchg() name for the new non-atomic version? > > I will try, but

Re: [Intel-gfx] [PATCH 1/5] linux/minmax.h: add non-atomic version of xchg

2022-12-13 Thread Andrzej Hajda
On 09.12.2022 18:16, Arnd Bergmann wrote: On Fri, Dec 9, 2022, at 16:48, 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

Re: [Intel-gfx] [PATCH 1/5] linux/minmax.h: add non-atomic version of xchg

2022-12-12 Thread David Laight
From: Andrzej Hajda > Sent: 09 December 2022 15:49 > > 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

Re: [Intel-gfx] [PATCH 1/5] linux/minmax.h: add non-atomic version of xchg

2022-12-09 Thread Andy Shevchenko
On Fri, Dec 09, 2022 at 08:56:28PM +0200, Andy Shevchenko wrote: > On Fri, Dec 09, 2022 at 04:48:39PM +0100, Andrzej Hajda wrote: ... > > 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

Re: [Intel-gfx] [PATCH 1/5] linux/minmax.h: add non-atomic version of xchg

2022-12-09 Thread Andy Shevchenko
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

Re: [Intel-gfx] [PATCH 1/5] linux/minmax.h: add non-atomic version of xchg

2022-12-09 Thread Arnd Bergmann
On Fri, Dec 9, 2022, at 16:48, 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

[Intel-gfx] [PATCH 1/5] linux/minmax.h: add non-atomic version of xchg

2022-12-09 Thread Andrzej Hajda
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