Received: by 2002:ab2:3141:0:b0:1ed:23cc:44d1 with SMTP id i1csp1695711lqg; Mon, 4 Mar 2024 00:16:36 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUmE5/FyQgKwCvE3TBMCCmDb+qiTc6XUviuz7Ey5JOEYQVETC2JP3l74+USKNLbbqN5RSDPrBZt89/bhdzEpJxEkKu5F0yoBSmrofRWmQ== X-Google-Smtp-Source: AGHT+IH2+N3e+NsqBslZbBHhULwD7Eq3uGedHTvbmYPvqnreCMwEWN87URSd4o2A4Iet6zdEngDz X-Received: by 2002:a05:6808:2915:b0:3c1:ea81:64e9 with SMTP id ev21-20020a056808291500b003c1ea8164e9mr2943130oib.44.1709540196580; Mon, 04 Mar 2024 00:16:36 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709540196; cv=pass; d=google.com; s=arc-20160816; b=SSd8TQtMOpT06OvN99l/mBt7g1cZoHBdi5DFSjvm8SJb+w7C/4cG/w7rz3XNThuOk0 t8/c7vNBs21OO+cgGaMNnE9dSp+8t1B0ySxt20ZHP/flPtV8zgiLkaLdm4M+RAL1PlOp +KPKwgLd8LNVRxSPzdli4HLdtq5vkSeXJTZ84L+BSLSHADg1qD4q3JP/h4JU6vlyRohn XiHcPARpYZT8pWorrGjzLUQ+9ah1mZYS6A8cwfIpheYiJj4bpoKjLemSRIlFmUVPbS+I Lz9boHw41FVSGTz+EViBWtrtUfrDxMNpKXWT+K3oytk3zOWrzXf0FQpBji9xdzQaNuV8 RUjQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=nPNnhD7u3Mm6wgXrNGhON5/bGI4wy7Z421ED7ypUMCI=; fh=rhVEr8MCaZXvvx+fn3MjJzZ0ungL5cVhybPOZ3ntD9U=; b=LHALYw6al6Lr7kxvt41ihQXTJokPMzz1LvmaQV6kG0PiHU84t6m+ZFM96tBMnh9sru JQ07UXdc/79QHqbsJiHB/eWK60zlX2hfZeKtTVHFCE+guLjeIT7z0MtDAxJJ6ctMn0Br 0RQJ7PvxdrMQGPIYBvIc0Xe8xCxsfIw1ohNn8t1bK/aGYzX2+ZtzE5/YQwv02aa6ESRN l1kcjiPcRCoKPg/QCqEk6Jl6BMTDIUyQwBQPSAN9l2iOstgF18fKHYYXNpYQEnork7Yh 7MK9FmPp2ne3uRqTWvgfRVXQY8qsLKIoHtZfMAGX1gdwTDKzAhm6teAZskBEyPexzXc9 N8NA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b="H6e/S3c4"; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-90178-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-90178-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id 131-20020a630089000000b005dd3d01b50asi7913951pga.17.2024.03.04.00.16.36 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Mar 2024 00:16:36 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-90178-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b="H6e/S3c4"; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-90178-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-90178-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 3983EB21E32 for ; Mon, 4 Mar 2024 08:15:06 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id AF78C171B0; Mon, 4 Mar 2024 08:14:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="H6e/S3c4" Received: from mail-io1-f43.google.com (mail-io1-f43.google.com [209.85.166.43]) (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 7FBC617BA9 for ; Mon, 4 Mar 2024 08:14:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.43 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709540085; cv=none; b=A0cfFhy2sHYMMhrmWxmIj0KOuAhTqQfP7/6Fs+3yI1AEBc/e7ArnQlvS8MVUVW1QyrekqV7vQoCWdCLxCnKYxabV+lo6OXJYPuZvevbzkDAjW/slBz0L3tkyZrrrb0PDcinIcroBvV0/2jldytAxt2RJsc0mJA7svUjEhmdHa/g= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709540085; c=relaxed/simple; bh=97XECp6ImGl0bxcVjD9vOm2RDIYctvChEeuK0x7tRrg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=jjXKh7u9f6mE3BKorRqm2wB8s1/702yXd7n19NGJ44qIu2rN/BP1cVE5qpxI9opx9YRUjLUXGS8H2hJtcfd18TI8hpSlGOBEGhm9t3fCQmIR6ZqSBJrUQNNEKgO0xP1Vo5a2RgmBl7yD9Vqup7477vecYC3bObBFH5jXzjfZI2Y= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=H6e/S3c4; arc=none smtp.client-ip=209.85.166.43 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-io1-f43.google.com with SMTP id ca18e2360f4ac-7bed9fb159fso259233639f.1 for ; Mon, 04 Mar 2024 00:14:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1709540083; x=1710144883; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=nPNnhD7u3Mm6wgXrNGhON5/bGI4wy7Z421ED7ypUMCI=; b=H6e/S3c4QDzprosK/gcKxHAuMi17BoaNAUBWA6yvutonMR1hjZ5quIM9q4ydHdLUPK mYYbkKOxbGEFGRTYqRxYbtfbBZL/qEwNff4sjuBQNIUP1yRI3WbKTegaRgzMLwLjJv2Y 4sSItnarMVwRUXPEaiqugCursDRdZxQ5ahWFyO+UaU5pTyqpPKe7ruadjtpADL/kVsyi tsUCduR+85/UgU2pMH1nTdXEgWWgr6ovWgues7skBZ5GmhLxuzv1OCgXHUqVzKrx9Jvf JVvLKCS43ny1UPy4xp40fe77dG/bh9EtjkjSBMy4IE2upl2CMU8Bq/JtGaDtIdWZCbl/ IxoA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709540083; x=1710144883; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=nPNnhD7u3Mm6wgXrNGhON5/bGI4wy7Z421ED7ypUMCI=; b=W34g+PakdrWOj+2qyCDgX8wGJbZ34QopM9PVrGA536bR0WnMrDZ9zIiGEi3VUx8oly ck8dodIdviikGtywI78uLcIrbCfSoBCP+Ozgl1L+99s3aSKfBmXeXXDvKWIBa8rW6yY3 VZznoOLTdR78k/YoiflUrathnNFcENJtMnfPErPeAUzUzdpTolG0GLQ0AT7Z+vG9+YDT 4JVBJTgsDlcdahEVeI1f1xgXuG7dvnKzWm2bhqBnZee/vn4W7i1EGrw4821YiYX2zXBp wAKG8tQ7NAqrMHzprLG3A6YzdgUfGjBuUo3d29diYrZRtkkscaOxTu5ae7a2R6cOwRDz aqQQ== X-Forwarded-Encrypted: i=1; AJvYcCWMluaJzmg6eulZth0Fq3eX1YgGR6TMQzG+PkQIM9/T2c7dkEXLyMwr1nMurTZ0x24xAKuNbGMWe8SmeSml2RU0+DeUc2PZ408XK1C2 X-Gm-Message-State: AOJu0YxWi2WNjsV9KCUiRJmqQspwSKVIEn4jB4RIhm3qoduoyMQkb6UP AfKiHptdCycclF1p6dPo8KLOGIOnHqyODNEZW08YrtRn5NmOD01V X-Received: by 2002:a05:6e02:1567:b0:365:f8d:50c3 with SMTP id k7-20020a056e02156700b003650f8d50c3mr11150779ilu.21.1709540083664; Mon, 04 Mar 2024 00:14:43 -0800 (PST) Received: from localhost.localdomain ([2407:7000:8942:5500:aaa1:59ff:fe57:eb97]) by smtp.gmail.com with ESMTPSA id ka42-20020a056a0093aa00b006e558a67374sm6686387pfb.0.2024.03.04.00.14.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Mar 2024 00:14:43 -0800 (PST) From: Barry Song <21cnbao@gmail.com> To: akpm@linux-foundation.org, linux-mm@kvack.org, ryan.roberts@arm.com Cc: chengming.zhou@linux.dev, chrisl@kernel.org, david@redhat.com, hannes@cmpxchg.org, kasong@tencent.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, mhocko@suse.com, nphamcs@gmail.com, shy828301@gmail.com, steven.price@arm.com, surenb@google.com, wangkefeng.wang@huawei.com, willy@infradead.org, xiang@kernel.org, ying.huang@intel.com, yosryahmed@google.com, yuzhao@google.com, Chuanhua Han , Barry Song Subject: [RFC PATCH v3 3/5] mm: swap: make should_try_to_free_swap() support large-folio Date: Mon, 4 Mar 2024 21:13:46 +1300 Message-Id: <20240304081348.197341-4-21cnbao@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240304081348.197341-1-21cnbao@gmail.com> References: <20240304081348.197341-1-21cnbao@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Chuanhua Han should_try_to_free_swap() works with an assumption that swap-in is always done at normal page granularity, aka, folio_nr_pages = 1. To support large folio swap-in, this patch removes the assumption. Signed-off-by: Chuanhua Han Co-developed-by: Barry Song Signed-off-by: Barry Song Acked-by: Chris Li --- mm/memory.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/memory.c b/mm/memory.c index abd4f33d62c9..e0d34d705e07 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -3837,7 +3837,7 @@ static inline bool should_try_to_free_swap(struct folio *folio, * reference only in case it's likely that we'll be the exlusive user. */ return (fault_flags & FAULT_FLAG_WRITE) && !folio_test_ksm(folio) && - folio_ref_count(folio) == 2; + folio_ref_count(folio) == (1 + folio_nr_pages(folio)); } static vm_fault_t pte_marker_clear(struct vm_fault *vmf) -- 2.34.1