From patchwork Mon Dec 23 14:15:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kaixiong Yu X-Patchwork-Id: 13918961 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 16B20E7718B for ; Mon, 23 Dec 2024 14:20:09 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9FCF36B00C0; Mon, 23 Dec 2024 09:20:08 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 9ABA86B00C1; Mon, 23 Dec 2024 09:20:08 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 84E4B6B00C2; Mon, 23 Dec 2024 09:20:08 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 62EB26B00C0 for ; Mon, 23 Dec 2024 09:20:08 -0500 (EST) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 298BF1C7AF4 for ; Mon, 23 Dec 2024 14:20:08 +0000 (UTC) X-FDA: 82926432540.11.C7DCC64 Received: from szxga04-in.huawei.com (szxga04-in.huawei.com [45.249.212.190]) by imf06.hostedemail.com (Postfix) with ESMTP id BE03B180011 for ; Mon, 23 Dec 2024 14:19:38 +0000 (UTC) Authentication-Results: imf06.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf06.hostedemail.com: domain of yukaixiong@huawei.com designates 45.249.212.190 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=1734963577; 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=GqYQu5wQWbkOOc13EQaq0CCUFAltULqQXlw7FUeDwt+Twar29aia1DgzHdxO5vxGKyy6XR Lagx2ibNcMcgERoCHL0RerBI8sE1HfOc2Rxx6S/paezmLh9S8gO1VH2iE456xnzimaq5h6 V4yoINNuoDvfi76m+7FRMH3xHXZAD4A= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf06.hostedemail.com: domain of yukaixiong@huawei.com designates 45.249.212.190 as permitted sender) smtp.mailfrom=yukaixiong@huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1734963577; a=rsa-sha256; cv=none; b=7J52+pCeYwQJQU+37vbj79hnZInNC+0Zy2E880Wz7Lw20YZWL0meNJSbtAzCFB4whRXvno ef6DdmrRZbvRyLk+nhD37lczWWncJunJ5e2r/T+tPmm6Uf+1w46gWPm8ZuyD9wbI9h3L0n 0dnnr0uDyT0mrZ3DU6oW1k/49zYmjEw= Received: from mail.maildlp.com (unknown [172.19.88.214]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4YH0VL21prz21npX; Mon, 23 Dec 2024 22:18:02 +0800 (CST) Received: from kwepemh100016.china.huawei.com (unknown [7.202.181.102]) by mail.maildlp.com (Postfix) with ESMTPS id 39B151A016C; Mon, 23 Dec 2024 22:20:00 +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:19:56 +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:27 +0800 Message-ID: <20241223141550.638616-9-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: BE03B180011 X-Rspamd-Server: rspam12 X-Stat-Signature: zipdbb7rh8ppptd1957cfw3ihuoi933d X-Rspam-User: X-HE-Tag: 1734963578-477045 X-HE-Meta: U2FsdGVkX1+xY3ZT+bpieTEF8yLcheb6H6HzNo3Cao8EpEs+Z2zuC8Y0dgB0lj8JW562kXcUO5OCUd0NKPOQ8PeyimQXpn1iJh2LG8VGA/ZZonOt6rABD8brNpWRMEwVbSSpWv2PUzfh/XVuS5dzNDncPU72scmoHUXfekO/zzUFeRL3JFCx8kN+R11nKmdlItl91erI6bg2a7GlDIFwCBOxcSFBq6yakV57f3yeyqJIUGakUKLCTR/VAwrnbpi9REc9Qmmr313+0gBuH/A+RxVMUB0K19Q4OS+r6w5TFBhbDODEu+RHiMdVxum8hrsEu5HL1x9giXlbww3B6adtEXiEmhV7iyoWKtG2qXp4PGYswk6lNZIul3cmoBpNlj7qXM68D8FdhzmpwZb/z4AqQNB93Pjf7lLN/X2fFrCL90e4/BDRvTGsuN+m0YIH513JUpaX+5EUeEC3Ju48oyNX+rzL2isybSEDk41KGn2nTdSh9aP5BmqvTj67PiMQ5Zq7ursdrqK2hYVj8IVOmsscDYZy84lm2ANzOoNkWCxl6csWauwZxEc92bIoFxdrE8lzgzInIrij1dLYajtT+MRuijvlwgfUCh+9iTmTK0p3t0JPXeR4KNtZcNYgjfzWOXeQfAU/AkJ6Rpvwx4eBSbKBVg3fzCmzy34XlILTg0tpCVQjP/CgbvmF6usuKjfkLnbYDIyMpx4QFpNiQXaX6S0X8Pqr0LmhTUhSAmPQmWsQtLGMkO4z7R4ispXBnkAupZFmezcDxZXgH/YYTt5TowK38IMNh+IB8a/+jpwdWQVvpXoOPPF2x13fLeLDfvHOOEUo69/qseNXgS1xAJwn/r/vcaqGqfeYxGEuD+K+rIIFPr0CltsLQc8/tqysjfIgkbOAcJIi5LiK44Ylf6K6MuzyoH7puN/dqfui3DQpZmo0Er5CJM/d5I/IF8sHVMAsqhn6FchJ7WIVcxHyEm9//5r xMAKVW9N Zc4tSujEaBnh8e9hnfKcOLbr2+N+Q56ZPuuyCP3Y43L/mb0j8BOUILl0sRolM3sRIJ5Xtzj6hkxjgsFlEzwSQMAyQB78WipDyZnY7beWbFpbgGr5H/hdJSXb/fU4RaeDepX+69EzH+zZf43wO6F0p1gT2SA== 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); } /*