[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20251118145618.7dd829f1@gandalf.local.home>
Date: Tue, 18 Nov 2025 14:56:18 -0500
From: Steven Rostedt <rostedt@...dmis.org>
To: Linus Torvalds <torvalds@...ux-foundation.org>
Cc: Bart Van Assche <bvanassche@....org>, James Bottomley
<James.Bottomley@...senpartnership.com>, ksummit@...ts.linux.dev, Dan
Williams <dan.j.williams@...el.com>, linux-kernel
<linux-kernel@...r.kernel.org>, Dan Carpenter <dan.carpenter@...aro.org>
Subject: Re: Clarifying confusion of our variable placement rules caused by
cleanup.h
On Tue, 18 Nov 2025 11:22:27 -0800
Linus Torvalds <torvalds@...ux-foundation.org> wrote:
> But again: I don't want to make this some kind of hard rule, and I
> think it should be done judiciously and with taste, not some kind of
> crazy conversion thing.
For the few places that do what that example shows, I may update them, as I
think it does make the code look better.
I do have several places that have something like this:
struct ring_buffer_per_cpu *cpu_buffer __free(kfree) = NULL;
struct ring_buffer_cpu_meta *meta;
struct buffer_page *bpage;
struct page *page;
int ret;
cpu_buffer = kzalloc_node(ALIGN(sizeof(*cpu_buffer), cache_line_size()),
GFP_KERNEL, cpu_to_node(cpu));
if (!cpu_buffer)
return NULL;
Where the allocation happens right after the declaration. I think I did it
this way because the full line goes over 80 characters, and breaks up the
declaration.
struct ring_buffer_per_cpu *cpu_buffer __free(kfree) =
kzalloc_node(ALIGN(sizeof(*cpu_buffer), cache_line_size()),
GFP_KERNEL, cpu_to_node(cpu));
struct ring_buffer_cpu_meta *meta;
struct buffer_page *bpage;
struct page *page;
int ret;
if (!cpu_buffer)
return NULL;
Doesn't look nice. I wonder since its the first allocation, if doing:
struct ring_buffer_cpu_meta *meta;
struct buffer_page *bpage;
struct page *page;
int ret;
struct ring_buffer_per_cpu *cpu_buffer __free(kfree) =
kzalloc_node(ALIGN(sizeof(*cpu_buffer), cache_line_size()),
GFP_KERNEL, cpu_to_node(cpu));
if (!cpu_buffer)
return NULL;
Would be acceptable? The "cpu_buffer" is declared right after the declaration,
but the space after the declaration also makes it easier to read than:
struct ring_buffer_cpu_meta *meta;
struct buffer_page *bpage;
struct page *page;
int ret;
struct ring_buffer_per_cpu *cpu_buffer __free(kfree) =
kzalloc_node(ALIGN(sizeof(*cpu_buffer), cache_line_size()),
GFP_KERNEL, cpu_to_node(cpu));
if (!cpu_buffer)
return NULL;
-- Steve
Powered by blists - more mailing lists