Received: by 2002:a05:6512:3d0e:0:0:0:0 with SMTP id d14csp39168lfv; Tue, 12 Apr 2022 16:22:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyL0t4qKKY+aLx6PO2wadZDj/mao6JZlue38Y91IBoM+U8Tx2zLaz5dwwPsweZMxD0C11tr X-Received: by 2002:a05:6a00:23d1:b0:505:bf44:84ee with SMTP id g17-20020a056a0023d100b00505bf4484eemr13081702pfc.75.1649805721332; Tue, 12 Apr 2022 16:22:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649805721; cv=none; d=google.com; s=arc-20160816; b=TrVBy7yo/7GVWzwFxisuu515tb0toSqmC1FlOTqFuPmPRNge6roXFM8T5qzVuoquts 5krVWX3tWd54l3REco8UuqQGfCOiCW9BJos+BMs4ptjIjFvBfIYaj9XurvgQ38Plig7X 1IEIor2MW0pmqp9ERGdD3lVauZulNIdbxNfByjuy2CcWZvOxPRK36XgJo21YX911j06Z 3fb+uLRCHUzhFv3VotpNJz83o439ReNBPiomIZN91mUyOwXZFlpfjAgXBPd5HzFT6xZC it1Kh93nI/b9qfl5PZ3LOaWcKOS8pujqyyeMpkqwWIeofDVehCyrqqOhh+5vc9q/bkCi daoQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:robot-unsubscribe :robot-id:message-id:mime-version:references:in-reply-to:cc:subject :to:reply-to:sender:from:dkim-signature:dkim-signature:date; bh=IVt12kz468OQdrqCs2Kyi7NJJl5/6htYUwCxOHxUqIs=; b=h8am4iYYpkaJpdNCpWneLsy7W+I1djW6YTcpvXGFoZ3kWOqYJ7xZzvO7CxRld7j0vO Rn1/qGczXcbApOtQSpdpwuoNeQffwqEWfvZkyoL9mgiOV+h93ANDKi74cTVNXrQ5c8RQ naQxCoFO0XgIhIn4vWny1Ku7RprfDSjnCZxY4Nf13QKA3fmfDST9OkFiP4QnkeSFUfpm F4+SmoSYxomp7Bv8dX1TE9Re4OuNXTfOwCj77Pe6LAVM2B9tQfSWCxIViaBu+ASaQ1N0 2BRKuRM6kr+hVGsLN4jfgnv4ylDHJw7z/aNH+CbN3y8TzRFXnLc81GBFORPzF28saq2r BoDg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=oRK6BWuh; dkim=neutral (no key) header.i=@linutronix.de header.b=YezGOUnp; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id 186-20020a6214c3000000b00505b770f007si1272083pfu.249.2022.04.12.16.22.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Apr 2022 16:22:01 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=oRK6BWuh; dkim=neutral (no key) header.i=@linutronix.de header.b=YezGOUnp; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (out1.vger.email [IPv6:2620:137:e000::1:20]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 8B2C5ECDA7; Tue, 12 Apr 2022 14:13:50 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236761AbiDJKtS (ORCPT + 99 others); Sun, 10 Apr 2022 06:49:18 -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: 7bit X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,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 The following commit has been merged into the timers/core branch of tip: Commit-ID: efaa0227f6c6a5073951b20cf2f8c63c4155306c Gitweb: https://git.kernel.org/tip/efaa0227f6c6a5073951b20cf2f8c63c4155306c 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 *); -#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[] = { .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 60aebf2..ef082d4 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); @@ -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 = 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[] = { + { + .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("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 */ @@ -251,19 +287,6 @@ void timers_update_nohz(void) schedule_work(&timer_update_work); } -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 = 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);