From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.0 required=3.0 tests=BAYES_00,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D466EC4742C for ; Fri, 30 Oct 2020 20:59:22 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 193D920791 for ; Fri, 30 Oct 2020 20:59:21 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 193D920791 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 3F90D6B0036; Fri, 30 Oct 2020 16:59:21 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3AC8F6B005C; Fri, 30 Oct 2020 16:59:21 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 29A8E6B005D; Fri, 30 Oct 2020 16:59:21 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0199.hostedemail.com [216.40.44.199]) by kanga.kvack.org (Postfix) with ESMTP id EF2096B0036 for ; Fri, 30 Oct 2020 16:59:20 -0400 (EDT) Received: from smtpin22.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 8CD60181AEF1A for ; Fri, 30 Oct 2020 20:59:20 +0000 (UTC) X-FDA: 77429807280.22.heart68_030a1fd27299 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin22.hostedemail.com (Postfix) with ESMTP id 77DDB18038E67 for ; Fri, 30 Oct 2020 20:59:20 +0000 (UTC) X-HE-Tag: heart68_030a1fd27299 X-Filterd-Recvd-Size: 3655 Received: from mail-ua1-f66.google.com (mail-ua1-f66.google.com [209.85.222.66]) by imf21.hostedemail.com (Postfix) with ESMTP for ; Fri, 30 Oct 2020 20:59:20 +0000 (UTC) Received: by mail-ua1-f66.google.com with SMTP id 52so2135916uaj.4 for ; Fri, 30 Oct 2020 13:59:19 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=0UF2Pmf+rwRBHY8l9mzh5Ann9thyXoIS3meDLoOTDgU=; b=CHkLDkgfJPgWXQafKM7aDNY4m2bKE4WzonFK/2fS57FCJtGFURbLaTO4FIP09LUjx0 ePHayeVbBgqUhGclZ7fyJAva3yPZ3ZJL03VdavnmlGhPK3oHL1c6ogAE6oAr2RA4fEjr 98hQ6JTRarvl+R5ixyadSxrRiY5kO9/qGTwbMxQHXGJIgCmcQsvXw0g/OkVuQwkg0PkZ xnwQUG06UfarOII1AC4BHB+eZhBW0J9uCxlfNhLTiHmlkZWESlckW1NA3H890jpBAJOP StUOJXPGr6AmmC5xHrvYTcQ+YCfGqelXeH8oixeS3uPEDV8uv9r/PQciyAq6QIw1h7cd 1nTw== X-Gm-Message-State: AOAM530AeVARemVj6aDeAc086cbNbXdMgb3m+T3IvRWzuymagBaKef81 uAdsgX/DhH44lEnG5dwui44= X-Google-Smtp-Source: ABdhPJyH72AuFmsvzp0sbpVX9j78iQsXQAIeLz8oNvMQJ3HePx7NsJR7CYskCVyb7OINrFDNoMoQWg== X-Received: by 2002:a9f:2212:: with SMTP id 18mr3048462uad.89.1604091559492; Fri, 30 Oct 2020 13:59:19 -0700 (PDT) Received: from killington.c.googlers.com.com (239.145.196.35.bc.googleusercontent.com. [35.196.145.239]) by smtp.gmail.com with ESMTPSA id w123sm874205vke.26.2020.10.30.13.59.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 30 Oct 2020 13:59:18 -0700 (PDT) From: Dennis Zhou To: Tejun Heo , Christoph Lameter Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Dennis Zhou Subject: [PATCH] percpu: convert flexible array initializers to use struct_size() Date: Fri, 30 Oct 2020 20:58:46 +0000 Message-Id: <20201030205846.1105106-1-dennis@kernel.org> X-Mailer: git-send-email 2.29.1.341.ge80a0c044ae-goog MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Use the safer macro as sparked by the long discussion in [1]. [1] https://lore.kernel.org/lkml/20200917204514.GA2880159@google.com/ Signed-off-by: Dennis Zhou --- I'll apply it to for-5.10-fixes. mm/percpu.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/mm/percpu.c b/mm/percpu.c index 66a93f096394..ad7a37ee74ef 100644 --- a/mm/percpu.c +++ b/mm/percpu.c @@ -1315,8 +1315,8 @@ static struct pcpu_chunk * __init pcpu_alloc_first_= chunk(unsigned long tmp_addr, region_size =3D ALIGN(start_offset + map_size, lcm_align); =20 /* allocate chunk */ - alloc_size =3D sizeof(struct pcpu_chunk) + - BITS_TO_LONGS(region_size >> PAGE_SHIFT) * sizeof(unsigned long); + alloc_size =3D struct_size(chunk, populated, + BITS_TO_LONGS(region_size >> PAGE_SHIFT)); chunk =3D memblock_alloc(alloc_size, SMP_CACHE_BYTES); if (!chunk) panic("%s: Failed to allocate %zu bytes\n", __func__, @@ -2521,8 +2521,8 @@ void __init pcpu_setup_first_chunk(const struct pcp= u_alloc_info *ai, pcpu_unit_pages =3D ai->unit_size >> PAGE_SHIFT; pcpu_unit_size =3D pcpu_unit_pages << PAGE_SHIFT; pcpu_atom_size =3D ai->atom_size; - pcpu_chunk_struct_size =3D sizeof(struct pcpu_chunk) + - BITS_TO_LONGS(pcpu_unit_pages) * sizeof(unsigned long); + pcpu_chunk_struct_size =3D struct_size(chunk, populated, + BITS_TO_LONGS(pcpu_unit_pages)); =20 pcpu_stats_save_ai(ai); =20 --=20 2.29.1.341.ge80a0c044ae-goog