Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp681401pxb; Tue, 1 Feb 2022 08:15:41 -0800 (PST) X-Google-Smtp-Source: ABdhPJw9tFrl+KnQb+u+fmCwCWfYcN48h9AtRrJASR1iwmeRcb9v++1XPu5h8GvXyhd0rrB2oNXs X-Received: by 2002:a62:4e4e:: with SMTP id c75mr25282699pfb.55.1643732141567; Tue, 01 Feb 2022 08:15:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643732141; cv=none; d=google.com; s=arc-20160816; b=QLly1aS+HgKvWpsYwWExHAUMiBmEEu5XaSXK5phYtTIaw5r3LB3Sl9dPI9DxvEldyI dxQIgIcfqBU7QwMVKT7vsR2v4qLWH+vd1GPyWyWi+2eHJBBMBTdR+TXxbYt+MSC8Fiz5 lpJpU+S9+OaF5JO0U+Bq60vRDbCK9aFtxPoyuaXgv+3NARabH7c1tz9VP+Kfg2LeLKjR qYsEsj+4FzdCAzBvs7B/xYthHQmlxKFNBKW0a0RGWwv8Sjs+fobNn2p4nfTrov9EXH9V J7u9o5xeWqqoTQ1uUXmszzipL0nT95IqMnTPlLVVhN34Qt08uUJ7uMBtD0YAyNLRrM3n GbdQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:feedback-id:content-transfer-encoding :mime-version:message-id:date:subject:cc:to:from; bh=PHRU6mq1VTAARAN3o7oULXdM7pOmqoSjAhF7qAdV32M=; b=aeCHYmSWwTnXhg2pKT9manJgQTFrFY/Nk6mRMRhnvwvX4ExJDChCmJXsQL/EJxgE67 j+leldxNgiayq+nohBmH7vs0A/WMLaTJLJ5mavmEB/JhTE2yxFDfuYCz+HIlN3tu3d7x v/U33N1nknMTQT8v2TH79xYOb1U/2WY/HRE7Fa0wJ1r+xtZuxa8MUAi6RG5iAivgdget t6k3cI5Ar0Z0IAgyN+V/Znaq3FvHkve9uYUuX2N1ZaiWu7+koHwFfeEtt8Epvdj0+QXw nhTjUFiM13y9vdeylY1U9aSXJ5e0hB0Ievc71O71XeD8D8VXLcFeXUjFBjCSDQmqR8sC FznA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id oo12si2994009pjb.186.2022.02.01.08.15.25; Tue, 01 Feb 2022 08:15:41 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1358144AbiAaKYC (ORCPT + 99 others); Mon, 31 Jan 2022 05:24:02 -0500 Received: from smtpbg701.qq.com ([203.205.195.86]:46828 "EHLO smtpproxy21.qq.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1358126AbiAaKX4 (ORCPT ); Mon, 31 Jan 2022 05:23:56 -0500 X-QQ-mid: bizesmtp11t1643624627tmhf9c2q Received: from localhost.localdomain (unknown [180.105.58.61]) by bizesmtp.qq.com (ESMTP) with id ; Mon, 31 Jan 2022 18:22:47 +0800 (CST) X-QQ-SSF: 01400000002000B0E000B00A0000000 X-QQ-FEAT: YSwSv5UBo8jqRMsFPvrPuKGE1HHFTE5HH6gTbBe1i0Gh8eAUIPWPPhTYKcMqY sFlA1wslD7Xu5go8t4ZC0LBMYLw2PBtAxWoYpFf8waY1logbhaZrinkuOu0LvOMUYwDA383 FuE4V9ikrDLJ7/w9J9hO2ZZpcGDNxMV2v0U7FPZNdvfRUlxN4T/Jm9duQ84hjNnonQYL45x LGYnzc9ai/bhc4Vtv7sjseXdXbTrN6XRquSnbwa8yxb32VM73BfeEUZ2Tf6X9VW16KCsSeV fDbX2SGJQGbqKGBVuapHW5Xd6B6Lc0UEIUNhwGyx2vTcryA29UhQS0fQ5uSOnL+IaI1NcE3 4NKUO1gcdhjSQGIdf1/dTk1cSLuIyBAfAlJOaWH X-QQ-GoodBg: 2 From: tangmeng To: tglx@linutronix.de, mcgrof@kernel.org, keescook@chromium.org, yzaikin@google.com, john.stultz@linaro.org, sboyd@kernel.org Cc: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, tangmeng Subject: [PATCH v5] kernel/time: move timer sysctls to its own file Date: Mon, 31 Jan 2022 18:22:14 +0800 Message-Id: <20220131102214.2284-1-tangmeng@uniontech.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:uniontech.com:qybgforeign:qybgforeign6 X-QQ-Bgrelay: 1 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org kernel/sysctl.c is a kitchen sink where everyone leaves their dirty dishes, this makes it very difficult to maintain. To help with this maintenance let's start by moving sysctls to places where they actually belong. The proc sysctl maintainers do not want to know what sysctl knobs you wish to add for your own piece of code, we just care about the core logic. So move the timer_migration sysctls to its own file. Signed-off-by: tangmeng --- include/linux/timer.h | 4 ---- kernel/sysctl.c | 11 ----------- kernel/time/timer.c | 26 ++++++++++++++++++++++++-- 3 files changed, 24 insertions(+), 17 deletions(-) diff --git a/include/linux/timer.h b/include/linux/timer.h index fda13c9d1256..793b6b7c5a3e 100644 --- a/include/linux/timer.h +++ b/include/linux/timer.h @@ -198,10 +198,6 @@ extern enum hrtimer_restart it_real_fn(struct hrtimer *); #if defined(CONFIG_SMP) && defined(CONFIG_NO_HZ_COMMON) struct ctl_table; - -extern unsigned int sysctl_timer_migration; -int timer_migration_handler(struct ctl_table *table, int write, - void *buffer, size_t *lenp, loff_t *ppos); #endif unsigned long __round_jiffies(unsigned long j, int cpu); diff --git a/kernel/sysctl.c b/kernel/sysctl.c index 5ae443b2882e..d6d133423e5d 100644 --- a/kernel/sysctl.c +++ b/kernel/sysctl.c @@ -2292,17 +2292,6 @@ static struct ctl_table kern_table[] = { .extra1 = SYSCTL_ZERO, .extra2 = SYSCTL_ONE, }, -#if defined(CONFIG_SMP) && defined(CONFIG_NO_HZ_COMMON) - { - .procname = "timer_migration", - .data = &sysctl_timer_migration, - .maxlen = sizeof(unsigned int), - .mode = 0644, - .proc_handler = timer_migration_handler, - .extra1 = SYSCTL_ZERO, - .extra2 = SYSCTL_ONE, - }, -#endif #ifdef CONFIG_BPF_SYSCALL { .procname = "unprivileged_bpf_disabled", diff --git a/kernel/time/timer.c b/kernel/time/timer.c index 85f1021ad459..2d3f4295614b 100644 --- a/kernel/time/timer.c +++ b/kernel/time/timer.c @@ -44,6 +44,7 @@ #include #include #include +#include #include #include @@ -223,7 +224,7 @@ static void timer_update_keys(struct work_struct *work); static DECLARE_WORK(timer_update_work, timer_update_keys); #ifdef CONFIG_SMP -unsigned int sysctl_timer_migration = 1; +static unsigned int sysctl_timer_migration = 1; DEFINE_STATIC_KEY_FALSE(timers_migration_enabled); @@ -251,7 +252,8 @@ void timers_update_nohz(void) schedule_work(&timer_update_work); } -int timer_migration_handler(struct ctl_table *table, int write, +#if defined(CONFIG_SMP) && defined(CONFIG_NO_HZ_COMMON) +static int timer_migration_handler(struct ctl_table *table, int write, void *buffer, size_t *lenp, loff_t *ppos) { int ret; @@ -264,6 +266,26 @@ int timer_migration_handler(struct ctl_table *table, int write, return ret; } +static struct ctl_table timer_sysctl[] = { + { + .procname = "timer_migration", + .data = &sysctl_timer_migration, + .maxlen = sizeof(unsigned int), + .mode = 0644, + .proc_handler = timer_migration_handler, + .extra1 = SYSCTL_ZERO, + .extra2 = SYSCTL_ONE, + }, + {} +}; + +static int __init timer_sysctl_init(void) +{ + register_sysctl_init("kernel", timer_sysctl); + return 0; +} +__initcall(timer_sysctl_init); +#endif static inline bool is_timers_nohz_active(void) { return static_branch_unlikely(&timers_nohz_active); -- 2.20.1