All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Gustavo A. R. Silva" <gustavoars@kernel.org>
To: Peter Zijlstra <peterz@infradead.org>
Cc: Lin Yujun <linyujun809@huawei.com>,
	mingo@redhat.com, acme@kernel.org, mark.rutland@arm.com,
	alexander.shishkin@linux.intel.com, jolsa@kernel.org,
	namhyung@kernel.org, tglx@linutronix.de, bp@alien8.de,
	dave.hansen@linux.intel.com, x86@kernel.org, hpa@zytor.com,
	linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org,
	johnny.chenyi@huawei.com, chenjiahao16@huawei.com,
	chenlifu@huawei.com, lizhengyu3@huawei.com,
	liaochang1@huawei.com, wangzhu9@huawei.com, xuyihang@huawei.com,
	chris.zjh@huawei.com, zouyipeng@huawei.com
Subject: Re: [PATCH -next] x86/events:Use struct_size() helper in kzalloc()
Date: Wed, 18 May 2022 11:03:45 -0500	[thread overview]
Message-ID: <20220518160345.GA43938@embeddedor> (raw)
In-Reply-To: <YoT6tHWbBOchi29i@hirez.programming.kicks-ass.net>

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@huawei.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


  reply	other threads:[~2022-05-18 15:54 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-18 13:16 [PATCH -next] x86/events:Use struct_size() helper in kzalloc() Lin Yujun
2022-05-18 13:49 ` Gustavo A. R. Silva
2022-05-18 13:55   ` Peter Zijlstra
2022-05-18 16:03     ` Gustavo A. R. Silva [this message]
2022-05-18 16:54       ` Borislav Petkov
2022-05-19  2:30   ` linyujun (C)

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220518160345.GA43938@embeddedor \
    --to=gustavoars@kernel.org \
    --cc=acme@kernel.org \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=bp@alien8.de \
    --cc=chenjiahao16@huawei.com \
    --cc=chenlifu@huawei.com \
    --cc=chris.zjh@huawei.com \
    --cc=dave.hansen@linux.intel.com \
    --cc=hpa@zytor.com \
    --cc=johnny.chenyi@huawei.com \
    --cc=jolsa@kernel.org \
    --cc=liaochang1@huawei.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=linyujun809@huawei.com \
    --cc=lizhengyu3@huawei.com \
    --cc=mark.rutland@arm.com \
    --cc=mingo@redhat.com \
    --cc=namhyung@kernel.org \
    --cc=peterz@infradead.org \
    --cc=tglx@linutronix.de \
    --cc=wangzhu9@huawei.com \
    --cc=x86@kernel.org \
    --cc=xuyihang@huawei.com \
    --cc=zouyipeng@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.