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 BEE6C3ACA43 for ; Tue, 18 Aug 2026 08:57:02 +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=1787043423; cv=none; b=CCl0p5Anq13dB5rmo8AbtkRQfziS2R7TVs9h0gql2mtYGczppARomG1vx8QVg5Nporop6d2l7uGjc5yL7lB2fnQR5KPZ06Wp/tpCQGoF2mnkjYLLPief0H3iSAjIRULv+wSdvd9Eqs1zPdR0rEv56Ae8AXPPLt42z6ArpvRZarQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787043423; c=relaxed/simple; bh=akDNmNuvNoTYLEuB9ptDv3PF2U2z90JQ4J4GrKBFZxU=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=rc3FWDfjFqQrA8L/kDH9tSwIU1cMYB8P+1psl4wEVxKh88ykaugVd7IqBzOwcArwJl377xLfEeoUfx7s7u+K7YyDxJtrIgXYDPzRyMIRf2V9JW/c3XuO2aAQ5mBmDadMT5wUXYvHW7ItCcTKn+kLpS9YmlMLoBwuaRSahE061pA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=oLN6x1RZ; 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="oLN6x1RZ" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C3AC71F000E9; Tue, 18 Aug 2026 08:56:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1787043422; bh=vhY62l99sNhBmAViuWQPBUCeNDQgs5Ra/zZqAiWiAzQ=; h=Date:From:To:Cc:Subject:References:In-Reply-To; b=oLN6x1RZlJ6qDs/H+h+Ay61SstBW7/YNPXc3SxbBy86CKNihdgkjOEtYXmxyDnQ+t YCfbtJMKKSRG7TK4/mO5PhDvvOER+hUWg/nmGYqu5fvUNa0jdcwcXHeoUiXpNHSmav zmc2Ahq5b81Iz6OGeB3J2uPQDtGpOhRhfbwnTbqG2DkqH/BqGejtFZmnoIHVT3rmjq 79vxQyRlFuMsF6WXXVA2Mj9dWl14eIYDh8+E84tUisTp692XcuouYzbXonB1aIR4SC Xna3tqsQyWClChM6RTfSaLYTYlifyVvlBRfhwJ4YvpBmXMr4lvMSPyhTVcFazGqByP kF8qS4PiZ39XA== Date: Tue, 18 Aug 2026 09:56:43 +0100 From: "Lorenzo Stoakes (ARM)" To: "David Hildenbrand (Arm)" Cc: Hongfu Li , akpm@linux-foundation.org, liam@infradead.org, lihongfu@kylinos.cn, linux-kernel@vger.kernel.org, linux-mm@kvack.org, mhocko@suse.com, rppt@kernel.org, surenb@google.com, vbabka@kernel.org Subject: Re: [PATCH v4] mm: Use a folio in the softleaf_is_device_private path Message-ID: References: <20260818021326.5910-1-hongfu.li@linux.dev> 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 Tue, Aug 18, 2026 at 09:30:40AM +0200, David Hildenbrand (Arm) wrote: > On 8/18/26 04:13, Hongfu Li wrote: > >>> So after migrate_to_ram() the folio might have been split or otherwise somehow > >>> the page doesn't belong to the same locked, refcount-incremented folio it did > >>> before? > >> > >> I suspect a split. > >> > >>> > >>> That's kinda a footgun... but this documents it at least. > >>> > >>> I think a comment explaining how this can happen would be helpful though as this > >>> doesn't seem intuitive. > >> > >> I think, conceptually, calling into something that consumes a page (vmf->page) > >> always needs care when operating on folios. > >> > >> Passing the vmf to some callback might be the odd thing here, because the > >> vmf->page contract is not really clear. > > > > I'm very sorry for introducing this regression. > > Thank you for identifying and testing this issue. > > > > I will double-check this code path and apply your fix to run further > > tests locally. > > > > Would it make sense to add a comment here like the below, to make this > > subtle behavior clearer for future readers? > > > > diff --git a/mm/memory.c b/mm/memory.c > > index 4134ac607ee0..2b6d6c863ecb 100644 > > --- a/mm/memory.c > > +++ b/mm/memory.c > > @@ -4937,6 +4937,12 @@ vm_fault_t do_swap_page(struct vm_fault *vmf) > > pte_unmap_unlock(vmf->pte, vmf->ptl); > > pgmap = page_pgmap(vmf->page); > > ret = pgmap->ops->migrate_to_ram(vmf); > > + /* > > + * migrate_to_ram() can split a large folio, updating > > + * vmf->page to a different folio. Re-fetch folio for > > + * correct unlock/put. > > + */ > > "migrate_to_ram() might have split the folio." > > Should be sufficient I guess. Agreed, no need for a schloppy long comment here! /* migrate_to_ram() might have split the folio. */ folio = page_folio(vmf->page); Should be fine. The commit message should be updated to reflect it too and mention that we are going from 4 -> 2 compound_head()'s now. > > -- > Cheers, > > David -- Cheers, Lorenzo