From nobody Sun Feb 8 15:01:33 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 38829EB64D9 for ; Tue, 27 Jun 2023 12:39:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231251AbjF0MjG (ORCPT ); Tue, 27 Jun 2023 08:39:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44696 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230063AbjF0MjE (ORCPT ); Tue, 27 Jun 2023 08:39:04 -0400 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 95B6726A5 for ; Tue, 27 Jun 2023 05:39:01 -0700 (PDT) Received: from kwepemm600003.china.huawei.com (unknown [172.30.72.54]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4Qr42P74fbzlW0J; Tue, 27 Jun 2023 20:36:13 +0800 (CST) Received: from huawei.com (10.175.113.32) by kwepemm600003.china.huawei.com (7.193.23.202) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Tue, 27 Jun 2023 20:38:56 +0800 From: Nanyong Sun To: CC: , , , , Subject: [PATCH] mm/ksm: delete the redundant ksm_merging_pages interafce in proc Date: Tue, 27 Jun 2023 21:35:42 +0800 Message-ID: <20230627133542.2446285-1-sunnanyong@huawei.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.175.113.32] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To kwepemm600003.china.huawei.com (7.193.23.202) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Since the ksm_merging_pages information already included in /proc//ksm_stat, we can delete /proc//ksm_merging_pages to make the directory more clean, and can save a little bit resources. Signed-off-by: Nanyong Sun Reviewed-by: xu xin --- Documentation/admin-guide/mm/ksm.rst | 6 +++--- .../translations/zh_CN/admin-guide/mm/ksm.rst | 4 ++-- fs/proc/base.c | 15 --------------- 3 files changed, 5 insertions(+), 20 deletions(-) diff --git a/Documentation/admin-guide/mm/ksm.rst b/Documentation/admin-gui= de/mm/ksm.rst index 7626392fe82c..e668d4b5e800 100644 --- a/Documentation/admin-guide/mm/ksm.rst +++ b/Documentation/admin-guide/mm/ksm.rst @@ -208,9 +208,9 @@ several times, which are unprofitable memory consumed. process_profit =3D~ ksm_merging_pages * sizeof(page) - ksm_rmap_items * sizeof(rmap_item). =20 - where ksm_merging_pages is shown under the directory ``/proc//``, - and ksm_rmap_items is shown in ``/proc//ksm_stat``. The process pr= ofit - is also shown in ``/proc//ksm_stat`` as ksm_process_profit. + where ksm_merging_pages and ksm_rmap_items is shown in the file + ``/proc//ksm_stat``. The process profit is also shown in + ``/proc//ksm_stat`` as ksm_process_profit. =20 From the perspective of application, a high ratio of ``ksm_rmap_items`` to ``ksm_merging_pages`` means a bad madvise-applied policy, so developers or diff --git a/Documentation/translations/zh_CN/admin-guide/mm/ksm.rst b/Docu= mentation/translations/zh_CN/admin-guide/mm/ksm.rst index 0029c4fd2201..1662f271efc8 100644 --- a/Documentation/translations/zh_CN/admin-guide/mm/ksm.rst +++ b/Documentation/translations/zh_CN/admin-guide/mm/ksm.rst @@ -167,8 +167,8 @@ KSM=E5=8F=AF=E4=BB=A5=E9=80=9A=E8=BF=87=E5=90=88=E5=B9= =B6=E7=9B=B8=E5=90=8C=E7=9A=84=E9=A1=B5=E9=9D=A2=E6=9D=A5=E8=8A=82=E7=9C=81= =E5=86=85=E5=AD=98=EF=BC=8C=E4=BD=86=E4=B9=9F=E4=BC=9A=E6=B6=88=E8=80=97=E9= =A2=9D=E5=A4=96=E7=9A=84 process_profit =3D~ ksm_merging_pages * sizeof(page) - ksm_rmap_items * sizeof(rmap_item). =20 - =E5=85=B6=E4=B8=ADksm_merging_pages=E6=98=BE=E7=A4=BA=E5=9C=A8 ``/proc/= /`` =E7=9B=AE=E5=BD=95=E4=B8=8B=EF=BC=8C=E8=80=8Cksm_rmap_items - =E6=98=BE=E7=A4=BA=E5=9C=A8 ``/proc//ksm_stat`` =E3=80=82 + =E5=85=B6=E4=B8=ADksm_merging_pages=E3=80=81ksm_rmap_items=E6=98=BE=E7= =A4=BA=E5=9C=A8 ``/proc//ksm_stat`` =E6=96=87=E4=BB=B6=E4=B8=AD=EF=BC= =8C=E6=94=B6=E7=9B=8A + =E5=80=BCksm_process_profit=E4=B9=9F=E6=98=BE=E7=A4=BA=E5=9C=A8=E8=AF= =A5=E6=96=87=E4=BB=B6=E4=B8=AD=E3=80=82 =20 =E4=BB=8E=E5=BA=94=E7=94=A8=E7=9A=84=E8=A7=92=E5=BA=A6=E6=9D=A5=E7=9C=8B= =EF=BC=8C ``ksm_rmap_items`` =E5=92=8C ``ksm_merging_pages`` =E7=9A=84=E9= =AB=98=E6=AF=94=E4=BE=8B=E6=84=8F =E5=91=B3=E7=9D=80=E4=B8=8D=E5=A5=BD=E7=9A=84madvise-applied=E7=AD=96=E7= =95=A5=EF=BC=8C=E6=89=80=E4=BB=A5=E5=BC=80=E5=8F=91=E8=80=85=E6=88=96=E7=AE= =A1=E7=90=86=E5=91=98=E5=BF=85=E9=A1=BB=E9=87=8D=E6=96=B0=E8=80=83=E8=99=91= =E5=A6=82=E4=BD=95=E6=94=B9=E5=8F=98madvis=E7=AD=96 diff --git a/fs/proc/base.c b/fs/proc/base.c index 05452c3b9872..173261dbeaea 100644 --- a/fs/proc/base.c +++ b/fs/proc/base.c @@ -3186,19 +3186,6 @@ static int proc_pid_patch_state(struct seq_file *m, = struct pid_namespace *ns, #endif /* CONFIG_LIVEPATCH */ =20 #ifdef CONFIG_KSM -static int proc_pid_ksm_merging_pages(struct seq_file *m, struct pid_names= pace *ns, - struct pid *pid, struct task_struct *task) -{ - struct mm_struct *mm; - - mm =3D get_task_mm(task); - if (mm) { - seq_printf(m, "%lu\n", mm->ksm_merging_pages); - mmput(mm); - } - - return 0; -} static int proc_pid_ksm_stat(struct seq_file *m, struct pid_namespace *ns, struct pid *pid, struct task_struct *task) { @@ -3348,7 +3335,6 @@ static const struct pid_entry tgid_base_stuff[] =3D { ONE("seccomp_cache", S_IRUSR, proc_pid_seccomp_cache), #endif #ifdef CONFIG_KSM - ONE("ksm_merging_pages", S_IRUSR, proc_pid_ksm_merging_pages), ONE("ksm_stat", S_IRUSR, proc_pid_ksm_stat), #endif }; @@ -3686,7 +3672,6 @@ static const struct pid_entry tid_base_stuff[] =3D { ONE("seccomp_cache", S_IRUSR, proc_pid_seccomp_cache), #endif #ifdef CONFIG_KSM - ONE("ksm_merging_pages", S_IRUSR, proc_pid_ksm_merging_pages), ONE("ksm_stat", S_IRUSR, proc_pid_ksm_stat), #endif }; --=20 2.25.1