linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Shivank Garg <shivagar@amd.com>
To: Matthew Wilcox <willy@infradead.org>, Calvin Owens <calvin@wbinvd.org>
Cc: linux-mm@kvack.org, Andrew Morton <akpm@linux-foundation.org>,
	David Hildenbrand <david@kernel.org>,
	Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
Subject: Re: [BUG next-20260105] khugepaged: kernel BUG at ./include/linux/xarray.h:1441
Date: Tue, 6 Jan 2026 01:24:03 +0530	[thread overview]
Message-ID: <d1cdf40c-9535-4d79-abaa-aa1675ec62f2@amd.com> (raw)
In-Reply-To: <aVwPii7dfR5owHbV@casper.infradead.org>

On 1/6/2026 12:52 AM, Matthew Wilcox wrote:
> On Mon, Jan 05, 2026 at 10:48:00AM -0800, Calvin Owens wrote:
>> [   16.042275][   T58] RIP: 0010:hpage_collapse_scan_file (./include/linux/xarray.h:1441 mm/khugepaged.c:2042 mm/khugepaged.c:2389)
> 
> Perfect.  2389 is the call to collapse_file(), then 2042 is
> xas_lock_irq().  And this is exactly the kind of thing we want to be
> catching; we drop the lock, then reuse the xa_state.  In the meantime,
> the xa_node might have been replaced, and the xa_state now has a pointer
> to a dead node.  It *might* still be safe in this instance; I'll look
> at this carefully for a bit and decide how best to fix it.
> 
> 

Hi,

I'm able to reproduce this issue locally. 
I tested with xas_reset() before taking lock and this fixed the issue.

Thanks,
Shivank

diff --git a/mm/khugepaged.c b/mm/khugepaged.c
index 6c8c35d3e0c9..641523111830 100644
--- a/mm/khugepaged.c
+++ b/mm/khugepaged.c
@@ -2039,6 +2039,7 @@ static int collapse_file(struct mm_struct *mm, unsigned long addr,
 			try_to_unmap(folio,
 					TTU_IGNORE_MLOCK | TTU_BATCH_FLUSH);
 
+		xas_reset(&xas);
 		xas_lock_irq(&xas);
 
 		VM_BUG_ON_FOLIO(folio != xa_load(xas.xa, index), folio);



  reply	other threads:[~2026-01-05 19:54 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-05 17:24 Calvin Owens
2026-01-05 17:51 ` Andrew Morton
2026-01-05 18:10   ` Calvin Owens
2026-01-05 18:31     ` Matthew Wilcox
2026-01-05 18:24 ` Matthew Wilcox
2026-01-05 18:48   ` Calvin Owens
2026-01-05 19:22     ` Matthew Wilcox
2026-01-05 19:54       ` Shivank Garg [this message]
2026-01-05 21:02         ` Matthew Wilcox

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=d1cdf40c-9535-4d79-abaa-aa1675ec62f2@amd.com \
    --to=shivagar@amd.com \
    --cc=akpm@linux-foundation.org \
    --cc=calvin@wbinvd.org \
    --cc=david@kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=lorenzo.stoakes@oracle.com \
    --cc=willy@infradead.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