linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Matthew Wilcox <willy@infradead.org>
To: Mikhail Pletnev <mmp.dux@gmail.com>
Cc: Thorsten Leemhuis <regressions@leemhuis.info>,
	bugzilla-daemon@kernel.org, linux-mm@kvack.org,
	Andrew Morton <akpm@linux-foundation.org>,
	decedion@gmail.com
Subject: Re: [Bug 216646] having TRANSPARENT_HUGEPAGE enabled hangs some applications (supervisor read access in kernel mode)
Date: Mon, 5 Dec 2022 20:25:11 +0000	[thread overview]
Message-ID: <Y45Tp1Br2Em8e3Fr@casper.infradead.org> (raw)
In-Reply-To: <20221203014420.76281b930dbc64f51eda0f8b@gmail.com>

On Sat, Dec 03, 2022 at 01:44:20AM +0300, Mikhail Pletnev wrote:
> On Fri, 2 Dec 2022 21:57:09 +0000
> Matthew Wilcox <willy@infradead.org> wrote:
> 
> > On Fri, Dec 02, 2022 at 04:58:42PM +0000, Matthew Wilcox wrote:
> > > Landing on 793917d997df makes a lot more sense.  That's where we
> > > actually start using large folios.  It doesn't really help narrow
> > > down the problem.  I have an idea for what it might be; patch to
> > > try will follow.  But I'll need feedback by email.
> > 
> > This will give us a bit more information when it does happen.
> > Further patch to catch it earlier will come "soon".
> > 
> > diff --git a/lib/xarray.c b/lib/xarray.c
> > index 6f47f6375808..b358b4e1dac6 100644
> > --- a/lib/xarray.c
> > +++ b/lib/xarray.c
> > @@ -6,6 +6,7 @@
> >   * Author: Matthew Wilcox <willy@infradead.org>
> >   */
> >  
> > +#define XA_DEBUG
> >  #include <linux/bitmap.h>
> >  #include <linux/export.h>
> >  #include <linux/list.h>
> > @@ -207,6 +208,12 @@ static void *xas_descend(struct xa_state *xas, struct xa_node *node)
> >  	if (xa_is_sibling(entry)) {
> >  		offset = xa_to_sibling(entry);
> >  		entry = xa_entry(xas->xa, node, offset);
> > +
> > +		if (xa_is_sibling(entry)) {
> > +			printk("***BAD SIBLING*** index %ld offset %d\n",
> > +					xas->xa_index, offset);
> > +			xa_dump_node(node);
> > +		}
> >  	}
> >  
> >  	xas->xa_offset = offset;
> 
> here is the crash with your patch (full dmesg in attachement):

Thanks!  I think this may be the problem ...

diff --git a/include/linux/xarray.h b/include/linux/xarray.h
index 44dd6d6e01bc..cc1fd1f849a7 100644
--- a/include/linux/xarray.h
+++ b/include/linux/xarray.h
@@ -1617,6 +1617,12 @@ static inline void xas_advance(struct xa_state *xas, unsigned long index)
 	xas->xa_offset = (index >> shift) & XA_CHUNK_MASK;
 }
 
+static inline void xas_adjust_order(struct xa_state *xas, unsigned int order)
+{
+	xas->xa_shift = order - (order % XA_CHUNK_SHIFT);
+	xas->xa_sibs = (1 << (order % XA_CHUNK_SHIFT)) - 1;
+}
+
 /**
  * xas_set_order() - Set up XArray operation state for a multislot entry.
  * @xas: XArray operation state.
@@ -1628,8 +1634,7 @@ static inline void xas_set_order(struct xa_state *xas, unsigned long index,
 {
 #ifdef CONFIG_XARRAY_MULTI
 	xas->xa_index = order < BITS_PER_LONG ? (index >> order) << order : 0;
-	xas->xa_shift = order - (order % XA_CHUNK_SHIFT);
-	xas->xa_sibs = (1 << (order % XA_CHUNK_SHIFT)) - 1;
+	xas_adjust_order(xas, order);
 	xas->xa_node = XAS_RESTART;
 #else
 	BUG_ON(order > 0);
diff --git a/mm/filemap.c b/mm/filemap.c
index 08341616ae7a..6e3f486131e4 100644
--- a/mm/filemap.c
+++ b/mm/filemap.c
@@ -305,11 +305,13 @@ static void page_cache_delete_batch(struct address_space *mapping,
 
 		WARN_ON_ONCE(!folio_test_locked(folio));
 
+		if (!folio_test_hugetlb(folio))
+			xas_adjust_order(&xas, folio_order(folio));
+		xas_store(&xas, NULL);
 		folio->mapping = NULL;
 		/* Leave folio->index set: truncation lookup relies on it */
 
 		i++;
-		xas_store(&xas, NULL);
 		total_pages += folio_nr_pages(folio);
 	}
 	mapping->nrpages -= total_pages;


  reply	other threads:[~2022-12-05 20:25 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <bug-216646-27@https.bugzilla.kernel.org/>
     [not found] ` <bug-216646-27-o4jKola2S5@https.bugzilla.kernel.org/>
2022-11-21 20:54   ` [Bug 216646] having TRANSPARENT_HUGEPAGE enabled hangs some applications (supervisor read access in kernel mode) Andrew Morton
2022-11-22  9:22     ` Bugzilla (was: Re: [Bug 216646] having TRANSPARENT_HUGEPAGE enabled hangs some applications (supervisor read access in kernel mode)) Thorsten Leemhuis
2022-12-02 11:56     ` [Bug 216646] having TRANSPARENT_HUGEPAGE enabled hangs some applications (supervisor read access in kernel mode) Thorsten Leemhuis
2022-12-02 16:58       ` Matthew Wilcox
2022-12-02 21:56         ` Mikhail Pletnev
2022-12-02 21:57         ` Matthew Wilcox
2022-12-02 22:44           ` Mikhail Pletnev
2022-12-05 20:25             ` Matthew Wilcox [this message]
2022-12-06  2:08               ` Mikhail Pletnev
2022-12-16  5:23                 ` Thorsten Leemhuis
2023-02-24 10:21                   ` Linux regression tracking (Thorsten Leemhuis)
2023-02-24 18:08                     ` Mikhail Pletenv
2023-03-14 10:17                       ` Linux regression tracking (Thorsten Leemhuis)
2023-04-17 11:12                         ` Linux regression tracking (Thorsten Leemhuis)

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=Y45Tp1Br2Em8e3Fr@casper.infradead.org \
    --to=willy@infradead.org \
    --cc=akpm@linux-foundation.org \
    --cc=bugzilla-daemon@kernel.org \
    --cc=decedion@gmail.com \
    --cc=linux-mm@kvack.org \
    --cc=mmp.dux@gmail.com \
    --cc=regressions@leemhuis.info \
    /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;
as well as URLs for NNTP newsgroup(s).