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 0BA5A23BD05 for ; Wed, 5 Aug 2026 07:54:15 +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=1785916457; cv=none; b=hFaxc6ChqPEfqDVAlNxqrfm/fVzJSN6VtMrJG0w6lJhX2rona5A1nSQBQ7aSI0b2PqiB7e7gfHaYtiaTnbRtk89cm0HzRWC7NPiYiNRyFk0trqNpE9tWJcuxXP7XwbKbMIJ0JRN5duEhO5g62a6MZqLtDM3sjx+lgLNcoy1lFWQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785916457; c=relaxed/simple; bh=rniLTxIjlWcNpR517leeSpr0oIpPLO2dqGIPhD2euWk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-type; b=fhylA/JNSUE5CVdC79E7RAM2WXHRWNfCWN41EFsCoKcSOUh/GQk8c1J63QPvtxisTgzcPX1ef+qwhyjqmpmnG+WPrPl6wO69l08WlXvHxi5sKXRXrZ9nj0YVbxZMh6FF2AeDH84zb1TS9vTg4TIrOwnStR4L7qj9DnUR+Vhhdz0= 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=MSUvCXlN; 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="MSUvCXlN" 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=1785916453; 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=Vyg1JuKKGQsuDU1bKZ0uj2oDV98R+6DJe0buLRSbuTU=; b=MSUvCXlNL2jJBQKWRW6MwT/fPVE0vP3PeCSPlPH7WhqywWqLqS1Xh114SiWC01cikNT09/ vfXD2m/xesXSYNU3Uzfu6TaN8oGfy6pMdMom1JUDyeE9I7rEKk2LCr72CVqA+BGcdQoSY6 xBeD/z12DtBqmFC/8ZqDvGdWQfznWFU= From: Baoquan He To: linux-mm@kvack.org Cc: chrisl@kernel.org, nphamcs@gmail.com, kasong@tencent.com, baohua@kernel.org, youngjun.park@lge.com, hannes@cmpxchg.org, yosry@kernel.org, david@kernel.org, shikemeng@huaweicloud.com, chengming.zhou@linux.dev, linux-kernel@vger.kernel.org, Baoquan He Subject: [RFC PATCH v2 02/10] mm, swap: add CONFIG_XSWAP and xswap fields to swap_info_struct Date: Wed, 5 Aug 2026 15:53:25 +0800 Message-ID: <20260805075336.3579395-3-baoquan.he@linux.dev> In-Reply-To: <20260805075336.3579395-1-baoquan.he@linux.dev> References: <20260805075336.3579395-1-baoquan.he@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-type: text/plain Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT Add CONFIG_XSWAP Kconfig option (depends on SWAP && 64BIT) for extendable (virtual) swap device support. Add three fields to struct swap_info_struct under CONFIG_XSWAP: - cluster_vm: the VM_SPARSE vm_struct backing the cluster_info array - nr_clusters: total number of clusters in the xswap address space - nr_clusters_mapped: number of clusters currently mapped (lazy grow) These fields enable lazy vmalloc-based dynamic cluster management where the cluster_info array is backed by a sparse vmalloc area that grows on demand and shrinks when clusters are freed. Signed-off-by: Baoquan He --- include/linux/swap.h | 5 +++++ mm/Kconfig | 9 +++++++++ 2 files changed, 14 insertions(+) diff --git a/include/linux/swap.h b/include/linux/swap.h index 78f4302b92e1..970232f6359d 100644 --- a/include/linux/swap.h +++ b/include/linux/swap.h @@ -248,6 +248,11 @@ struct swap_info_struct { signed char type; /* strange name for an index */ unsigned int max; /* size of this swap device */ struct swap_cluster_info *cluster_info; /* cluster info. Only for SSD */ +#ifdef CONFIG_XSWAP + struct vm_struct *cluster_vm; /* VM_SPARSE area for xswap dynamic cluster_info */ + unsigned long nr_clusters; /* total cluster count for xswap */ + unsigned long nr_clusters_mapped; /* currently mapped cluster count */ +#endif struct list_head free_clusters; /* free clusters list */ struct list_head full_clusters; /* full clusters list */ struct list_head nonfull_clusters[SWAP_NR_ORDERS]; diff --git a/mm/Kconfig b/mm/Kconfig index 060190e12bce..82f62f4c5b23 100644 --- a/mm/Kconfig +++ b/mm/Kconfig @@ -122,6 +122,15 @@ config ZSWAP_COMPRESSOR_DEFAULT default "zstd" if ZSWAP_COMPRESSOR_DEFAULT_ZSTD default "" +config XSWAP + bool "Extendable (virtual) swap device" + depends on SWAP && 64BIT + help + Adds support for extendable swap devices (xswap) that decouple + PTE swap entries from physical backing storage. The cluster_info + array is backed by a sparse vmalloc area that grows and shrinks + on demand, avoiding static pre-allocation overhead. + config ZSMALLOC tristate -- 2.54.0