[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20220518160345.GA43938@embeddedor>
Date: Wed, 18 May 2022 11:03:45 -0500
From: "Gustavo A. R. Silva" <gustavoars@...nel.org>
To: Peter Zijlstra <peterz@...radead.org>
Cc: Lin Yujun <linyujun809@...wei.com>, mingo@...hat.com,
acme@...nel.org, mark.rutland@....com,
alexander.shishkin@...ux.intel.com, jolsa@...nel.org,
namhyung@...nel.org, tglx@...utronix.de, bp@...en8.de,
dave.hansen@...ux.intel.com, x86@...nel.org, hpa@...or.com,
linux-perf-users@...r.kernel.org, linux-kernel@...r.kernel.org,
johnny.chenyi@...wei.com, chenjiahao16@...wei.com,
chenlifu@...wei.com, lizhengyu3@...wei.com, liaochang1@...wei.com,
wangzhu9@...wei.com, xuyihang@...wei.com, chris.zjh@...wei.com,
zouyipeng@...wei.com
Subject: Re: [PATCH -next] x86/events:Use struct_size() helper in kzalloc()
On Wed, May 18, 2022 at 03:55:00PM +0200, Peter Zijlstra wrote:
> On Wed, May 18, 2022 at 08:49:20AM -0500, Gustavo A. R. Silva wrote:
>
> > > Signed-off-by: Lin Yujun <linyujun809@...wei.com>
> > > ---
> > > arch/x86/events/rapl.c | 2 +-
> > > 1 file changed, 1 insertion(+), 1 deletion(-)
> > >
> > > diff --git a/arch/x86/events/rapl.c b/arch/x86/events/rapl.c
> > > index 77e3a47af5ad..c7e79f0ac04f 100644
> > > --- a/arch/x86/events/rapl.c
> > > +++ b/arch/x86/events/rapl.c
> > > @@ -685,7 +685,7 @@ static int __init init_rapl_pmus(void)
> > > int maxdie = topology_max_packages() * topology_max_die_per_package();
> > > size_t size;
> > >
> > > - size = sizeof(*rapl_pmus) + maxdie * sizeof(struct rapl_pmu *);
> > > + size = struct_size(rapl_pmus, pmus, maxdie);
> > > rapl_pmus = kzalloc(size, GFP_KERNEL);
> >
> > It seems that in this case, size could be entirely replaced by
> > struct_size().
>
> Except every time I look at struct_size() I go: WTF does that do; while
> the code as-is is crystal clear, no de-obfucstaion required.
Naming it flex_struct_size() would be more informative?
--
Gustavo
Powered by blists - more mailing lists