From: Michal Hocko <mhocko@kernel.org>
To: Oscar Salvador <osalvador@suse.de>
Cc: akpm@linux-foundation.org, anshuman.khandual@arm.com,
william.kucharski@oracle.com, linux-mm@kvack.org,
linux-kernel@vger.kernel.org, Jan Kara <jack@suse.cz>,
Hugh Dickins <hughd@google.com>
Subject: Re: [PATCH] mm: Fix __dump_page when mapping->host is not set
Date: Fri, 15 Mar 2019 13:47:33 +0100 [thread overview]
Message-ID: <20190315124733.GE15672@dhcp22.suse.cz> (raw)
In-Reply-To: <20190315121826.23609-1-osalvador@suse.de>
[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 <osalvador@suse.de>
> ---
> 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
next prev parent reply other threads:[~2019-03-15 12:47 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-03-15 12:18 Oscar Salvador
2019-03-15 12:47 ` Michal Hocko [this message]
2019-03-15 14:33 ` Oscar Salvador
2019-03-15 17:21 ` Hugh Dickins
2019-03-16 8:34 ` Michal Hocko
2019-03-16 8:23 ` Michal Hocko
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190315124733.GE15672@dhcp22.suse.cz \
--to=mhocko@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=anshuman.khandual@arm.com \
--cc=hughd@google.com \
--cc=jack@suse.cz \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=osalvador@suse.de \
--cc=william.kucharski@oracle.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox