From patchwork Tue Oct 12 18:26:43 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Matthew Wilcox (Oracle)" X-Patchwork-Id: 12553489 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 4C7F0C433EF for ; Tue, 12 Oct 2021 18:30:54 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id EB7EE60C40 for ; Tue, 12 Oct 2021 18:30:53 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org EB7EE60C40 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id 5E6BE900003; Tue, 12 Oct 2021 14:30:53 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 56F91900002; Tue, 12 Oct 2021 14:30:53 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 40EAB900003; Tue, 12 Oct 2021 14:30:53 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0148.hostedemail.com [216.40.44.148]) by kanga.kvack.org (Postfix) with ESMTP id 2CF97900002 for ; Tue, 12 Oct 2021 14:30:53 -0400 (EDT) Received: from smtpin28.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id DA3238249980 for ; Tue, 12 Oct 2021 18:30:52 +0000 (UTC) X-FDA: 78688626744.28.C7A524B Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf19.hostedemail.com (Postfix) with ESMTP id A2765B0000BE for ; Tue, 12 Oct 2021 18:30:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=fp5zyYopnSA5SPNNcYfHw/8IZOhJat0YYN5dWsZW5kc=; b=Yo4/6TLZ16XPP5ybfWQ/WcF80V WyVAp2exQKa2KfMAdRniumWqgZYz/6vUdbJmgrU772m4H1MnLF+GENdaK9aVgEhrz99P54+DuSFsu nGj28y0r5oCKx8+W50YQfPOEOwdkZimyuqzUdTsYH/zWULN/ZwMD94tMgP0n8+dqRz6SEOhLmxCVX YAuWxUGtKf2Q/BPcPnb+sbmV9X7DkDk/wqGcPgim/0Lw4ceVP8V/KMOJEHSDzpvebvzTnKFt+417O vSm58uKQWxziaLahhTmjT2rYSK71W5/t+k1pPtYXJNZ+96EPRPHpCV+m9gnGQYbEWNQp6cnn++wc/ kMAv9E+g==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1maMVS-006jfp-12; Tue, 12 Oct 2021 18:28:19 +0000 From: "Matthew Wilcox (Oracle)" To: Yafang Shao Cc: "Matthew Wilcox (Oracle)" , Sergey Senozhatsky , Petr Mladek , linux-mm@kvack.org, Vlastimil Babka , Rasmus Villemoes Subject: [PATCH 1/5] test_printf: Make pft array const Date: Tue, 12 Oct 2021 19:26:43 +0100 Message-Id: <20211012182647.1605095-2-willy@infradead.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211012182647.1605095-1-willy@infradead.org> References: <20211012182647.1605095-1-willy@infradead.org> MIME-Version: 1.0 X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: A2765B0000BE X-Stat-Signature: a958ttopdzkix9ibj4ktxp4o1kj7bm4k Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b="Yo4/6TLZ"; dmarc=none; spf=none (imf19.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org X-HE-Tag: 1634063452-233853 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: 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) Reviewed-by: Yafang Shao Reviewed-by: Petr Mladek Reviewed-by: Anshuman Khandual --- 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; } From patchwork Tue Oct 12 18:26:44 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Matthew Wilcox (Oracle)" X-Patchwork-Id: 12553491 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 6734AC433EF for ; Tue, 12 Oct 2021 18:32:10 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id D088C60EE5 for ; Tue, 12 Oct 2021 18:32:09 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org D088C60EE5 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id 63222900003; Tue, 12 Oct 2021 14:32:09 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5E239900002; Tue, 12 Oct 2021 14:32:09 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4AAC5900003; Tue, 12 Oct 2021 14:32:09 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0118.hostedemail.com [216.40.44.118]) by kanga.kvack.org (Postfix) with ESMTP id 3ABB3900002 for ; Tue, 12 Oct 2021 14:32:09 -0400 (EDT) Received: from smtpin37.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id E7C152DD8F for ; Tue, 12 Oct 2021 18:32:08 +0000 (UTC) X-FDA: 78688629936.37.8F1A92B Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf12.hostedemail.com (Postfix) with ESMTP id A98D010000B6 for ; Tue, 12 Oct 2021 18:32:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=nsogbl0ugs0YiRL5cE9BFTBfHzDN0SwJQRRUzFF+/PI=; b=gjJYR6ER03bYtSK2ha+71VPaNw w/zLKepNX+PC9csYSFQ4kdmnOKZ3hlQk2YhtL1a4hvhvVxvtPcjxC7UIxcyJbSAH04gtAHCkMbV2t r3udZdCYMlcC6hYBXSpJwnOHyQgaiSYRWI7dk1litpJ/Mf9WsGyxQ5GJDv82IcBwdLZ0tRKFl+gmi 9vuEOFW+KzEfVvduhKgX5EIs2TBrB8FDlruY1F8TUMZBAbPyCffD+TkEKDFcqSM+D/yqHtM0p8Gge TVhZYMZGMTKexU8eFOdLBLeQfMqe0bOWH2ka6UJecpGxDvYbQFRJQiHDSfMslOwlYJDp/SVayPqhT jeXvld3Q==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1maMW8-006jiq-Kk; Tue, 12 Oct 2021 18:29:14 +0000 From: "Matthew Wilcox (Oracle)" To: Yafang Shao Cc: "Matthew Wilcox (Oracle)" , Sergey Senozhatsky , Petr Mladek , linux-mm@kvack.org, Vlastimil Babka , Rasmus Villemoes Subject: [PATCH 2/5] test_printf: Assign all flags to page_flags Date: Tue, 12 Oct 2021 19:26:44 +0100 Message-Id: <20211012182647.1605095-3-willy@infradead.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211012182647.1605095-1-willy@infradead.org> References: <20211012182647.1605095-1-willy@infradead.org> MIME-Version: 1.0 X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: A98D010000B6 X-Stat-Signature: biwtsc17y97f4exqp7scn5sr7paprj1r Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=gjJYR6ER; dmarc=none; spf=none (imf12.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org X-HE-Tag: 1634063528-136627 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: Even unknown flags should be passed to %pGp so that we can test what it does with them (today: nothing). Signed-off-by: Matthew Wilcox (Oracle) Reviewed-by: Yafang Shao Reviewed-by: Petr Mladek --- lib/test_printf.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/lib/test_printf.c b/lib/test_printf.c index a52c1c3a55ba..f744b0498672 100644 --- a/lib/test_printf.c +++ b/lib/test_printf.c @@ -608,14 +608,12 @@ page_flags_test(int section, int node, int zone, int last_cpupid, int kasan_tag, int flags, const char *name, char *cmp_buf) { unsigned long values[] = {section, node, zone, last_cpupid, kasan_tag}; - unsigned long page_flags = 0; + unsigned long page_flags = flags; unsigned long size = 0; bool append = false; int i; - flags &= PAGEFLAGS_MASK; - if (flags) { - page_flags |= flags; + if (flags & PAGEFLAGS_MASK) { snprintf(cmp_buf + size, BUF_SIZE - size, "%s", name); size = strlen(cmp_buf); #if SECTIONS_WIDTH || NODES_WIDTH || ZONES_WIDTH || \ From patchwork Tue Oct 12 18:26:45 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Matthew Wilcox (Oracle)" X-Patchwork-Id: 12553497 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 9F154C433F5 for ; Tue, 12 Oct 2021 18:33:05 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 3F32C60EDF for ; Tue, 12 Oct 2021 18:33:05 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 3F32C60EDF Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id D3626940007; Tue, 12 Oct 2021 14:33:04 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id CE5B8900002; Tue, 12 Oct 2021 14:33:04 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BD49A940007; Tue, 12 Oct 2021 14:33:04 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0174.hostedemail.com [216.40.44.174]) by kanga.kvack.org (Postfix) with ESMTP id AD9C1900002 for ; Tue, 12 Oct 2021 14:33:04 -0400 (EDT) Received: from smtpin01.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 66B9039492 for ; Tue, 12 Oct 2021 18:33:04 +0000 (UTC) X-FDA: 78688632288.01.982F8F3 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf19.hostedemail.com (Postfix) with ESMTP id 22307B0000A5 for ; Tue, 12 Oct 2021 18:33:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=x0WgwJogmzpJSyMxHgNVxggvHDeZjJFni/7huLmq+s8=; b=vQoJik/xyf5rP0YgSqWBrWLmQ/ zUj/Iedry9+tBLoWcRp7r1kqjVhcbCtMfKuu9BGz22VwFjvc5xqwlHyUetlg1BHVrwhH7fdQWBmp3 cJ5a0xm9ogwu1NuJEO6Cu9DaCVMqJLQL2wIg9/jDLLSdxBY+FlbXpl6IKgzr5fqFIPdhT0Ve1b6Dq 7Fs3PIgp96dtykrFP+CLcxFtsTtcbXRF8zKIYHoHOSHgjFL0n3iySz6qIC122qz1YCgoMTWP59G47 1FCvHUuJLen1XwFQptyJnP5eiqFe8JajkbJKYzuXzRcnWAX9JV+1epOo6pwKLheO4bopijoxc+K3N zOdleryA==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1maMXp-006jpv-89; Tue, 12 Oct 2021 18:31:18 +0000 From: "Matthew Wilcox (Oracle)" To: Yafang Shao Cc: "Matthew Wilcox (Oracle)" , Sergey Senozhatsky , Petr Mladek , linux-mm@kvack.org, Vlastimil Babka , Rasmus Villemoes Subject: [PATCH 3/5] test_printf: Remove custom appending of '|' Date: Tue, 12 Oct 2021 19:26:45 +0100 Message-Id: <20211012182647.1605095-4-willy@infradead.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211012182647.1605095-1-willy@infradead.org> References: <20211012182647.1605095-1-willy@infradead.org> MIME-Version: 1.0 X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 22307B0000A5 X-Stat-Signature: c4xo7niz4zhadwyh4pxek7g17rnpg49p Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b="vQoJik/x"; dmarc=none; spf=none (imf19.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org X-HE-Tag: 1634063584-491781 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: Instead of having an ifdef to decide whether to print a |, use the 'append' functionality of the main loop to print it. Signed-off-by: Matthew Wilcox (Oracle) Reviewed-by: Yafang Shao Reviewed-by: Petr Mladek Reviewed-by: Anshuman Khandual --- lib/test_printf.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/lib/test_printf.c b/lib/test_printf.c index f744b0498672..60cdf4ba991e 100644 --- a/lib/test_printf.c +++ b/lib/test_printf.c @@ -616,12 +616,7 @@ page_flags_test(int section, int node, int zone, int last_cpupid, if (flags & PAGEFLAGS_MASK) { snprintf(cmp_buf + size, BUF_SIZE - size, "%s", name); size = strlen(cmp_buf); -#if SECTIONS_WIDTH || NODES_WIDTH || ZONES_WIDTH || \ - LAST_CPUPID_WIDTH || KASAN_TAG_WIDTH - /* Other information also included in page flags */ - snprintf(cmp_buf + size, BUF_SIZE - size, "|"); - size = strlen(cmp_buf); -#endif + append = true; } for (i = 0; i < ARRAY_SIZE(pft); i++) { From patchwork Tue Oct 12 18:26:46 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Matthew Wilcox (Oracle)" X-Patchwork-Id: 12553499 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 0624DC433EF for ; Tue, 12 Oct 2021 18:33:59 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id A03A160C40 for ; Tue, 12 Oct 2021 18:33:58 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org A03A160C40 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id 3980E900004; Tue, 12 Oct 2021 14:33:58 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 34845900002; Tue, 12 Oct 2021 14:33:58 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 237B8900004; Tue, 12 Oct 2021 14:33:58 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0248.hostedemail.com [216.40.44.248]) by kanga.kvack.org (Postfix) with ESMTP id 11AAC900002 for ; Tue, 12 Oct 2021 14:33:58 -0400 (EDT) Received: from smtpin40.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id C391D39492 for ; Tue, 12 Oct 2021 18:33:57 +0000 (UTC) X-FDA: 78688634514.40.779B6EF Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf22.hostedemail.com (Postfix) with ESMTP id 89D781910 for ; Tue, 12 Oct 2021 18:33:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=hxuHUoytUuk4x4tbpoAi8hfD81lXg3HGcPsmGGD2qLs=; b=YySSYhUGcvD+8JyLmi3XreBEyB 2ixrqYgbktMbQ6TJTfGNAJ7vpSq+dvV9axQFW08wF2RrZGUzy08hFz8gLfIJC28a9CFMiigT0l8Li uC6I4AAYCTpkq8BUiypGEQHriP2AQWeBVjlguLRRwomgU0WuRfZyiKZcHEr3fK0S92Fh5KjTHLyyr lJBBw55RNQwFtHogVRyDS7jQQSE+PwkvShMh4DlrPUyrb4XnXQqADdUmnE1SME9VZGdLmrE3elwMs UvrnnHx1gPNdNh5kM/Nc/OWS5wY8gkYp9P83fcc5Df2no9UDkXzWCnOYAxqb52wDR6S12FYgkULy+ GtZjoPNQ==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1maMZL-006jux-IP; Tue, 12 Oct 2021 18:32:27 +0000 From: "Matthew Wilcox (Oracle)" To: Yafang Shao Cc: "Matthew Wilcox (Oracle)" , Sergey Senozhatsky , Petr Mladek , linux-mm@kvack.org, Vlastimil Babka , Rasmus Villemoes Subject: [PATCH 4/5] test_printf: Append '|' more efficiently Date: Tue, 12 Oct 2021 19:26:46 +0100 Message-Id: <20211012182647.1605095-5-willy@infradead.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211012182647.1605095-1-willy@infradead.org> References: <20211012182647.1605095-1-willy@infradead.org> MIME-Version: 1.0 X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 89D781910 X-Stat-Signature: ph9mt6qygohhhwetkrsj7ai3c1yuiyg4 Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=YySSYhUG; dmarc=none; spf=none (imf22.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org X-HE-Tag: 1634063637-530068 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: Instead of calling snprintf(), just append '|' by hand. Signed-off-by: Matthew Wilcox (Oracle) --- lib/test_printf.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/test_printf.c b/lib/test_printf.c index 60cdf4ba991e..662c3785aa57 100644 --- a/lib/test_printf.c +++ b/lib/test_printf.c @@ -623,9 +623,9 @@ page_flags_test(int section, int node, int zone, int last_cpupid, if (!pft[i].width) continue; - if (append) { - snprintf(cmp_buf + size, BUF_SIZE - size, "|"); - size = strlen(cmp_buf); + if (append && size < BUF_SIZE) { + cmp_buf[size++] = '|'; + cmp_buf[size] = '\0'; } page_flags |= (values[i] & pft[i].mask) << pft[i].shift; From patchwork Tue Oct 12 18:26:47 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Matthew Wilcox (Oracle)" X-Patchwork-Id: 12553501 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 B0B5EC433EF for ; Tue, 12 Oct 2021 18:34:56 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 4D59F60C40 for ; Tue, 12 Oct 2021 18:34:56 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 4D59F60C40 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id C97E9940007; Tue, 12 Oct 2021 14:34:55 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C4839900002; Tue, 12 Oct 2021 14:34:55 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B0F55940007; Tue, 12 Oct 2021 14:34:55 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0224.hostedemail.com [216.40.44.224]) by kanga.kvack.org (Postfix) with ESMTP id A2AA8900002 for ; Tue, 12 Oct 2021 14:34:55 -0400 (EDT) Received: from smtpin29.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 5094E18037FCF for ; Tue, 12 Oct 2021 18:34:55 +0000 (UTC) X-FDA: 78688636950.29.825B709 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf29.hostedemail.com (Postfix) with ESMTP id 00523900025B for ; Tue, 12 Oct 2021 18:34:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=/63nhLqE3Qn8wZP8+aMN9gIKITOAczM36pmwC/CiiRE=; b=ecRk6bVZQoyJyfWiaD1mEJlILD KXkJmowERy8cqUw0iLtinbEBUhzCSjMPhWt5/igc6aum2+6LeG+mkb2Df0RwqNaKbClKj2dWF86Oo 7DvqusMkZG08cN/S97Yr1AGWk01+6L1mMasp1povF3vxQX4d1LFBsFCzwZY2UkDiTt6J9ct1aOTKS 8hEVlEA45TsZ9Pc4xyry0uvrajSykLvARYrcb7uSvVAlIuJsLe44kecI+oCS8uM7yrkbFjqU3r1r5 eACmmD5btGZHhFfdgIZ0kO8Q3+0rHHWK/sqf0Tab+klOCLYSds1FTTMlcDtiQ3hrX0tRDEfV/kPjk DMIyoSwQ==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1maMa7-006jxe-S6; Tue, 12 Oct 2021 18:33:11 +0000 From: "Matthew Wilcox (Oracle)" To: Yafang Shao Cc: "Matthew Wilcox (Oracle)" , Sergey Senozhatsky , Petr Mladek , linux-mm@kvack.org, Vlastimil Babka , Rasmus Villemoes Subject: [PATCH 5/5] vsprintf: Make %pGp print the hex value Date: Tue, 12 Oct 2021 19:26:47 +0100 Message-Id: <20211012182647.1605095-6-willy@infradead.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211012182647.1605095-1-willy@infradead.org> References: <20211012182647.1605095-1-willy@infradead.org> MIME-Version: 1.0 Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=ecRk6bVZ; spf=none (imf29.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 00523900025B X-Stat-Signature: paszo36gx5rq6gu59orq4htd3twopp9w X-HE-Tag: 1634063694-767541 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: All existing users of %pGp want the hex value as well as the decoded flag names. This looks awkward (passing the same parameter to printf twice), so move that functionality into the core. If we want, we can make that optional with flag arguments to %pGp in the future. Signed-off-by: Matthew Wilcox (Oracle) --- lib/test_printf.c | 10 +++++++++- lib/vsprintf.c | 8 ++++++++ mm/debug.c | 2 +- mm/memory-failure.c | 8 ++++---- mm/page_owner.c | 4 ++-- mm/slub.c | 4 ++-- 6 files changed, 26 insertions(+), 10 deletions(-) diff --git a/lib/test_printf.c b/lib/test_printf.c index 662c3785aa57..a60b1a749e87 100644 --- a/lib/test_printf.c +++ b/lib/test_printf.c @@ -613,6 +613,10 @@ page_flags_test(int section, int node, int zone, int last_cpupid, bool append = false; int i; + for (i = 0; i < ARRAY_SIZE(values); i++) + page_flags |= (values[i] & pft[i].mask) << pft[i].shift; + snprintf(cmp_buf + size, BUF_SIZE - size, "%#lx(", page_flags); + size = strlen(cmp_buf); if (flags & PAGEFLAGS_MASK) { snprintf(cmp_buf + size, BUF_SIZE - size, "%s", name); size = strlen(cmp_buf); @@ -628,7 +632,6 @@ page_flags_test(int section, int node, int zone, int last_cpupid, cmp_buf[size] = '\0'; } - 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, @@ -637,6 +640,11 @@ page_flags_test(int section, int node, int zone, int last_cpupid, append = true; } + if (size < BUF_SIZE) { + cmp_buf[size++] = ')'; + cmp_buf[size] = '\0'; + } + test(cmp_buf, "%pGp", &page_flags); } diff --git a/lib/vsprintf.c b/lib/vsprintf.c index d7ad44f2c8f5..214098248610 100644 --- a/lib/vsprintf.c +++ b/lib/vsprintf.c @@ -2023,6 +2023,11 @@ char *format_page_flags(char *buf, char *end, unsigned long flags) bool append = false; int i; + buf = number(buf, end, flags, default_flag_spec); + if (buf < end) + *buf = '('; + buf++; + /* Page flags from the main area. */ if (main_flags) { buf = format_flags(buf, end, main_flags, pageflag_names); @@ -2051,6 +2056,9 @@ char *format_page_flags(char *buf, char *end, unsigned long flags) append = true; } + if (buf < end) + *buf = ')'; + buf++; return buf; } diff --git a/mm/debug.c b/mm/debug.c index fae0f81ad831..714be101dec9 100644 --- a/mm/debug.c +++ b/mm/debug.c @@ -162,7 +162,7 @@ static void __dump_page(struct page *page) out_mapping: BUILD_BUG_ON(ARRAY_SIZE(pageflag_names) != __NR_PAGEFLAGS + 1); - pr_warn("%sflags: %#lx(%pGp)%s\n", type, head->flags, &head->flags, + pr_warn("%sflags: %pGp%s\n", type, &head->flags, page_cma ? " CMA" : ""); print_hex_dump(KERN_WARNING, "raw: ", DUMP_PREFIX_NONE, 32, sizeof(unsigned long), page, diff --git a/mm/memory-failure.c b/mm/memory-failure.c index 3e6449f2102a..e4e122a2e9b1 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -2109,14 +2109,14 @@ static int __soft_offline_page(struct page *page) if (!list_empty(&pagelist)) putback_movable_pages(&pagelist); - pr_info("soft offline: %#lx: %s migration failed %d, type %lx (%pGp)\n", - pfn, msg_page[huge], ret, page->flags, &page->flags); + pr_info("soft offline: %#lx: %s migration failed %d, type %pGp\n", + pfn, msg_page[huge], ret, &page->flags); if (ret > 0) ret = -EBUSY; } } else { - pr_info("soft offline: %#lx: %s isolation failed, page count %d, type %lx (%pGp)\n", - pfn, msg_page[huge], page_count(page), page->flags, &page->flags); + pr_info("soft offline: %#lx: %s isolation failed, page count %d, type %pGp\n", + pfn, msg_page[huge], page_count(page), &page->flags); ret = -EBUSY; } return ret; diff --git a/mm/page_owner.c b/mm/page_owner.c index 62402d22539b..4afc713ca525 100644 --- a/mm/page_owner.c +++ b/mm/page_owner.c @@ -351,12 +351,12 @@ print_page_owner(char __user *buf, size_t count, unsigned long pfn, pageblock_mt = get_pageblock_migratetype(page); page_mt = gfp_migratetype(page_owner->gfp_mask); ret += snprintf(kbuf + ret, count - ret, - "PFN %lu type %s Block %lu type %s Flags %#lx(%pGp)\n", + "PFN %lu type %s Block %lu type %s Flags %pGp\n", pfn, migratetype_names[page_mt], pfn >> pageblock_order, migratetype_names[pageblock_mt], - page->flags, &page->flags); + &page->flags); if (ret >= count) goto err; diff --git a/mm/slub.c b/mm/slub.c index 3d2025f7163b..f7ac28646580 100644 --- a/mm/slub.c +++ b/mm/slub.c @@ -763,9 +763,9 @@ void print_tracking(struct kmem_cache *s, void *object) static void print_page_info(struct page *page) { - pr_err("Slab 0x%p objects=%u used=%u fp=0x%p flags=%#lx(%pGp)\n", + pr_err("Slab 0x%p objects=%u used=%u fp=0x%p flags=%pGp\n", page, page->objects, page->inuse, page->freelist, - page->flags, &page->flags); + &page->flags); }