Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp600758iob; Wed, 18 May 2022 08:55:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxjs9bbQ/Vcqgy8vMBdrWuP/Evq6h3whuv3v/4dJJ6SYfVPmVY/4ZDhfavSgCKC2PVvltZy X-Received: by 2002:a65:4bc2:0:b0:3d0:2d36:ac2 with SMTP id p2-20020a654bc2000000b003d02d360ac2mr97835pgr.603.1652889348617; Wed, 18 May 2022 08:55:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652889348; cv=none; d=google.com; s=arc-20160816; b=NUucQShUFAa/2+8b9LEWlZOW7CaQvsO/6nL+Ck85jguWgIpByWrjmS+8lpvTI91E0l lo1OTTyw4e6ZBOGxkXB4wR8tIxU48qXd48R1AB8G3tLiCoS03veFuZyNe+knxcqY+arH dycdODLRDAA8lvmJvLz/OFYc1tsVwyn0X4h7w1HS1Fpj09DTye2JzimrbXMYGlCHHr2o bdJX7sYfsNCcyql6DoXfhueBau95CRqNA2NlUgM5YZNBeZ3GVRfbDMC1oyX8AgjMHLRB YXAD/4+2F6auSAwlQY2iiva43EBftMN6wYs0J8IijBQYO8upegLrB/KfzozBWccphjEp EgkQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=nQbd2DumfwPNnVqQa+iC2ZmXHSj8n2k6TmDS5nwSszc=; b=nANuyEO4aKf9Dkxg63rvBoQabFORXkwQZYXtFR//iyu4db/GbWefJ8xOM0tGWqjJuG N3jOsB3/PAivdhOkYzAMR7DAwx2ARM1eGXcKlhV5kNQJN2XTDhFEG0nWnplXegVnCol1 uTzapyXGG2ZVHweFtxLu3uG0xOLe1MVDkFivVBAQmQrclCfoeBNYp5tC1sxaotppbjlf AlRFcsICrzjW+DHdegJrS22v3OveUaHgiZ1oGqnpnIAA3eIB0PBneEope4yutEch1om1 Q9frZn0szEQx2GVIO1iG5gt0e0hnZRxxt7fwi/pVlRYHZJlgFshxxhOyZ0z6VkZEMAwC qZfw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=KL54s7+j; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id o2-20020a170903210200b0015eabaaa170si2773096ple.215.2022.05.18.08.55.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 May 2022 08:55:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=KL54s7+j; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id A4D971CE62B; Wed, 18 May 2022 08:54:40 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239621AbiERPyc (ORCPT + 99 others); Wed, 18 May 2022 11:54:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58056 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239726AbiERPy1 (ORCPT ); Wed, 18 May 2022 11:54:27 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 30F511CC9BB; Wed, 18 May 2022 08:54:23 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id B8CA3B82162; Wed, 18 May 2022 15:54:21 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6101AC385A5; Wed, 18 May 2022 15:54:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1652889260; bh=prv+Ye/H1mstl526vAK0JQj51CiNh01NdvehTiX0OrY=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=KL54s7+jyxQ1hiSfnf2oJBJo9yCTsB/6fsZAVfj4vEhnGh3Xrgk2KolU/7mHh+Wmm wEVJaX0REY2vi8KE/n1rATu92AKEJJEN0/F0NexNz5CeB1T725/pJ1LprH2RzTD1D5 6LLRQ2Ss3tbygJUEFd9Vl5GJllQwWvEnie3/YBRHIoru49Jdc7kJ5n/89E8AvSwUmZ rg2248jMnVt4UoY3CefYw0HMoS8O57IdQoN6otO2a/ET1KYfh8MnmbAP4WUv/W0MIa CEMaVF/6fYZiNSUJgTPVTi9ROseGQSvBa8a5wRsmhoQxRt7A7dIvpDGkfc1L7U4SQD jThtgEZl2X5PA== Date: Wed, 18 May 2022 11:03:45 -0500 From: "Gustavo A. R. Silva" To: Peter Zijlstra Cc: Lin Yujun , 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() Message-ID: <20220518160345.GA43938@embeddedor> References: <20220518131626.109123-1-linyujun809@huawei.com> <20220518134920.GA8361@embeddedor> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 > > > --- > > > 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