From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-oi1-f175.google.com (mail-oi1-f175.google.com [209.85.167.175]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AECA73BED40 for ; Mon, 23 Mar 2026 16:35:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.175 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774283750; cv=none; b=LAeLDMtAEY3QqDk8shf1izGWMNxJ5VgZiP2LvxfSKLN40A/ePjnDaBmR2ba4gxO2gWilBqXokQsCnrdMb5VthNRJJ2qAjhIhs295Sve2Pkp68bLHILW17RL5y0JoDl8+fQl472WLI6ID34R10TCx/RlxOaRNFt0+0s1mnnoRrMM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774283750; c=relaxed/simple; bh=geQkxxCjtfkm9aOeDchp0R8fqi7bTJFGurZPlUQoqqk=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=n23K6l4sZyDMWkR+IO4ZMKk3GfXxV7HAb7MfCikiYmzlsqaFHfpiMoKC+sIg+gYsSOVne+gMFFa31AbHMApt6ijq+BHASVQp00508dNRLLzsYhVHGq3DcR5t/3K1/J2fytn9zeb7bhj5SzrXf//8mFo6EvQKtYrxUzkXWztCfsM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=cloudflare.com; spf=pass smtp.mailfrom=cloudflare.com; dkim=pass (2048-bit key) header.d=cloudflare.com header.i=@cloudflare.com header.b=O834Oco4; arc=none smtp.client-ip=209.85.167.175 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=cloudflare.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=cloudflare.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=cloudflare.com header.i=@cloudflare.com header.b="O834Oco4" Received: by mail-oi1-f175.google.com with SMTP id 5614622812f47-467166cb638so900940b6e.2 for ; Mon, 23 Mar 2026 09:35:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cloudflare.com; s=google09082023; t=1774283747; x=1774888547; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=au/DBt4TsnTCso1YPGCkQuN+bqByYyQKJLWa66VyrXc=; b=O834Oco4lhx9/IOthVK8Uc93bxpnFyeL7jE9Id6YdwluiHFaRju+q8DweZs4SNg51a 71neU9MlQhbkf/9RlQFnp31iP1MRGD76wi/HukoAW1OQNUqCiWbXVjXBMHvQWV1g+inP lagcw+rr63lG5c8ztmbmTnHr/W1Mk3/jqTnK/8qIubImsAyQLsxwIQVtUgUVfMwNtOnd qUD0Jgp3V+3xCXpYRJfYK/gzdTNhFt1eyvkz9cDUF3DnDEkXeTtX8IybwfiurPCV36rM vw6VBdhAqPMNA9al5ACOtjLflJTxoixQwtWzrxgOa4IIbfG30xOFWzOXG9PM++K63OZN gQJQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1774283747; x=1774888547; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=au/DBt4TsnTCso1YPGCkQuN+bqByYyQKJLWa66VyrXc=; b=RB+/Qy3aaidkHirEHsoYDPnwh/hHGC/ZiZ7mILahYdcq4Xj39C8OMTmb02hQ5TsyLm nBdU6edMf9sPOU6WjCW8mpw1t7ciaBZTNM0hg7VqHoBtvrmL3enoNB7bPNdMYZzY+eAs YTVlz4naw4y8kqQRoTQ/vq2k8JQkiJ+ceSTs+UeMQR/VwZuNLij7R2rq1TJYb+S6uBgk JjePIGRxCGjMrEBzMqFBs8SCQ9AFpzKEVcZz431K5qRHIWJf54AKuVBm17+L2J2upi+m /XQS24qZze6YQTJNfMAg6hH6kqfI/tCOS/3lUlGNBYquKQm8Edyr2sRGszMF72hTvNZ/ vcBQ== X-Forwarded-Encrypted: i=1; AJvYcCViKNN6TYfaoELmRvBeiPkHA5TFnojk7yUSPDFHwWLHhW9Dbv6Ae7/T44QEB4KKiIm0dnKRQB5lMs0sNfc=@vger.kernel.org X-Gm-Message-State: AOJu0Yy/q2iZ/O44D3ALMiUN2C2+eb6bx0kL4lP34/6iVTt0U1cd68Gl eCiPOARsAgppa82q+QIS9rbvSla1MeAZ5ETWvHq2BAQcwJEZxdC4VR56hZz9HmUXrv8= X-Gm-Gg: ATEYQzxQyxZPqKu6shMmbGHhfn/xdeub9vrEetkl3AG2vsBqNvSoDH3pAY4lQ2sKDzL C8Bxj5Z4YqK7JppXQRKzKOqjQV9pAF5WDw7MVl0eNYLIqjGgetQqk5WcKLSG0sfwh3SWfEsRoq2 n28Jm6XUIEhthby1RTQDvS99PlZLcv4JzGieinywx8tmHxB1JD58GAklNaGM1KDb/pIf3NKeefl 5Ut42z862ltcp2AdsktqGHDVvIH1cdzxdDfZfUHNGKuM/OKVR7AAwwar2XWheeFeAeYwyEXD/V0 pfi/2nQ9Ir+lgygxVshh8crVcpCVfC7pOnRuQVAMDuns+Hx0iwB1wNUq8p89PPSHkMTD6TUfjDp tFyQuyk21m0FDFFawsnWATm5GNYnON7L7fY+zuVvO2hoVdko+Os0dUKCxbE254B1IGJT7BK42qv 93k6peig== X-Received: by 2002:a05:6808:669a:20b0:463:8fba:5e00 with SMTP id 5614622812f47-467e5eebfe8mr5354383b6e.30.1774283747596; Mon, 23 Mar 2026 09:35:47 -0700 (PDT) Received: from 20HS2G4 ([2a09:bac6:bf21:2632::3ce:1]) by smtp.gmail.com with ESMTPSA id 5614622812f47-46811e5164esm3658248b6e.0.2026.03.23.09.35.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Mar 2026 09:35:46 -0700 (PDT) Date: Mon, 23 Mar 2026 11:35:44 -0500 From: Chris Arges To: Kiryl Shutsemau Cc: Matthew Wilcox , akpm@linux-foundation.org, william.kucharski@oracle.com, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, kernel-team@cloudflare.com Subject: Re: [PATCH RFC 1/1] mm/filemap: handle large folio split race in page cache lookups Message-ID: References: <20260305183438.1062312-1-carges@cloudflare.com> <20260305183438.1062312-2-carges@cloudflare.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: On 2026-03-06 20:21:59, Kiryl Shutsemau wrote: > On Fri, Mar 06, 2026 at 02:11:22PM -0600, Chris Arges wrote: > > On 2026-03-06 16:28:19, Matthew Wilcox wrote: > > > On Fri, Mar 06, 2026 at 02:13:26PM +0000, Kiryl Shutsemau wrote: > > > > On Thu, Mar 05, 2026 at 07:24:38PM +0000, Matthew Wilcox wrote: > > > > > folio_split() needs to be sure that it's the only one holding a reference > > > > > to the folio. To that end, it calculates the expected refcount of the > > > > > folio, and freezes it (sets the refcount to 0 if the refcount is the > > > > > expected value). Once filemap_get_entry() has incremented the refcount, > > > > > freezing will fail. > > > > > > > > > > But of course, we can race. filemap_get_entry() can load a folio first, > > > > > the entire folio_split can happen, then it calls folio_try_get() and > > > > > succeeds, but it no longer covers the index we were looking for. That's > > > > > what the xas_reload() is trying to prevent -- if the index is for a > > > > > folio which has changed, then the xas_reload() should come back with a > > > > > different folio and we goto repeat. > > > > > > > > > > So how did we get through this with a reference to the wrong folio? > > > > > > > > What would xas_reload() return if we raced with split and index pointed > > > > to a tail page before the split? > > > > > > > > Wouldn't it return the folio that was a head and check will pass? > > > > > > It's not supposed to return the head in this case. But, check the code: > > > > > > if (!node) > > > return xa_head(xas->xa); > > > if (IS_ENABLED(CONFIG_XARRAY_MULTI)) { > > > offset = (xas->xa_index >> node->shift) & XA_CHUNK_MASK; > > > entry = xa_entry(xas->xa, node, offset); > > > if (!xa_is_sibling(entry)) > > > return entry; > > > offset = xa_to_sibling(entry); > > > } > > > return xa_entry(xas->xa, node, offset); > > > > > > (obviously CONFIG_XARRAY_MULTI is enabled) > > > > > Yes we have this CONFIG enabled. > > > > Also FWIW, happy to run some additional experiments or more debugging. We _can_ > > reproduce this, as a machine hits this about every day on a sample of ~128 > > machines. We also do get crashdumps so we can poke around there as needed. > > > > I was going to deploy this patch onto a subset of machines, but reading through > > this thread I'm a bit concerned if a retry doesn't actually fix the problem, > > then we will just loop on this condition and hang. > > I would be useful to know if the condition is persistent or if retry > "fixes" the problem. I was able to deploy my patch into a set of machines and test from March 11th until now. So far it seems like this patch addresses this issue. While removing the BUG_ON means that we will no longer see the call trace messages, I looked for any lockups that would be related folio/filesystem activities and did not find any. Let me know what else would be useful here, I am happy to re-propose my patch without the RFC, unless more verification/analysis is needed. --chris