From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mta0.migadu.com (out-106.mta0.migadu.com [91.218.175.106]) (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 653A333BBC0 for ; Tue, 18 Aug 2026 09:50:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.106 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787046616; cv=none; b=a1tq2aKOFBx74dOIJzN/BWib5kIg2xJhFfjmWWeBsJngRAfhehBBITg+KM1D25GRvbBF2ixIJFxAVu/GZqyRhUZRgm/ReX21rNcZMEGzrFjQWsyGambGIKlQZo2TNmhWiOFCI2vHIkO1ezcBpweBOq35tJFHmpNkGuHgi3ipDu4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787046616; c=relaxed/simple; bh=UlfNwq9i0Izd95buPQLfyQ20iUq29NLoc+MekKaF5hA=; h=Message-ID:Date:MIME-Version:Cc:Subject:To:References:From: In-Reply-To:Content-Type; b=XtmFTF2zXtbZ8ytIqaOxCY/+RYVZb44UW4e3eEqAIqbPTFYuAAddhynSMVmVQTe1UbxMI0Odt5SsbfW3b9cgy69xn0/kGJtsU8aiiVvbhSc53g/V3AIb1xPaC6+N702/zDk1l0stOusTq7bpjrdPI+A7poTd9D53fGXLhd7OCeI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=vrDI1CzN; arc=none smtp.client-ip=91.218.175.106 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="vrDI1CzN" X-Envelope-To: linux-kernel@vger.kernel.org DKIM-Signature: a=rsa-sha256; bh=UlfNwq9i0Izd95buPQLfyQ20iUq29NLoc+MekKaF5hA=; c=simple/simple; d=linux.dev; h=from:to:subject:date:message-id:mime-version:content-type; s=key1; t=1787046613; v=1; x=1787651413; b=vrDI1CzNWx0GrsXYkU9bKe6X2e99WlhCiMqZz3zU0uBRB1dDYZO1sBvbfBBIJBx8z+vIATAT w8WFNfCF7GkNWfSl2xBcZxFo0HszQNd+hY1oCH4HZu55iSMb/Ok/g0brdJIvkJABlXvXJFtiR0K nChGx7KCcVtStSg/TMCVhCIA= X-Envelope-To: linux-kernel@vger.kernel.org Received: from [192.168.109.123] (223.70.160.239) by smtp.migadu.com with ESMTPS id 155241efdf8f6d39; Tue, 18 Aug 2026 09:50:10 +0000 X-Migadu-Flow: FLOW_OUT Message-ID: <73cbb2f3-98ad-498d-8f33-ff7e39fe6ac0@linux.dev> Date: Tue, 18 Aug 2026 17:50:00 +0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Cc: hongfu.li@linux.dev, 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 To: "Lorenzo Stoakes (ARM)" , "David Hildenbrand (Arm)" References: <20260818021326.5910-1-hongfu.li@linux.dev> From: Hongfu Li In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit On 8/18/26 4:56 PM, Lorenzo Stoakes (ARM) wrote: > 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. Thanks a lot for the suggestion. A shorter comment is indeed better. Will use your suggested one‑line comment, add the folio re‑fetch, and update commit message for v5. >> -- >> Cheers, >> >> David > -- > Cheers, Lorenzo -- Best regards, Hongfu