From patchwork Mon Feb 8 10:14:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yafang Shao X-Patchwork-Id: 12074777 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,URIBL_BLOCKED, 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 C427DC433E0 for ; Mon, 8 Feb 2021 10:15:11 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 516F464DE8 for ; Mon, 8 Feb 2021 10:15:11 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 516F464DE8 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 B6C3C6B006C; Mon, 8 Feb 2021 05:15:10 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id B44196B006E; Mon, 8 Feb 2021 05:15:10 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A59BF6B0070; Mon, 8 Feb 2021 05:15:10 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0065.hostedemail.com [216.40.44.65]) by kanga.kvack.org (Postfix) with ESMTP id 904716B006C for ; Mon, 8 Feb 2021 05:15:10 -0500 (EST) Received: from smtpin26.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 596078249980 for ; Mon, 8 Feb 2021 10:15:10 +0000 (UTC) X-FDA: 77794692780.26.show24_2d1513f275fd Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin26.hostedemail.com (Postfix) with ESMTP id 35B761804B656 for ; Mon, 8 Feb 2021 10:15:10 +0000 (UTC) X-HE-Tag: show24_2d1513f275fd X-Filterd-Recvd-Size: 4531 Received: from mail-ot1-f43.google.com (mail-ot1-f43.google.com [209.85.210.43]) by imf04.hostedemail.com (Postfix) with ESMTP for ; Mon, 8 Feb 2021 10:15:09 +0000 (UTC) Received: by mail-ot1-f43.google.com with SMTP id i20so13657364otl.7 for ; Mon, 08 Feb 2021 02:15:09 -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=AfzWei4umlGVQDuzDsu/6vxC6VqYoM19+5981ukNvio=; b=f747CuabzW6jNHZmUHMnJFaY9lfhzlNIpY/CW3aucW05mfIRlJI06OKmbh3oFbo28o K8w14VbfkqpQYBvM4wZDQPTGsm4rgqus+hLTuSS1NvDMZOfTccJ94JSJLqXxMsqYH9G/ yELGoNhfoJ0QcmTUDZfabkygXTmCThBq9z0LKkt0LoMMD7BqZ0j/rtXSht5TxZ7Tv22m QBXu7/9tci11r5a6OB11h1rFox3bn/jJ/iv5/f2kf71gBgB0z/MRxOSAMICo3OcJea9S +hUcaFWS76E6oz5kFrmXUfXqLKQaj6k0FQV0ZZxX6yhalplMMBbId+2AirlLhOibyrpc lvmw== 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=AfzWei4umlGVQDuzDsu/6vxC6VqYoM19+5981ukNvio=; b=eOchbO2Uh1E22n75QM0Yzp3Ue37c6T0xkF/Zq6r3AqA+kTZWot6TA3aoE/noPH+jqQ nHil3ExxSrsz1S0701F23C1540dE9Ara4OeDyPMfqPuRphZxBcq1PIl3m7xOHrUztW9y NnTpF4QREcDAX5U5sWgSJH7TTN93uOo5KR0GZux+oHDx8k6KguWKRjpv66WP6U9TvTl6 flkc5t3y2+FUB8SsOafQaaUH6vRbdYxJSzZy/xhHRy92Y/AavWXS0b+qzF+mbYWvTvUK +xeXrXIUbW0ejktROeeezT1vCRCec6JEr6PW2UqdVkdbPjZC//HCw+/uBIGHs82k6dgs 2qtA== X-Gm-Message-State: AOAM530xCyhDFo+mMB9ypxwVnsMb/eJjbb4HkCBEioWDrB5UCOZTOBcQ LtbeQjCSYVBGQeAmGraT3dc= X-Google-Smtp-Source: ABdhPJzIcYkSTcrgXQFDdnYYRK99jagCTwAnxOCgJDgXzdOQkUEOoLXdzrnsr5Hde1YeF151SZy4gw== X-Received: by 2002:a9d:71c6:: with SMTP id z6mr12266305otj.276.1612779309010; Mon, 08 Feb 2021 02:15:09 -0800 (PST) Received: from localhost.localdomain ([50.236.19.102]) by smtp.gmail.com with ESMTPSA id t3sm607226otb.36.2021.02.08.02.15.03 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 08 Feb 2021 02:15:08 -0800 (PST) From: Yafang Shao To: andriy.shevchenko@linux.intel.com, david@redhat.com, vbabka@suse.cz, willy@infradead.org, cl@linux.com, linmiaohe@huawei.com, penberg@kernel.org, rientjes@google.com, iamjoonsoo.kim@lge.com, akpm@linux-foundation.org, pmladek@suse.com, rostedt@goodmis.org, sergey.senozhatsky@gmail.com, joe@perches.com Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Yafang Shao Subject: [PATCH v3 1/3] mm, slub: use pGp to print page flags Date: Mon, 8 Feb 2021 18:14:37 +0800 Message-Id: <20210208101439.55474-2-laoar.shao@gmail.com> X-Mailer: git-send-email 2.24.3 (Apple Git-128) In-Reply-To: <20210208101439.55474-1-laoar.shao@gmail.com> References: <20210208101439.55474-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) Reviewed-by: David Hildenbrand Reviewed-by: Vlastimil Babka Acked-by: David Rientjes Acked-by: Christoph Lameter Signed-off-by: Yafang Shao Reviewed-by: Matthew Wilcox (Oracle) Reviewed-by: Miaohe Lin --- mm/slub.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/mm/slub.c b/mm/slub.c index 34dcc09e2ec9..87ff086e68a4 100644 --- a/mm/slub.c +++ b/mm/slub.c @@ -638,8 +638,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 8 10:14:38 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yafang Shao X-Patchwork-Id: 12074779 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,URIBL_BLOCKED, 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 A6F3AC433DB for ; Mon, 8 Feb 2021 10:15:17 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 246DA64E76 for ; Mon, 8 Feb 2021 10:15:17 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 246DA64E76 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 AD08F6B006E; Mon, 8 Feb 2021 05:15:16 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id A82AB6B0070; Mon, 8 Feb 2021 05:15:16 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9970E6B0071; Mon, 8 Feb 2021 05:15:16 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0092.hostedemail.com [216.40.44.92]) by kanga.kvack.org (Postfix) with ESMTP id 851EF6B006E for ; Mon, 8 Feb 2021 05:15:16 -0500 (EST) Received: from smtpin19.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 46D22181AEF1D for ; Mon, 8 Feb 2021 10:15:16 +0000 (UTC) X-FDA: 77794693032.19.self93_5600aef275fd Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin19.hostedemail.com (Postfix) with ESMTP id 254DF1AD1BA for ; Mon, 8 Feb 2021 10:15:16 +0000 (UTC) X-HE-Tag: self93_5600aef275fd X-Filterd-Recvd-Size: 5840 Received: from mail-ot1-f47.google.com (mail-ot1-f47.google.com [209.85.210.47]) by imf32.hostedemail.com (Postfix) with ESMTP for ; Mon, 8 Feb 2021 10:15:15 +0000 (UTC) Received: by mail-ot1-f47.google.com with SMTP id t25so13681890otc.5 for ; Mon, 08 Feb 2021 02:15: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=j9ylQWblYtnPRQvoph8wZjHjgqRFeyFluXHMnXSNEII=; b=awjEmhyhbPa7TQcywn8ev/HkkPlBSZJqzZvYodfSwHh8vMdr2noz+9czPlIAqP2wBD zunFWlnDaxpggVrd+plHciOdwF9/oWhdrR19PMwM+ZVOh5mhGtJUe92Kk6ThP61UnKxU dN1ngdbXFri6QfupQj5jfXkV4aUqIJWwv2JpFuumEHQPbiuytYPRZb8ufB3LHum9Me6B ZAWssz6+EyuZZ7uowOaenyYte+Urkwxx7jUmc3HamrrlhZVk2HRnN2p3VabmZ/xlSsup aDUKw7BDjS/gaP3vg9S7e2I/87aB06ttFeZaFcXcusAsZKMkqiGq05IvQ8Ed6MhOerEJ fzAQ== 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=j9ylQWblYtnPRQvoph8wZjHjgqRFeyFluXHMnXSNEII=; b=DSPeSLiT67S45xKUp+WOb9JKzVDx6yOoIsdiQBz4W3+09gfe2lZP+XUbxVKThah6ir ElEuA5gd/Z5SNcqQehRKQqfj36g3gTdTkyh7bx9nb1gJVc6JCbevmCKi49O4JaUMoii2 7DZIqTs6Wflx7dP5hBodhOFmQmKH9YVOk5+FoN/DXf4slizSIGf2xY3QpHU3dnc+FIjG 39sc1C+7ZLQPvqQd8criFtwfuPnVlToPVXXjM8xuSe75iagCYs2vj101CGPRV7auGilF AZVpf9fk9Au/k68pNRqFpbwoaKwr63TtFjp4Eve1KzM3ZJ4X4/LYwTFILVNnXLl9KsyX 6t0Q== X-Gm-Message-State: AOAM531dJXuBn4IE8Q3bkDTKFe+6io9mXes+ARcNsvJ9KIRaZGgcVoNQ htJoFc27W57O2tWPPgNzjEw= X-Google-Smtp-Source: ABdhPJySj3w4RJY0tl1RpCm1w7jT4MVla6K/FvhIrBymhMRaBZ22qFnBwEYLdS8HLfU15O32j3gdiA== X-Received: by 2002:a9d:6c51:: with SMTP id g17mr12595020otq.197.1612779315154; Mon, 08 Feb 2021 02:15:15 -0800 (PST) Received: from localhost.localdomain ([50.236.19.102]) by smtp.gmail.com with ESMTPSA id t3sm607226otb.36.2021.02.08.02.15.09 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 08 Feb 2021 02:15:14 -0800 (PST) From: Yafang Shao To: andriy.shevchenko@linux.intel.com, david@redhat.com, vbabka@suse.cz, willy@infradead.org, cl@linux.com, linmiaohe@huawei.com, penberg@kernel.org, rientjes@google.com, iamjoonsoo.kim@lge.com, akpm@linux-foundation.org, pmladek@suse.com, rostedt@goodmis.org, sergey.senozhatsky@gmail.com, joe@perches.com Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Yafang Shao Subject: [PATCH v3 2/3] mm, slub: don't combine pr_err with INFO Date: Mon, 8 Feb 2021 18:14:38 +0800 Message-Id: <20210208101439.55474-3-laoar.shao@gmail.com> X-Mailer: git-send-email 2.24.3 (Apple Git-128) In-Reply-To: <20210208101439.55474-1-laoar.shao@gmail.com> References: <20210208101439.55474-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 Cc: David Hildenbrand Signed-off-by: Yafang Shao Acked-by: Vlastimil Babka Reviewed-by: Miaohe Lin --- mm/slub.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/mm/slub.c b/mm/slub.c index 87ff086e68a4..2514c37ab4e4 100644 --- a/mm/slub.c +++ b/mm/slub.c @@ -612,7 +612,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 { @@ -638,7 +638,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); @@ -695,7 +695,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) @@ -788,7 +788,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); @@ -3854,7 +3854,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 8 10:14: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: 12074781 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,URIBL_BLOCKED, 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 27FBCC433E0 for ; Mon, 8 Feb 2021 10:15:26 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id A229B64E54 for ; Mon, 8 Feb 2021 10:15:25 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A229B64E54 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 26A8F6B0070; Mon, 8 Feb 2021 05:15:25 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 21D0B6B0071; Mon, 8 Feb 2021 05:15:25 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 134406B0072; Mon, 8 Feb 2021 05:15:25 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0183.hostedemail.com [216.40.44.183]) by kanga.kvack.org (Postfix) with ESMTP id F22866B0070 for ; Mon, 8 Feb 2021 05:15:24 -0500 (EST) Received: from smtpin10.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id BD6A81EE6 for ; Mon, 8 Feb 2021 10:15:24 +0000 (UTC) X-FDA: 77794693368.10.bike07_550ded7275fd Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin10.hostedemail.com (Postfix) with ESMTP id 94DC616A4A1 for ; Mon, 8 Feb 2021 10:15:24 +0000 (UTC) X-HE-Tag: bike07_550ded7275fd X-Filterd-Recvd-Size: 13702 Received: from mail-oi1-f175.google.com (mail-oi1-f175.google.com [209.85.167.175]) by imf44.hostedemail.com (Postfix) with ESMTP for ; Mon, 8 Feb 2021 10:15:24 +0000 (UTC) Received: by mail-oi1-f175.google.com with SMTP id k204so13467500oih.3 for ; Mon, 08 Feb 2021 02:15:24 -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=+XLXO2SWQmK2X0C7Wbz/yh9K6ApniIN/1/cELGqtW0Q=; b=Kdy9Sqn7DCDG1wqfJ081gBqy9T8jd5LM7NLDIuSz7ngUHNiA5Iie8JOLkCIZ3gpEE6 RJr2mP9RkMRrqAUYu9X2+HFgiUTe5gXt5oovX+fqeJYRz+FxnY/xdQvbsad53ptWgVVT pcGwZ1lx1UyDssXPknhcpPbZxU9dPav/pqdlku1gQlYBGHLlFVk+kPBVHqbX7gopsdks sb6yqdxhC8r/sV6qj3bOprCNp7IvF4AqjaYZiFxwUHyia5IjnS8mvCx/RxG/cllUi8J0 39qsy/Z9SDEJaG/2YRf09msRgP9PDYfY4BCkmAysZDWIfSDglpZ1Cxpe7/yne/6bQx3l Po3A== 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=+XLXO2SWQmK2X0C7Wbz/yh9K6ApniIN/1/cELGqtW0Q=; b=LcBjhWUQFjsvYwvbnOqUtTwV/kSzIzU7B2r05FC5wsad4Wt728XLvj0slE6z7KGa79 5xc7WXFa5DX3WVSZudOmuvNJ/l7X8/8eMXTQqHXTVuIvPW0RqAKOUtGUHPKqFgv+r26b O0/Nl3Q9s531AvwXi5qUD0zG4e9oJGN34g3XTPV3YXZ2NZ6KYl7YRsgkZIzFULkmDwJo gSaW2GC627wLUyBPLVcOob7XuRVdwAwjUag0KsGYEni9MLbcMIp/1qFDFjvFHmTmMJ7s PZ+H2GQTjl/n380izIqIDmKjNFLWTWuH5VTXOdKr9FBPd+NTFWrzXPWOIi4JRu/Q2SRM IJBw== X-Gm-Message-State: AOAM531WCZnV/h0rkHQ34eKxFexd3SY0enc3OPeBEaa3AiyPrR368/vr /zqL3HvskuGryEG+ywIngEU= X-Google-Smtp-Source: ABdhPJwOm0jkdq4/RyBfteF+RUUKSmIJHOSKSFHjBYk3+hHt6YbAUL4kLGOc74QoxLjc7fSQI+T5lQ== X-Received: by 2002:aca:1c08:: with SMTP id c8mr1131514oic.7.1612779323529; Mon, 08 Feb 2021 02:15:23 -0800 (PST) Received: from localhost.localdomain ([50.236.19.102]) by smtp.gmail.com with ESMTPSA id t3sm607226otb.36.2021.02.08.02.15.15 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 08 Feb 2021 02:15:23 -0800 (PST) From: Yafang Shao To: andriy.shevchenko@linux.intel.com, david@redhat.com, vbabka@suse.cz, willy@infradead.org, cl@linux.com, linmiaohe@huawei.com, penberg@kernel.org, rientjes@google.com, iamjoonsoo.kim@lge.com, akpm@linux-foundation.org, pmladek@suse.com, rostedt@goodmis.org, sergey.senozhatsky@gmail.com, joe@perches.com Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Yafang Shao Subject: [PATCH v3 3/3] vsprintf: introduce new format to dump full information of page flags Date: Mon, 8 Feb 2021 18:14:39 +0800 Message-Id: <20210208101439.55474-4-laoar.shao@gmail.com> X-Mailer: git-send-email 2.24.3 (Apple Git-128) In-Reply-To: <20210208101439.55474-1-laoar.shao@gmail.com> References: <20210208101439.55474-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: The existed pGp shows the names of page flags only, rather than the full information including section, node, zone, last cpuipid and kasan tag. While it is not easy to parse these information manually because there are so many flavors. We'd better interpret them in printf. To avoid breaking some tools which parsing pGp via debugfs or affecting the printf buffer, other new formats are introduced, so the user can choose what and in which order they want, suggested by Andy. These new introduced format as follows, pGpb: print other information first and then the names of page flags pGpl: print the names of page flags first and then the other info The differece between them looks like the difference between big-endian and little-endian, that's why they are named like that. The examples of the output as follows, %pGpb 0x17ffffc0010200(node=0|zone=2|lastcpupid=0x1fffff|slab|head) %pGpl 0x17ffffc0010200(slab|head|node=0|zone=2|lastcpupid=0x1fffff) 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 doc and test cases are also updated. Below is the output of the test cases, [ 4299.847655] test_printf: loaded. [ 4299.848301] test_printf: all 404 tests passed [ 4299.850371] test_printf: unloaded. Cc: David Hildenbrand Cc: Joe Perches Cc: Miaohe Lin Cc: Vlastimil Babka Cc: Andy Shevchenko Cc: Matthew Wilcox Signed-off-by: Yafang Shao --- Documentation/core-api/printk-formats.rst | 2 + lib/test_printf.c | 126 +++++++++++++++++++--- lib/vsprintf.c | 115 +++++++++++++++++++- 3 files changed, 226 insertions(+), 17 deletions(-) diff --git a/Documentation/core-api/printk-formats.rst b/Documentation/core-api/printk-formats.rst index 6d26c5c6ac48..56f8e0fc3963 100644 --- a/Documentation/core-api/printk-formats.rst +++ b/Documentation/core-api/printk-formats.rst @@ -539,6 +539,8 @@ Flags bitfields such as page flags, gfp_flags :: %pGp referenced|uptodate|lru|active|private + %pGpb node=0|zone=2|referenced|uptodate|lru|active|private + %pGpl referenced|uptodate|lru|active|private|node=0|zone=2 %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..af2945bb730a 100644 --- a/lib/test_printf.c +++ b/lib/test_printf.c @@ -569,24 +569,130 @@ netdev_features(void) { } +static void __init +page_flags_build_info(char *cmp_buf, int prefix, int sec, int node, int zone, + int last_cpupid, int kasan_tag, unsigned long *flags) +{ + unsigned long size = prefix; + +#ifdef SECTION_IN_PAGE_FLAGS + *flags |= (sec & SECTIONS_MASK) << SECTIONS_PGSHIFT; + snprintf(cmp_buf + size, BUF_SIZE - size, "section=%#x|", sec); + size = strlen(cmp_buf); +#endif + + *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 + *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) + *flags |= (tag & KASAN_TAG_MASK) << KASAN_TAG_PGSHIFT; + snprintf(cmp_buf + size, BUF_SIZE - size, "|kasantag=%#x", tag); + size = strlen(cmp_buf); +#endif +} + static void __init -flags(void) +page_flags_build_names(char *cmp_buf, int prefix, const char *expect, + unsigned long flags, unsigned long *page_flags) { + *page_flags |= flags; + snprintf(cmp_buf + prefix, BUF_SIZE - prefix, "%s", expect); +} + +static void __init +__page_flags_test(const char *expect, unsigned long flags) +{ + test(expect, "%pGp", &flags); +} + +static void __init +page_flags_test_be(char *cmp_buf, int sec, int node, int zone, + int last_cpupid, int kasan_tag, const char *name, + unsigned long flags) +{ + unsigned long page_flags = 0; + int size; + + page_flags_build_info(cmp_buf, 0, sec, node, zone, last_cpupid, + kasan_tag, &page_flags); + + if (*name) { + size = strlen(cmp_buf); + if (size < BUF_SIZE - 2) { + *(cmp_buf + size) = '|'; + *(cmp_buf + size + 1) = '\0'; + } + page_flags_build_names(cmp_buf, strlen(cmp_buf), name, flags, &page_flags); + } + + test(cmp_buf, "%pGpb", &page_flags); +} + +static void __init +page_flags_test_le(char *cmp_buf, int sec, int node, int zone, + int last_cpupid, int kasan_tag, const char *name, + unsigned long flags) +{ + unsigned long page_flags = 0; + int size = 0; + + if (*name) { + page_flags_build_names(cmp_buf, 0, name, flags, &page_flags); + size = strlen(cmp_buf); + if (size < BUF_SIZE - 2) { + *(cmp_buf + size) = '|'; + *(cmp_buf + size + 1) = '\0'; + } + size = strlen(cmp_buf); + } + + page_flags_build_info(cmp_buf, size, sec, node, zone, last_cpupid, + kasan_tag, &page_flags); + + test(cmp_buf, "%pGpl", &page_flags); +} + +static void __init +page_flags_test(char *cmp_buf) +{ + char *name = "uptodate|dirty|lru|active|swapbacked"; unsigned long flags; - gfp_t gfp; - char *cmp_buffer; flags = 0; - test("", "%pGp", &flags); + __page_flags_test("", flags); + page_flags_test_be(cmp_buf, 0, 0, 0, 0, 0, "", flags); + page_flags_test_le(cmp_buf, 0, 0, 0, 0, 0, "", flags); - /* Page flags should filter the zone id */ flags = 1UL << NR_PAGEFLAGS; - test("", "%pGp", &flags); + __page_flags_test("", flags); flags |= 1UL << PG_uptodate | 1UL << PG_dirty | 1UL << PG_lru - | 1UL << PG_active | 1UL << PG_swapbacked; - test("uptodate|dirty|lru|active|swapbacked", "%pGp", &flags); + | 1UL << PG_active | 1UL << PG_swapbacked; + __page_flags_test(name, flags); + page_flags_test_be(cmp_buf, 1, 1, 1, 0x1fffff, 1, name, flags); + page_flags_test_le(cmp_buf, 1, 1, 1, 0x1fffff, 1, name, flags); +} + +static void __init +flags(void) +{ + unsigned long flags; + gfp_t gfp; + char *cmp_buffer; + cmp_buffer = kmalloc(BUF_SIZE, GFP_KERNEL); + if (!cmp_buffer) + return; + + page_flags_test(cmp_buffer); flags = VM_READ | VM_EXEC | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC | VM_DENYWRITE; @@ -601,10 +707,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 14c9a6af1b23..c912cc9bddb0 100644 --- a/lib/vsprintf.c +++ b/lib/vsprintf.c @@ -1916,6 +1916,115 @@ char *format_flags(char *buf, char *end, unsigned long flags, return buf; } +struct page_flags_layout { + int width; + int shift; + int mask; + const struct printf_spec *spec; + const char *name; +}; + +static const struct page_flags_layout pfl[] = { + {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) +{ + DECLARE_BITMAP(mask, ARRAY_SIZE(pfl)); + unsigned long last; + int i; + + for (i = 0; i < ARRAY_SIZE(pfl); i++) + __assign_bit(i, mask, pfl[i].width); + + last = find_last_bit(mask, ARRAY_SIZE(pfl)); + + for_each_set_bit(i, mask, ARRAY_SIZE(pfl)) { + /* Format: Flag Name + '=' (equals sign) + Number + '|' (separator) */ + buf = string(buf, end, pfl[i].name, *pfl[i].spec); + + if (buf < end) + *buf = '='; + buf++; + buf = number(buf, end, (flags >> pfl[i].shift) & pfl[i].mask, + *pfl[i].spec); + + /* No separator for the last entry */ + if (i != last) { + if (buf < end) + *buf = '|'; + buf++; + } + } + + return buf; +} + +static +char *format_page_flags_be(char *buf, char *end, unsigned long flags) +{ + unsigned long mask = BIT(NR_PAGEFLAGS) - 1; + + buf = __format_page_flags(buf, end, flags); + + if (flags & mask) { + if (buf < end) + *buf = '|'; + buf++; + } + + return format_flags(buf, end, flags & mask, pageflag_names); +} + +static +char *format_page_flags_le(char *buf, char *end, unsigned long flags) +{ + unsigned long mask = BIT(NR_PAGEFLAGS) - 1; + + buf = format_flags(buf, end, flags & mask, pageflag_names); + + if (flags & mask) { + if (buf < end) + *buf = '|'; + buf++; + } + + return __format_page_flags(buf, end, flags & ~mask); +} + +static +char *format_page_flags(char *buf, char *end, void *flags_ptr, + struct printf_spec spec, const char *fmt) +{ + unsigned long flags = *(unsigned long *)flags_ptr; + unsigned long mask = BIT(NR_PAGEFLAGS) - 1; + + if (strlen(fmt) == 2) { + flags &= mask; + return format_flags(buf, end, flags, pageflag_names); + } + + switch (fmt[2]) { + case 'b': + return format_page_flags_be(buf, end, flags); + case 'l': + return format_page_flags_le(buf, end, flags); + default: + flags &= mask; + return format_flags(buf, end, flags, pageflag_names); + } +} + static noinline_for_stack char *flags_string(char *buf, char *end, void *flags_ptr, struct printf_spec spec, const char *fmt) @@ -1928,11 +2037,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, flags_ptr, spec, fmt); case 'v': flags = *(unsigned long *)flags_ptr; names = vmaflag_names;