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 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id AF109C433F5 for ; Mon, 18 Oct 2021 05:33:02 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 3006260EE3 for ; Mon, 18 Oct 2021 05:33:02 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 3006260EE3 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id 4F9D86B006C; Mon, 18 Oct 2021 01:33:01 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 4A9C46B0071; Mon, 18 Oct 2021 01:33:01 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3986E900002; Mon, 18 Oct 2021 01:33:01 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0111.hostedemail.com [216.40.44.111]) by kanga.kvack.org (Postfix) with ESMTP id 293A26B006C for ; Mon, 18 Oct 2021 01:33:01 -0400 (EDT) Received: from smtpin25.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id BE002183381E5 for ; Mon, 18 Oct 2021 05:33:00 +0000 (UTC) X-FDA: 78708439320.25.041C30E Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf21.hostedemail.com (Postfix) with ESMTP id E8710D044FDB for ; Mon, 18 Oct 2021 05:32:58 +0000 (UTC) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 84928106F; Sun, 17 Oct 2021 22:32:59 -0700 (PDT) Received: from [10.163.74.6] (unknown [10.163.74.6]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id D8B9F3F73D; Sun, 17 Oct 2021 22:32:56 -0700 (PDT) From: Anshuman Khandual Subject: Re: [PATCH 1/5] test_printf: Make pft array const To: "Matthew Wilcox (Oracle)" , Yafang Shao Cc: Sergey Senozhatsky , Petr Mladek , linux-mm@kvack.org, Vlastimil Babka , Rasmus Villemoes References: <20211012182647.1605095-1-willy@infradead.org> <20211012182647.1605095-2-willy@infradead.org> Message-ID: <2fdec629-47f6-fc81-7cf6-64d1f8d5eab7@arm.com> Date: Mon, 18 Oct 2021 11:02:55 +0530 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <20211012182647.1605095-2-willy@infradead.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Rspamd-Queue-Id: E8710D044FDB Authentication-Results: imf21.hostedemail.com; dkim=none; spf=pass (imf21.hostedemail.com: domain of anshuman.khandual@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=anshuman.khandual@arm.com; dmarc=pass (policy=none) header.from=arm.com X-Stat-Signature: agitjpuzapkoisz17zix8jqpma6jmb9u X-Rspamd-Server: rspam05 X-HE-Tag: 1634535178-596521 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: On 10/12/21 11:56 PM, Matthew Wilcox (Oracle) wrote: > Instead of assigning ptf[i].value, leave the values in the on-stack > array and then we can make the array const. > > Signed-off-by: Matthew Wilcox (Oracle) > --- > lib/test_printf.c | 21 ++++++++------------- > 1 file changed, 8 insertions(+), 13 deletions(-) > > diff --git a/lib/test_printf.c b/lib/test_printf.c > index 55082432f37e..a52c1c3a55ba 100644 > --- a/lib/test_printf.c > +++ b/lib/test_printf.c > @@ -586,22 +586,21 @@ struct page_flags_test { > int width; > int shift; > int mask; > - unsigned long value; > const char *fmt; > const char *name; > }; > > -static struct page_flags_test pft[] = { > +static const struct page_flags_test pft[] = { > {SECTIONS_WIDTH, SECTIONS_PGSHIFT, SECTIONS_MASK, > - 0, "%d", "section"}, > + "%d", "section"}, > {NODES_WIDTH, NODES_PGSHIFT, NODES_MASK, > - 0, "%d", "node"}, > + "%d", "node"}, > {ZONES_WIDTH, ZONES_PGSHIFT, ZONES_MASK, > - 0, "%d", "zone"}, > + "%d", "zone"}, > {LAST_CPUPID_WIDTH, LAST_CPUPID_PGSHIFT, LAST_CPUPID_MASK, > - 0, "%#x", "lastcpupid"}, > + "%#x", "lastcpupid"}, > {KASAN_TAG_WIDTH, KASAN_TAG_PGSHIFT, KASAN_TAG_MASK, > - 0, "%#x", "kasantag"}, > + "%#x", "kasantag"}, > }; > > static void __init > @@ -627,10 +626,6 @@ page_flags_test(int section, int node, int zone, int last_cpupid, > #endif > } > > - /* Set the test value */ > - for (i = 0; i < ARRAY_SIZE(pft); i++) > - pft[i].value = values[i]; > - > for (i = 0; i < ARRAY_SIZE(pft); i++) { > if (!pft[i].width) > continue; > @@ -640,11 +635,11 @@ page_flags_test(int section, int node, int zone, int last_cpupid, > size = strlen(cmp_buf); > } > > - page_flags |= (pft[i].value & pft[i].mask) << pft[i].shift; > + page_flags |= (values[i] & pft[i].mask) << pft[i].shift; > snprintf(cmp_buf + size, BUF_SIZE - size, "%s=", pft[i].name); > size = strlen(cmp_buf); > snprintf(cmp_buf + size, BUF_SIZE - size, pft[i].fmt, > - pft[i].value & pft[i].mask); > + values[i] & pft[i].mask); > size = strlen(cmp_buf); > append = true; > } > Reviewed-by: Anshuman Khandual