Received: by 2002:ac0:a874:0:0:0:0:0 with SMTP id c49csp414600ima; Fri, 15 Mar 2019 05:49:46 -0700 (PDT) X-Google-Smtp-Source: APXvYqwIxEM5ToToV6jhHFizeRB2qsB0zRIUAidgPI+zEtm/gBYqsgO88/U9EiWwq0OQlqNLNnXv X-Received: by 2002:a17:902:9008:: with SMTP id a8mr4130668plp.38.1552654186793; Fri, 15 Mar 2019 05:49:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1552654186; cv=none; d=google.com; s=arc-20160816; b=k3ubiUzitAlWQFkIfXmT7BOYvCB4jrnSvf/9N9ABkqt0ieNkedBSfPQNKZvHsafjdd q8XuT1G+j9SbSZAWRWsHlEP0nuTw0UoWeijfZXpPXOdKj+3FiVQczDMYzuiqxIoPT9aJ nhGBz8dheM3OFdm2/fibIRDHzHwRSjdwLqX9cQvuD7YXpWfEDyMnaCdcubjOzGYDR46d MnkuyFh5/Lh7aAAZ4VRr9GMcLDDiYo490oUqrMZ9ClqbFv4bleQ5ekBWCgykAitIXCaV 0kjEi4hu1ktXAr0MydG1Gx0Gbt1mQSIADP+OFxIlfZiPYPVTgtSo0JdgzoQNoQ4l40A7 5asQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=eZBtUAJr3wktdAqHIEK90tllrFtORHScIG821hL0ZGc=; b=mSpML4s5uDLw0FyiV/6HI20lTGHmb4UsMX6K7Lpwm6jLfCD44emQnaFV6p12mPBpT2 KKRSWDCrEk+Ws445PDHALhBOrcQ2Sny8cXggJhPjeRuJbpfBEroutlIha1Dq6XNqD0Kc 1wuQtiWb73sKq2dQaX6MhB8lg9ZBrpsXoPc8SiN69VLrU/y5dJbelKFUZi064c73YHYO ssFGf+kgqJTntAaBzFGlLrerMTDmC5MH0S9+eGbgGZAQLEVgM0Xk30Wvy0+dL4XMWn1W CyLbVzcyHPfbrIULct32cbAjmY52PNZWNhOvzdbnm+AlDXzlL3JK3oOyEJ82FTIRMW8Z w7LQ== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a3si1808598pff.139.2019.03.15.05.49.32; Fri, 15 Mar 2019 05:49:46 -0700 (PDT) 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729057AbfCOMrh (ORCPT + 99 others); Fri, 15 Mar 2019 08:47:37 -0400 Received: from mx2.suse.de ([195.135.220.15]:59202 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727492AbfCOMrh (ORCPT ); Fri, 15 Mar 2019 08:47:37 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id C9C45AFCC; Fri, 15 Mar 2019 12:47:35 +0000 (UTC) Date: Fri, 15 Mar 2019 13:47:33 +0100 From: Michal Hocko To: Oscar Salvador Cc: akpm@linux-foundation.org, anshuman.khandual@arm.com, william.kucharski@oracle.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Jan Kara , Hugh Dickins Subject: Re: [PATCH] mm: Fix __dump_page when mapping->host is not set Message-ID: <20190315124733.GE15672@dhcp22.suse.cz> References: <20190315121826.23609-1-osalvador@suse.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190315121826.23609-1-osalvador@suse.de> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [Cc Jack and Hugh - the full patch is http://lkml.kernel.org/r/20190315121826.23609-1-osalvador@suse.de] On Fri 15-03-19 13:18:26, Oscar Salvador wrote: > While debugging something, I added a dump_page() into do_swap_page(), > and I got the splat from below. > The issue happens when dereferencing mapping->host in __dump_page(): > > ... > else if (mapping) { > pr_warn("%ps ", mapping->a_ops); > if (mapping->host->i_dentry.first) { > struct dentry *dentry; > dentry = container_of(mapping->host->i_dentry.first, struct dentry, d_u.d_alias); > pr_warn("name:\"%pd\" ", dentry); > } > } > ... > > Swap address space does not contain an inode information, and so mapping->host > equals NULL. > > Although the dump_page() call was added artificially into do_swap_page(), > I am not sure if we can hit this from any other path, so it looks worth > fixing it. It is certainly worth fixing. We cannot assume anything about the calling context for __dump_page > We can easily do that by cheking mapping->host first. [...] The splat is still surprising to me because I thought that all file backed mappings have a host. Swap file/partition certainly has a mapping but swapcache mapping is special because the underlying swap storage is hidden in the swap_info_struct. I am wondering whether we should do that special casing for PageSwapCache in __dump_page rather than hid the mapping details instead diff --git a/mm/debug.c b/mm/debug.c index 1611cf00a137..499c26d5ebe5 100644 --- a/mm/debug.c +++ b/mm/debug.c @@ -78,6 +78,9 @@ void __dump_page(struct page *page, const char *reason) else if (PageKsm(page)) pr_warn("ksm "); else if (mapping) { + if (PageSwapCache(page)) + mapping = page_swap_info(page)->swap_file->f_mapping; + pr_warn("%ps ", mapping->a_ops); if (mapping->host->i_dentry.first) { struct dentry *dentry; But I am not really sure this will work for all swap cases. Thanks for reporting this Oscar! > Fixes: 1c6fb1d89e73c ("mm: print more information about mapping in __dump_page") > Signed-off-by: Oscar Salvador > --- > mm/debug.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/mm/debug.c b/mm/debug.c > index c0b31b6c3877..7759f12a8fbb 100644 > --- a/mm/debug.c > +++ b/mm/debug.c > @@ -79,7 +79,7 @@ void __dump_page(struct page *page, const char *reason) > pr_warn("ksm "); > else if (mapping) { > pr_warn("%ps ", mapping->a_ops); > - if (mapping->host->i_dentry.first) { > + if (mapping->host && mapping->host->i_dentry.first) { > struct dentry *dentry; > dentry = container_of(mapping->host->i_dentry.first, struct dentry, d_u.d_alias); > pr_warn("name:\"%pd\" ", dentry); > -- > 2.13.7 -- Michal Hocko SUSE Labs