From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (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 DDDEE175A94 for ; Wed, 8 Apr 2026 02:49:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775616567; cv=none; b=WjBBp+ofISgtYRUfx5Q+Btggn9aLDZpxhhiCWjriFOjWJmRVtN0PzAvVj5yaDth2FCYaonFbkQJpWTorHwmyySfU1+fDtsonRQSUQ4tZzkNg3QUPbysQauzxwAq1roONg7Xr/c/lUhKJbhTtdSOpEdO5F2GG8oG6ADTd35YmMhw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775616567; c=relaxed/simple; bh=cJTUoTU7NyfHcyic2BUAavYCY/maUSbDdS2MamW4GeY=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=XVEnqVZj6uR+cc7TdV63PhiMfH4o/+WjYUVhre4b5R2cyTy2yhVrm0ZIy6nE1ykbiFQxukOGD1ZBN9+42s6vpAA24w/YI7s69qu+vrwfhAb83SUsn0y508uWq9jGmQIMHai9Msc3bIabby1+ViFotoRgn7XhQ1y9vqzwom1GNBs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=O+F0AIDt; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="O+F0AIDt" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1775616564; 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=XAHOhaZnMi2g4QNdL7Fre1v9gU9ZPxngZ75akcpvl5w=; b=O+F0AIDtc9X5FgH5Gk081U7sZi2aJ/hk7p+nGUIRhZrAh/vIKm8OR0gu2Emit4pXn8i/WF 0Kypm2m7DL1cQO6idSLH0VVtlEJOuhSpkPaXjSg5yxCiQoWCn/LVK++qJslFBGuIdl6izc i8JC/bIK8IDZF9bOOCa4jWK4XGWByXk= Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-662-byPuJsC6NNafl8IYg_Ar7w-1; Tue, 07 Apr 2026 22:49:21 -0400 X-MC-Unique: byPuJsC6NNafl8IYg_Ar7w-1 X-Mimecast-MFC-AGG-ID: byPuJsC6NNafl8IYg_Ar7w_1775616559 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id CBC3B1956094; Wed, 8 Apr 2026 02:49:17 +0000 (UTC) Received: from localhost (unknown [10.72.112.14]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 5A6CE300019F; Wed, 8 Apr 2026 02:49:15 +0000 (UTC) Date: Wed, 8 Apr 2026 10:49:12 +0800 From: Baoquan He To: Barry Song Cc: Johannes Weiner , Jianyue Wu , linux-mm@kvack.org, akpm@linux-foundation.org, david@kernel.org, mhocko@suse.com, zhengqi.arch@bytedance.com, shakeel.butt@linux.dev, lorenzo.stoakes@oracle.com, chrisl@kernel.org, kasong@tencent.com, shikemeng@huaweicloud.com, nphamcs@gmail.com, linux-kernel@vger.kernel.org Subject: Re: [PATCH] mm: move folio LRU helpers out of swap Message-ID: References: <20260407110002.204755-1-wujianyue000@gmail.com> 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-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 On 04/08/26 at 10:20am, Barry Song wrote: > On Wed, Apr 8, 2026 at 9:39 AM Baoquan He wrote: > > > > On 04/07/26 at 10:22am, Johannes Weiner wrote: > > > On Tue, Apr 07, 2026 at 07:00:02PM +0800, Jianyue Wu wrote: > > > > All allocated folios are added into lru lists for later reclaim whether > > > > they are file or anonymous folios. However those folio lru operation codes > > > > are put in mm/swap.c which is not so appropriate. Because swap code is > > > > only for anonymous folios. > > > > > > Ironically, the only thing that doesn't fit in this file is the swap > > > stuff. The page_cluster & sysctl should be static in swap_state.c. > > > > > > The rest seems thematically relatively clean - infrastructure for > > > managing folio lifetime. swap.c is not the best name for it, but short > > > of finding a very clear improvement I'd just leave it alone. > > > > Can't agree more. We should move page_cluster & sysctl and swap_setup() > > to mm/swap_state.c, and rename mm/swap.c to mm/folio_lru.c or something > > like that. > > Another issue is that many MM-internal items are placed in the > top-level include/linux/swap.h, which is supposed to be used by > code outside the MM subsystem as well. > > For example, the following are actually MM-internal: > > extern int vm_swappiness; > swap_setup(); > workingset_*(); > try_to_free_pages(); > zone_reclaimable_pages(); > lruvec_lru_size(); > try_to_free_mem_cgroup_pages(); > ... Ah, indeed. Seems we have been putting generic code related to reclaim into swap.h|.c due to historic reason. From discussion, I think the below three things are doable. 1) move page_cluster & sysctl and swap_setup() into mm/swap_state.c because page_cluster is only used in mm/swap_state.c as Johannes suggestd. And swap_setup() may need be renamed too? 2) rename mm/swap.c to mm/folio_lru.c or something like that to reflect its real content; 3) Just Barry pointed out, move generic code related to reclaim out of include/linux/swap.h e.g move into mm/internal.h if they are only called inside mm/ folder, Thanks Baoquan