Re: [PATCH v2] mm, dump_page: do not crash with bad compound_mapcount()

2020-08-07 Thread John Hubbard
On 8/7/20 9:48 AM, Kirill A. Shutemov wrote: [...] +static inline int head_mapcount(struct page *head) +{ Do we want VM_BUG_ON_PAGE(!PageHead(head), head) here? Well, no. That was the point of the bug report -- by the time we called compound_mapcount, the page was no longer a head page.

Re: [PATCH v2] mm, dump_page: do not crash with bad compound_mapcount()

2020-08-07 Thread Kirill A. Shutemov
On Fri, Aug 07, 2020 at 04:10:29PM +0100, Matthew Wilcox wrote: > On Fri, Aug 07, 2020 at 05:35:04PM +0300, Kirill A. Shutemov wrote: > > On Tue, Aug 04, 2020 at 02:48:07PM -0700, John Hubbard wrote: > > > If a compound page is being split while dump_page() is being run on that > > > page, we can

Re: [PATCH v2] mm, dump_page: do not crash with bad compound_mapcount()

2020-08-07 Thread Matthew Wilcox
On Fri, Aug 07, 2020 at 05:35:04PM +0300, Kirill A. Shutemov wrote: > On Tue, Aug 04, 2020 at 02:48:07PM -0700, John Hubbard wrote: > > If a compound page is being split while dump_page() is being run on that > > page, we can end up calling compound_mapcount() on a page that is no > > longer

Re: [PATCH v2] mm, dump_page: do not crash with bad compound_mapcount()

2020-08-07 Thread Kirill A. Shutemov
On Thu, Aug 06, 2020 at 06:15:00PM +0100, Matthew Wilcox wrote: > On Thu, Aug 06, 2020 at 05:53:10PM +0200, Vlastimil Babka wrote: > > On 8/6/20 5:39 PM, Matthew Wilcox wrote: > > >> >> +++ b/mm/huge_memory.c > > >> >> @@ -2125,7 +2125,7 @@ static void __split_huge_pmd_locked(struct > > >> >>

Re: [PATCH v2] mm, dump_page: do not crash with bad compound_mapcount()

2020-08-07 Thread Kirill A. Shutemov
On Tue, Aug 04, 2020 at 02:48:07PM -0700, John Hubbard wrote: > If a compound page is being split while dump_page() is being run on that > page, we can end up calling compound_mapcount() on a page that is no > longer compound. This leads to a crash (already seen at least once in > the field), due

Re: [PATCH v2] mm, dump_page: do not crash with bad compound_mapcount()

2020-08-06 Thread Matthew Wilcox
On Thu, Aug 06, 2020 at 01:45:11PM +0200, Vlastimil Babka wrote: > How about this additional patch now that we have head_mapcoun()? (I wouldn't > go for squashing as the goal and scope is too different). I like it. It bothers me that the compiler doesn't know that compound_head(compound_head(x))

Re: [PATCH v2] mm, dump_page: do not crash with bad compound_mapcount()

2020-08-06 Thread Matthew Wilcox
On Thu, Aug 06, 2020 at 05:53:10PM +0200, Vlastimil Babka wrote: > On 8/6/20 5:39 PM, Matthew Wilcox wrote: > >> >> +++ b/mm/huge_memory.c > >> >> @@ -2125,7 +2125,7 @@ static void __split_huge_pmd_locked(struct > >> >> vm_area_struct *vma, pmd_t *pmd, > >> >> * Set PG_double_map before

Re: [PATCH v2] mm, dump_page: do not crash with bad compound_mapcount()

2020-08-06 Thread Vlastimil Babka
On 8/4/20 11:48 PM, John Hubbard wrote: > If a compound page is being split while dump_page() is being run on that > page, we can end up calling compound_mapcount() on a page that is no > longer compound. This leads to a crash (already seen at least once in > the field), due to the

Re: [PATCH v2] mm, dump_page: do not crash with bad compound_mapcount()

2020-08-06 Thread Matthew Wilcox
On Thu, Aug 06, 2020 at 05:13:05PM +0200, Vlastimil Babka wrote: > On 8/6/20 3:48 PM, Matthew Wilcox wrote: > > On Thu, Aug 06, 2020 at 01:45:11PM +0200, Vlastimil Babka wrote: > >> How about this additional patch now that we have head_mapcoun()? (I > >> wouldn't > >> go for squashing as the goal

Re: [PATCH v2] mm, dump_page: do not crash with bad compound_mapcount()

2020-08-06 Thread Vlastimil Babka
On 8/6/20 3:48 PM, Matthew Wilcox wrote: > On Thu, Aug 06, 2020 at 01:45:11PM +0200, Vlastimil Babka wrote: >> How about this additional patch now that we have head_mapcoun()? (I wouldn't >> go for squashing as the goal and scope is too different). > > I like it. It bothers me that the compiler

Re: [PATCH v2] mm, dump_page: do not crash with bad compound_mapcount()

2020-08-06 Thread Vlastimil Babka
On 8/6/20 5:39 PM, Matthew Wilcox wrote: >> >> +++ b/mm/huge_memory.c >> >> @@ -2125,7 +2125,7 @@ static void __split_huge_pmd_locked(struct >> >> vm_area_struct *vma, pmd_t *pmd, >> >>* Set PG_double_map before dropping compound_mapcount to avoid >> >>* false-negative page_mapped(). >>

[PATCH v2] mm, dump_page: do not crash with bad compound_mapcount()

2020-08-04 Thread John Hubbard
If a compound page is being split while dump_page() is being run on that page, we can end up calling compound_mapcount() on a page that is no longer compound. This leads to a crash (already seen at least once in the field), due to the VM_BUG_ON_PAGE() assertion inside compound_mapcount(). (The