From patchwork Wed Feb 20 13:32:55 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peng Fan X-Patchwork-Id: 10822149 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9112513BF for ; Wed, 20 Feb 2019 13:33:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6DB9C2E0AD for ; Wed, 20 Feb 2019 13:33:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5E3D62E11C; Wed, 20 Feb 2019 13:33:01 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 93D772E0AD for ; Wed, 20 Feb 2019 13:33:00 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4B7458E0016; Wed, 20 Feb 2019 08:32:59 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 48CFE8E0002; Wed, 20 Feb 2019 08:32:59 -0500 (EST) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 37D448E0016; Wed, 20 Feb 2019 08:32:59 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-ed1-f69.google.com (mail-ed1-f69.google.com [209.85.208.69]) by kanga.kvack.org (Postfix) with ESMTP id D5B1A8E0002 for ; Wed, 20 Feb 2019 08:32:58 -0500 (EST) Received: by mail-ed1-f69.google.com with SMTP id s50so9929835edd.11 for ; Wed, 20 Feb 2019 05:32:58 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:cc:subject:thread-topic :thread-index:date:message-id:accept-language:content-language :content-transfer-encoding:mime-version; bh=AB4rRS8rcRqh7jm65JECv60j93qZmlgVAseiSxW41zQ=; b=Ta9ryRfwS342QH7ZIen/Xdk78+KXu9FT/bYwpLA0dpuBmBpBXvILEFWgDTFHzLAq2o bKdpsoc4/6DyMdtxvRfWOt4s79Z0NS6xmJNbt0hq7Py/q7A3uEG/8DYVdQNEngJXL2Y/ ddIVYQV5Qx8db248zKLjJC0WbeVf+TlXXsh694C/4E8hDin8J7gbK2U/HKPFdyAiMz9n D+s2AAOUf/7Xz9E6t+avqrbFW/C4lB/0iIkjHT0eY/ZXBPUqKilTT+0mUlIAw+W6ldTR wM9GrxHk9UBq/gAgmM2f+J1BVVqvv668oLIUXf6OJUVOzqwIBjulV5fjq/CQ1iqfkgpK bp7w== X-Gm-Message-State: AHQUAuYHLxocHPVmTSanXuMHozP9aCXjv01G18QE4JN8wgW2GCD8i2P7 JVzFvG4q51iZzHJPSLmoE2WFjyNASddSYpRyIL0wwE2Di0KjoKoSfKgr16lJWpVtj9cyeXStdnx DtPMplbyfQkG9cwCyGq6FfTuKqq9k9YWmS+/N0HhusrX2puytRtrzZixAqTKU4zHItQ== X-Received: by 2002:a50:a53d:: with SMTP id y58mr19721714edb.282.1550669578142; Wed, 20 Feb 2019 05:32:58 -0800 (PST) X-Google-Smtp-Source: AHgI3IZddi51wzZydyd5SK59PXad0r38lnjjVIc+NB2eJNmZ0RWGa+UOcxJ8+4jjJiuZZk5qu3yg X-Received: by 2002:a50:a53d:: with SMTP id y58mr19721662edb.282.1550669577172; Wed, 20 Feb 2019 05:32:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550669577; cv=none; d=google.com; s=arc-20160816; b=ldYgrDYsermQQcnJO4Ptt0wmJb1z28iB3q4MuKuYNqV0D8wzrkv+e5Nb91hFOGUtmn 1ufjueQlv6nCbP5YMJIcCqvYElzsxQUwS13/WZAt/unUIiOsBJxN04cUSFKjf+mQeja/ ynv/Lx2WDB2Y7BE+n8Z6l8RTiYygtQcJYI+A0Bvyb3VhVhL/9bn//YkNemRIxjvUquss kzDk8Ar/SjEHIGaqogBOIa4R/80zbV4icWZSH1B/meLugmfsc7kmPx888CHKQOH2+0d5 zraZhITxTdQtxZhYlVENmFxVdSIx4LWgu2hWrIkfNJQqwpnja1e+2BhVqf23l9f98fID h+Wg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:content-transfer-encoding:content-language :accept-language:message-id:date:thread-index:thread-topic:subject :cc:to:from:dkim-signature; bh=AB4rRS8rcRqh7jm65JECv60j93qZmlgVAseiSxW41zQ=; b=xxQoMI9XtyvTflvwXCrJyflQu1aPoDtkhUR6iT6pY3mOSfYfUIAb6dcVCRa+2tEz2i aCf4icK5xhBgzFvp2GUasTgvfsLtOOlW5jQYr6pj4eCrqghy5R6RjJcqqQX4gG/QFMyY b2nARhWnEs50onSTqMlOE+rgzqP88j2eS0EzdOsQiMbvWb4uKSNwEA9kS/8Np6YUMG0f 0sgMId8B7Ur7/F5+pArC9GeTFOEj35jpDIyyKorj0I5oR8x2VUHX7BxRxpHYEL9IHKn+ XU5dZSYvs9c7ueyvpXzO9RpYpvbpwVE6dbIJ06t6dfmbiFNh+TDG7HC+gXlGqqh3yb0U yU6Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nxp.com header.s=selector1 header.b=u2xEIFPS; spf=pass (google.com: domain of peng.fan@nxp.com designates 40.107.8.74 as permitted sender) smtp.mailfrom=peng.fan@nxp.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-eopbgr80074.outbound.protection.outlook.com. [40.107.8.74]) by mx.google.com with ESMTPS id p12si97151eda.232.2019.02.20.05.32.56 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 20 Feb 2019 05:32:57 -0800 (PST) Received-SPF: pass (google.com: domain of peng.fan@nxp.com designates 40.107.8.74 as permitted sender) client-ip=40.107.8.74; Authentication-Results: mx.google.com; dkim=pass header.i=@nxp.com header.s=selector1 header.b=u2xEIFPS; spf=pass (google.com: domain of peng.fan@nxp.com designates 40.107.8.74 as permitted sender) smtp.mailfrom=peng.fan@nxp.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nxp.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=AB4rRS8rcRqh7jm65JECv60j93qZmlgVAseiSxW41zQ=; b=u2xEIFPS8+pMWFQ2jemXREHKkxicUSv8BrBZhUqTO8HM8MrQRrZjK++txhO4HIW6k6eDwPHK5Zs4zQp5KtgK0EfF6WvGdkRwoH7qzR5QkaTWfiP4QQWn0nODL3s4k0Jq/M0Rjf2U+BpAQ1lCSvcPQKN+pTifm+fyHN3iBiX+K1M= Received: from DB7PR04MB4490.eurprd04.prod.outlook.com (52.135.138.16) by DB7PR04MB5355.eurprd04.prod.outlook.com (20.178.85.212) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1622.19; Wed, 20 Feb 2019 13:32:55 +0000 Received: from DB7PR04MB4490.eurprd04.prod.outlook.com ([fe80::fd45:a391:7591:1aa5]) by DB7PR04MB4490.eurprd04.prod.outlook.com ([fe80::fd45:a391:7591:1aa5%6]) with mapi id 15.20.1622.020; Wed, 20 Feb 2019 13:32:55 +0000 From: Peng Fan To: "dennis@kernel.org" , "tj@kernel.org" , "cl@linux.com" CC: "linux-mm@kvack.org" , "linux-kernel@vger.kernel.org" , "van.freenix@gmail.com" , Peng Fan Subject: [RFC] percpu: use nr_groups as check condition Thread-Topic: [RFC] percpu: use nr_groups as check condition Thread-Index: AQHUySDJI5EsBnYxBEew8wybkHZ3fg== Date: Wed, 20 Feb 2019 13:32:55 +0000 Message-ID: <20190220134353.24456-1-peng.fan@nxp.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-mailer: git-send-email 2.16.4 x-clientproxiedby: HK0PR03CA0071.apcprd03.prod.outlook.com (2603:1096:203:52::35) To DB7PR04MB4490.eurprd04.prod.outlook.com (2603:10a6:5:35::16) authentication-results: spf=none (sender IP is ) smtp.mailfrom=peng.fan@nxp.com; x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [119.31.174.71] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: cf8672d9-3cdc-4b76-23e2-08d69737eb69 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0;PCL:0;RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600110)(711020)(4605104)(4618075)(2017052603328)(7153060)(7193020);SRVR:DB7PR04MB5355; x-ms-traffictypediagnostic: DB7PR04MB5355: x-microsoft-exchange-diagnostics: =?iso-8859-1?q?1=3BDB7PR04MB5355=3B23=3A/A?= =?iso-8859-1?q?rm5YerdDf8qMusZYcWzIflAOzz2gdyXsc7cFy3Ec74l1BO1KiWfYLGfmSO1K?= =?iso-8859-1?q?whqqSyXoV4ABFC+b7ciO9p80Pt84sS2Mvr2nK3FA4QJ6o1nw1C8MvBvXEQo0?= =?iso-8859-1?q?u2uQQUmWv9zbvQyI37xDkT8yUI0mwo7YUXNRQElJXzHpwpiKzUtbhWqTDXl8?= =?iso-8859-1?q?R2LOYXIsFeTw0Tu9ptfw1Typw1hclH1jLkyipfznI5TBK4EOfpfBkLtqr4Hq?= =?iso-8859-1?q?WG3j9A6IR8ZLfdhcWaszz1ZCTJMafknbHNoq2OV1OrNEyQG0NX0kb/RruK+1?= =?iso-8859-1?q?90uSNFkB1z1Wq1ImRKG3zI/wZDyl7TnuvIMXvHJ67UMwprbR96yaZCCQa8nD?= =?iso-8859-1?q?usZpf5SwtlnIFsGTNx0xpfM0B2mQtOZjnB4bhlJDDFnHtqRC4ygS3CvzqS2g?= =?iso-8859-1?q?PbXwAdkYdi4ot8ATiz7QMoWjprs5Yqg4i69V/9voBr0KH5DK/mNp/D0EXRqU?= =?iso-8859-1?q?N6yQh6cShrazTUIlTSse6QMul8VmcaOEnBo9EcU/Kmnq/inz+MVwIj61Wypk?= =?iso-8859-1?q?EeyXcYYPN19qKtSK7QQjV52574vfn9Gu7mwKi5IuZ0nBkHhDNJdIHwPr+ovu?= =?iso-8859-1?q?ZeJCquEoiIZ8Rz7bcQYLnmqcdR7SotK08y9CBw00NmOrgvsSz89WhDlJxbpx?= =?iso-8859-1?q?BGlXSERq5Bwe/Xk49U7idEHRWsc3uNCAo+E2IsT8FW5VhkAqgdXKqdcSlcz3?= =?iso-8859-1?q?ibWfG1rgrpkSl4TueE3TakcQny0GcNaJVwUf0JAg2+qMZZyN65t+NbX7yT9K?= =?iso-8859-1?q?rDjeNWoD91I43tFajYx9ZGCXHiGogN9XVlH3TYYpr2HZd51hXep9V974Yukn?= =?iso-8859-1?q?hsLq7RxkdcOuLWFrPOh7oXtwJE9NiteviGQn6SLD86irszqXhQdNEFURiKYj?= =?iso-8859-1?q?aKvrtI23fjAfpBarWgVGWpfDUEF5yZqR0yybLRliE9rux7BEP9IgVqNcygqv?= =?iso-8859-1?q?auKHD+6MNwH3LCf5e0VPv7G4B26thG6lPIu6NT3RGI4ylO5qdfwRJL3KgWw4?= =?iso-8859-1?q?7IPIqffzq32KUbd4rF+2eYUK9q0APruBChEfp6N32jjO7Uqc2OV10fKZ/kRV?= =?iso-8859-1?q?fRmAUoCehfrWjZbJtbfGtUyVgjNEGi0uAY+kKc2bEHgrthETGIXc86MZ81/0?= =?iso-8859-1?q?zda/MXzePECMPXc4+tHTkI22rywGaIWsAsitbJcLlc+cmWech+h9R5TtF0fF?= =?iso-8859-1?q?3w9gObLM4JnIsjjLqUhnBL7SMiX6vzDDJC/3jMV/T1wbfZSoKPJM02i5E=3D?= x-microsoft-antispam-prvs: x-forefront-prvs: 0954EE4910 x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(39860400002)(376002)(396003)(346002)(136003)(366004)(199004)(189003)(25786009)(486006)(97736004)(52116002)(44832011)(478600001)(316002)(110136005)(6512007)(99286004)(26005)(105586002)(54906003)(66066001)(7736002)(4326008)(2501003)(186003)(3846002)(68736007)(6116002)(53936002)(14454004)(305945005)(71190400001)(71200400001)(81156014)(81166006)(8936002)(50226002)(2616005)(36756003)(4744005)(86362001)(2906002)(6486002)(102836004)(106356001)(1076003)(6436002)(476003)(256004)(14444005)(8676002)(386003)(6506007)(2201001)(5660300002);DIR:OUT;SFP:1101;SCL:1;SRVR:DB7PR04MB5355;H:DB7PR04MB4490.eurprd04.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;A:1;MX:1; received-spf: None (protection.outlook.com: nxp.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: 12G8hzUO9t/sGSUMFCVA8yQEo5oM7tZOJoDbTLauX3KmMLNju8Oi04pMFt20GWCiskHNMBrYgZOrAVl9e/WQ7RocAtSCuzwmwQhh4nip1XzjyCAbadscMZWCHcid0XY51hk4374gkE9SiA58OAm9t/EVXKwXhiNKQ6U9qbBcP58mr3ScLRHzuerYOCZioLBD0oTRYJRoz757CCI/SyEGC1vgx8x/4G9bXsNyIhwjPb1QfzzNSq4DmkC8Ycz7QOVe1D1BZydpp9ksXpWoaRHSYJHFV7Lcain5jFtK8f021eVGGr0cAl9NUanAJxUsQ6ITWPPj9Pnw14ACk3evcnTv+uJEJsDgMyayYAZoGhvRUMSwpZsHVSxawtXaWV4gi/1HasYHJ+Q61oPsg30J8mFYPcVO0rWOTY0u83vtSSzA7/A= MIME-Version: 1.0 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: cf8672d9-3cdc-4b76-23e2-08d69737eb69 X-MS-Exchange-CrossTenant-originalarrivaltime: 20 Feb 2019 13:32:51.5592 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB7PR04MB5355 X-Bogosity: Ham, tests=bogofilter, spamicity=0.011615, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP group_cnt array is defined with NR_CPUS entries, but normally nr_groups will not reach up to NR_CPUS. So there is no issue to the current code. Checking other parts of pcpu_build_alloc_info, use nr_groups as check condition, so make it consistent to use 'group < nr_groups' as for loop check. In case we do have nr_groups equals with NR_CPUS, we could also avoid memory access out of bounds. Signed-off-by: Peng Fan --- mm/percpu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/percpu.c b/mm/percpu.c index db86282fd024..c5c750781628 100644 --- a/mm/percpu.c +++ b/mm/percpu.c @@ -2384,7 +2384,7 @@ static struct pcpu_alloc_info * __init pcpu_build_alloc_info( ai->atom_size = atom_size; ai->alloc_size = alloc_size; - for (group = 0, unit = 0; group_cnt[group]; group++) { + for (group = 0, unit = 0; group < nr_groups; group++) { struct pcpu_group_info *gi = &ai->groups[group]; /*