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 48F44C433EF for ; Wed, 13 Oct 2021 05:25:15 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id CCBEB60231 for ; Wed, 13 Oct 2021 05:25:14 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org CCBEB60231 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id 6B1826B006C; Wed, 13 Oct 2021 01:25:14 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 660F5940007; Wed, 13 Oct 2021 01:25:14 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5500D900002; Wed, 13 Oct 2021 01:25:14 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0191.hostedemail.com [216.40.44.191]) by kanga.kvack.org (Postfix) with ESMTP id 45DD06B006C for ; Wed, 13 Oct 2021 01:25:14 -0400 (EDT) Received: from smtpin19.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 04FCA8249980 for ; Wed, 13 Oct 2021 05:25:14 +0000 (UTC) X-FDA: 78690275748.19.94404AB Received: from mail-il1-f175.google.com (mail-il1-f175.google.com [209.85.166.175]) by imf29.hostedemail.com (Postfix) with ESMTP id B22B09000163 for ; Wed, 13 Oct 2021 05:25:13 +0000 (UTC) Received: by mail-il1-f175.google.com with SMTP id w10so1326116ilc.13 for ; Tue, 12 Oct 2021 22:25:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=wNuVKzEjUVTwXmK0mEFB9la5xyEtNka8Mq3qCbZ1PFw=; b=nH15vcJXME2cZjnAte//4yxaeTfqoHNjhJk1DCLPS251DeQ8cYOp2egO1N83TyEHhu Qzyf+5M7q1gOiB+n6Y4VoW6yr1W57a3AojGM7zvmng5GlgUOCbBvLKGhyKl/Ky5D/nB6 zM2Suv01A5iqBMmZax54JunxAQN9u6it2NgkhJ7/u4xZ54SvBZ6H/qDMDuSRAbsrhFJ5 oSaw3/HenlQB3kkzmAxTHabySbn748+4hLokN2MC8DdAf1alcBUtQqNA8u00BTkfiDVj /UDLQ/4K4L4q3QRvaAs2KWr2eLsUv0O86yN2XV4lzxek/chXsb+oF9z6bts+imyaGIVR GgvQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=wNuVKzEjUVTwXmK0mEFB9la5xyEtNka8Mq3qCbZ1PFw=; b=0HuFgEigB0sZitxpN35Fwj1FY1WH8KnGMdiGaVLXhNsHfCcmVMN3DUoIH5mF79m6wZ RoQ+QaoOI6QSPEj4Y872+Hp8ZLmD7n0Hw1QOXLJMa5PaFpudaCZeY4taWJDDbAWEGNBx bmRXScCw+jFv/fBQNysi8Dqh6XEArMI1ydRHyUgnrLosRABqblL++tUOFCd6H8Q4V2SW Ry9Mi4XkynP+3PoymQeLQkgX35ZlnIVQP2n8+NmZ4ZBJX5WY99yNQOg3qsVlTvkd0ntS HE2u0MSHr8gTXKDDX2qKwq5GuYRMCW6b1XyKGPrpK3Z4w22dxuEopiyKd3XhNsJd7b4R HmaA== X-Gm-Message-State: AOAM530e3rnTN6AaK8hItNscDzPfVj10/VSjMPQwIfqTcQRa861UOkxl q3ID3dZvOeoAlE5OVsGhxkyQan7hIyHjr1teH10= X-Google-Smtp-Source: ABdhPJxbKkWZwoSO+EosuMgWKGOopkpOvz5B88AXdbjydUQVmwB546HyQCx9BSY5pxR0BjQZd1WzB/f9tzPjKTqEaO4= X-Received: by 2002:a05:6e02:20ed:: with SMTP id q13mr10600727ilv.254.1634102713161; Tue, 12 Oct 2021 22:25:13 -0700 (PDT) MIME-Version: 1.0 References: <20211012182647.1605095-1-willy@infradead.org> <20211012182647.1605095-6-willy@infradead.org> In-Reply-To: <20211012182647.1605095-6-willy@infradead.org> From: Yafang Shao Date: Wed, 13 Oct 2021 13:24:36 +0800 Message-ID: Subject: Re: [PATCH 5/5] vsprintf: Make %pGp print the hex value To: "Matthew Wilcox (Oracle)" Cc: Sergey Senozhatsky , Petr Mladek , Linux MM , Vlastimil Babka , Rasmus Villemoes Content-Type: text/plain; charset="UTF-8" X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: B22B09000163 X-Stat-Signature: zub89fdsbyscupmjq3kc4tnj75z5wffw Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=nH15vcJX; spf=pass (imf29.hostedemail.com: domain of laoar.shao@gmail.com designates 209.85.166.175 as permitted sender) smtp.mailfrom=laoar.shao@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-HE-Tag: 1634102713-902914 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 Wed, Oct 13, 2021 at 2:34 AM Matthew Wilcox (Oracle) wrote: > > 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) { Same with the prev patch. Should it be: if (size < BUF_SIZE - 1) { ? Except that, the other parts look good to me. > + 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); > > } > > -- > 2.32.0 > -- Thanks Yafang