From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out-186.mta1.migadu.com (out-186.mta1.migadu.com [95.215.58.186]) (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 592B9494A04 for ; Wed, 29 Jul 2026 14:26:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.186 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785335203; cv=none; b=TZHPKH4C4K2MKKaSNlk5xs285kbqxM+2vCudDw5eFsl4GhmNcddEamDKu6S9dSDVHZRloaDjLjtKJZ09umFkmgr9ctYQ8dIo+1WooAEuhuKZiBq04Vo6vWv7Ne5pf1LSSIOppV5xdB+tl9I9lRgt7H1mNKMRqZMlfKORwT/wogg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785335203; c=relaxed/simple; bh=cZ35Ka37tyaFaDBjlLZvydo3/eatgtOVZ4GFfqTLoas=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=Kwa4QHlkxrgCvQy9I7eq8D6Rr7XgU3sMhzlPBtsT6dxjVEHQ7tJ9klhALdiWE+rZX5GanvEuXROU+BIVOTbsFgyJaPvqYT1rd/yCPMbXZ/J7jmCv91S0pBToLDjMnvb9gZlKiaokEDtEmWsqRB3xEEiAFA+Zaje0hLfF9GKqwfc= 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=ZH36KbU0; arc=none smtp.client-ip=95.215.58.186 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="ZH36KbU0" Date: Wed, 29 Jul 2026 22:26:18 +0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1785335197; 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=lQ5sw2S8TC3g0HBtNAS/PmD4W872YaLT1+5/e811w7I=; b=ZH36KbU0TXhYvzDJMRFthBhwpNzP6gy8d5toUvOh03i9AxaR7l5NVXBc5GIgnJEnLbou7Y qEIrZMkfu3UeIGNMp08k3GNdDX3Elxne6HgumLnOffUAVrB4lqksGrvkf8d7BI4d+gAPO3 eDwjusN4E3c+LmeOx6KZvDy7gbsvRF0= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Baoquan He To: Chris Li Cc: linux-mm@kvack.org, akpm@linux-foundation.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 Subject: Re: [RFC PATCH 02/11] mm, swap: add CONFIG_XSWAP and xswap fields to swap_info_struct Message-ID: References: <20260727135029.1059441-1-baoquan.he@linux.dev> <20260727140503.1060918-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; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Migadu-Flow: FLOW_OUT On 07/27/26 at 08:26am, Chris Li wrote: > On Mon, Jul 27, 2026 at 7:05 AM Baoquan He wrote: > > > > 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 80c83dd8804f..5f6b14d30758 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 > > We might need more than one dynamic kvmalloc grow array. Maybe > abstract this into a struct so it can be reused for arrays other than > clusters as well. The abstraction can also include the element size so > it can have a generic function to calculate how many pages it needs > for N elements. I agree in principle. I think we can pull that out as a follow-up when the second user emerges, rather than abstracting prematurely.