Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp5130974ybl; Tue, 14 Jan 2020 04:06:06 -0800 (PST) X-Google-Smtp-Source: APXvYqwSFISVO2dP3I4tpLFBsFQZeFYVGz1SSs5r6PeYwhFNUvo+b69CTBEOrmaIDFZrmCy6vKeo X-Received: by 2002:a9d:7cd9:: with SMTP id r25mr15463178otn.326.1579003566890; Tue, 14 Jan 2020 04:06:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579003566; cv=none; d=google.com; s=arc-20160816; b=St08wyCWA4Jt9QpgO690FRZ1nMRUmfAMv0ELNuW9iOpl5CNkDGC6D3N6f1F1NWK2D/ dXSs+Nl4d5UodeKHBOq7z4eFMdR9VvmeSddTqWgqq4UEDsPHK6I8SiEGQF3Or/SwVPZu 9k6LuKf+wBiLQjNwRumAO1uGrVZ7NAVMuDXDGMeqGkupuiKinqC4iuAUqDM/ZxaSVYi3 t2tool6hrx8VXY+G2/X6e5Gi4vPdLP3WwtvXTHUrifMocDHp8KmDZ3MdqaW/1c56ZplO CXbH+XM874dsFG3aGlrh8sKhCKl0daAP0V7w8u+Y6XifnTQorsvccYFehMsS1kcMYvKH jKEQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=39seNANsZrW2+k0gV+rr8ZygK0Nid4qUyaMYrLfeoiU=; b=neEW2oKl8NBx/VUebNHszTXKitMKBf48yWPbuH1O/2Vwdm1JIHyBTblGxPNxlZQ+PW S4vzV5I8ZB/z7UHStqKUXL1rTCDDHaIYzsFK8EqPlTq80N5ffzO+mcZbyH86NBkj568R x1JIETv8is2c0a+nU4lr1qBxasPWxqZmmpM7iL8JJjf8YF/WhshKRUfp53uZyyUCBiSb 7UKQcILHDA+5StNSowrRfA4IBck/t0JR+1wdpxoEd88FwhMjiXW0iwa12Zq//aaASFpN 53UdbL2ymKZuIqp/bMY1VeAiCpnnCx5fhNLixq9pDFqhmdJ7TsKc1vy2bJFcTjEq80n4 ZfYA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a9si7325667oid.132.2020.01.14.04.05.44; Tue, 14 Jan 2020 04:06:06 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729652AbgANMEf (ORCPT + 99 others); Tue, 14 Jan 2020 07:04:35 -0500 Received: from mx2.suse.de ([195.135.220.15]:41866 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725956AbgANMEf (ORCPT ); Tue, 14 Jan 2020 07:04:35 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 9E1C9AE34; Tue, 14 Jan 2020 12:04:32 +0000 (UTC) Subject: [PATCH] mm, debug: always print flags in dump_page() To: Michal Hocko , linux-mm@kvack.org, Andrew Morton Cc: Anshuman Khandual , David Hildenbrand , Qian Cai , Oscar Salvador , Mel Gorman , Mike Rapoport , Dan Williams , Pavel Tatashin , linux-kernel@vger.kernel.org, Ralph Campbell References: <49fa7dea-00ac-155f-e7b7-eeca206556b5@arm.com> <6A58E80B-7A5F-4CAD-ACF1-89BCCBE4D3B1@lca.pw> <20200114091013.GD19428@dhcp22.suse.cz> <1f3ff7fc-2f6b-d8e5-85a5-078f0e1a0daf@suse.cz> <20200114113230.GM19428@dhcp22.suse.cz> From: Vlastimil Babka Message-ID: <9f884d5c-ca60-dc7b-219c-c081c755fab6@suse.cz> Date: Tue, 14 Jan 2020 13:04:31 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.3.1 MIME-Version: 1.0 In-Reply-To: <20200114113230.GM19428@dhcp22.suse.cz> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 1/14/20 12:32 PM, Michal Hocko wrote: > On Tue 14-01-20 11:23:52, Vlastimil Babka wrote: >> On 1/14/20 10:10 AM, Michal Hocko wrote: >> > [Cc Ralph] >> >> The reason is dump_page() does not print page->flags universally >> >> and only does so for KSM, Anon and File pages while excluding >> >> reserved pages at boot. Wondering should not we make printing >> >> page->flags universal ? >> > >> > We used to do that and this caught me as a surprise when looking again. >> > This is a result of 76a1850e4572 ("mm/debug.c: __dump_page() prints an >> > extra line") which is a cleanup patch and I suspect this result was not >> > anticipated. >> > >> > The following will do the trick but I cannot really say I like the code >> > duplication. pr_cont in this case sounds like a much cleaner solution to >> > me. >> >> How about this then? > > Yes makes sense as well. Ok here's a proper formatted patch ----8<---- From 7b673c45bc16526586ae8ea6fba416a547baa04e Mon Sep 17 00:00:00 2001 From: Vlastimil Babka Date: Tue, 14 Jan 2020 12:52:48 +0100 Subject: [PATCH] mm, debug: always print flags in dump_page() Commit 76a1850e4572 ("mm/debug.c: __dump_page() prints an extra line") inadvertently removed printing of page flags for pages that are neither anon nor ksm nor have a mapping. Fix that. Using pr_cont() again would be a solution, but the commit explicitly removed its use. Avoiding the danger of mixing up split lines from multiple CPUs might be beneficial for near-panic dumps like this, so fix this without reintroducing pr_cont(). Reported-by: Anshuman Khandual Reported-by: Michal Hocko Fixes: 76a1850e4572 ("mm/debug.c: __dump_page() prints an extra line") Signed-off-by: Vlastimil Babka --- mm/debug.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/mm/debug.c b/mm/debug.c index 0461df1207cb..6a52316af839 100644 --- a/mm/debug.c +++ b/mm/debug.c @@ -47,6 +47,7 @@ void __dump_page(struct page *page, const char *reason) struct address_space *mapping; bool page_poisoned = PagePoisoned(page); int mapcount; + char *type = ""; /* * If struct page is poisoned don't access Page*() functions as that @@ -78,9 +79,9 @@ void __dump_page(struct page *page, const char *reason) page, page_ref_count(page), mapcount, page->mapping, page_to_pgoff(page)); if (PageKsm(page)) - pr_warn("ksm flags: %#lx(%pGp)\n", page->flags, &page->flags); + type = "ksm "; else if (PageAnon(page)) - pr_warn("anon flags: %#lx(%pGp)\n", page->flags, &page->flags); + type = "anon "; else if (mapping) { if (mapping->host && mapping->host->i_dentry.first) { struct dentry *dentry; @@ -88,10 +89,11 @@ void __dump_page(struct page *page, const char *reason) pr_warn("%ps name:\"%pd\"\n", mapping->a_ops, dentry); } else pr_warn("%ps\n", mapping->a_ops); - pr_warn("flags: %#lx(%pGp)\n", page->flags, &page->flags); } BUILD_BUG_ON(ARRAY_SIZE(pageflag_names) != __NR_PAGEFLAGS + 1); + pr_warn("%sflags: %#lx(%pGp)\n", type, page->flags, &page->flags); + hex_only: print_hex_dump(KERN_WARNING, "raw: ", DUMP_PREFIX_NONE, 32, sizeof(unsigned long), page, -- 2.24.1