From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 21C703F1662 for ; Fri, 21 Aug 2026 19:18:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787339926; cv=none; b=XyqptbTz6clhvrA+ESXBxbjWy1lyu+RVK59SZ6FshqKQVWV/9jJ0EQb8NNw8pffW8quOYiV8tmkYJVj2QHTWS7U7Pz+iOgq0wEG4yqEBY2nh4vT/nolO19qv4xMXa9ngjLm1ugcz8ijdGpofdeDEszwCcFwqXnuM2Zjunb/7x7k= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787339926; c=relaxed/simple; bh=aBFDVnyfk+tTEQ1N82DJwXfWzCDv3hKEnwbL7/5QiKk=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=C5eMwCtByycZNFuIo0tLcFEPyQ+iXqmgXEu0tDtoLU1iKz1r4+UQkjBIJs0ZMI4IltxSKPlmvz9xQ7sxvzHx9LL/s2Yikihu5H6bZFvuvuDNyM3G0TJ6xge7+LF4WD+THdGh+AYmhlPE8PDoWk4x4SL+8vne6Ri+wT6en76/QgA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=OSP3N6On; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="OSP3N6On" Received: by smtp.kernel.org (Postfix) with ESMTPSA id F3C6B1F00A3A; Fri, 21 Aug 2026 19:18:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1787339924; bh=A7EQwwPAnKK4q8enDsZaq/QP/VU09oRuTvIZgOemLOg=; h=Date:From:To:Cc:Subject:References:In-Reply-To; b=OSP3N6OnFOMNhcH624P0dAupyoQ36T9SMi18isQoZ2T2H9c2kTKzVA5MZHwmFxfIj oH1Uk59SThYcIqFox/PhnHA/aYvL+QTZmXia/ENAGLuO3d3zvrJEYO89xEKzOCGbjN qvL0ChNSKVHltC4r6giprL7AMSDpJvJOW/R1C90ZOnKvN+ACvDkLhtmoWqirmqTT+w KwpP0mkS0GlQpr9HodQgZwfAScXRWzxwhyY+wQH5y38FlMxUGRcqOCK0ok1vepNAaV PkXbsBBTUffsvPe5548y9Lw4O2Q3vOReOsyWc5jaTgylhLSsC20JZdsOhcbsEa55Fk 5CofarYyRYTOw== Date: Fri, 21 Aug 2026 20:18:39 +0100 From: "Lorenzo Stoakes (ARM)" To: Gregory Price Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, kernel-team@meta.com, akpm@linux-foundation.org, liam@infradead.org, david@kernel.org, vbabka@kernel.org, jannh@google.com, sashiko-bot Subject: Re: [PATCH] mm/madvise: use folio_trylock() in the cold/pageout PMD split Message-ID: References: <20260821150912.183976-1-gourry@gourry.net> 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 Fri, Aug 21, 2026 at 02:42:01PM -0400, Gregory Price wrote: > On Fri, Aug 21, 2026 at 07:23:34PM +0100, Lorenzo Stoakes (ARM) wrote: > > On Fri, Aug 21, 2026 at 11:09:12AM -0400, Gregory Price wrote: > > > > I am _so_ glad to see an actual reproducer used in a sashiko bug fix. THANKS. :) > > > > fwiw i try to produce reproducers on all my sashiko submitted fixes, > i've just been dumb about including them in the changelog. Trying to > fix that from now on. > > > > + if (!folio_trylock(folio)) > > > + goto huge_unlock; > > > > Doesn't this violate lock ordering? > > > > From rmap.c: > > > > folio_lock > > ... > > mm->page_table_lock or pte_lock > > > > So now you hold the ptl lock _before_ you obtain the folio lock? > > > > I'm not sure if it being a trylock gets us out of that particular situation? And > > I'd be reticent for us to violate it... unless I'm missing something :) > > > > This was the thing i was least sure about, but the deadlock condition > should only happen if we tried to spin on the folio lock right? > > It does look weird, so it would be wrong of me to say i'm 100% > confident this is the best change. Hmm yeah. I worry about subtleties here. I suppose you are avoiding what you'd obviously worry about with a PTL lock/folio lock inversion causing a deadlock. madvise_free_pte_range() seems to 'violate' this also with a trlock, seems it's not an uncommon pattern. I suppose the question is - what else is likely to lock this? It does seem likely to be the race you flag in general. So probably this is fine then. And the window is relatively small also... This kind of stuff gives me the heebie-jeebies :) I know that's not exactly technical but there we go. I guess there's just no other way of resolving this either. That with the reproducer suggests this is fine then! Since it scares me I think A-b rather than R-b ;) Acked-by: Lorenzo Stoakes (ARM) > > ~Gregory -- Cheers, Lorenzo