Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp2706959pxb; Mon, 25 Apr 2022 00:03:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyFlYZHWeKBr+El1cCWfnyKF11TeQmGp/pVZEE7dvbqTpY3PEvgasgpkjY8QFQanIPGgBl1 X-Received: by 2002:a17:902:6bc9:b0:158:b9d0:1e3b with SMTP id m9-20020a1709026bc900b00158b9d01e3bmr16428721plt.84.1650870210954; Mon, 25 Apr 2022 00:03:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650870210; cv=none; d=google.com; s=arc-20160816; b=GT1WO/KMt8nw9POoomL/AAkVK9p3Hn8XqjI7YDa6IvvhcbjChxOoTW2IwfyQ3QrN5n wKUZ/Fo5ee8H372PqQwIc0sVSQRgo2DBGVD4TZUhU3jnv62XNTMsEP1OuNbakFBDO3UZ idTCMjwhP4lOYA+35Mc7tCOxqCyLB67O5Sc/a4L0GXvc8q37Sr7gQQ/SQS2ZBPj4jYcC h2eChXAjVJaS4TlzAYQMMUFVi9EmWbcnOlNsM9orRNpK/3yIJ6gEXZ6AQVEdsgYkCT7u 7f2qrnx/DM4HP0DUo2nmn9+I6FgXekpdlgcTJhQ4nlVpwSwMCbUTccY/UpUsbzkbhTln mglA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=8GbFmCefgBpmKKdFZo3IemUn7Gi1rSWSvsuH7dgtsIw=; b=n1bcAgVRNBNovhWINN4C9zLwX6qUkuG63r96H8N0GvrytcDIbfQMr8DrY54pgPm0+l POEHcHMHLNreq4qbge6QMvAAJn6alyEvGqZkI83TCDH1gJwCzpx9b6ZQ4G4rjDIqYk6P V3ZYLqH5N2pMtQawvPHJqbPKPCkhV82AMB2D0c+3xJcHIiJ0JnJZjWOkXbEiTyJXyqGj yB+dhirTiQFUGzATiPhViNwAcEFg47hxJYw/R4BnCJAmHBgc+ERiByM3wjQIKAG4mu7Y I1DKMv9mfQaXRSGGuRcyqi6NzZxlKSqt/eRbRRJT/BiiazXmh7EGUbjkHhjXYW9G26yQ gAIA== 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; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m16-20020a637110000000b003ab4280ada7si2254921pgc.106.2022.04.25.00.03.16; Mon, 25 Apr 2022 00:03:30 -0700 (PDT) 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; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237915AbiDXDCN (ORCPT + 99 others); Sat, 23 Apr 2022 23:02:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52594 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231260AbiDXDCL (ORCPT ); Sat, 23 Apr 2022 23:02:11 -0400 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1954413FD8B; Sat, 23 Apr 2022 19:59:11 -0700 (PDT) Received: from dggpeml500022.china.huawei.com (unknown [172.30.72.56]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4KmCXM72zlzhYKj; Sun, 24 Apr 2022 10:58:59 +0800 (CST) Received: from dggpeml100012.china.huawei.com (7.185.36.121) by dggpeml500022.china.huawei.com (7.185.36.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Sun, 24 Apr 2022 10:59:10 +0800 Received: from Linux-SUSE12SP5.huawei.com (10.67.189.3) by dggpeml100012.china.huawei.com (7.185.36.121) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Sun, 24 Apr 2022 10:59:09 +0800 From: yingelin To: , , , , CC: , , , , , , , Subject: [PATCH sysctl-testing v2] kernel/kexec_core: move kexec_core sysctls into its own file Date: Sun, 24 Apr 2022 10:57:40 +0800 Message-ID: <20220424025740.50371-1-yingelin@huawei.com> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.67.189.3] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To dggpeml100012.china.huawei.com (7.185.36.121) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS 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 This move the kernel/kexec_core.c respective sysctls to its own file. kernel/sysctl.c has grown to an insane mess, We move sysctls to places where features actually belong to improve the readability and reduce merge conflicts. At the same time, the proc-sysctl maintainers can easily care about the core logic other than the sysctl knobs added for some feature. We already moved all filesystem sysctls out. This patch is part of the effort to move kexec related sysctls out. Signed-off-by: yingelin --- v2: 1. Add the explanation to commit log to help patch review and subsystem maintainers better understand the context/logic behind the migration 2. Add CONFIG_SYSCTL to to isolate the sysctl 3. Change subject-prefix of sysctl-next to sysctl-testing v1: https://lore.kernel.org/lkml/20220223030318.213093-1-yingelin@huawei.com/ 1. Lack more informations in the commit log to help patch review better 2. Lack isolation of the sysctl 3. Use subject-prefix of sysctl-next --- kernel/kexec_core.c | 22 ++++++++++++++++++++++ kernel/sysctl.c | 13 ------------- 2 files changed, 22 insertions(+), 13 deletions(-) diff --git a/kernel/kexec_core.c b/kernel/kexec_core.c index 68480f731192..a0456baf52cc 100644 --- a/kernel/kexec_core.c +++ b/kernel/kexec_core.c @@ -936,6 +936,28 @@ int kimage_load_segment(struct kimage *image, struct kimage *kexec_image; struct kimage *kexec_crash_image; int kexec_load_disabled; +#ifdef CONFIG_SYSCTL +static struct ctl_table kexec_core_sysctls[] = { + { + .procname = "kexec_load_disabled", + .data = &kexec_load_disabled, + .maxlen = sizeof(int), + .mode = 0644, + /* only handle a transition from default "0" to "1" */ + .proc_handler = proc_dointvec_minmax, + .extra1 = SYSCTL_ONE, + .extra2 = SYSCTL_ONE, + }, + { } +}; + +static int __init kexec_core_sysctl_init(void) +{ + register_sysctl_init("kernel", kexec_core_sysctls); + return 0; +} +late_initcall(kexec_core_sysctl_init); +#endif /* * No panic_cpu check version of crash_kexec(). This function is called diff --git a/kernel/sysctl.c b/kernel/sysctl.c index b60345cbadf0..0f3cb61a2e39 100644 --- a/kernel/sysctl.c +++ b/kernel/sysctl.c @@ -61,7 +61,6 @@ #include #include #include -#include #include #include #include @@ -1712,18 +1711,6 @@ static struct ctl_table kern_table[] = { .proc_handler = tracepoint_printk_sysctl, }, #endif -#ifdef CONFIG_KEXEC_CORE - { - .procname = "kexec_load_disabled", - .data = &kexec_load_disabled, - .maxlen = sizeof(int), - .mode = 0644, - /* only handle a transition from default "0" to "1" */ - .proc_handler = proc_dointvec_minmax, - .extra1 = SYSCTL_ONE, - .extra2 = SYSCTL_ONE, - }, -#endif #ifdef CONFIG_MODULES { .procname = "modprobe", -- 2.26.2