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 X-Spam-Level: X-Spam-Status: No, score=-6.8 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS 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 B41A4C352A4 for ; Mon, 10 Feb 2020 12:42:11 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 766A321569 for ; Mon, 10 Feb 2020 12:42:11 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=shutemov-name.20150623.gappssmtp.com header.i=@shutemov-name.20150623.gappssmtp.com header.b="DDrYY0Uk" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 766A321569 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=shutemov.name Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 105F26B00EF; Mon, 10 Feb 2020 07:42:11 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 0B5E36B00F1; Mon, 10 Feb 2020 07:42:11 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id F0E1D6B00F2; Mon, 10 Feb 2020 07:42:10 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0074.hostedemail.com [216.40.44.74]) by kanga.kvack.org (Postfix) with ESMTP id D858C6B00EF for ; Mon, 10 Feb 2020 07:42:10 -0500 (EST) Received: from smtpin28.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 6FF76180AD801 for ; Mon, 10 Feb 2020 12:42:10 +0000 (UTC) X-FDA: 76474180020.28.patch44_4d16658c9c446 X-HE-Tag: patch44_4d16658c9c446 X-Filterd-Recvd-Size: 5739 Received: from mail-lj1-f195.google.com (mail-lj1-f195.google.com [209.85.208.195]) by imf26.hostedemail.com (Postfix) with ESMTP for ; Mon, 10 Feb 2020 12:42:09 +0000 (UTC) Received: by mail-lj1-f195.google.com with SMTP id o15so6962203ljg.6 for ; Mon, 10 Feb 2020 04:42:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=shutemov-name.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=vHZ+N2si2x4apra2Iai7q6cZCsf6Fbz1AFfd/UUQDLw=; b=DDrYY0UkHqzIcmtIFlzZbrmPmMGKGudZBQ9orFS+tqBF3Ipxtt5WhIT7bE2alkvK3q L5QvX/DQdpJ1Z6vsuRJpNcvEIvsDbIduLzOJNuKRjnnho9FoUpyW0dxPf2bw3BeZ3L7B /wlBnQZ80HH4XGbJO9PB3+viHsaq4BWOKmy4tS4KDiLzkS2nqLXymRxdF8bq8E+KBXO8 YeibPHPLwXgPQHzBn1BgV3qek4OldHFPNviUaGqtBBZnXmua5D98jq15L9hx5Mtt9LCV 83K/KopO6o3Zab8ueVHPGqw8NOyAzmgEUzHmho2srw8XTwiT5Y8YqYNzZuLOBwfULvM9 9L8w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=vHZ+N2si2x4apra2Iai7q6cZCsf6Fbz1AFfd/UUQDLw=; b=kGJZdYT+zwzg9NdQ2pbA3/UlbRR294D0HMQ6tOVRPbn4aV7EDz2h7GqjZffSJiY2Ui IUNDOEx43nNT8GZVQtqqTU5fJH9ibQ6HEPI7EBMT6w+xzWiJNX0G15h7izy/DBdevZi/ 8XmABhStSflpMFrI+hQbYV+dIwMyAkuGfNTO1f2vhKV2jC2N9k4ylLRAK36ZCh0Tc1dI ZwIgX87bE8mo2oPOTJ8DdW+wJ0fbZBmXIEHtY17FIfiqcGNKNVgy0VcswJ6Yb91oxb7W 23qmaWEpCfF3J7XXTLumNoB8b5et32fptJ7D2V3NFX9zixZq4bXwQijiwyp6ZvV5TW/P sHWw== X-Gm-Message-State: APjAAAXGKM8HfN4u/f8dfPQ8i95smTLff7IEA8SBPBlwkCm7BxdNgCjN ixowo1MApDHmSuB6LW0rx8EtLw== X-Google-Smtp-Source: APXvYqzSHY9yZ2vNO02OwrhJzdnq+BmWM4G8i1RypnkTWmcWj5sLPSjNsfhMf4XPP6uZNuvUdzWrBQ== X-Received: by 2002:a2e:8e84:: with SMTP id z4mr782474ljk.207.1581338528035; Mon, 10 Feb 2020 04:42:08 -0800 (PST) Received: from box.localdomain ([86.57.175.117]) by smtp.gmail.com with ESMTPSA id b1sm204140ljp.72.2020.02.10.04.42.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Feb 2020 04:42:07 -0800 (PST) Received: by box.localdomain (Postfix, from userid 1000) id F3043100B0A; Mon, 10 Feb 2020 15:42:25 +0300 (+03) Date: Mon, 10 Feb 2020 15:42:25 +0300 From: "Kirill A. Shutemov" To: Matthew Wilcox Cc: linux-mm@kvack.org, "Kirill A . Shutemov" , John Hubbard Subject: Re: [PATCH] mm: Improve dump_page() for compound pages Message-ID: <20200210124225.56cjwblfa7njgp5o@box> References: <20200208044415.30012-1-willy@infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200208044415.30012-1-willy@infradead.org> 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 Fri, Feb 07, 2020 at 08:44:15PM -0800, Matthew Wilcox wrote: > From: "Matthew Wilcox (Oracle)" > > There was no protection against a corrupted struct page having an > implausible compound_head(). Sanity check that a compound page has > a head within reach of the maximum allocatable page (this will need > to be adjusted if one of the plans to allocate 1GB pages comes to > fruition). In addition, > > - Print the mapping pointer using %p insted of %px. The actual value of > the pointer can be read out of the raw page dump and using %p gives a > chance to correlate it with an earlier printk of the mapping pointer > - Print the mapping pointer from the head page, not the tail page > (the tail ->mapping pointer may be in use for other purposes, eg part > of a list_head) > - Print the order of the page for compound pages > - Dump the raw head page as well as the raw page > - Print the refcount from the head page, not the tail page > > Suggested-by: Kirill A. Shutemov > Co-developed-by: John Hubbard > Signed-off-by: Matthew Wilcox (Oracle) > --- > mm/debug.c | 33 +++++++++++++++++++++++---------- > 1 file changed, 23 insertions(+), 10 deletions(-) > > diff --git a/mm/debug.c b/mm/debug.c > index ecccd9f17801..3594951cc408 100644 > --- a/mm/debug.c > +++ b/mm/debug.c > @@ -44,8 +44,10 @@ const struct trace_print_flags vmaflag_names[] = { > > void __dump_page(struct page *page, const char *reason) > { > + struct page *head = compound_head(page); > struct address_space *mapping; > bool page_poisoned = PagePoisoned(page); > + bool compound = PageCompound(page); > /* > * Accessing the pageblock without the zone lock. It could change to > * "isolate" again in the meantime, but since we are just dumping the > @@ -66,25 +68,32 @@ void __dump_page(struct page *page, const char *reason) > goto hex_only; > } > > - mapping = page_mapping(page); > + if (page < head || (page >= head + MAX_ORDER_NR_PAGES)) { > + /* Corrupt page, cannot call page_mapping */ > + mapping = page->mapping; > + head = page; > + compound = false; > + } else { > + mapping = page_mapping(page); > + } > > /* > * Avoid VM_BUG_ON() in page_mapcount(). > * page->_mapcount space in struct page is used by sl[aou]b pages to > * encode own info. > */ > - mapcount = PageSlab(page) ? 0 : page_mapcount(page); > + mapcount = PageSlab(head) ? 0 : page_mapcount(head); This is wrong. We want to see mapcount for the tail page, not head. -- Kirill A. Shutemov