From nobody Fri Jun 26 19:18:49 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 CC347C433F5 for ; Sat, 19 Feb 2022 07:24:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241639AbiBSHZC (ORCPT ); Sat, 19 Feb 2022 02:25:02 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:53440 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229737AbiBSHY5 (ORCPT ); Sat, 19 Feb 2022 02:24:57 -0500 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D97986929A; Fri, 18 Feb 2022 23:24:37 -0800 (PST) Received: from kwepemi500021.china.huawei.com (unknown [172.30.72.55]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4K10MG1HVkzbbZM; Sat, 19 Feb 2022 15:20:10 +0800 (CST) Received: from kwepemm600010.china.huawei.com (7.193.23.86) by kwepemi500021.china.huawei.com (7.221.188.245) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.21; Sat, 19 Feb 2022 15:24:35 +0800 Received: from linux_suse_sp4_work.huawei.com (10.67.133.232) by kwepemm600010.china.huawei.com (7.193.23.86) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.21; Sat, 19 Feb 2022 15:24:35 +0800 From: Liao Hua To: , , , CC: , , , , Subject: [PATCH] latencytop: move latencytop sysctl to its own file Date: Sat, 19 Feb 2022 15:24:33 +0800 Message-ID: <20220219072433.86983-1-liaohua4@huawei.com> X-Mailer: git-send-email 2.12.3 MIME-Version: 1.0 X-Originating-IP: [10.67.133.232] X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To kwepemm600010.china.huawei.com (7.193.23.86) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: liaohua This moves latencytop sysctl to kernel/latencytop.c Signed-off-by: liaohua --- include/linux/latencytop.h | 3 --- kernel/latencytop.c | 41 +++++++++++++++++++++++++++++------------ kernel/sysctl.c | 10 ---------- 3 files changed, 29 insertions(+), 25 deletions(-) diff --git a/include/linux/latencytop.h b/include/linux/latencytop.h index abe3d95f795b..84f1053cf2a8 100644 --- a/include/linux/latencytop.h +++ b/include/linux/latencytop.h @@ -38,9 +38,6 @@ account_scheduler_latency(struct task_struct *task, int u= secs, int inter) =20 void clear_tsk_latency_tracing(struct task_struct *p); =20 -int sysctl_latencytop(struct ctl_table *table, int write, void *buffer, - size_t *lenp, loff_t *ppos); - #else =20 static inline void diff --git a/kernel/latencytop.c b/kernel/latencytop.c index 166d7bf49666..d2d17a856de0 100644 --- a/kernel/latencytop.c +++ b/kernel/latencytop.c @@ -55,6 +55,7 @@ #include #include #include +#include =20 static DEFINE_RAW_SPINLOCK(latency_lock); =20 @@ -63,6 +64,31 @@ static struct latency_record latency_record[MAXLR]; =20 int latencytop_enabled; =20 +static int sysctl_latencytop(struct ctl_table *table, int write, void *buf= fer, + size_t *lenp, loff_t *ppos) +{ + int err; + + err =3D proc_dointvec(table, write, buffer, lenp, ppos); + if (latencytop_enabled) + force_schedstat_enabled(); + + return err; +} + +#ifdef CONFIG_SYSCTL +static struct ctl_table latencytop_sysctl[] =3D { + { + .procname =3D "latencytop", + .data =3D &latencytop_enabled, + .maxlen =3D sizeof(int), + .mode =3D 0644, + .proc_handler =3D sysctl_latencytop, + }, + {} +}; +#endif + void clear_tsk_latency_tracing(struct task_struct *p) { unsigned long flags; @@ -266,18 +292,9 @@ static const struct proc_ops lstats_proc_ops =3D { static int __init init_lstats_procfs(void) { proc_create("latency_stats", 0644, NULL, &lstats_proc_ops); +#ifdef CONFIG_SYSCTL + register_sysctl_init("kernel", latencytop_sysctl); +#endif return 0; } - -int sysctl_latencytop(struct ctl_table *table, int write, void *buffer, - size_t *lenp, loff_t *ppos) -{ - int err; - - err =3D proc_dointvec(table, write, buffer, lenp, ppos); - if (latencytop_enabled) - force_schedstat_enabled(); - - return err; -} device_initcall(init_lstats_procfs); diff --git a/kernel/sysctl.c b/kernel/sysctl.c index 5ae443b2882e..57ec448b1268 100644 --- a/kernel/sysctl.c +++ b/kernel/sysctl.c @@ -65,7 +65,6 @@ #include #include #include -#include #include #include =20 @@ -1824,15 +1823,6 @@ static struct ctl_table kern_table[] =3D { .extra2 =3D SYSCTL_ONE, }, #endif -#ifdef CONFIG_LATENCYTOP - { - .procname =3D "latencytop", - .data =3D &latencytop_enabled, - .maxlen =3D sizeof(int), - .mode =3D 0644, - .proc_handler =3D sysctl_latencytop, - }, -#endif #ifdef CONFIG_BLK_DEV_INITRD { .procname =3D "real-root-dev", --=20 2.12.3