From nobody Mon Apr 6 17:25:09 2026 Received: from mail-oa1-f52.google.com (mail-oa1-f52.google.com [209.85.160.52]) (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 34A9C389458 for ; Wed, 18 Mar 2026 22:30:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773873010; cv=none; b=ljYz8RlAYbkbCpipxLKIk5xa8UEDeDr+3tgJMwuxx+5gZGp4tz8Z2cpoqb5+8jJkZ2bsdk0SsK7mgkG0pJycmo265dxc8xKN8jiSfrRbL22ul2vzNdbgmd31Tm4ve7yIxOjDthlBvJmh9WrZy8zMoENJUKQt5eUCNoxuCUC09Cs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773873010; c=relaxed/simple; bh=RtjI20tpXl2gzkkeQFik239RRAiwP1G/DuOJFlw72jc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=XJNxDDzyXEvTef7GFH0V+nbnhfmaw8vZ76vPH0/EGgqAukydg2bcvxqmANg4p6+AVpJ5RFh4VdzMLcmwfwzau0o7pDIQffOCFePv1BI6qTb8BCA1vnd2kKyvA0Z6fBmms3jo87KsiVws1puZlVat6GifZiieeLLw6wmnTPiR6Jk= 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=K9wqLewo; arc=none smtp.client-ip=209.85.160.52 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="K9wqLewo" Received: by mail-oa1-f52.google.com with SMTP id 586e51a60fabf-40ea36b56b7so364098fac.3 for ; Wed, 18 Mar 2026 15:30:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1773873007; x=1774477807; 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=0uOXWFDfbhJT9tG5Yl+ef83GJnrWQ5V7qgRvvdgSeJQ=; b=K9wqLewoSybShJc0AVArPIwS51nucN5E08RGEHDXaZbsq5CE93fWblAZ2pZ7WI0l6p mCd82ayyEhxDqgeh99XjSxmbJsdMnLAgsi8/7UAN398nI53qZSiKP8MXqWZMUzwE3li2 44GpfIm+Y/oIbjoTtTv7non18oj/6T6m3X9b+6gIHxTPQCVBGZyyrjfF7/xPbahBcFyX DsgZf+bn3grIXTJ/Po05RsbsOoEkSoFds9/LeLWGUYjbDite97+zfAesmi9OABEOBzfh cqOWM2K5SRFF+YHToYD9OALJn6jdC2BdUdw8rBSzQFVoyMIcTmop7MYF5Yt3/a1QIyzb BTEA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1773873007; x=1774477807; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=0uOXWFDfbhJT9tG5Yl+ef83GJnrWQ5V7qgRvvdgSeJQ=; b=Xvoz9MsgVaJMsQe2O1f4NIREQ77tf5E6lEGb+55mCZfH03KkrBVCqZH4wO2K/PGCkO nS6nA8U4f/Y5EwRJ6AwNJCbFjbjdt0l1mYLEI4fCi0lI57b9F9fNFGY2EMgL3ZFyaG2D YpebicsV4YriiqRO8nTAiMvhdQL5aZ3p8P3Ls+h0xXaafI85G8KAcFGXki83S19fGP3q WKDvD50t94bRvsLqlzMpm+wGxv2JZJ+RjVuNOun7tv2D4D5pvl6vR0bnDL1BRYBGkTZv hKLGJ8llH1mDYQv3aj2dtZcqbiBIgWnfLA1pnxtIz0QiiwthF/qultBHEul+FOQhUQ3Q d/Vw== X-Forwarded-Encrypted: i=1; AJvYcCUbFaB/EruqPPqiZ+o22NkgOk4mIFoFaQ7EK++Sz4rOVd+tKzsrvq25oF3up7Epc5fjoax6gWh7uIB7mt4=@vger.kernel.org X-Gm-Message-State: AOJu0YzES3E7B7rAlfNOoYet3J3un5X08hH/nzjMDRlk1TqsfJU3+8x4 Z59h+H/dLLg4I2lJoyD96f3DL7L4jt3u4XXU4+IGTy4wrBzMjCflpprQ X-Gm-Gg: ATEYQzzIzsxs0h5pp1lD5alqahpX4DBkzUCbSD4RbIG/4sh1sZM6qig0QVBnWRn0a4U SDsLiPpWV7e36QIMeDXBJreoMy2m9w8ghQcFW1nOCa2Bqz8mbc1oBSFBn7rSL1yB8IgPiClvhRg 8bOp+FNQqujMnUtVKqM70y0ORDFypswnx3yf1c0lDHJ4qlqLlOaTJQKjQWKK5qijIHhpELWZiTV AQ/x0nkrHidfvaGUKgMFPwPNjSULrRTp/FrOsC9QTyg926GH9PaXh4VWLAoZUWvgUToNqDpimZg djI4zRSOX9bWzndqKkgPSMt9U50dAHzeRunRjnirPwMlj0Rdnb3STEQEixCb6Yd5viw12qe11Hz T3zFIxl8cORSgKpzWVMsstN31OizTgCduW1wPutOo5z+F2tntX4auJIDZR+CrptOBMseEdY2aBN ArWiU6UXKatXET376XMByz81/MgQuVbjtPvGZQTnLgHgufBA== X-Received: by 2002:a05:6870:1405:b0:417:14d1:9671 with SMTP id 586e51a60fabf-41bd3f7d47cmr3526021fac.34.1773873006867; Wed, 18 Mar 2026 15:30:06 -0700 (PDT) Received: from localhost ([2a03:2880:10ff:73::]) by smtp.gmail.com with ESMTPSA id 586e51a60fabf-41bd22dee78sm4108849fac.0.2026.03.18.15.30.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Mar 2026 15:30:06 -0700 (PDT) From: Nhat Pham To: kasong@tencent.com Cc: Liam.Howlett@oracle.com, akpm@linux-foundation.org, apopple@nvidia.com, axelrasmussen@google.com, baohua@kernel.org, baolin.wang@linux.alibaba.com, bhe@redhat.com, byungchul@sk.com, cgroups@vger.kernel.org, chengming.zhou@linux.dev, chrisl@kernel.org, corbet@lwn.net, david@kernel.org, dev.jain@arm.com, gourry@gourry.net, hannes@cmpxchg.org, hughd@google.com, jannh@google.com, joshua.hahnjy@gmail.com, lance.yang@linux.dev, lenb@kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-pm@vger.kernel.org, lorenzo.stoakes@oracle.com, matthew.brost@intel.com, mhocko@suse.com, muchun.song@linux.dev, npache@redhat.com, nphamcs@gmail.com, pavel@kernel.org, peterx@redhat.com, peterz@infradead.org, pfalcato@suse.de, rafael@kernel.org, rakie.kim@sk.com, roman.gushchin@linux.dev, rppt@kernel.org, ryan.roberts@arm.com, shakeel.butt@linux.dev, shikemeng@huaweicloud.com, surenb@google.com, tglx@kernel.org, vbabka@suse.cz, weixugc@google.com, ying.huang@linux.alibaba.com, yosry.ahmed@linux.dev, yuanchu@google.com, zhengqi.arch@bytedance.com, ziy@nvidia.com, kernel-team@meta.com, riel@surriel.com Subject: [PATCH v4 07/21] mm: create scaffolds for the new virtual swap implementation Date: Wed, 18 Mar 2026 15:29:38 -0700 Message-ID: <20260318222953.441758-8-nphamcs@gmail.com> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260318222953.441758-1-nphamcs@gmail.com> References: <20260318222953.441758-1-nphamcs@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: quoted-printable Content-Type: text/plain; charset="utf-8" In prepration for the implementation of swap virtualization, add new scaffolds for the new code: a new mm/vswap.c source file, which currently only holds the logic to set up the (for now, empty) vswap debugfs directory. Hook this up in the swap setup step in mm/swap_state.c, and set up vswap compilation in the Makefile. Other than the debugfs directory, no behavioral change intended. Finally, make Johannes a swap reviewer, given that he has contributed majorly to the developments of virtual swap. Signed-off-by: Nhat Pham --- MAINTAINERS | 2 ++ include/linux/swap.h | 3 +++ mm/Makefile | 2 +- mm/swap_state.c | 6 ++++++ mm/vswap.c | 35 +++++++++++++++++++++++++++++++++++ 5 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 mm/vswap.c diff --git a/MAINTAINERS b/MAINTAINERS index e087673237636..b21038b160a07 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -16728,6 +16728,7 @@ R: Kemeng Shi R: Nhat Pham R: Baoquan He R: Barry Song +R: Johannes Weiner L: linux-mm@kvack.org S: Maintained F: Documentation/mm/swap-table.rst @@ -16740,6 +16741,7 @@ F: mm/swap.h F: mm/swap_table.h F: mm/swap_state.c F: mm/swapfile.c +F: mm/vswap.c =20 MEMORY MANAGEMENT - THP (TRANSPARENT HUGE PAGE) M: Andrew Morton diff --git a/include/linux/swap.h b/include/linux/swap.h index 918b47da55f44..df0771903a952 100644 --- a/include/linux/swap.h +++ b/include/linux/swap.h @@ -423,6 +423,9 @@ extern void __meminit kswapd_stop(int nid); =20 #ifdef CONFIG_SWAP =20 +/* Virtual swap space API (mm/vswap.c) */ +int vswap_init(void); + /* Lifecycle swap API (mm/swapfile.c) */ int folio_alloc_swap(struct folio *folio); bool folio_free_swap(struct folio *folio); diff --git a/mm/Makefile b/mm/Makefile index 2d0570a16e5be..67fa4586e7e18 100644 --- a/mm/Makefile +++ b/mm/Makefile @@ -75,7 +75,7 @@ ifdef CONFIG_MMU obj-$(CONFIG_ADVISE_SYSCALLS) +=3D madvise.o endif =20 -obj-$(CONFIG_SWAP) +=3D page_io.o swap_state.o swapfile.o +obj-$(CONFIG_SWAP) +=3D page_io.o swap_state.o swapfile.o vswap.o obj-$(CONFIG_ZSWAP) +=3D zswap.o obj-$(CONFIG_HAS_DMA) +=3D dmapool.o obj-$(CONFIG_HUGETLBFS) +=3D hugetlb.o hugetlb_sysfs.o hugetlb_sysctl.o diff --git a/mm/swap_state.c b/mm/swap_state.c index e2e9f55bea3bb..29ec666be4204 100644 --- a/mm/swap_state.c +++ b/mm/swap_state.c @@ -882,6 +882,12 @@ static int __init swap_init(void) int err; struct kobject *swap_kobj; =20 + err =3D vswap_init(); + if (err) { + pr_err("failed to initialize virtual swap space\n"); + return err; + } + swap_kobj =3D kobject_create_and_add("swap", mm_kobj); if (!swap_kobj) { pr_err("failed to create swap kobject\n"); diff --git a/mm/vswap.c b/mm/vswap.c new file mode 100644 index 0000000000000..e68234f053fc9 --- /dev/null +++ b/mm/vswap.c @@ -0,0 +1,35 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Virtual swap space + * + * Copyright (C) 2024 Meta Platforms, Inc., Nhat Pham + */ +#include + +#ifdef CONFIG_DEBUG_FS +#include + +static struct dentry *vswap_debugfs_root; + +static int vswap_debug_fs_init(void) +{ + if (!debugfs_initialized()) + return -ENODEV; + + vswap_debugfs_root =3D debugfs_create_dir("vswap", NULL); + return 0; +} +#else +static int vswap_debug_fs_init(void) +{ + return 0; +} +#endif + +int vswap_init(void) +{ + if (vswap_debug_fs_init()) + pr_warn("Failed to initialize vswap debugfs\n"); + + return 0; +} --=20 2.52.0