From patchwork Mon Feb 15 15:51:39 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yafang Shao X-Patchwork-Id: 12088643 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.5 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1CBA9C433E0 for ; Mon, 15 Feb 2021 15:53:10 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id B3F2A61494 for ; Mon, 15 Feb 2021 15:53:09 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B3F2A61494 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 3F27D8D011A; Mon, 15 Feb 2021 10:53:09 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 3CA338D00FD; Mon, 15 Feb 2021 10:53:09 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2E11A8D011A; Mon, 15 Feb 2021 10:53:09 -0500 (EST) 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 17BFF8D00FD for ; Mon, 15 Feb 2021 10:53:09 -0500 (EST) Received: from smtpin25.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id C56C78157 for ; Mon, 15 Feb 2021 15:53:08 +0000 (UTC) X-FDA: 77820946056.25.son58_400875f2763c Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin25.hostedemail.com (Postfix) with ESMTP id 98F701801E360 for ; Mon, 15 Feb 2021 15:53:08 +0000 (UTC) X-HE-Tag: son58_400875f2763c X-Filterd-Recvd-Size: 4764 Received: from mail-pg1-f179.google.com (mail-pg1-f179.google.com [209.85.215.179]) by imf01.hostedemail.com (Postfix) with ESMTP for ; Mon, 15 Feb 2021 15:53:08 +0000 (UTC) Received: by mail-pg1-f179.google.com with SMTP id o21so4408627pgn.12 for ; Mon, 15 Feb 2021 07:53:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=lMogc+88WyQtKfJD7auvy+h4i72decXJNUKFaJ3X740=; b=f1k2NYrwwh8xNqd+o6sELNC/Xmn6BqejfYUsOdc/hz0lBUnnqJbmZ6ctx3UFqArygT 17RseW+oVDoiLEI7HMJNK21OEjCqDymgNg0x7NUkKvm3mqEJUMMFTqwXVTreKYEAMaVn NT5WTNjazDqjE6gbKospAb/bP2MIm/2KO7K6DQSVS5pmtIVQ/fk0y3P2Z44fyk9cSNfI 6m8XtvcXoTYU4Ar6eV8caQZzWuWCgbAMi/hIpyAapvGN0W22M84wPxIq+wI/kmalhFX0 Xk5B8uoaiiAyioEjYb+3HBMPnnn5+dfTuIvRTn/InmeIAUyoc+4DkOZkJyM3wksC3W91 WFXQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=lMogc+88WyQtKfJD7auvy+h4i72decXJNUKFaJ3X740=; b=h83JBP4BuJu8r2a9P/cGn1gGsD09tlhYD8b2I+ksW0BXktUbddRv8i5lI8uYNdFQtI h1qWx1E8XUFqpobhaZprH12lKs/R32QXlL+MXd1Qk3+In8wSdmzczt4oQGgKyG28UgY/ BYJFjixDgi7WaHznntCd4O358DBIzQuWhfSQ/nKXubaG7ep6ty1MhWCgFCU1MLnnYpkE ggg0xuiFg5Xl9T/GUH4j1XIwKgUsEFdOaLR04w0+Nd9PMdFgoWtxxLnpwdeKlB2vTGEC lQBE6zm5wve0tvRUlL535QO7Z3bY1JqG7flvS5k4guWDSr+lf/ld2+1W9WsSYJWbK217 YurA== X-Gm-Message-State: AOAM531mFJHBeLmUxIVhYUNr/GDdN6AlqnGyx1cQWO51rNaPswpSsKXP mj5bUEeJjM76yBDsCZgLbX0= X-Google-Smtp-Source: ABdhPJzyd3xnuMeGDrvMoMMEnluGJNTY+zKXAvszGpcjAWV7U3QqkpZ5CMs1fRYSM3tyK5jr+hTz/Q== X-Received: by 2002:a62:3852:0:b029:1da:7238:1cb1 with SMTP id f79-20020a6238520000b02901da72381cb1mr15988342pfa.11.1613404387231; Mon, 15 Feb 2021 07:53:07 -0800 (PST) Received: from localhost.localdomain ([50.236.19.102]) by smtp.gmail.com with ESMTPSA id i1sm19771215pfq.158.2021.02.15.07.53.00 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 15 Feb 2021 07:53:06 -0800 (PST) From: Yafang Shao To: pmladek@suse.com, willy@infradead.org, andriy.shevchenko@linux.intel.com, david@redhat.com, linmiaohe@huawei.com, vbabka@suse.cz, cl@linux.com, penberg@kernel.org, rientjes@google.com, iamjoonsoo.kim@lge.com, akpm@linux-foundation.org, rostedt@goodmis.org, sergey.senozhatsky@gmail.com, joe@perches.com Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Yafang Shao Subject: [PATCH v5 1/3] mm, slub: use pGp to print page flags Date: Mon, 15 Feb 2021 23:51:39 +0800 Message-Id: <20210215155141.47432-2-laoar.shao@gmail.com> X-Mailer: git-send-email 2.24.3 (Apple Git-128) In-Reply-To: <20210215155141.47432-1-laoar.shao@gmail.com> References: <20210215155141.47432-1-laoar.shao@gmail.com> MIME-Version: 1.0 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: As pGp has been already introduced in printk, we'd better use it to make the output human readable. Before this change, the output is, [ 6155.716018] INFO: Slab 0x000000004027dd4f objects=33 used=3 fp=0x000000008cd1579c flags=0x17ffffc0010200 While after this change, the output is, [ 8846.517809] INFO: Slab 0x00000000f42a2c60 objects=33 used=3 fp=0x0000000060d32ca8 flags=0x17ffffc0010200(slab|head) Signed-off-by: Yafang Shao Reviewed-by: David Hildenbrand Reviewed-by: Vlastimil Babka Acked-by: David Rientjes Acked-by: Christoph Lameter Reviewed-by: Matthew Wilcox (Oracle) Reviewed-by: Miaohe Lin Reviewed-by: Andy Shevchenko --- mm/slub.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/mm/slub.c b/mm/slub.c index 7ecbbbe5bc0c..ddd429832577 100644 --- a/mm/slub.c +++ b/mm/slub.c @@ -641,8 +641,9 @@ void print_tracking(struct kmem_cache *s, void *object) static void print_page_info(struct page *page) { - pr_err("INFO: Slab 0x%p objects=%u used=%u fp=0x%p flags=0x%04lx\n", - page, page->objects, page->inuse, page->freelist, page->flags); + pr_err("INFO: Slab 0x%p objects=%u used=%u fp=0x%p flags=%#lx(%pGp)\n", + page, page->objects, page->inuse, page->freelist, + page->flags, &page->flags); } From patchwork Mon Feb 15 15:51:40 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yafang Shao X-Patchwork-Id: 12088645 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.5 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B7716C433DB for ; Mon, 15 Feb 2021 15:53:17 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 58F3B64DE0 for ; Mon, 15 Feb 2021 15:53:17 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 58F3B64DE0 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id D41B18D011B; Mon, 15 Feb 2021 10:53:16 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id CF2998D00FD; Mon, 15 Feb 2021 10:53:16 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C06DE8D011B; Mon, 15 Feb 2021 10:53:16 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0080.hostedemail.com [216.40.44.80]) by kanga.kvack.org (Postfix) with ESMTP id A88C98D00FD for ; Mon, 15 Feb 2021 10:53:16 -0500 (EST) Received: from smtpin20.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 72FA018022BE1 for ; Mon, 15 Feb 2021 15:53:16 +0000 (UTC) X-FDA: 77820946392.20.feast93_0d039532763c Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin20.hostedemail.com (Postfix) with ESMTP id 503C91810DA51 for ; Mon, 15 Feb 2021 15:53:16 +0000 (UTC) X-HE-Tag: feast93_0d039532763c X-Filterd-Recvd-Size: 6057 Received: from mail-pl1-f181.google.com (mail-pl1-f181.google.com [209.85.214.181]) by imf25.hostedemail.com (Postfix) with ESMTP for ; Mon, 15 Feb 2021 15:53:15 +0000 (UTC) Received: by mail-pl1-f181.google.com with SMTP id f8so2353702plg.5 for ; Mon, 15 Feb 2021 07:53:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=3e9p58enmPrHBj/qg6RhNzmlmUNgPoZWys+AfRFnkts=; b=RnWdyHBEmyUOIzHTTr0e0/OcEI4j2IT49LUcBBXYa/fsvM9ONHWMAwC2ek2w5jT1ne XjkgbNP4o5aj+ps3vJPS01bxUiSEebUfH1A2OUPv/7+gL92Jekmx0M7y/H9fyBp9N2TW IppdiI7upRht+jJOSaxlOgTVz9H4UCu/2gyo/tl+Lve+AXGXv/R9ZxNUbKJ4b2/l5aAS NZ5FKnJzptAXI1862MlAStC0MifUhGqqTxdr9wWvKcirpK1M2w3XQKSeS/6q1QUDSNRZ 2ssx74blDE7G6YilTwd76L+P43mdDv+ZoyASCdklIcqWlTuhjEOpZPvsBhDYzwjl6YQV eVFA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=3e9p58enmPrHBj/qg6RhNzmlmUNgPoZWys+AfRFnkts=; b=DsNbM7BN0g6Qv9u51Gq1ABnk6S8Va6zRdIyqxJ81wV1tdtKXqvErX5lVjyjxUIhrg8 ZHrqTd0z7gAnSjxFlpNwCsiz3HtfJZ8xg/R6Tt9upFLjlsc60YyeSSliV7RYd3Pr3F+h WGQVy5tTD1rfU1mf+OxUz2CJyBhT8sJIzCOANR2NDSXaqHT7VDz+jYt6MZw5cobtCbT5 MppqEMz9v+E79Ky8jeV7BxFnrj+WRFdQZ9hchL4L3/tIC2Exy1Nw+mtH9OGraDZRfpAh JXDDx6KEr4UqO0izLA3eIPRUsU7Y0aT6WzA9u7wSnSD5CiJwn48HuDXcdSm7uwE4zxeB UoeQ== X-Gm-Message-State: AOAM530mGI311JGLi8lQPaqoGPi6JWiWfykeviW8m0ak4e5AIcRiCEUg 0nQgOit89wLqhb4PwSR2nZc= X-Google-Smtp-Source: ABdhPJzs7iQp8Bu1myc2lzmtjCMtr7xo0mUxbPVeN24kaQ8+zyXdHKQ6o9EGAkDlxKD+0n+nSfGkEA== X-Received: by 2002:a17:90a:4a0d:: with SMTP id e13mr16271613pjh.96.1613404394549; Mon, 15 Feb 2021 07:53:14 -0800 (PST) Received: from localhost.localdomain ([50.236.19.102]) by smtp.gmail.com with ESMTPSA id i1sm19771215pfq.158.2021.02.15.07.53.07 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 15 Feb 2021 07:53:14 -0800 (PST) From: Yafang Shao To: pmladek@suse.com, willy@infradead.org, andriy.shevchenko@linux.intel.com, david@redhat.com, linmiaohe@huawei.com, vbabka@suse.cz, cl@linux.com, penberg@kernel.org, rientjes@google.com, iamjoonsoo.kim@lge.com, akpm@linux-foundation.org, rostedt@goodmis.org, sergey.senozhatsky@gmail.com, joe@perches.com Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Yafang Shao Subject: [PATCH v5 2/3] mm, slub: don't combine pr_err with INFO Date: Mon, 15 Feb 2021 23:51:40 +0800 Message-Id: <20210215155141.47432-3-laoar.shao@gmail.com> X-Mailer: git-send-email 2.24.3 (Apple Git-128) In-Reply-To: <20210215155141.47432-1-laoar.shao@gmail.com> References: <20210215155141.47432-1-laoar.shao@gmail.com> MIME-Version: 1.0 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: It is strange to combine "pr_err" with "INFO", so let's remove the prefix completely. This patch is motivated by David's comment[1]. - before the patch [ 8846.517809] INFO: Slab 0x00000000f42a2c60 objects=33 used=3 fp=0x0000000060d32ca8 flags=0x17ffffc0010200(slab|head) - after the patch [ 6343.396602] Slab 0x000000004382e02b objects=33 used=3 fp=0x000000009ae06ffc flags=0x17ffffc0010200(slab|head) [1]. https://lore.kernel.org/linux-mm/b9c0f2b6-e9b0-0c36-ebdd-2bc684c5a762@redhat.com/#t Suggested-by: Vlastimil Babka Signed-off-by: Yafang Shao Acked-by: Vlastimil Babka Reviewed-by: Miaohe Lin Reviewed-by: Andy Shevchenko Reviewed-by: David Hildenbrand Cc: Matthew Wilcox Acked-by: David Rientjes --- mm/slub.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/mm/slub.c b/mm/slub.c index ddd429832577..d66a7ebd21fe 100644 --- a/mm/slub.c +++ b/mm/slub.c @@ -615,7 +615,7 @@ static void print_track(const char *s, struct track *t, unsigned long pr_time) if (!t->addr) return; - pr_err("INFO: %s in %pS age=%lu cpu=%u pid=%d\n", + pr_err("%s in %pS age=%lu cpu=%u pid=%d\n", s, (void *)t->addr, pr_time - t->when, t->cpu, t->pid); #ifdef CONFIG_STACKTRACE { @@ -641,7 +641,7 @@ void print_tracking(struct kmem_cache *s, void *object) static void print_page_info(struct page *page) { - pr_err("INFO: 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=%#lx(%pGp)\n", page, page->objects, page->inuse, page->freelist, page->flags, &page->flags); @@ -698,7 +698,7 @@ static void print_trailer(struct kmem_cache *s, struct page *page, u8 *p) print_page_info(page); - pr_err("INFO: Object 0x%p @offset=%tu fp=0x%p\n\n", + pr_err("Object 0x%p @offset=%tu fp=0x%p\n\n", p, p - addr, get_freepointer(s, p)); if (s->flags & SLAB_RED_ZONE) @@ -791,7 +791,7 @@ static int check_bytes_and_report(struct kmem_cache *s, struct page *page, end--; slab_bug(s, "%s overwritten", what); - pr_err("INFO: 0x%p-0x%p @offset=%tu. First byte 0x%x instead of 0x%x\n", + pr_err("0x%p-0x%p @offset=%tu. First byte 0x%x instead of 0x%x\n", fault, end - 1, fault - addr, fault[0], value); print_trailer(s, page, object); @@ -3855,7 +3855,7 @@ static void list_slab_objects(struct kmem_cache *s, struct page *page, for_each_object(p, s, addr, page->objects) { if (!test_bit(__obj_to_index(s, addr, p), map)) { - pr_err("INFO: Object 0x%p @offset=%tu\n", p, p - addr); + pr_err("Object 0x%p @offset=%tu\n", p, p - addr); print_tracking(s, p); } } From patchwork Mon Feb 15 15:51:41 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yafang Shao X-Patchwork-Id: 12088647 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.5 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B4AE0C433DB for ; Mon, 15 Feb 2021 15:53:24 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 407A161494 for ; Mon, 15 Feb 2021 15:53:24 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 407A161494 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id D1A328D011C; Mon, 15 Feb 2021 10:53:23 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id CCAE58D00FD; Mon, 15 Feb 2021 10:53:23 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BE16F8D011C; Mon, 15 Feb 2021 10:53:23 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0095.hostedemail.com [216.40.44.95]) by kanga.kvack.org (Postfix) with ESMTP id A86808D00FD for ; Mon, 15 Feb 2021 10:53:23 -0500 (EST) Received: from smtpin06.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 73A4118022BF6 for ; Mon, 15 Feb 2021 15:53:23 +0000 (UTC) X-FDA: 77820946686.06.A9488EA Received: from mail-pg1-f172.google.com (mail-pg1-f172.google.com [209.85.215.172]) by imf12.hostedemail.com (Postfix) with ESMTP id 511B2DA for ; Mon, 15 Feb 2021 15:53:20 +0000 (UTC) Received: by mail-pg1-f172.google.com with SMTP id z21so4440226pgj.4 for ; Mon, 15 Feb 2021 07:53:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=4E1nnM6ZaInBESVeB5VZaUIJRc1fwF45IAGjtqazWmg=; b=YUJ59Vsx1Ga127DXK5+mjIbzGwFfJpB/Z3jROGhW8HlDgobdrSukwz1snyPO3MYBFd moS9Kqk8rfEkjI65EV1Uj7FKKDHVJAIi0pl9BU/+/amLq/c179hDddA3NWjskb5LTlwG bS4HJHL3k3+Mb7C3sz8Xm1rRdpOvHaD0TH1JPnMnOczq1KhgdpwAokBHbpm8AXsFMrz8 6RLztNJrvyno0aaYDr2kouh2jAoFECPXbBPczrlp3KpeIqAxfE7/bm5wHjoP5qEmV9/O Xy78qxmz9MUEInNVmsYZ6xErJYeE0NH3u6QQSSw2g7NR7Uu5BLzu3flFBZv1wTi3tP6S ahjw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=4E1nnM6ZaInBESVeB5VZaUIJRc1fwF45IAGjtqazWmg=; b=CtC0Ax+HCZ66MKnhnWUA+2JIiBo4Kk2JjWVi/4p/UPw3LL2+zql3CAKbNwFegZSU4s tdAAYEDdMrGLDHdTFLxlGhMszi5R6DAjLw0xioJAhA8TVPzmnQ8lJfo+fDQK8KQnn9Jo x3vAEHtWnAlu9bvVoXkQoX0KO4ab66MYkLTxjZSpMKkCL1Wwtl2I1XwcJuShKaAczY66 fnhErUgkRQ1HVR7bP8mfpmpmTFkTz8u/XfGETqHSFUJjNEj3+8wrVd2QTdGQmhM0VyIn KNC5DwSeqqjyzcGVdP0XxrFzhb+oOd2yCeed+NqXVJ404iGcuqQ4VOGHwJ6ZfWbJFUhc uGVw== X-Gm-Message-State: AOAM530QgWNlSzKSZM67U2RcSOCuOAHzourt4t3XibIG1Of+u/stpzXE in7YLHyaUPu0DCoRAb5ezjo= X-Google-Smtp-Source: ABdhPJx/8nHb7iHo0bu5n/F7o8RaHABs/aj3mosjk57ZVEoFsRESDBimsq6asncktIyJY1ta5wBwZg== X-Received: by 2002:a63:f956:: with SMTP id q22mr7473399pgk.115.1613404401978; Mon, 15 Feb 2021 07:53:21 -0800 (PST) Received: from localhost.localdomain ([50.236.19.102]) by smtp.gmail.com with ESMTPSA id i1sm19771215pfq.158.2021.02.15.07.53.14 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 15 Feb 2021 07:53:21 -0800 (PST) From: Yafang Shao To: pmladek@suse.com, willy@infradead.org, andriy.shevchenko@linux.intel.com, david@redhat.com, linmiaohe@huawei.com, vbabka@suse.cz, cl@linux.com, penberg@kernel.org, rientjes@google.com, iamjoonsoo.kim@lge.com, akpm@linux-foundation.org, rostedt@goodmis.org, sergey.senozhatsky@gmail.com, joe@perches.com Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Yafang Shao Subject: [PATCH v5 3/3] vsprintf: dump full information of page flags in pGp Date: Mon, 15 Feb 2021 23:51:41 +0800 Message-Id: <20210215155141.47432-4-laoar.shao@gmail.com> X-Mailer: git-send-email 2.24.3 (Apple Git-128) In-Reply-To: <20210215155141.47432-1-laoar.shao@gmail.com> References: <20210215155141.47432-1-laoar.shao@gmail.com> MIME-Version: 1.0 X-Stat-Signature: 1pfkynf9ehgwnjaqwax9xq8kpmmeywfh X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: 511B2DA Received-SPF: none (gmail.com>: No applicable sender policy available) receiver=imf12; identity=mailfrom; envelope-from=""; helo=mail-pg1-f172.google.com; client-ip=209.85.215.172 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1613404400-348639 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: Currently the pGp only shows the names of page flags, rather than the full information including section, node, zone, last cpupid and kasan tag. While it is not easy to parse these information manually because there're so many flavors. Let's interpret them in pGp as well. To be compitable with the existed format of pGp, the new introduced ones also use '|' as the separator, then the user tools parsing pGp won't need to make change, suggested by Matthew. The new information is tracked onto the end of the existed one. One example of the output in mm/slub.c as follows, - Before the patch, [ 6343.396602] Slab 0x000000004382e02b objects=33 used=3 fp=0x000000009ae06ffc flags=0x17ffffc0010200(slab|head) - After the patch, [ 8448.272530] Slab 0x0000000090797883 objects=33 used=3 fp=0x00000000790f1c26 flags=0x17ffffc0010200(slab|head|node=0|zone=2|lastcpupid=0x1fffff) The documentation and test cases are also updated. The output of the test cases as follows, [11585.830272] test_printf: loaded. [11585.830454] test_printf: all 388 tests passed [11585.831401] test_printf: unloaded. Signed-off-by: Yafang Shao Cc: David Hildenbrand Cc: Joe Perches Cc: Miaohe Lin Cc: Vlastimil Babka Cc: Andy Shevchenko Cc: Matthew Wilcox Cc: Petr Mladek Reviewed-by: Petr Mladek --- Documentation/core-api/printk-formats.rst | 2 +- lib/test_printf.c | 60 +++++++++++++++++---- lib/vsprintf.c | 66 +++++++++++++++++++++-- 3 files changed, 112 insertions(+), 16 deletions(-) diff --git a/Documentation/core-api/printk-formats.rst b/Documentation/core-api/printk-formats.rst index 160e710d992f..00d07c7eefd4 100644 --- a/Documentation/core-api/printk-formats.rst +++ b/Documentation/core-api/printk-formats.rst @@ -540,7 +540,7 @@ Flags bitfields such as page flags, gfp_flags :: - %pGp referenced|uptodate|lru|active|private + %pGp referenced|uptodate|lru|active|private|node=0|zone=2|lastcpupid=0x1fffff %pGg GFP_USER|GFP_DMA32|GFP_NOWARN %pGv read|exec|mayread|maywrite|mayexec|denywrite diff --git a/lib/test_printf.c b/lib/test_printf.c index 7ac87f18a10f..148773dfe97a 100644 --- a/lib/test_printf.c +++ b/lib/test_printf.c @@ -569,24 +569,68 @@ netdev_features(void) { } +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) +{ + unsigned long page_flags = 0; + unsigned long size = 0; + + flags &= BIT(NR_PAGEFLAGS) - 1; + if (flags) { + page_flags |= flags; + snprintf(cmp_buf + size, BUF_SIZE - size, "%s|", name); + size = strlen(cmp_buf); + } + +#ifdef SECTION_IN_PAGE_FLAGS + page_flags |= (sec & SECTIONS_MASK) << SECTIONS_PGSHIFT; + snprintf(cmp_buf + size, BUF_SIZE - size, "section=%#x|", sec); + size = strlen(cmp_buf); +#endif + + page_flags |= ((node & NODES_MASK) << NODES_PGSHIFT) | + ((zone & ZONES_MASK) << ZONES_PGSHIFT); + snprintf(cmp_buf + size, BUF_SIZE - size, "node=%d|zone=%d", node, zone); + size = strlen(cmp_buf); + +#ifndef LAST_CPUPID_NOT_IN_PAGE_FLAGS + page_flags |= (last_cpupid & LAST_CPUPID_MASK) << LAST_CPUPID_PGSHIFT; + snprintf(cmp_buf + size, BUF_SIZE - size, "|lastcpupid=%#x", last_cpupid); + size = strlen(cmp_buf); +#endif + +#if defined(CONFIG_KASAN_SW_TAGS) || defined(CONFIG_KASAN_HW_TAGS) + page_flags |= (tag & KASAN_TAG_MASK) << KASAN_TAG_PGSHIFT; + snprintf(cmp_buf + size, BUF_SIZE - size, "|kasantag=%#x", tag); + size = strlen(cmp_buf); +#endif + + test(cmp_buf, "%pGp", &page_flags); +} + static void __init flags(void) { unsigned long flags; - gfp_t gfp; char *cmp_buffer; + gfp_t gfp; + + cmp_buffer = kmalloc(BUF_SIZE, GFP_KERNEL); + if (!cmp_buffer) + return; flags = 0; - test("", "%pGp", &flags); + page_flags_test(0, 0, 0, 0, 0, flags, "", cmp_buffer); - /* Page flags should filter the zone id */ flags = 1UL << NR_PAGEFLAGS; - test("", "%pGp", &flags); + page_flags_test(0, 0, 0, 0, 0, flags, "", cmp_buffer); flags |= 1UL << PG_uptodate | 1UL << PG_dirty | 1UL << PG_lru | 1UL << PG_active | 1UL << PG_swapbacked; - test("uptodate|dirty|lru|active|swapbacked", "%pGp", &flags); - + page_flags_test(1, 1, 1, 0x1fffff, 1, flags, + "uptodate|dirty|lru|active|swapbacked", + cmp_buffer); flags = VM_READ | VM_EXEC | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC | VM_DENYWRITE; @@ -601,10 +645,6 @@ flags(void) gfp = __GFP_ATOMIC; test("__GFP_ATOMIC", "%pGg", &gfp); - cmp_buffer = kmalloc(BUF_SIZE, GFP_KERNEL); - if (!cmp_buffer) - return; - /* Any flags not translated by the table should remain numeric */ gfp = ~__GFP_BITS_MASK; snprintf(cmp_buffer, BUF_SIZE, "%#lx", (unsigned long) gfp); diff --git a/lib/vsprintf.c b/lib/vsprintf.c index 3b53c73580c5..0dc776f7dfa4 100644 --- a/lib/vsprintf.c +++ b/lib/vsprintf.c @@ -1916,6 +1916,66 @@ char *format_flags(char *buf, char *end, unsigned long flags, return buf; } +struct page_flags_fields { + int width; + int shift; + int mask; + const struct printf_spec *spec; + const char *name; +}; + +static const struct page_flags_fields pff[] = { + {SECTIONS_WIDTH, SECTIONS_PGSHIFT, SECTIONS_MASK, + &default_dec_spec, "section"}, + {NODES_WIDTH, NODES_PGSHIFT, NODES_MASK, + &default_dec_spec, "node"}, + {ZONES_WIDTH, ZONES_PGSHIFT, ZONES_MASK, + &default_dec_spec, "zone"}, + {LAST_CPUPID_WIDTH, LAST_CPUPID_PGSHIFT, LAST_CPUPID_MASK, + &default_flag_spec, "lastcpupid"}, + {KASAN_TAG_WIDTH, KASAN_TAG_PGSHIFT, KASAN_TAG_MASK, + &default_flag_spec, "kasantag"}, +}; + +static +char *format_page_flags(char *buf, char *end, unsigned long flags) +{ + unsigned long main_flags = flags & (BIT(NR_PAGEFLAGS) - 1); + bool append = false; + int i; + + /* Page flags from the main area. */ + if (main_flags) { + buf = format_flags(buf, end, main_flags, pageflag_names); + append = true; + } + + /* Page flags from the fields area */ + for (i = 0; i < ARRAY_SIZE(pff); i++) { + /* Skip undefined fields. */ + if (!pff[i].width) + continue; + + /* Format: Flag Name + '=' (equals sign) + Number + '|' (separator) */ + if (append) { + if (buf < end) + *buf = '|'; + buf++; + } + + buf = string(buf, end, pff[i].name, *pff[i].spec); + if (buf < end) + *buf = '='; + buf++; + buf = number(buf, end, (flags >> pff[i].shift) & pff[i].mask, + *pff[i].spec); + + append = true; + } + + return buf; +} + static noinline_for_stack char *flags_string(char *buf, char *end, void *flags_ptr, struct printf_spec spec, const char *fmt) @@ -1928,11 +1988,7 @@ char *flags_string(char *buf, char *end, void *flags_ptr, switch (fmt[1]) { case 'p': - flags = *(unsigned long *)flags_ptr; - /* Remove zone id */ - flags &= (1UL << NR_PAGEFLAGS) - 1; - names = pageflag_names; - break; + return format_page_flags(buf, end, *(unsigned long *)flags_ptr); case 'v': flags = *(unsigned long *)flags_ptr; names = vmaflag_names;