linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: "Matthew Wilcox (Oracle)" <willy@infradead.org>
To: Yafang Shao <laoar.shao@gmail.com>
Cc: "Matthew Wilcox (Oracle)" <willy@infradead.org>,
	Sergey Senozhatsky <senozhatsky@chromium.org>,
	Petr Mladek <pmladek@suse.com>,
	linux-mm@kvack.org, Vlastimil Babka <vbabka@suse.cz>,
	Rasmus Villemoes <linux@rasmusvillemoes.dk>,
	Anshuman Khandual <anshuman.khandual@arm.com>
Subject: [PATCH v2 1/5] test_printf: Make pft array const
Date: Tue, 19 Oct 2021 15:26:17 +0100	[thread overview]
Message-ID: <20211019142621.2810043-2-willy@infradead.org> (raw)
In-Reply-To: <20211019142621.2810043-1-willy@infradead.org>

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) <willy@infradead.org>
Reviewed-by: Yafang Shao <laoar.shao@gmail.com>
Reviewed-by: Petr Mladek <pmladek@suse.com>
Reviewed-by: Anshuman Khandual <anshuman.khandual@arm.com>
---
 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;
 	}
-- 
2.32.0



  reply	other threads:[~2021-10-19 14:29 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-19 14:26 [PATCH v2 0/5] Improvements to %pGp Matthew Wilcox (Oracle)
2021-10-19 14:26 ` Matthew Wilcox (Oracle) [this message]
2021-10-19 14:26 ` [PATCH v2 2/5] test_printf: Remove separate page_flags variable Matthew Wilcox (Oracle)
2021-10-22 15:12   ` Yafang Shao
2021-10-27  9:47   ` Petr Mladek
2021-10-19 14:26 ` [PATCH v2 3/5] test_printf: Remove custom appending of '|' Matthew Wilcox (Oracle)
2021-10-19 14:26 ` [PATCH v2 4/5] test_printf: Append strings more efficiently Matthew Wilcox (Oracle)
2021-10-22 15:13   ` Yafang Shao
2021-10-27 10:14   ` Petr Mladek
2021-10-19 14:26 ` [PATCH v2 5/5] vsprintf: Make %pGp print the hex value Matthew Wilcox (Oracle)
2021-10-22 15:14   ` Yafang Shao
2021-10-27 10:27   ` Petr Mladek
2021-10-27 12:48   ` [PATCH] vsprintf: Update %pGp documentation about that it prints " Petr Mladek
2021-10-29  2:15     ` Yafang Shao
2021-10-29  2:18       ` Yafang Shao
2021-11-02  9:35         ` Petr Mladek
2021-10-27 12:09 ` [PATCH v2 0/5] Improvements to %pGp Petr Mladek

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20211019142621.2810043-2-willy@infradead.org \
    --to=willy@infradead.org \
    --cc=anshuman.khandual@arm.com \
    --cc=laoar.shao@gmail.com \
    --cc=linux-mm@kvack.org \
    --cc=linux@rasmusvillemoes.dk \
    --cc=pmladek@suse.com \
    --cc=senozhatsky@chromium.org \
    --cc=vbabka@suse.cz \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).