From patchwork Tue Oct 19 14:26:17 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: 12570071 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 76DBDC433F5 for ; Tue, 19 Oct 2021 14:29:38 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 0C28A610C7 for ; Tue, 19 Oct 2021 14:29:38 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 0C28A610C7 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 9F4916B0071; Tue, 19 Oct 2021 10:29:37 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 97D566B0072; Tue, 19 Oct 2021 10:29:37 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 845466B0073; Tue, 19 Oct 2021 10:29:37 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 762596B0071 for ; Tue, 19 Oct 2021 10:29:37 -0400 (EDT) Received: from smtpin15.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 2D736181AEF1E for ; Tue, 19 Oct 2021 14:29:37 +0000 (UTC) X-FDA: 78713420394.15.793B668 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf16.hostedemail.com (Postfix) with ESMTP id 5D705F000098 for ; Tue, 19 Oct 2021 14:29:34 +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=XflQmu+9ZIgNRCNVo0+euXYeEM3C2NpD324hdp3HDoU=; b=LJEiAVPoKjddTWg/MKRWDmdSc9 hNDHk3rS+vSo/074CCyzzU/3BN1YUlEStwlkWgTBXb0uOnBC9GZ4DLNTcfWzjkxMSiSetwUeAnGMg wWb8jfUVvVjdhUKwD1UmOpZsj2ngp3RDwSZwa5QwLJEA0V6tZM4UCs7sGKFcbYWkWBF0qpPXj2vLC oGOmlOEBCo0YTTLGRQhyKKvHzi9LEjjjOYie7M3Islz2zOD3bHKydtq7+M75RQQ+cNJJtNAbxR9uv RsFp1G3OZzSSReM9kC3p4zA746OOdWP9uqWyYe6iUPhQH/fVqrK62YyLzHmvcGK2xFrn4ia5CKP4t OycvFUIg==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1mcq5k-00Bn4C-L8; Tue, 19 Oct 2021 14:28:04 +0000 From: "Matthew Wilcox (Oracle)" To: Yafang Shao Cc: "Matthew Wilcox (Oracle)" , Sergey Senozhatsky , Petr Mladek , linux-mm@kvack.org, Vlastimil Babka , Rasmus Villemoes , Anshuman Khandual Subject: [PATCH v2 1/5] test_printf: Make pft array const Date: Tue, 19 Oct 2021 15:26:17 +0100 Message-Id: <20211019142621.2810043-2-willy@infradead.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211019142621.2810043-1-willy@infradead.org> References: <20211019142621.2810043-1-willy@infradead.org> MIME-Version: 1.0 X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: 5D705F000098 X-Stat-Signature: e9kmet77qer6iw5hmt3imf53b69u4h8h Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=LJEiAVPo; dmarc=none; spf=none (imf16.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: 1634653774-759225 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 19 14:26:18 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: 12570073 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 15FDAC433EF for ; Tue, 19 Oct 2021 14:30:31 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id A2CD960FC1 for ; Tue, 19 Oct 2021 14:30:30 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org A2CD960FC1 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 4015A6B006C; Tue, 19 Oct 2021 10:30:30 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 388E66B0072; Tue, 19 Oct 2021 10:30:30 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 22A14900002; Tue, 19 Oct 2021 10:30:30 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0243.hostedemail.com [216.40.44.243]) by kanga.kvack.org (Postfix) with ESMTP id 13C196B006C for ; Tue, 19 Oct 2021 10:30:30 -0400 (EDT) Received: from smtpin16.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id C2D0F183AB0BD for ; Tue, 19 Oct 2021 14:30:29 +0000 (UTC) X-FDA: 78713422578.16.ED3BEFB Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf22.hostedemail.com (Postfix) with ESMTP id 5D3ED1908 for ; Tue, 19 Oct 2021 14:30:28 +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=be9ub126mtaRy3YmFJcE5Dh1u2HQa5PSWqhjnH8ilvU=; b=mHUDr35gaQbBtoLk4zJs1JSPWh GEJ04rETgQdvk0SbzXsQWl7+lDHUjk3sDhdPXerBQ7d+1bkhKU6jaoMixrvDlCo2u+dtWOagBC9TA qDrqEb99X4Vo4PgIwKJ3OWQTy9h86qk0iRNe43puswSBcuhg/lgQpO81GvwaZn8siZqqyAgUGU4Dq sNGyqHyq8+5BmvvSDOBDPX0FFFMoiNS2w2IJDpjuYIa2A7DnbmcZsoBd6qr25IqoPE0iRP5EDD0xO l1xiGRAyPNaraUadHAYJVheisbV7MmK1JH3iWOEpzVEC/3xlvS3R1jNbQojr9Ijr16OZWG+dm5XeL WTgJ+29w==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1mcq6U-00Bn5H-H6; Tue, 19 Oct 2021 14:28:54 +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 v2 2/5] test_printf: Remove separate page_flags variable Date: Tue, 19 Oct 2021 15:26:18 +0100 Message-Id: <20211019142621.2810043-3-willy@infradead.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211019142621.2810043-1-willy@infradead.org> References: <20211019142621.2810043-1-willy@infradead.org> MIME-Version: 1.0 X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: 5D3ED1908 X-Stat-Signature: nk6wr8537oww1a9bm54b6ob96prkusgn Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=mHUDr35g; 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: 1634653828-761180 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: Keep flags intact so that we also test what happens when unknown flags are passed to %pGp. Signed-off-by: Matthew Wilcox (Oracle) Reviewed-by: Yafang Shao Reviewed-by: Petr Mladek --- lib/test_printf.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/lib/test_printf.c b/lib/test_printf.c index a52c1c3a55ba..4531063afd45 100644 --- a/lib/test_printf.c +++ b/lib/test_printf.c @@ -605,17 +605,15 @@ static const struct page_flags_test pft[] = { static void __init page_flags_test(int section, int node, int zone, int last_cpupid, - int kasan_tag, int flags, const char *name, char *cmp_buf) + int kasan_tag, unsigned long flags, const char *name, + char *cmp_buf) { unsigned long values[] = {section, node, zone, last_cpupid, kasan_tag}; - unsigned long page_flags = 0; 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 || \ @@ -635,7 +633,7 @@ page_flags_test(int section, int node, int zone, int last_cpupid, size = strlen(cmp_buf); } - page_flags |= (values[i] & pft[i].mask) << pft[i].shift; + 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, @@ -644,7 +642,7 @@ page_flags_test(int section, int node, int zone, int last_cpupid, append = true; } - test(cmp_buf, "%pGp", &page_flags); + test(cmp_buf, "%pGp", &flags); } static void __init From patchwork Tue Oct 19 14:26:19 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: 12570075 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 5FDF3C433F5 for ; Tue, 19 Oct 2021 14:32:05 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id EDD376112D for ; Tue, 19 Oct 2021 14:32:04 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org EDD376112D 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 7D0A26B006C; Tue, 19 Oct 2021 10:32:04 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 77EB66B0071; Tue, 19 Oct 2021 10:32:04 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6463B900002; Tue, 19 Oct 2021 10:32:04 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0004.hostedemail.com [216.40.44.4]) by kanga.kvack.org (Postfix) with ESMTP id 53E426B006C for ; Tue, 19 Oct 2021 10:32:04 -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 EADCA31E61 for ; Tue, 19 Oct 2021 14:32:03 +0000 (UTC) X-FDA: 78713426526.37.A8B4EE4 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf01.hostedemail.com (Postfix) with ESMTP id 9A93250824FD for ; Tue, 19 Oct 2021 14:31:58 +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=ydhR3UpARa1cfwyzU0eenF7PRdg/8ED7cq8uYIOGV7o=; b=NX87jcQjPK9wKj7Y0YRBbWVBfm yaSsyX/vjHlFRVXvwLBmN3PgOC+rdneMyZAyh84P+QwnpfERNuiWgoQKZlHpXrHb0tiyjCMhvGBk8 e6ZT/PX3SAFSFnFnMQWTDtbwGlI7/OtgYgGCtDgYgDPlYXbUCBsFwSYydToyBfG8kD7WnILOazOHV bASglCVoQg+6ha0ru7TjG3c3vXnb7Qs1fxYwELA3gyK0+ovFP5KxwQbbMDNOQ5fdbBc03fLO0H2HV W2oFQdGGx77TyJMIH9uYETcH8XRPMWiXjutZdEMHh7FuqoNxhSutn9GXlU/chZWlpZ1JkwFLNIso8 cR8oxITw==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1mcq7K-00Bn93-TJ; Tue, 19 Oct 2021 14:29:42 +0000 From: "Matthew Wilcox (Oracle)" To: Yafang Shao Cc: "Matthew Wilcox (Oracle)" , Sergey Senozhatsky , Petr Mladek , linux-mm@kvack.org, Vlastimil Babka , Rasmus Villemoes , Anshuman Khandual Subject: [PATCH v2 3/5] test_printf: Remove custom appending of '|' Date: Tue, 19 Oct 2021 15:26:19 +0100 Message-Id: <20211019142621.2810043-4-willy@infradead.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211019142621.2810043-1-willy@infradead.org> References: <20211019142621.2810043-1-willy@infradead.org> MIME-Version: 1.0 X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: 9A93250824FD X-Stat-Signature: 8rni7gieatg6xwfzapco379orxw3y4uy Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=NX87jcQj; dmarc=none; spf=none (imf01.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: 1634653918-911814 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 4531063afd45..ec584196cb99 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 19 14:26:20 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: 12570085 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 500E6C433EF for ; Tue, 19 Oct 2021 14:33:48 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 966476115A for ; Tue, 19 Oct 2021 14:33:47 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 966476115A 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 3394A6B006C; Tue, 19 Oct 2021 10:33:47 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 2E8DC6B0071; Tue, 19 Oct 2021 10:33:47 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1D799900002; Tue, 19 Oct 2021 10:33:47 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0066.hostedemail.com [216.40.44.66]) by kanga.kvack.org (Postfix) with ESMTP id 0D83B6B006C for ; Tue, 19 Oct 2021 10:33:47 -0400 (EDT) Received: from smtpin24.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id BC348181CC1C2 for ; Tue, 19 Oct 2021 14:33:46 +0000 (UTC) X-FDA: 78713430852.24.901881B Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf08.hostedemail.com (Postfix) with ESMTP id F37C930000B1 for ; Tue, 19 Oct 2021 14:33:41 +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=bauy/NBIkxCTiWPPxOuFHCX4UJjkp/ChiiCjTaqvSSU=; b=NH3FDQNy+psWnsc7e1NqaW0lQY +dox/UFnAjZorRh1IC/Jtp9Cf0Pedu8dLCpFcsASSJ4bxdzI236JDcUo38cBdsu0Qgx+4Igf+yVCO FzowYM4G4A/hYSwraliGvFV7TpcnQqXf2ZifvkwZE2D+RnPngHnxz+OvqMiD0z0E3b4bPYh/OO50Q YW8WvVnr8ICLcdPCBR6XCAkNJQepb+kdeimQpvY6aY9ZZIh2fzAMcI7DzTTZPObvjDRb30VrVtoMu gubCnlqIQuBuFvT8ExPMnL72Gl3ReOYmfEAzT7Kfr7c/kp+rcqFdqiyqvzq3WYCpBxjYYSo6EiU6N KOpddm+A==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1mcq8K-00BnAb-1b; Tue, 19 Oct 2021 14:31:03 +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 v2 4/5] test_printf: Append strings more efficiently Date: Tue, 19 Oct 2021 15:26:20 +0100 Message-Id: <20211019142621.2810043-5-willy@infradead.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211019142621.2810043-1-willy@infradead.org> References: <20211019142621.2810043-1-willy@infradead.org> MIME-Version: 1.0 Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=NH3FDQNy; dmarc=none; spf=none (imf08.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: F37C930000B1 X-Stat-Signature: j3nhcirpwi4zydaqouisu8y4gwpzeuar X-HE-Tag: 1634654021-632219 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 scnprintf instead of snprintf + strlen. Signed-off-by: Matthew Wilcox (Oracle) Reviewed-by: Yafang Shao Reviewed-by: Petr Mladek --- lib/test_printf.c | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/lib/test_printf.c b/lib/test_printf.c index ec584196cb99..d09993fca463 100644 --- a/lib/test_printf.c +++ b/lib/test_printf.c @@ -614,8 +614,7 @@ page_flags_test(int section, int node, int zone, int last_cpupid, int i; if (flags & PAGEFLAGS_MASK) { - snprintf(cmp_buf + size, BUF_SIZE - size, "%s", name); - size = strlen(cmp_buf); + size += scnprintf(cmp_buf + size, BUF_SIZE - size, "%s", name); append = true; } @@ -623,17 +622,14 @@ 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 += scnprintf(cmp_buf + size, BUF_SIZE - size, "|"); 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, - values[i] & pft[i].mask); - size = strlen(cmp_buf); + size += scnprintf(cmp_buf + size, BUF_SIZE - size, "%s=", + pft[i].name); + size += scnprintf(cmp_buf + size, BUF_SIZE - size, pft[i].fmt, + values[i] & pft[i].mask); append = true; } From patchwork Tue Oct 19 14:26:21 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: 12570087 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 7B3AFC433FE for ; Tue, 19 Oct 2021 14:35:21 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 1D0836115A for ; Tue, 19 Oct 2021 14:35:21 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 1D0836115A 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 AB1F96B0071; Tue, 19 Oct 2021 10:35:20 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A3A566B0072; Tue, 19 Oct 2021 10:35:20 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 928DB6B0073; Tue, 19 Oct 2021 10:35:20 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0113.hostedemail.com [216.40.44.113]) by kanga.kvack.org (Postfix) with ESMTP id 82E916B0071 for ; Tue, 19 Oct 2021 10:35:20 -0400 (EDT) Received: from smtpin21.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 3771D2DEB9 for ; Tue, 19 Oct 2021 14:35:20 +0000 (UTC) X-FDA: 78713434800.21.508A23E Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf15.hostedemail.com (Postfix) with ESMTP id B91ECD000081 for ; Tue, 19 Oct 2021 14:35:16 +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=Rq5xxZ3fm9eNauFFvcKIA2C9/+5UDRw3Mg6hxQN8Dmw=; b=ODhamrZuMnOV78k5UkBttGeVhz koANH3FMLLLkWLQXJTS6fyqZhkdplKLJWnZARV15yGXKNdSSpKTR1ss/VwBokyG1UHbBUCsbmsRAB 52a2HekhZrVq0ZoCCwPyXlRapAb6gFnhx/e65TupjHLOfJtOyIVsM3VB7XpBV82azVhxRXcPQfwYl f4ZB5M2A5Szjoq6VUI58g0mxyUL31NFKWPt5MhPaVZrE7Hkew4a5l6Q0JW4J7/UPwRA8aN7FgpJs8 brt4mApCA/HdgimhHGbZLofZrVlIlw8VrawEWP80qrXXbtSqKQYhWL5Gr7FlP9sywWY6i+f2lBwVa hXTx4UIg==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1mcq9p-00BnDF-GR; Tue, 19 Oct 2021 14:32:33 +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 v2 5/5] vsprintf: Make %pGp print the hex value Date: Tue, 19 Oct 2021 15:26:21 +0100 Message-Id: <20211019142621.2810043-6-willy@infradead.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211019142621.2810043-1-willy@infradead.org> References: <20211019142621.2810043-1-willy@infradead.org> MIME-Version: 1.0 Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=ODhamrZu; dmarc=none; spf=none (imf15.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: B91ECD000081 X-Stat-Signature: usdy4fcannpuafsk9wfie7f1xcuezfr7 X-HE-Tag: 1634654116-721979 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) Reviewed-by: Yafang Shao Reviewed-by: Petr Mladek --- lib/test_printf.c | 9 +++++++-- 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, 24 insertions(+), 11 deletions(-) diff --git a/lib/test_printf.c b/lib/test_printf.c index d09993fca463..07309c45f327 100644 --- a/lib/test_printf.c +++ b/lib/test_printf.c @@ -609,10 +609,14 @@ page_flags_test(int section, int node, int zone, int last_cpupid, char *cmp_buf) { unsigned long values[] = {section, node, zone, last_cpupid, kasan_tag}; - unsigned long size = 0; + unsigned long size; bool append = false; int i; + for (i = 0; i < ARRAY_SIZE(values); i++) + flags |= (values[i] & pft[i].mask) << pft[i].shift; + + size = scnprintf(cmp_buf, BUF_SIZE, "%#lx(", flags); if (flags & PAGEFLAGS_MASK) { size += scnprintf(cmp_buf + size, BUF_SIZE - size, "%s", name); append = true; @@ -625,7 +629,6 @@ page_flags_test(int section, int node, int zone, int last_cpupid, if (append) size += scnprintf(cmp_buf + size, BUF_SIZE - size, "|"); - flags |= (values[i] & pft[i].mask) << pft[i].shift; size += scnprintf(cmp_buf + size, BUF_SIZE - size, "%s=", pft[i].name); size += scnprintf(cmp_buf + size, BUF_SIZE - size, pft[i].fmt, @@ -633,6 +636,8 @@ page_flags_test(int section, int node, int zone, int last_cpupid, append = true; } + snprintf(cmp_buf + size, BUF_SIZE - size, ")"); + test(cmp_buf, "%pGp", &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); }