From patchwork Mon Dec 23 14:15:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kaixiong Yu X-Patchwork-Id: 13918976 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5EA47E7718B for ; Mon, 23 Dec 2024 14:21:00 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E1C716B00E0; Mon, 23 Dec 2024 09:20:59 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id DA5A96B00E2; Mon, 23 Dec 2024 09:20:59 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C44E66B00E3; Mon, 23 Dec 2024 09:20:59 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id A3BF46B00E0 for ; Mon, 23 Dec 2024 09:20:59 -0500 (EST) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 603001417D2 for ; Mon, 23 Dec 2024 14:20:59 +0000 (UTC) X-FDA: 82926434682.16.E03FDAF Received: from szxga07-in.huawei.com (szxga07-in.huawei.com [45.249.212.35]) by imf22.hostedemail.com (Postfix) with ESMTP id 40527C0008 for ; Mon, 23 Dec 2024 14:20:16 +0000 (UTC) Authentication-Results: imf22.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf22.hostedemail.com: domain of yukaixiong@huawei.com designates 45.249.212.35 as permitted sender) smtp.mailfrom=yukaixiong@huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1734963614; h=from:from:sender: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=KSwhYT2WK8fapxw3LL6iWwicHeC3MEU+LN4cXu8E0hM=; b=VDDTIlIfwnGLkLmtWHS7QpTIWec/pLeTlDypW+zWHIcEEEhw31Wd99ONzcAILMhqCaJmYC sFTwEEd19NjNBhVQFndjzaDbH1rfMJlsJHn/2I2ivw9OA5t7SHOVcI+jTJS3wU8/NWUbfr gt8vswQKYmylO6ywoBSrYN3wGNdBNxA= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1734963614; a=rsa-sha256; cv=none; b=dT4Idc48xCMosKV9+tIgaRrRYyactHow/Lab6NIQy0lJhK0UZbf/2IZQafCQKzee96uUfQ SAFIvpx+w12bNIM5Uk6lpAcClJ8pwQBdwSPvrKJLhY6XNhj8LPTE7ETykbbqne53mbLZ5W HUIbMdsLx+aiiLI8GYEgWobRgHwdWDQ= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf22.hostedemail.com: domain of yukaixiong@huawei.com designates 45.249.212.35 as permitted sender) smtp.mailfrom=yukaixiong@huawei.com Received: from mail.maildlp.com (unknown [172.19.163.44]) by szxga07-in.huawei.com (SkyGuard) with ESMTP id 4YH0VW5mCTz1T711; Mon, 23 Dec 2024 22:18:11 +0800 (CST) Received: from kwepemh100016.china.huawei.com (unknown [7.202.181.102]) by mail.maildlp.com (Postfix) with ESMTPS id 9907F140202; Mon, 23 Dec 2024 22:20:53 +0800 (CST) Received: from huawei.com (10.175.113.32) by kwepemh100016.china.huawei.com (7.202.181.102) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Mon, 23 Dec 2024 22:20:50 +0800 From: Kaixiong Yu To: , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v4 -next 08/15] mm: nommu: move sysctl to mm/nommu.c Date: Mon, 23 Dec 2024 22:15:43 +0800 Message-ID: <20241223141550.638616-25-yukaixiong@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241223141550.638616-1-yukaixiong@huawei.com> References: <20241223141550.638616-1-yukaixiong@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.113.32] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To kwepemh100016.china.huawei.com (7.202.181.102) X-Rspamd-Queue-Id: 40527C0008 X-Rspam-User: X-Rspamd-Server: rspam07 X-Stat-Signature: zipdbb7rh8ppptd1957cfw3ihuoi933d X-HE-Tag: 1734963616-60217 X-HE-Meta: U2FsdGVkX18886v7f9DNuMmkextIRYO+HIzWrpLM5A8e54n8E0D5K4En7X2f9+AsweZfexdimmKl2dmlMPhHltVzixx+qDQsRarw9PlceZkc5TF95bYYvY6rKLx/Pu0YKuh5gtfyseIs6TlhD9j5EpDcon8CzJXwwvFkDQek9FxCGN7E2mozGy/B3f5GivHKg4Iae0zIpwXEy5aYCcYEdUX5UocAWsNRhkhPaZDjaMudeBV7GGIPOgRcjFtRU/Te/rlwJPIYapNShnU9CW9bJOdl6K5yEQKEsXtNkhJ/Tu2OYLqnOGUDDdvkvn6zyr2VuCgNRRS1fqY4fHosGd6jG3Dda2tqXf3BQX6tsHmbJLz9EB/C0lvyoAxuG6REaeiU6JOxrAZnVw3/NRJiC/ox/3z2kJrWNxeck+0aE9IkBjvsEZSOHweNdubz9hd/KGex743m7b/qgcbBmq88geI3TMdlobywLT43d64PrFzD2YDxvVLgpD4WH/GKoMGQWKuWO8bKMiEOSUSGupfo05YZE2AqNhGO0lD0yJ0fCBwoZ+7JOkLhfNa1BvyT4SOetJVtwR08whU0UxFaB4vmPAZ7LPsI28O7bYsKZCJ4/wDp4TDvTBvzTwm5QuDq/N/k4O+aBYDGgFbMY063slxQTMUApJDCJmsf7il7pJnExK0nlnRMW4OOm4Z8Zst3vhE5KbYqwCeL/fgdehy3aPhkLLtEKQDKGq89FL9IW5wXySQQ7NdMJ1uSP8sdCuSJoWTAHSc+XS/Yf20fay0ESGjPveMac3oiX1ZmXS0GzoOX9darBNvK/cZ3NTP1Ts1yLaDYAVDIlu6bAx5rNzjPLb6jNF15gHaGRGu/jROJHDHC7quFV4wbYWflRIjKT5AU+OglmEzUMonDQ63zpAGlAo2u19zoW5TR71ScbEcW5aipxltF1zjkSgIrzxSER0BDiaRXsKkP/p8k4CiuJaHYFWiTOq4 8adABeNR UkEYtp1xmTq/dG2/pfk1CAnfQ5X6CEHCQRWEynr08CVxXyD2m1LyTqrjpOG6T2ig+5Eo392gs7x4LzZyMHfnXMSxNsygT2ABn+d5zbwkT1gKM8lMI+uB8LdW+8cX4EOIyOLcN8rG6fYqSZmM= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: The sysctl_nr_trim_pages belongs to nommu.c, move it to mm/nommu.c from /kernel/sysctl.c. And remove the useless extern variable declaration from include/linux/mm.h Signed-off-by: Kaixiong Yu --- v4: - const qualify struct ctl_table nommu_table v3: - change the title v2: - fix the build error: expected ';' after top level declarator - fix the build error: call to undeclared function 'register_syscall_init', use 'register_sysctl_init' to replace it. --- --- include/linux/mm.h | 2 -- kernel/sysctl.c | 10 ---------- mm/nommu.c | 15 ++++++++++++++- 3 files changed, 14 insertions(+), 13 deletions(-) diff --git a/include/linux/mm.h b/include/linux/mm.h index b3b87c1dc1e4..9813b5b9c093 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -4080,8 +4080,6 @@ unsigned long wp_shared_mapping_range(struct address_space *mapping, pgoff_t first_index, pgoff_t nr); #endif -extern int sysctl_nr_trim_pages; - #ifdef CONFIG_PRINTK void mem_dump_obj(void *object); #else diff --git a/kernel/sysctl.c b/kernel/sysctl.c index 62a58e417c40..97f9abffff0f 100644 --- a/kernel/sysctl.c +++ b/kernel/sysctl.c @@ -2031,16 +2031,6 @@ static struct ctl_table vm_table[] = { .extra1 = SYSCTL_ONE, .extra2 = SYSCTL_FOUR, }, -#ifndef CONFIG_MMU - { - .procname = "nr_trim_pages", - .data = &sysctl_nr_trim_pages, - .maxlen = sizeof(sysctl_nr_trim_pages), - .mode = 0644, - .proc_handler = proc_dointvec_minmax, - .extra1 = SYSCTL_ZERO, - }, -#endif { .procname = "vfs_cache_pressure", .data = &sysctl_vfs_cache_pressure, diff --git a/mm/nommu.c b/mm/nommu.c index baa79abdaf03..3c32f8b1eb54 100644 --- a/mm/nommu.c +++ b/mm/nommu.c @@ -48,7 +48,6 @@ struct page *mem_map; unsigned long max_mapnr; EXPORT_SYMBOL(max_mapnr); unsigned long highest_memmap_pfn; -int sysctl_nr_trim_pages = CONFIG_NOMMU_INITIAL_TRIM_EXCESS; int heap_stack_gap = 0; atomic_long_t mmap_pages_allocated; @@ -392,6 +391,19 @@ SYSCALL_DEFINE1(brk, unsigned long, brk) return mm->brk = brk; } +static int sysctl_nr_trim_pages = CONFIG_NOMMU_INITIAL_TRIM_EXCESS; + +static const struct ctl_table nommu_table[] = { + { + .procname = "nr_trim_pages", + .data = &sysctl_nr_trim_pages, + .maxlen = sizeof(sysctl_nr_trim_pages), + .mode = 0644, + .proc_handler = proc_dointvec_minmax, + .extra1 = SYSCTL_ZERO, + }, +}; + /* * initialise the percpu counter for VM and region record slabs */ @@ -402,6 +414,7 @@ void __init mmap_init(void) ret = percpu_counter_init(&vm_committed_as, 0, GFP_KERNEL); VM_BUG_ON(ret); vm_region_jar = KMEM_CACHE(vm_region, SLAB_PANIC|SLAB_ACCOUNT); + register_sysctl_init("vm", nommu_table); } /*