From: "Petr Vaněk" <arkamar@atlas.cz>
To: Matthew Wilcox <willy@infradead.org>
Cc: Juergen Gross <jgross@suse.com>,
linux-kernel@vger.kernel.org,
Kevin Brodsky <kevin.brodsky@arm.com>,
Andrew Morton <akpm@linux-foundation.org>,
linux-mm@kvack.org, x86@kernel.org,
xen-devel@lists.xenproject.org, linux-arch@vger.kernel.org
Subject: Re: Regression from a9b3c355c2e6 ("asm-generic: pgalloc: provide generic __pgd_{alloc,free}") with CONFIG_DEBUG_VM_PGFLAGS=y and Xen
Date: Wed, 16 Apr 2025 15:53:25 +0200 [thread overview]
Message-ID: <2025416135325-Z_-2VTPsw81jMgCm-arkamar@atlas.cz> (raw)
In-Reply-To: <Z_-lj5kCg084MXRI@casper.infradead.org>
On Wed, Apr 16, 2025 at 01:41:51PM +0100, Matthew Wilcox wrote:
> On Wed, Apr 16, 2025 at 02:07:20PM +0200, Petr Vaněk wrote:
> > I have discovered a regression introduced in commit a9b3c355c2e6
> > ("asm-generic: pgalloc: provide generic __pgd_{alloc,free}") [1,2] in
> > kernel version 6.14. The problem occurs when the x86 kernel is
> > configured with CONFIG_DEBUG_VM_PGFLAGS=y and is run as a PV Dom0 in Xen
> > 4.19.1. During the startup, the kernel panics with the error log below.
>
> You also have to have CONFIG_MITIGATION_PAGE_TABLE_ISOLATION enabled
> to hit this problem, otherwise we allocate an order-0 page.
Indeed, the issue disappears when I disable
CONFIG_MITIGATION_PAGE_TABLE_ISOLATION.
> > The commit changed PGD allocation path. In the new implementation
> > _pgd_alloc allocates memory with __pgd_alloc, which indirectly calls
> >
> > alloc_pages_noprof(gfp | __GFP_COMP, order);
> >
> > This is in contrast to the old behavior, where __get_free_pages was
> > used, which indirectly called
> >
> > alloc_pages_noprof(gfp_mask & ~__GFP_HIGHMEM, order);
> >
> > The key difference is that the new allocator can return a compound page.
> > When xen_pin_page is later called on such a page, it call
> > TestSetPagePinned function, which internally uses the PF_NO_COMPOUND
> > macro. This macro enforces VM_BUG_ON_PGFLAGS if PageCompound is true,
> > triggering the panic when CONFIG_DEBUG_VM_PGFLAGS is enabled.
>
> I suspect the right thing to do here is to change the PF_NO_COMPOUND to
> PF_HEAD. Probably for all of these:
>
> /* Xen */
> PAGEFLAG(Pinned, pinned, PF_NO_COMPOUND)
> TESTSCFLAG(Pinned, pinned, PF_NO_COMPOUND)
> PAGEFLAG(SavePinned, savepinned, PF_NO_COMPOUND);
> PAGEFLAG(Foreign, foreign, PF_NO_COMPOUND);
> PAGEFLAG(XenRemapped, xen_remapped, PF_NO_COMPOUND)
> TESTCLEARFLAG(XenRemapped, xen_remapped, PF_NO_COMPOUND)
>
> Could you give that a try?
Yes, I could. Changing PF_NO_COMPOUND to PF_HEAD in those lines resolves
the issue for me.
Petr
next prev parent reply other threads:[~2025-04-16 13:53 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-16 12:07 Petr Vaněk
2025-04-16 12:41 ` Matthew Wilcox
2025-04-16 13:53 ` Petr Vaněk [this message]
2025-04-16 12:57 ` Jürgen Groß
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=2025416135325-Z_-2VTPsw81jMgCm-arkamar@atlas.cz \
--to=arkamar@atlas.cz \
--cc=akpm@linux-foundation.org \
--cc=jgross@suse.com \
--cc=kevin.brodsky@arm.com \
--cc=linux-arch@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=willy@infradead.org \
--cc=x86@kernel.org \
--cc=xen-devel@lists.xenproject.org \
/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