From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out-188.mta1.migadu.com (out-188.mta1.migadu.com [95.215.58.188]) (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 73FDA3859EC for ; Fri, 31 Jul 2026 09:41:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.188 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785490904; cv=none; b=Iw2O5Pfbe4Q8Aj77z0RJr7VRgn+NmOIiwMRLqso9CzU5AgUzONE5Gkt5X8aUwDHwZv8pN8xz2Qchnt+uy/8ZvVJEpd3/FhlHKS/KrcbPayB2/utDZobx2ulpDlFlU9AN9VyH64zkCUJOtfzhLkR7FvsXA6dPZjwDYXnMfNJtCpM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785490904; c=relaxed/simple; bh=cwOyCWPA2evOGOv9ivwS2pRqgvuMlsIF3fGxt3c4SCI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=O3vk5DEhZuwyrt9VYRL2fth5eKjd5U7RMUBRh/Kbmyvjxjxwwz1mfKtCuH8n1x83PEwPf2hcrUJSlpI2U3iB2UP8dIsw8uoWb+cwwMpYWDtWv3HHIiglf9veOVWVU/CJTQo6OdnQV6V5Oqbtb2pXTA0FIsnNM41hYfhKV8b0LD4= 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=OxPWSkfs; arc=none smtp.client-ip=95.215.58.188 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="OxPWSkfs" X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1785490900; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Jgxl9CIQj6KttRa1KpmqjLcUf7cr/iCoTYx4L9S8blw=; b=OxPWSkfspY3uM75dNzMXC6xjyjOI4Bs9bAbnQqGjK7gWWpIQC2JpWVvU/gw2bX1cjSzmjc gb6sYVIdfp4EeWcNS6P6Nc0xfsjxwAeRnEQcJeqxcbfhMft3GOALuVI3Yd1kE5DlChSYiM DgDAMlRTiyVsZDt5xxAmIFvyTBXgKug= From: Hongfu Li To: ljs@kernel.org Cc: akpm@linux-foundation.org, david@kernel.org, hongfu.li@linux.dev, 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 v2 1/2] mm: Use a folio in the softleaf_is_device_private path Date: Fri, 31 Jul 2026 17:40:54 +0800 Message-ID: <20260731094054.90791-1-hongfu.li@linux.dev> In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT > > mm/memory.c | 11 ++++++----- > > 1 file changed, 6 insertions(+), 5 deletions(-) > > > > diff --git a/mm/memory.c b/mm/memory.c > > index d5e87624f692..ae521baa8c84 100644 > > --- a/mm/memory.c > > +++ b/mm/memory.c > > @@ -4871,18 +4871,19 @@ vm_fault_t do_swap_page(struct vm_fault *vmf) > > goto unlock; > > > > Up here we have: > > vmf->page = softleaf_to_page(entry); > vmf->pte = pte_offset_map_lock(vma->vm_mm, vmf->pmd, > vmf->address, &vmf->ptl); > if (unlikely(!vmf->pte || > !pte_same(ptep_get(vmf->pte), > vmf->orig_pte))) > > Since we're canonicalising to folio why not actually set folio using > softleaf_to_folio()? > > So > > + folio = softleaf_to_folio(entry); > - vmf->page = softleaf_to_page(entry); > + vmf->page = &folio->page; > > This would also make more sense in your 2/2. But more on that in a sec. Thanks, I've thought through your suggestion carefully. Could entry reference a tail page of a folio here? If so, softleaf_to_folio() retrieves the folio containing this page, and vmf->page = &folio->page would point to the folio's head page, which may not be correct. Best regards, Hongfu