From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out-170.mta0.migadu.com (out-170.mta0.migadu.com [91.218.175.170]) (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 96D36344DA4 for ; Fri, 12 Jun 2026 01:18:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.170 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781227116; cv=none; b=iCcpgIlXGZY5I3mSeQjKBw3MfAgmjqmvvFd0IvSjHGfYizN1L1Ywu5jRZIbUHtTwxhgLGy4R+U4a71IJc07HX58ke8UuSXFgopyppt+KMbgoZY209PGYop6tDdElQNdZ01CfHjJ55GyOI2gI+MxRbEqt38MSi41HZhaucBPVQas= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781227116; c=relaxed/simple; bh=qgtqDz8LrUdYlDGMH0a0h4/gNgoGNAVhhRrqgrb20Ck=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=HQ5Fny4hgC+krn2yxnyuDE/PP0PMhOYyXP6j8Htcqurl9n7sO39EqFbdW0FFZQe4rK/X58BZfv2joJ3WfKHsawYWmKBTrE8mBAqL8UAMSmSBelAJBVZazaHRxyQDxAw/yzu3V7p9Gg9BqyfFxy8qQtz8jNEEvxVdpWQzDXXmnA4= 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=W6CnD78p; arc=none smtp.client-ip=91.218.175.170 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="W6CnD78p" Date: Fri, 12 Jun 2026 09:18:23 +0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1781227111; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=njxNq3hwRVxN/lbap5PGlQkdMVNaPFVAUzcLxbSGsSA=; b=W6CnD78pjnIJvDPa8/MfNG9GeRM11voNki5R/hxGqh244Ns3iLOCIfsArwU1EJdezYowQp /ug9hjNnCoSGsBJJYKqFZHOrxbQ7UE2y/H+P8EzQfDptRIU3vh6Y3ApJOvJMt+0kTolnv7 0SACJoUjCc/14QQa3eWaVb8L6ZGUmNA= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Baoquan He To: "Barry Song (Xiaomi)" Cc: akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, david@kernel.org, ljs@kernel.org, liam@infradead.org, vbabka@kernel.org, rppt@kernel.org, surenb@google.com, mhocko@suse.com, chrisl@kernel.org, kasong@tencent.com, shikemeng@huaweicloud.com, nphamcs@gmail.com, youngjun.park@lge.com, jp.kobryn@linux.dev, usama.arif@linux.dev, shakeel.butt@linux.dev Subject: Re: [RFC PATCH 2/3] mm: drop stale folio_ref_count()==1 check in do_swap_page reuse logic Message-ID: References: <20260611105124.98668-1-baohua@kernel.org> <20260611105124.98668-3-baohua@kernel.org> 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: <20260611105124.98668-3-baohua@kernel.org> X-Migadu-Flow: FLOW_OUT On 06/11/26 at 06:51pm, Barry Song (Xiaomi) wrote: > The "we just allocated them without exposing them to the swapcache" > case no longer exists, as Kairui has routed synchronous I/O through > the swapcache as well in his series "unify swapin use swap cache and > cleanup flags"[1]. As a result, folio_ref_count() should never be 1 > in this path, since at least two references are held (base ref plus > swapcache). Remove the folio_ref_count()==1 check and update the > comment accordingly. > > [1] https://lore.kernel.org/all/20251220-swap-table-p2-v5-0-8862a265a033@tencent.com/ > Signed-off-by: Barry Song (Xiaomi) > --- > mm/memory.c | 7 ++----- > 1 file changed, 2 insertions(+), 5 deletions(-) > > diff --git a/mm/memory.c b/mm/memory.c > index 487a34377a7b..ce8ef27e7a54 100644 > --- a/mm/memory.c > +++ b/mm/memory.c > @@ -5049,12 +5049,9 @@ vm_fault_t do_swap_page(struct vm_fault *vmf) > > /* > * Same logic as in do_wp_page(); however, optimize for pages that are > - * certainly not shared either because we just allocated them without > - * exposing them to the swapcache or because the swap entry indicates > - * exclusivity. > + * certainly not because the swap entry indicates exclusivity. > */ > - if (!folio_test_ksm(folio) && > - (exclusive || folio_ref_count(folio) == 1)) { > + if (!folio_test_ksm(folio) && exclusive) { > if ((vma->vm_flags & VM_WRITE) && !userfaultfd_pte_wp(vma, pte) && > !pte_needs_soft_dirty_wp(vma, pte)) { > pte = pte_mkwrite(pte, vma); Reviewed-by: Baoquan He > -- > 2.39.3 (Apple Git-146) > >