From nobody Fri Jun 19 01:05:53 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 9FCFEC433EF for ; Sun, 10 Apr 2022 10:47:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236801AbiDJKtT (ORCPT ); Sun, 10 Apr 2022 06:49:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39202 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232051AbiDJKtQ (ORCPT ); Sun, 10 Apr 2022 06:49:16 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5426E52B0C; Sun, 10 Apr 2022 03:47:06 -0700 (PDT) Date: Sun, 10 Apr 2022 10:47:03 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1649587624; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=IVt12kz468OQdrqCs2Kyi7NJJl5/6htYUwCxOHxUqIs=; b=oRK6BWuh0i2aLqYZ1oTqUGVKgQlF/oPmvRq++IDnIdQg7N6XOYJAa9ra01DTt4g+dCOiOA BqgGyc9JwgtKmbgBdZzyAHN0sc6PLQNyDdsXi9hneYisAUunnajqvYUOk2Jdfpp4PD4LTN tfwjoTeZgXFjiRgnxFWf32e24gsIj88SW7jSiPQcp1N4xvULSvi4qn7SHJq0l3OM3mcLhS C4GDB0/B2E3j6+uqFYEdXd/ed9k1Jes/yKmeDa2A956YuT1H/+tEGMXhLGIYLN0WlK1UeH iCvdS3/q/jXksj2lM/TmOSdoz/YWVHZzRLG2RdibQU84Zzwr4Q3GLUrAQpKT1Q== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1649587624; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=IVt12kz468OQdrqCs2Kyi7NJJl5/6htYUwCxOHxUqIs=; b=YezGOUnpU/Ti/eHky2EbSnMO0mkYjcrObfBmSUyIAe5Ylxy8BHF/412ZLFLnVrpv40D24p EGWxJiGEy1BK9QAA== From: "tip-bot2 for tangmeng" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: timers/core] timers: Move timer sysctl into the timer code Cc: tangmeng , Thomas Gleixner , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20220215065019.7520-1-tangmeng@uniontech.com> References: <20220215065019.7520-1-tangmeng@uniontech.com> MIME-Version: 1.0 Message-ID: <164958762332.4207.10820440905687416367.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The following commit has been merged into the timers/core branch of tip: Commit-ID: efaa0227f6c6a5073951b20cf2f8c63c4155306c Gitweb: https://git.kernel.org/tip/efaa0227f6c6a5073951b20cf2f8c63c4= 155306c Author: tangmeng AuthorDate: Tue, 15 Feb 2022 14:50:19 +08:00 Committer: Thomas Gleixner CommitterDate: Sun, 10 Apr 2022 12:38:45 +02:00 timers: Move timer sysctl into the timer code This is part of the effort to reduce kernel/sysctl.c to only contain the core logic. Signed-off-by: tangmeng Signed-off-by: Thomas Gleixner Link: https://lore.kernel.org/r/20220215065019.7520-1-tangmeng@uniontech.com --- include/linux/timer.h | 8 +------ kernel/sysctl.c | 11 +--------- kernel/time/timer.c | 53 ++++++++++++++++++++++++++++++------------ 3 files changed, 38 insertions(+), 34 deletions(-) diff --git a/include/linux/timer.h b/include/linux/timer.h index fda13c9..648f001 100644 --- a/include/linux/timer.h +++ b/include/linux/timer.h @@ -196,14 +196,6 @@ extern void init_timers(void); struct hrtimer; extern enum hrtimer_restart it_real_fn(struct hrtimer *); =20 -#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); unsigned long __round_jiffies_relative(unsigned long j, int cpu); unsigned long round_jiffies(unsigned long j); diff --git a/kernel/sysctl.c b/kernel/sysctl.c index 830aaf8..5b7b1a8 100644 --- a/kernel/sysctl.c +++ b/kernel/sysctl.c @@ -2288,17 +2288,6 @@ static struct ctl_table kern_table[] =3D { .extra1 =3D SYSCTL_ZERO, .extra2 =3D SYSCTL_ONE, }, -#if defined(CONFIG_SMP) && defined(CONFIG_NO_HZ_COMMON) - { - .procname =3D "timer_migration", - .data =3D &sysctl_timer_migration, - .maxlen =3D sizeof(unsigned int), - .mode =3D 0644, - .proc_handler =3D timer_migration_handler, - .extra1 =3D SYSCTL_ZERO, - .extra2 =3D SYSCTL_ONE, - }, -#endif #ifdef CONFIG_BPF_SYSCALL { .procname =3D "unprivileged_bpf_disabled", diff --git a/kernel/time/timer.c b/kernel/time/timer.c index 60aebf2..ef082d4 100644 --- a/kernel/time/timer.c +++ b/kernel/time/timer.c @@ -44,6 +44,7 @@ #include #include #include +#include =20 #include #include @@ -223,7 +224,7 @@ static void timer_update_keys(struct work_struct *work); static DECLARE_WORK(timer_update_work, timer_update_keys); =20 #ifdef CONFIG_SMP -unsigned int sysctl_timer_migration =3D 1; +static unsigned int sysctl_timer_migration =3D 1; =20 DEFINE_STATIC_KEY_FALSE(timers_migration_enabled); =20 @@ -234,7 +235,42 @@ static void timers_update_migration(void) else static_branch_disable(&timers_migration_enabled); } -#else + +#ifdef CONFIG_SYSCTL +static int timer_migration_handler(struct ctl_table *table, int write, + void *buffer, size_t *lenp, loff_t *ppos) +{ + int ret; + + mutex_lock(&timer_keys_mutex); + ret =3D proc_dointvec_minmax(table, write, buffer, lenp, ppos); + if (!ret && write) + timers_update_migration(); + mutex_unlock(&timer_keys_mutex); + return ret; +} + +static struct ctl_table timer_sysctl[] =3D { + { + .procname =3D "timer_migration", + .data =3D &sysctl_timer_migration, + .maxlen =3D sizeof(unsigned int), + .mode =3D 0644, + .proc_handler =3D timer_migration_handler, + .extra1 =3D SYSCTL_ZERO, + .extra2 =3D SYSCTL_ONE, + }, + {} +}; + +static int __init timer_sysctl_init(void) +{ + register_sysctl("kernel", timer_sysctl); + return 0; +} +device_initcall(timer_sysctl_init); +#endif /* CONFIG_SYSCTL */ +#else /* CONFIG_SMP */ static inline void timers_update_migration(void) { } #endif /* !CONFIG_SMP */ =20 @@ -251,19 +287,6 @@ void timers_update_nohz(void) schedule_work(&timer_update_work); } =20 -int timer_migration_handler(struct ctl_table *table, int write, - void *buffer, size_t *lenp, loff_t *ppos) -{ - int ret; - - mutex_lock(&timer_keys_mutex); - ret =3D proc_dointvec_minmax(table, write, buffer, lenp, ppos); - if (!ret && write) - timers_update_migration(); - mutex_unlock(&timer_keys_mutex); - return ret; -} - static inline bool is_timers_nohz_active(void) { return static_branch_unlikely(&timers_nohz_active);