Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E588EC433F5 for ; Tue, 21 Dec 2021 13:20:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238154AbhLUNUr (ORCPT ); Tue, 21 Dec 2021 08:20:47 -0500 Received: from szxga08-in.huawei.com ([45.249.212.255]:30087 "EHLO szxga08-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234517AbhLUNUq (ORCPT ); Tue, 21 Dec 2021 08:20:46 -0500 Received: from dggpeml500023.china.huawei.com (unknown [172.30.72.56]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4JJH7P1mYCz1DJw0; Tue, 21 Dec 2021 21:17:37 +0800 (CST) Received: from ubuntu1804.huawei.com (10.67.174.58) by dggpeml500023.china.huawei.com (7.185.36.114) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.20; Tue, 21 Dec 2021 21:20:44 +0800 From: Xiu Jianfeng To: , , , , , , , , CC: Subject: [PATCH -next] sched: Use struct_size() helper in task_numa_group() Date: Tue, 21 Dec 2021 21:21:38 +0800 Message-ID: <20211221132138.49464-1-xiujianfeng@huawei.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.67.174.58] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To dggpeml500023.china.huawei.com (7.185.36.114) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Make use of struct_size() helper instead of an open-coded calculation. There is no functional change in this patch. Link: https://github.com/KSPP/linux/issues/160 Signed-off-by: Xiu Jianfeng --- kernel/sched/fair.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 095b0aa378df..265e37be0c92 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -2437,11 +2437,8 @@ static void task_numa_group(struct task_struct *p, int cpupid, int flags, int i; if (unlikely(!deref_curr_numa_group(p))) { - unsigned int size = sizeof(struct numa_group) + - NR_NUMA_HINT_FAULT_STATS * - nr_node_ids * sizeof(unsigned long); - - grp = kzalloc(size, GFP_KERNEL | __GFP_NOWARN); + grp = kzalloc(struct_size(grp, faults, NR_NUMA_HINT_FAULT_STATS * nr_node_ids), + GFP_KERNEL | __GFP_NOWARN); if (!grp) return; -- 2.17.1