From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id C2BA4C47090 for ; Mon, 5 Dec 2022 20:25:15 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1DE6D8E0002; Mon, 5 Dec 2022 15:25:15 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 18F1C8E0001; Mon, 5 Dec 2022 15:25:15 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0561C8E0002; Mon, 5 Dec 2022 15:25:14 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id E86B18E0001 for ; Mon, 5 Dec 2022 15:25:14 -0500 (EST) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id C069240B18 for ; Mon, 5 Dec 2022 20:25:14 +0000 (UTC) X-FDA: 80209382148.05.DD7B46D Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf13.hostedemail.com (Postfix) with ESMTP id 3FCCC2000C for ; Mon, 5 Dec 2022 20:25:11 +0000 (UTC) Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=kTRsDIBG; spf=none (imf13.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1670271914; a=rsa-sha256; cv=none; b=nE6yERLOHaNcX+myiRfnX8r4TV8/Ng0uNt2lU2zoxAtfxOwfrpZwAE5OnBD8fSDXrsSwEh IEyEzvqXFRlcwswsXylVOsUSoswc3JvkjZHbuTLEFOTs6Wzo8AzNLssnVyzjr+VgL/raQ9 9dgMsNpJFXvKi/U8lpU7W8pD2lb5B5w= ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=kTRsDIBG; spf=none (imf13.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1670271914; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=cyntgf66m4hIpstt3dxdLUA7UzZi69S+NcM9g1FGPBI=; b=SbmTVUta7jSZtzX3V9B9T4N76jwDQWn8bfE9c06VVrGNbstV4J9p9qT0/dJOg9FjRRjwgs 4cPuZPS+i18HE86Pji+dkhfirI7MgqCndBOsavY0wqeLNVqM9TCL2RfCZ84D4lWZUnq8Jj hygpDhgSyVf4IuZiNnW0hYr+9PJLjjU= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=cyntgf66m4hIpstt3dxdLUA7UzZi69S+NcM9g1FGPBI=; b=kTRsDIBGlBRroZUJBDHqKJHKlL 7oasTKdhoWfmzWtpklXGs3scIQzaKyRFyhuXwAgCjQCwhqawQKeSBVprH6zDOS5m3vlBaP1vpnEyE VBKBiuJZ9zHUiD3dgHTrYZJLXSMQgWHh4E+ceQ0Dq1TaI8KeMMHpO4jXHspLVRNaO4Kkqk/zRu9Bn AB0fBq6lfZIvzwvooy5V9oVpDlDk9uVo+qY7SXHNm3hGiccdze2DYHHfhhM/EQAhn5Zv7pmexJSKT xZ2XODpPEL1+ardafzJ5CGhWWSxG5IdWGNZSG8P3cV2Ui5jP2NzLYPw/vCa2xemDh/XbXzNk2TP5m ZgSHBe7A==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1p2I1X-003cou-L9; Mon, 05 Dec 2022 20:25:11 +0000 Date: Mon, 5 Dec 2022 20:25:11 +0000 From: Matthew Wilcox To: Mikhail Pletnev Cc: Thorsten Leemhuis , bugzilla-daemon@kernel.org, linux-mm@kvack.org, Andrew Morton , decedion@gmail.com Subject: Re: [Bug 216646] having TRANSPARENT_HUGEPAGE enabled hangs some applications (supervisor read access in kernel mode) Message-ID: References: <20221121125400.334190a6d2791b0c9afbfea0@linux-foundation.org> <220fd094-7cf1-9d17-8380-98d5663dc5da@leemhuis.info> <20221203014420.76281b930dbc64f51eda0f8b@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20221203014420.76281b930dbc64f51eda0f8b@gmail.com> X-Rspam-User: X-Spamd-Result: default: False [-3.70 / 9.00]; BAYES_HAM(-6.00)[100.00%]; SUSPICIOUS_RECIPS(1.50)[]; SUBJECT_HAS_UNDERSCORES(1.00)[]; R_DKIM_ALLOW(-0.20)[infradead.org:s=casper.20170209]; MIME_GOOD(-0.10)[text/plain]; RCVD_NO_TLS_LAST(0.10)[]; R_SPF_NA(0.00)[no SPF record]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; ARC_SIGNED(0.00)[hostedemail.com:s=arc-20220608:i=1]; RCVD_COUNT_TWO(0.00)[2]; DKIM_TRACE(0.00)[infradead.org:+]; TO_MATCH_ENVRCPT_SOME(0.00)[]; RCPT_COUNT_FIVE(0.00)[6]; FROM_HAS_DN(0.00)[]; MID_RHS_MATCH_FROMTLD(0.00)[]; TO_DN_SOME(0.00)[]; DMARC_NA(0.00)[infradead.org]; TAGGED_RCPT(0.00)[]; ARC_NA(0.00)[] X-Rspamd-Queue-Id: 3FCCC2000C X-Rspamd-Server: rspam01 X-Stat-Signature: iq7d1nz6d1mfzuzxmg7e91cf7f5apu4s X-HE-Tag: 1670271911-256664 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Sat, Dec 03, 2022 at 01:44:20AM +0300, Mikhail Pletnev wrote: > On Fri, 2 Dec 2022 21:57:09 +0000 > Matthew Wilcox 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 > > */ > > > > +#define XA_DEBUG > > #include > > #include > > #include > > @@ -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;