From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out-179.mta0.migadu.com (out-179.mta0.migadu.com [91.218.175.179]) (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 B272030DD2A for ; Wed, 17 Jun 2026 13:51:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.179 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781704310; cv=none; b=PPrnT5HofDBUnKNsJ3TXdbw8WWnkexquHc/owP5hvWk/zWDW3M5QAoO2Gv7FyeRfIbMDHG4IsMAVlOVVvUORBrrbTvU5i82Ip1renFb+oIEgFOH70FGL6e+Ifa79ALBO1LAz/mP1qQ6vZ1bGKfB0QZrAFlg+knW+zOP4wb4/2CY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781704310; c=relaxed/simple; bh=I3wZG9AbgTb+hq7rPdBFgtNthjJ5w+ytcy2YNtLYIqE=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=nwb3FPYQC3N4uDOgdOFEiGUEWPSjqvRx4q3YVBAWCTVanJWGYic4D3y48lWWmbnzqNwXDEcFEAugpa2sGUmIINcnrl19WukCpFljDrxmrnqTGvFDYC2bIokQDtVmhL3ZfohNxxcK6P4BTGVdLcY8N8j9HafCJN2+jAiAu+/3aHc= 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=MaBFkKfc; arc=none smtp.client-ip=91.218.175.179 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="MaBFkKfc" Message-ID: <4893f184-6534-4347-af5c-efdfd255e27b@linux.dev> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1781704305; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=YIzS4bCHp9S83OoqwEMXqx1qAOUh83rabFYWqN1URrI=; b=MaBFkKfcN4lk5r4MkmdK+GZRvXI+xtusr6G5VXoo+7mIVzfBakOlg3co21OwaOst4cNLsR cvjbjn4fKdY5qcOxKwD3XBJ65y5ENwGybo7r18zOVCP/qLiuzg1t7fRTHHZ74AQvu2scjz 1JRS3/CeFteR6Rrne4uEGkcT0wyInR0= Date: Wed, 17 Jun 2026 09:51:38 -0400 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Subject: Re: [RFC PATCH 2/3] mm: drop stale folio_ref_count()==1 check in do_swap_page reuse logic To: "Barry Song (Xiaomi)" , akpm@linux-foundation.org, linux-mm@kvack.org Cc: 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, baoquan.he@linux.dev, youngjun.park@lge.com, jp.kobryn@linux.dev, shakeel.butt@linux.dev References: <20260611105124.98668-1-baohua@kernel.org> <20260611105124.98668-3-baohua@kernel.org> Content-Language: en-US X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Usama Arif In-Reply-To: <20260611105124.98668-3-baohua@kernel.org> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Migadu-Flow: FLOW_OUT On 11/06/2026 11:51, 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); Acked-by: Usama Arif