Thread (44 messages) 44 messages, 10 authors, 2020-10-19

Re: [PATCH] block: convert tasklets to use new tasklet_setup() API

From: Kees Cook <hidden>
Date: 2020-08-18 20:10:30
Also in: dri-devel, intel-gfx, linux-arm-kernel, linux-block, linux-hyperv, linux-input, linux-mmc, linux-s390, linux-spi, linux-um, lkml

On Tue, Aug 18, 2020 at 01:00:33PM -0700, James Bottomley wrote:
On Mon, 2020-08-17 at 13:02 -0700, Jens Axboe wrote:
quoted
On 8/17/20 12:48 PM, Kees Cook wrote:
quoted
On Mon, Aug 17, 2020 at 12:44:34PM -0700, Jens Axboe wrote:
quoted
On 8/17/20 12:29 PM, Kees Cook wrote:
quoted
On Mon, Aug 17, 2020 at 06:56:47AM -0700, Jens Axboe wrote:
quoted
On 8/17/20 2:15 AM, Allen Pais wrote:
quoted
From: Allen Pais <redacted>

In preparation for unconditionally passing the
struct tasklet_struct pointer to all tasklet
callbacks, switch to using the new tasklet_setup()
and from_tasklet() to pass the tasklet pointer explicitly.
Who came up with the idea to add a macro 'from_tasklet' that
is just container_of? container_of in the code would be
_much_ more readable, and not leave anyone guessing wtf
from_tasklet is doing.

I'd fix that up now before everything else goes in...
As I mentioned in the other thread, I think this makes things
much more readable. It's the same thing that the timer_struct
conversion did (added a container_of wrapper) to avoid the
ever-repeating use of typeof(), long lines, etc.
But then it should use a generic name, instead of each sub-system 
using some random name that makes people look up exactly what it
does. I'm not huge fan of the container_of() redundancy, but
adding private variants of this doesn't seem like the best way
forward. Let's have a generic helper that does this, and use it
everywhere.
I'm open to suggestions, but as things stand, these kinds of
treewide
On naming? Implementation is just as it stands, from_tasklet() is
totally generic which is why I objected to it. from_member()? Not
great with naming... But I can see this going further and then we'll
suddenly have tons of these. It's not good for readability.
Since both threads seem to have petered out, let me suggest in
kernel.h:

#define cast_out(ptr, container, member) \
	container_of(ptr, typeof(*container), member)

It does what you want, the argument order is the same as container_of
with the only difference being you name the containing structure
instead of having to specify its type.
I like this! Shall I send this to Linus to see if this can land in -rc2
for use going forward?

-- 
Kees Cook
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help