Received: by 2002:a05:6a10:7420:0:0:0:0 with SMTP id hk32csp2757032pxb; Sat, 19 Feb 2022 23:11:03 -0800 (PST) X-Google-Smtp-Source: ABdhPJxeHkiFZL7m+T8opW05fRXQ/utiSbmAY7tA8gXBNtJ6FgEpUD47MTUy8dWRLqVXkJxRGzUk X-Received: by 2002:a17:906:7c0c:b0:6b3:d16e:7e40 with SMTP id t12-20020a1709067c0c00b006b3d16e7e40mr12311546ejo.104.1645341063380; Sat, 19 Feb 2022 23:11:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645341063; cv=none; d=google.com; s=arc-20160816; b=DBUfowzsijbUj06B+jD2da4Wj/hlDPR8Pe+6AheWRzcXnkSTsvjOzlg3TotEOnoWQD epQo/1V7fDmzKbzK62nTbPw0HG7TfeF38SJFCC2JrTUkspr079Vtjv28g7X052nWQzay wDO7o7k4pbiZ5QI+kUoV9gMTZHn+VSnoc4qwO1k0MF50qTNuA3LR98GSUc2J5E/XkMgP LmcFUyNR9oyby1zZapeeDY/PLK55qI83wtE3njpN92U8mVDnMt7yQLdiJTdPC9Vu9kWu uC98JfC38zoCCkk5mvSIBtKlMtjlQSpwzzFmOT+1PfQgba7sKWOkbuMpCbCE0tWmVDTV pzxA== 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=dGq/8ocOHxIqqtlXhxe86XWtgu/XVI0X3ugoj7HKMNA=; b=UvKjsiVpHnaOL0SOGAtQ01tUreQj5tJ5fKLZO/4v+FxY6AQX7vpR0dBuO84rtOSqBS y+DpNH9k48W/FboX0ROGlmOe3EJ0M6yWw+HCNFUnSpEJNwwtkUlYdjZA+o0IFRgD+442 5alNfZ7DSoojbjRunSV8pvR+L5DubOdo8fhcLEN5HYeZL+km1357DnR1l5Bc0ofzTlJ1 OW2rt0nbVpezE0/1ZCQog/sIkH1f2/e0R+/r6ehA87u0/PdICMnKU7fHvhricOcdo18w GRulfRmOS0kope2mHRz0+cPVGawJbd+YOSmqQJVLIzgqsOG1y0WzaQdsEEOyGB4lYcA7 wmTw== 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:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j26si6425713ejy.88.2022.02.19.23.10.39; Sat, 19 Feb 2022 23:11:03 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237047AbiBTGBW (ORCPT + 99 others); Sun, 20 Feb 2022 01:01:22 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:47500 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235343AbiBTGBQ (ORCPT ); Sun, 20 Feb 2022 01:01:16 -0500 Received: from smtpbg516.qq.com (smtpbg516.qq.com [203.205.250.54]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DA1DA4E38D for ; Sat, 19 Feb 2022 22:00:55 -0800 (PST) X-QQ-mid: bizesmtp89t1645336851t7aadi5n Received: from localhost.localdomain (unknown [180.102.102.45]) by bizesmtp.qq.com (ESMTP) with id ; Sun, 20 Feb 2022 14:00:44 +0800 (CST) X-QQ-SSF: 01400000002000B0F000B00A0000000 X-QQ-FEAT: F3yR32iATbi/mkLSpOZvYvncsiPLQQBpqaeLowKGG86n/yfoUl7HczKwqnGvv AFWPx+giiUSNc8US0Rbd28oDJVUomiKnOUWitwatSMKDHPGqDMumpZqZfzJDxrovodrq43f 49BMtuG34fiwk4h+xaM2l2UXpZNlYx+xxYY15iIqSNg7oS8tx85P3VefeKbCmUBg1Yhz35Y jlu5+RAb9yexYmgw85jyi8wQp6kUektl441hPSDvSAjdbRv7cL7lZ+Gbgh07RdNx28OApP5 7PLG2Xv9DaK0TQCsJb9FpjEHKvtXYC8q/uvPTU9L4xioHQG5gnPA/F9/bf5zGToG7HTKvhd 6c1+GVUZ1rsBHfwHA5h3YsFnUHZJAOaCODOnT/t X-QQ-GoodBg: 2 From: tangmeng To: mcgrof@kernel.org, keescook@chromium.org, yzaikin@google.com Cc: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, nizhen@uniontech.com, zhanglianjie@uniontech.com, nixiaoming@huawei.com, tangmeng Subject: [PATCH 04/11] kernel/fork: move threads-max sysctl to its own file Date: Sun, 20 Feb 2022 14:00:41 +0800 Message-Id: <20220220060041.13531-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:qybgforeign5 X-QQ-Bgrelay: 1 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,SPF_PASS,T_SCC_BODY_TEXT_LINE, T_SPF_HELO_TEMPERROR autolearn=ham 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 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. All filesystem syctls now get reviewed by fs folks. This commit follows the commit of fs, move the threads-max sysctl to its own file, kernel/fork.c. Signed-off-by: tangmeng --- include/linux/sysctl.h | 3 --- kernel/fork.c | 22 +++++++++++++++++++++- kernel/sysctl.c | 7 ------- 3 files changed, 21 insertions(+), 11 deletions(-) diff --git a/include/linux/sysctl.h b/include/linux/sysctl.h index e00bf436d63b..1d3467b5e2f3 100644 --- a/include/linux/sysctl.h +++ b/include/linux/sysctl.h @@ -295,7 +295,4 @@ static inline void do_sysctl_args(void) } #endif /* CONFIG_SYSCTL */ -int sysctl_max_threads(struct ctl_table *table, int write, void *buffer, - size_t *lenp, loff_t *ppos); - #endif /* _LINUX_SYSCTL_H */ diff --git a/kernel/fork.c b/kernel/fork.c index d75a528f7b21..0ac42feb3f71 100644 --- a/kernel/fork.c +++ b/kernel/fork.c @@ -3143,7 +3143,8 @@ int unshare_files(void) return 0; } -int sysctl_max_threads(struct ctl_table *table, int write, +#ifdef CONFIG_SYSCTL +static int sysctl_max_threads(struct ctl_table *table, int write, void *buffer, size_t *lenp, loff_t *ppos) { struct ctl_table t; @@ -3165,3 +3166,22 @@ int sysctl_max_threads(struct ctl_table *table, int write, return 0; } + +static struct ctl_table kern_fork_table[] = { + { + .procname = "threads-max", + .data = NULL, + .maxlen = sizeof(int), + .mode = 0644, + .proc_handler = sysctl_max_threads, + }, + { } +}; + +static __init int kernel_fork_sysctls_init(void) +{ + register_sysctl_init("kernel", kern_fork_table); + return 0; +} +late_initcall(kernel_fork_sysctls_init); +#endif /* CONFIG_SYSCTL */ diff --git a/kernel/sysctl.c b/kernel/sysctl.c index 126d47e8224d..e6d99bbf9a9d 100644 --- a/kernel/sysctl.c +++ b/kernel/sysctl.c @@ -1829,13 +1829,6 @@ static struct ctl_table kern_table[] = { .proc_handler = proc_do_cad_pid, }, #endif - { - .procname = "threads-max", - .data = NULL, - .maxlen = sizeof(int), - .mode = 0644, - .proc_handler = sysctl_max_threads, - }, { .procname = "usermodehelper", .mode = 0555, -- 2.20.1