From nobody Mon Dec 1 21:33:25 2025 Received: from mta21.hihonor.com (mta21.honor.com [81.70.160.142]) (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 8584D199252; Fri, 28 Nov 2025 03:10:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=81.70.160.142 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764299431; cv=none; b=H3cdYdeg1SJ8k6IqoOh5pOW/Y0vjF08p+ACin5mosdzUrZLNXn0r0p7USwUkBKWi253HFq4n0/vLd3YFMcK4YRXRz7t0CMyAcz7BIzc6tCi8J6vNgQg3p+n3aBusdyTcRbKR2/eig0kXSSuku4zFDF7nNakZgCvGMvzAJLtI4Rg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764299431; c=relaxed/simple; bh=hk9UQh9z/96n9IuZCKnIWje2f+aFL+5nYxKb4bxDZbU=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=X0+l0oRWrcJflI02YzPpcOMKrmiXVsjPPAwrZKVbhjQXXN71FmxsvxXZvpSmb0vfhtxAJ+X57CJdzLfE1i0hmMwNqCMr3zQ9EsOJb9EW9CbfaWxXb1CUBBo9SqHFn75mm5eBUOdbsDlftRcggy9z4iZHliYBPTuzsbAeFoAuzq8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=honor.com; spf=pass smtp.mailfrom=honor.com; arc=none smtp.client-ip=81.70.160.142 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=honor.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=honor.com Received: from w002.hihonor.com (unknown [10.68.28.120]) by mta21.hihonor.com (SkyGuard) with ESMTPS id 4dHdBy1DhFzYmZ9w; Fri, 28 Nov 2025 10:52:58 +0800 (CST) Received: from localhost.localdomain (10.144.5.36) by w002.hihonor.com (10.68.28.120) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Fri, 28 Nov 2025 10:54:19 +0800 From: Zicheng Wang To: , , , , CC: , , , , , , , , , , , , , , Zicheng Wang Subject: [PATCH 1/3] mm/lru_gen: add procfs support for lru_gen interfaces Date: Fri, 28 Nov 2025 10:53:13 +0800 Message-ID: <20251128025315.3520689-2-wangzicheng@honor.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20251128025315.3520689-1-wangzicheng@honor.com> References: <20251128025315.3520689-1-wangzicheng@honor.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 X-ClientProxiedBy: w012.hihonor.com (10.68.27.189) To w002.hihonor.com (10.68.28.120) Content-Type: text/plain; charset="utf-8" This patch refactors the lru_gen and lru_gen_full control files to allow their interfaces to be exposed under either debugfs or procfs. Two main changes: 1. minimal code modification by reusing the existing seq_operations. 2. lru_gen file mode update from 0644 to 0664, so that Android's group "system" can write to the file when procfs interface is enabled. Signed-off-by: Zicheng Wang --- mm/vmscan.c | 37 +++++++++++++++++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-) diff --git a/mm/vmscan.c b/mm/vmscan.c index 674999999..dd30f3949 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -58,6 +58,7 @@ #include #include #include +#include =20 #include #include @@ -5324,9 +5325,17 @@ static const struct attribute_group lru_gen_attr_gro= up =3D { }; =20 /*************************************************************************= ***** - * debugfs interface + * lru_gen interface *************************************************************************= *****/ =20 +static inline bool lru_gen_show_is_full(const struct file *file) +{ + /* procfs: i_private =3D (void *)1 means full + * debugfs: also works because debugfs sets i_private + */ + return file->f_inode->i_private !=3D NULL; +} + static void *lru_gen_seq_start(struct seq_file *m, loff_t *pos) { struct mem_cgroup *memcg; @@ -5435,7 +5444,7 @@ static void lru_gen_seq_show_full(struct seq_file *m,= struct lruvec *lruvec, static int lru_gen_seq_show(struct seq_file *m, void *v) { unsigned long seq; - bool full =3D debugfs_get_aux_num(m->file); + bool full =3D lru_gen_show_is_full(m->file); struct lruvec *lruvec =3D v; struct lru_gen_folio *lrugen =3D &lruvec->lrugen; int nid =3D lruvec_pgdat(lruvec)->node_id; @@ -5671,6 +5680,7 @@ static int lru_gen_seq_open(struct inode *inode, stru= ct file *file) return seq_open(file, &lru_gen_seq_ops); } =20 +#ifndef CONFIG_LRU_GEN_PROCFS_CTRL static const struct file_operations lru_gen_rw_fops =3D { .open =3D lru_gen_seq_open, .read =3D seq_read, @@ -5685,6 +5695,22 @@ static const struct file_operations lru_gen_ro_fops = =3D { .llseek =3D seq_lseek, .release =3D seq_release, }; +#else +static const struct proc_ops lru_gen_proc_rw_ops =3D { + .proc_open =3D lru_gen_seq_open, + .proc_read =3D seq_read, + .proc_write =3D lru_gen_seq_write, + .proc_lseek =3D seq_lseek, + .proc_release =3D seq_release, +}; + +static const struct proc_ops lru_gen_proc_ro_ops =3D { + .proc_open =3D lru_gen_seq_open, + .proc_read =3D seq_read, + .proc_lseek =3D seq_lseek, + .proc_release =3D seq_release, +}; +#endif =20 /*************************************************************************= ***** * initialization @@ -5772,10 +5798,17 @@ static int __init init_lru_gen(void) if (sysfs_create_group(mm_kobj, &lru_gen_attr_group)) pr_err("lru_gen: failed to create sysfs group\n"); =20 +#ifndef CONFIG_LRU_GEN_PROCFS_CTRL debugfs_create_file_aux_num("lru_gen", 0644, NULL, NULL, false, &lru_gen_rw_fops); debugfs_create_file_aux_num("lru_gen_full", 0444, NULL, NULL, true, &lru_gen_ro_fops); +#else + proc_create_data("lru_gen", 0664, NULL, + &lru_gen_proc_rw_ops, NULL); + proc_create_data("lru_gen_full", 0444, NULL, + &lru_gen_proc_ro_ops, (void *)1); +#endif =20 return 0; }; --=20 2.25.1 From nobody Mon Dec 1 21:33:25 2025 Received: from mta21.hihonor.com (mta21.honor.com [81.70.160.142]) (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 9C4B227E7F0; Fri, 28 Nov 2025 03:10:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=81.70.160.142 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764299431; cv=none; b=eMtiNw+ninoQtP6+O0yIFAOtIkDu4j1mIG0Ei1wfo1OapZtioIeeUK6tQS54K4135KgreHRU1EF5J6pwmcjOWDWPa8efIwv3u80IHivaaX40iAUsPIHFMuCceyjMP8eBAHw0TBvLwS5ncLeWju8KwaNY94nMHN8sC34Xfa8pQFA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764299431; c=relaxed/simple; bh=RvZ0qCmwZ3fJPqm5mLK+MGtwlfZWW35XmWu/Rt1Gxr0=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=HaGhZqT9cSFtPM4pDSlo0PcpYILBstRxYbirgoVwdqJc7wuQ1QfybqJzcjphjIMEUjE9r+fpYC3oXzv6C1oeUd/66puNs00J/s9w+OT5qfEM5w/bItwMbZuvyPXRVH4bNth/epEZR6tPIuifXfqdZVLF9BWFzDjmAICxKIqUlUA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=honor.com; spf=pass smtp.mailfrom=honor.com; arc=none smtp.client-ip=81.70.160.142 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=honor.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=honor.com Received: from w002.hihonor.com (unknown [10.68.28.120]) by mta21.hihonor.com (SkyGuard) with ESMTPS id 4dHdBy2jyCzYmZBB; Fri, 28 Nov 2025 10:52:58 +0800 (CST) Received: from localhost.localdomain (10.144.5.36) by w002.hihonor.com (10.68.28.120) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Fri, 28 Nov 2025 10:54:19 +0800 From: Zicheng Wang To: , , , , CC: , , , , , , , , , , , , , , Zicheng Wang Subject: [PATCH 2/3] mm/lru_gen: add configuration option to select debugfs/procfs for lru_gen Date: Fri, 28 Nov 2025 10:53:14 +0800 Message-ID: <20251128025315.3520689-3-wangzicheng@honor.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20251128025315.3520689-1-wangzicheng@honor.com> References: <20251128025315.3520689-1-wangzicheng@honor.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 X-ClientProxiedBy: w012.hihonor.com (10.68.27.189) To w002.hihonor.com (10.68.28.120) Content-Type: text/plain; charset="utf-8" Signed-off-by: Zicheng Wang --- mm/Kconfig | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/mm/Kconfig b/mm/Kconfig index e443fe8cd..be7efa794 100644 --- a/mm/Kconfig +++ b/mm/Kconfig @@ -1325,6 +1325,16 @@ config LRU_GEN_STATS config LRU_GEN_WALKS_MMU def_bool y depends on LRU_GEN && ARCH_HAS_HW_PTE_YOUNG + +config LRU_GEN_PROCFS_CTRL + bool "Move lru_gen files from debugfs to procfs" + depends on LRU_GEN && PROC_FS + help + Move lru_gen management from debugfs to procfs (/proc/lru_gen). + This production-ready feature provides critical memory reclaim + prediction and control. It is no longer experimental. + The migration ensures availability in commercial products where + debugfs may be disabled. # } =20 config ARCH_SUPPORTS_PER_VMA_LOCK --=20 2.25.1 From nobody Mon Dec 1 21:33:25 2025 Received: from mta22.hihonor.com (mta22.hihonor.com [81.70.192.198]) (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 1780027E7F0; Fri, 28 Nov 2025 03:11:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=81.70.192.198 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764299518; cv=none; b=UcGFIyUDwosJZdEx1hoK71Q+UpQ2XCvo0priKZGhaI1psvOHPQxAxVKMrK/F8n1vPDjm1U+7OFHmxoXb32wAZ2HOuX8Qy9lb0ps4Cz8ERpNu+WU3TgNrsTUi26Vu1RAkkEQjIv43jETpkO5uKZ/yuHm+8DGbnRsAN/cVS75B8WE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764299518; c=relaxed/simple; bh=gU0jwzK/DYSOitX7LplGaHqyCltgRlPoQldaJbSs83I=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=hEekpy4Vi1MW+DJU42ZyedJgNH3SBphWeDHlJUXck4segNUjgzWVXRj07auHwDQs0NpxJ6+4znikIneWFI6k6oyuBhbeLuwdgX2pyxicDO2yAcJSXKcAJqPgpMb30ZOLvKJOqb7dgH2MbqMSA4tthIKrtizAoYwZKfLJgVbkDsg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=honor.com; spf=pass smtp.mailfrom=honor.com; dkim=pass (1024-bit key) header.d=honor.com header.i=@honor.com header.b=D/ONv38m; arc=none smtp.client-ip=81.70.192.198 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=honor.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=honor.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=honor.com header.i=@honor.com header.b="D/ONv38m" dkim-signature: v=1; a=rsa-sha256; d=honor.com; s=dkim; c=relaxed/relaxed; q=dns/txt; h=To:From; bh=ayengAhX69VuLBH0udWTRo6vLW+weVNlnBoDZD4F89Y=; b=D/ONv38mN1pq1e7180jj6fLd5a8259bJluYa3QO18y6zFy5F/tRiYEJP8sym2N7hA863amxvr UmNMVh51G4h4+er9cvTf/XqUjjc4dCIuQNJ6lR9iPwniiE+8aoFvWlI/2gJhYBYcJyOxXcb7XTV KBo6WDRcjPl4ShX19XnFtbQ= Received: from w002.hihonor.com (unknown [10.68.28.120]) by mta22.hihonor.com (SkyGuard) with ESMTPS id 4dHdBN5DVfzYmwXH; Fri, 28 Nov 2025 10:52:28 +0800 (CST) Received: from localhost.localdomain (10.144.5.36) by w002.hihonor.com (10.68.28.120) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Fri, 28 Nov 2025 10:54:19 +0800 From: Zicheng Wang To: , , , , CC: , , , , , , , , , , , , , , Zicheng Wang Subject: [PATCH 3/3] mm/lru_gen: document procfs interface for lru_gen Date: Fri, 28 Nov 2025 10:53:15 +0800 Message-ID: <20251128025315.3520689-4-wangzicheng@honor.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20251128025315.3520689-1-wangzicheng@honor.com> References: <20251128025315.3520689-1-wangzicheng@honor.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 X-ClientProxiedBy: w012.hihonor.com (10.68.27.189) To w002.hihonor.com (10.68.28.120) Content-Type: text/plain; charset="utf-8" Signed-off-by: Zicheng Wang --- Documentation/admin-guide/mm/multigen_lru.rst | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/Documentation/admin-guide/mm/multigen_lru.rst b/Documentation/= admin-guide/mm/multigen_lru.rst index 9cb54b4ff..d9927b254 100644 --- a/Documentation/admin-guide/mm/multigen_lru.rst +++ b/Documentation/admin-guide/mm/multigen_lru.rst @@ -161,3 +161,22 @@ cold pages because of the overestimation, it retries o= n the next server according to the ranking result obtained from the working set estimation step. This less forceful approach limits the impacts on the existing jobs. + +Procfs Migration +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D +The multi-gen LRU control interface has been moved from debugfs to procfs +via ``CONFIG_LRU_GEN_PROCFS_CTRL``: + +New Path +-------- +- Control interface: ``/proc/lru_gen`` +- Replaces debugfs path: ``/sys/kernel/debug/lru_gen`` + +Key Advantages +-------------- +1. Production-ready availability (works when debugfs is not allowed) +2. Maintains identical ABI to original debugfs interface +3. Preserves all core functionality (working set estimation, proactive rec= laim) +4. Standardized location matching memory management conventions + +Note: Requires both ``CONFIG_PROC_FS`` and ``CONFIG_LRU_GEN`` --=20 2.25.1