From patchwork Sat Jan 11 07:07:43 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kaixiong Yu X-Patchwork-Id: 13935839 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 AD806E7719C for ; Sat, 11 Jan 2025 07:12:53 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3EE4A6B00A6; Sat, 11 Jan 2025 02:12:53 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 378C36B00A9; Sat, 11 Jan 2025 02:12:53 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1F1E76B00AC; Sat, 11 Jan 2025 02:12:53 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id EDA0E6B00A6 for ; Sat, 11 Jan 2025 02:12:52 -0500 (EST) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 9DB9AAEE2E for ; Sat, 11 Jan 2025 07:12:52 +0000 (UTC) X-FDA: 82994303784.23.0E13A53 Received: from szxga05-in.huawei.com (szxga05-in.huawei.com [45.249.212.191]) by imf05.hostedemail.com (Postfix) with ESMTP id 44609100007 for ; Sat, 11 Jan 2025 07:12:49 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf05.hostedemail.com: domain of yukaixiong@huawei.com designates 45.249.212.191 as permitted sender) smtp.mailfrom=yukaixiong@huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1736579571; a=rsa-sha256; cv=none; b=YZ8JT8x0l1IcMdikPIj1GqFH3TBwYBPHG4O/qEdggPQNjbyNmP6YA5jz/GZfPtmAOH4xMG 9s5btUPhqvO8jQarSN88MXEyoi+h4tsZsRYG3/gVoAKUeddo8CMMCHDYGjpx3b3lzaAD0N LkMtCC/Pa+bsJ39EE2mR6hk6ZnJW7WM= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf05.hostedemail.com: domain of yukaixiong@huawei.com designates 45.249.212.191 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=1736579571; 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=9h7L3kt7UCCDfQqZONztIqoeNRwNjA8A4qLkL1IULWw=; b=UxgBDhnoXHsos7WOCIrMSYPKYNQ9js6R2PVtfL+zj5TQARr7WiOwrnxEHzOQC17dcR8/Jr cDL1VZzpRcXrZ9YVm1873DPwfgDsJX7VJLASmbmkliQuJ+nw60GFtDiw4PHiOtc63yKa3q 2RZS/BdWt5TkEhBqbAxWnb91cXGE6ic= Received: from mail.maildlp.com (unknown [172.19.162.112]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4YVV5L0Rz1z1ky3H; Sat, 11 Jan 2025 15:09:42 +0800 (CST) Received: from kwepemh100016.china.huawei.com (unknown [7.202.181.102]) by mail.maildlp.com (Postfix) with ESMTPS id DC77C1402DB; Sat, 11 Jan 2025 15:12:46 +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; Sat, 11 Jan 2025 15:12:43 +0800 From: Kaixiong Yu To: , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v5 -next 08/16] mm: nommu: move sysctl to mm/nommu.c Date: Sat, 11 Jan 2025 15:07:43 +0800 Message-ID: <20250111070751.2588654-9-yukaixiong@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250111070751.2588654-1-yukaixiong@huawei.com> References: <20250111070751.2588654-1-yukaixiong@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.113.32] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To kwepemh100016.china.huawei.com (7.202.181.102) X-Rspam-User: X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: 44609100007 X-Stat-Signature: xwek9oz4749xyqjjd4tcfxuc9otpunhb X-HE-Tag: 1736579569-474715 X-HE-Meta: U2FsdGVkX1/853lRxzmFyE8PFNY0ojZvOM0AOcDwp/QIQPzGsCErIxAxJ0cbUgDhPIXZcC4btwr2zaq530esPTQO/uE/2LeJpzhNZkGbVg0Rz9Ob77msnCuLtsF0YAyQEvzIguDgEZjuDxgc5LrOZTcBBcT6Kcru2MsIlwRqJNt0XGwnp6UwY9aVjIbbav7XczlKYifXjsuhLCGlVlOloxBaX5YFUaxVfyzpHDB42GX9bLwpBNA0nzPZWhGnopm/Id6Y4Ui+EhAeKMmiyuTPdjTwq76tyF/clGlYZcT0ytOmq4QbgShUoGwy0rudiJWGpIULYsKVi1qLCtwrEkNUDfGlrZ3xJyFfuIsIBIRf/qXrFN0SPLWHBXstnSwjPvPD7ODgmcPITS3vlELDdX6qzmByaqGeQ1xsA0d1u8iBU/7JzkwThNqs+KKy5RfBAOMQLmucKzAu7bK0H6zk+HUv9TjghyPdB9xeDeN3LIsV1hurdCxSZr9WY2A5lkIRvSTUcgEkvqEuaSjw/iiKt1IQt8HMULckLdrR5JTgnJBcX+B18YbZxHsyQwyOY9Yj5z6z96ijyWZGZs1Q0QagWv6IYRdUjQvOB84PgV0/5983BdfaxWSY9LHX7xVSO8Zha2AXLxApqJ263SxTqSz3ApBkucZ7xqqJ8K30G83pKsMmmDfF9uwrYb4oDMLmA+THJsDxxOd9bFHemPYt5wyf0zI+NcGGXOTW411eJfDbwk7ImdpkUwd+hVQW8T+/3CGap0Zxd5JLR93fniLRAmJgvBQcG1vfJW5qJczrFjZWaeihnLjjxi56Obimuy7SESdeSZZqvta79Aqp9Jr+3NYnvhzFj3VY+0rUj4YoOpvAi5uT5GIfwwxuNSGbbm+tG+YAdd/48jIMb2Au5MVcUulzgFMTAw1Ks2AWfj44vfStIgQ0bBURusj9DHHOvf2TlJ3lgCoUmjeP/G87Px2Ouw8+FEc 5t33wHHt 203HLqVkcQBCxKXvTkLeyzcq+4d5FMtdjfcGEYKRMuSoRoHLwIbMJVPmfGbMKUBq1HpDQ7cs8ueJsQGLVZ7M9vwAyiiVXlelo1yx09WBU5ip7VEHkXmVnWBHEwRJjtjSIIAZ5LADPe2yxDIf7/2LiJk5SskIaW8p10qK+e765hQyT9UA= 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 Reviewed-by: Lorenzo Stoakes --- v5: - add Reviewed-by: Lorenzo Stoakes 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 5776bc524087..98654abef3b8 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -4150,8 +4150,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_ANON_VMA_NAME int madvise_set_anon_name(struct mm_struct *mm, unsigned long start, unsigned long len_in, 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); } /*