[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <6617dfb150f94cbb9654a585843e3287@AcuMS.aculab.com>
Date: Thu, 5 Jan 2023 14:41:43 +0000
From: David Laight <David.Laight@...LAB.COM>
To: 'Daniel Vetter' <daniel@...ll.ch>
CC: 'Jani Nikula' <jani.nikula@...ux.intel.com>,
Arnd Bergmann <arnd@...db.de>,
"intel-gfx@...ts.freedesktop.org" <intel-gfx@...ts.freedesktop.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
"dri-devel@...ts.freedesktop.org" <dri-devel@...ts.freedesktop.org>,
'Andrzej Hajda' <andrzej.hajda@...el.com>,
Rodrigo Vivi <rodrigo.vivi@...el.com>,
Andrew Morton <akpm@...ux-foundation.org>,
Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
Subject: RE: [Intel-gfx] [PATCH 1/5] linux/minmax.h: add non-atomic version of
xchg
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, new_value);
> >
> > But two statements are much clearer.
>
> Yeah this is my point for fetch_and_zero or any of the other proposals.
> We're essentially replacing these two lines:
>
> var = some->pointer->chase;
> some->pointer->chase = NULL;
>
> with a macro. C is verbose, and sometimes painfully so,
Try ADA or VHDL :-)
> if the pointer
> chase is really to onerous then I think that should be refactored with a
> meaningfully locally name variable, not fancy macros wrapped around to
> golf a few characters away.
Provided 'var' is a local the compiler is pretty likely to only do the
'pointer chase' once.
You can also do:
var = NULL;
swap(some->pointer->chase, var);
and get pretty much the same object code.
> But what about swap() you ask? That one needs a temp variable, and it does
> make sense to hide that in a ({}) block in a macro.
Sometimes, but not enough for the 'missed opportunity for swap()'
message.
> But for the above two
> lines I really don't see a point outside of obfuscated C contexts.
Indeed.
Isn't the suggested __xchg() in one of the 'reserved for implementation'
namespaces - so shouldn't be a function that might be expected to be
actually used.
David
-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)
Powered by blists - more mailing lists