Message ID | 20200709202117.7216-2-willy@infradead.org (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | Improvements for dump_page() | expand |
On 2020-07-09 13:21, Matthew Wilcox (Oracle) wrote: > If we can't call page_mapping() to get the page mapping, handle the > anon/ksm/movable bits correctly. Hi Matthew, I see why you did this, as otherwise the new printing won't work. > > Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org> > --- > mm/debug.c | 7 ++++++- > 1 file changed, 6 insertions(+), 1 deletion(-) > > diff --git a/mm/debug.c b/mm/debug.c > index 4f376514744d..e5de63406b59 100644 > --- a/mm/debug.c > +++ b/mm/debug.c > @@ -70,7 +70,12 @@ void __dump_page(struct page *page, const char *reason) > > if (page < head || (page >= head + MAX_ORDER_NR_PAGES)) { > /* Corrupt page, cannot call page_mapping */ It's tricky to step lightly through the debris of corrupted page pointer here, but how about this updated comment, to replace the one-liner above: /* * Corrupt page, so we cannot call page_mapping. Instead, do a * safe subset of the steps that page_mapping() does. Caution: * this will be misleading for tail pages, PageSwapCache pages, * and potentially other situations. (See the page_mapping() * implementation for what's missing here.) */ > - mapping = page->mapping; > + unsigned long tmp = (unsigned long)page->mapping; > + > + if (tmp & PAGE_MAPPING_ANON) > + mapping = NULL; > + else > + mapping = (void *)(tmp & ~PAGE_MAPPING_FLAGS); > head = page; > compound = false; > } else { > thanks,
On 2020-07-10 18:30, John Hubbard wrote: > On 2020-07-09 13:21, Matthew Wilcox (Oracle) wrote: >> If we can't call page_mapping() to get the page mapping, handle the >> anon/ksm/movable bits correctly. > > Hi Matthew, > > I see why you did this, as otherwise the new printing won't work. Oh, and I forget to add: my only comment was just a documentation suggestion, not critical at all, and so: Reviewed-by: John Hubbard <jhubbard@nvidia.com> thanks,
On 7/9/20 10:21 PM, Matthew Wilcox (Oracle) wrote: > If we can't call page_mapping() to get the page mapping, handle the > anon/ksm/movable bits correctly. > > Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org> Acked-by: Vlastimil Babka <vbabka@suse.cz> John's updated comment looks fine too. > --- > mm/debug.c | 7 ++++++- > 1 file changed, 6 insertions(+), 1 deletion(-) > > diff --git a/mm/debug.c b/mm/debug.c > index 4f376514744d..e5de63406b59 100644 > --- a/mm/debug.c > +++ b/mm/debug.c > @@ -70,7 +70,12 @@ void __dump_page(struct page *page, const char *reason) > > if (page < head || (page >= head + MAX_ORDER_NR_PAGES)) { > /* Corrupt page, cannot call page_mapping */ > - mapping = page->mapping; > + unsigned long tmp = (unsigned long)page->mapping; > + > + if (tmp & PAGE_MAPPING_ANON) > + mapping = NULL; > + else > + mapping = (void *)(tmp & ~PAGE_MAPPING_FLAGS); > head = page; > compound = false; > } else { >
diff --git a/mm/debug.c b/mm/debug.c index 4f376514744d..e5de63406b59 100644 --- a/mm/debug.c +++ b/mm/debug.c @@ -70,7 +70,12 @@ void __dump_page(struct page *page, const char *reason) if (page < head || (page >= head + MAX_ORDER_NR_PAGES)) { /* Corrupt page, cannot call page_mapping */ - mapping = page->mapping; + unsigned long tmp = (unsigned long)page->mapping; + + if (tmp & PAGE_MAPPING_ANON) + mapping = NULL; + else + mapping = (void *)(tmp & ~PAGE_MAPPING_FLAGS); head = page; compound = false; } else {
If we can't call page_mapping() to get the page mapping, handle the anon/ksm/movable bits correctly. Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org> --- mm/debug.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)