Received: by 2002:a05:6a10:83d0:0:0:0:0 with SMTP id o16csp68254pxh; Thu, 7 Apr 2022 14:12:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy84z27TUAveO0V4ZxxdU+iYXMvLp6n2s+n6K2XKwRVhII7iNYkO4oBX4qWDljNhAq1bP0B X-Received: by 2002:a17:902:e743:b0:153:a902:8d8c with SMTP id p3-20020a170902e74300b00153a9028d8cmr15668567plf.150.1649365962249; Thu, 07 Apr 2022 14:12:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649365962; cv=none; d=google.com; s=arc-20160816; b=jb8PBggCXeWU3dciynZqIQ9Ky+Ka9PS8YXkNiK4ex72nH20iniouLX67qi3Qsvpcbv ghgJ/P7XdPyBs/qk1aFmWkLzC+sysSKF1tdErvpZ31uSBswZ8FPBBrxuDh0cjMHMd7w8 LOouywB1ZJyVedHx58BxysFtXbzKBO7ebi0Ckgkm0v0vswOwLQqE/H4oGMLSI6oFpBG3 IBZZW9/KU7X04MAYHdcZz8nc5IXGSxK0mu6KE3zbEUaBYW+ITZbcZGbGAJMxnSFBmwK1 MizcxhkGk2L51T/9I5Rr56GnVpLt9C7rcsawukc0OcGc2sCC3cJuvwFyd9JCbTJPbkM4 UuQw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:subject:cc:to:from; bh=YiLzLosYU9OOccG5dFfwFauzCtkwbGIPOOGQPR6urMk=; b=s8qPhbaz6bmy2u3WEoZgKTlCEuVRLDYqU3vq8HpvsfIQS4QYvtMtXvlUf0dHTDuu+A oRBRwU9NoIz6hlCR5+/2HMsiOqh7NkM6PQtE29nJhR+pBoT1ih3Z98jsj/bHFLTDccCu v3DJW5S5GsynTiOIYiZ5yzwug/OZoeWPIfnc5uuopD/AmI2nXRUdjQJcWnOyBx3bh0ZU RzoiPHqPWmm8CmDpA7Gr5KNjNjeh5bQRjdaXpZGKE4E0SfgqsGaDAISkcm4pMkxkrMvE pBE5c/QAxH9zvJekWNeG02h8Lvx+gemCWbi52XEx4MB4X98oHhE65517d+dgo/rnuJND iL7Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id my13-20020a17090b4c8d00b001c6c8e19f0csi3070843pjb.98.2022.04.07.14.12.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Apr 2022 14:12:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 75EE84480B6; Thu, 7 Apr 2022 13:05:13 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241779AbiDGHb6 (ORCPT + 99 others); Thu, 7 Apr 2022 03:31:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56186 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234761AbiDGHb4 (ORCPT ); Thu, 7 Apr 2022 03:31:56 -0400 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 97EA04ECF2; Thu, 7 Apr 2022 00:29:55 -0700 (PDT) Received: from kwepemi500025.china.huawei.com (unknown [172.30.72.57]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4KYtJl1dzNzgYWg; Thu, 7 Apr 2022 15:28:07 +0800 (CST) Received: from kwepemm600010.china.huawei.com (7.193.23.86) by kwepemi500025.china.huawei.com (7.221.188.170) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Thu, 7 Apr 2022 15:29:52 +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; Thu, 7 Apr 2022 15:29:51 +0800 From: Liao Hua To: , , , CC: , , Subject: [PATCH sysctl-next v3] latencytop: move sysctl to its own file Date: Thu, 7 Apr 2022 15:29:48 +0800 Message-ID: <20220407072948.55820-1-liaohua4@huawei.com> X-Mailer: git-send-email 2.12.3 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.67.133.232] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To kwepemm600010.china.huawei.com (7.193.23.86) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: liaohua This moves latencytop sysctl to kernel/latencytop.c Signed-off-by: liaohua ------ v3: Base the patch on the latest sysctl-next and resubmit. v2: https://lore.kernel.org/lkml/20220223094710.103378-1-liaohua4@huawei.com/ Move latencytop sysctl to its own file base based on sysctl-next. v1: https://lore.kernel.org/lkml/20220219072433.86983-1-liaohua4@huawei.com/ Move latencytop sysctl to its own file base based on linux master. --- 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 usecs, int inter) void clear_tsk_latency_tracing(struct task_struct *p); -int sysctl_latencytop(struct ctl_table *table, int write, void *buffer, - size_t *lenp, loff_t *ppos); - #else static inline void diff --git a/kernel/latencytop.c b/kernel/latencytop.c index 166d7bf49666..76166df011a4 100644 --- a/kernel/latencytop.c +++ b/kernel/latencytop.c @@ -55,6 +55,7 @@ #include #include #include +#include static DEFINE_RAW_SPINLOCK(latency_lock); @@ -63,6 +64,31 @@ static struct latency_record latency_record[MAXLR]; int latencytop_enabled; +#ifdef CONFIG_SYSCTL +static int sysctl_latencytop(struct ctl_table *table, int write, void *buffer, + size_t *lenp, loff_t *ppos) +{ + int err; + + err = proc_dointvec(table, write, buffer, lenp, ppos); + if (latencytop_enabled) + force_schedstat_enabled(); + + return err; +} + +static struct ctl_table latencytop_sysctl[] = { + { + .procname = "latencytop", + .data = &latencytop_enabled, + .maxlen = sizeof(int), + .mode = 0644, + .proc_handler = 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 = { 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 = 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 21172d3dad6e..2db637ca91c9 100644 --- a/kernel/sysctl.c +++ b/kernel/sysctl.c @@ -65,7 +65,6 @@ #include #include #include -#include #include #include "../lib/kstrtox.h" @@ -1685,15 +1684,6 @@ static struct ctl_table kern_table[] = { .extra2 = SYSCTL_ONE, }, #endif -#ifdef CONFIG_LATENCYTOP - { - .procname = "latencytop", - .data = &latencytop_enabled, - .maxlen = sizeof(int), - .mode = 0644, - .proc_handler = sysctl_latencytop, - }, -#endif { .procname = "print-fatal-signals", .data = &print_fatal_signals, -- 2.12.3