From patchwork Sat Dec 28 14:57:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: yukaixiong X-Patchwork-Id: 13922370 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 3FAE9E7718F for ; Sat, 28 Dec 2024 15:02:17 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C4CE16B009C; Sat, 28 Dec 2024 10:02:16 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id BFEC96B009D; Sat, 28 Dec 2024 10:02:16 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AC6D96B009E; Sat, 28 Dec 2024 10:02:16 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 8D7346B009C for ; Sat, 28 Dec 2024 10:02:16 -0500 (EST) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 52586C1481 for ; Sat, 28 Dec 2024 15:02:16 +0000 (UTC) X-FDA: 82944680364.17.3DECB9F Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by imf28.hostedemail.com (Postfix) with ESMTP id EDE8FC001B for ; Sat, 28 Dec 2024 15:01:25 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf28.hostedemail.com: domain of yukaixiong@huawei.com designates 45.249.212.187 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=1735398114; 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=YnwB75c5//uj/kf3/vjDhqR833wxu1Rp0nrDjNHp/OJjrWctWaPcR3w4WNXEwwcmYSBJ1G 3chqAZkDul/UoLloRnL5800Th/XZGbfEZBZYf+//kxSpmGy8thx94a0BmX5Nz8EarffMmH 8y/Wcz2SuXfFQnK2xg20PEHISEA7nj8= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf28.hostedemail.com: domain of yukaixiong@huawei.com designates 45.249.212.187 as permitted sender) smtp.mailfrom=yukaixiong@huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1735398114; a=rsa-sha256; cv=none; b=OTXE+lIuK10eIrJxT3Xp4qycUqtiGOMVrjiC0xLI12HpaaFAjtLsylbKrD0PqJYnkogU0n Q4VA2tgPKMFUlEEl3l5+fjs+SiR7cZTBjcZ+5eIURRuzI4y/lB6MHs6dCaQDMEq/L0du51 Ai41lm9mBADQWW61hlS3PLLjaE/sFeY= Received: from mail.maildlp.com (unknown [172.19.88.194]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4YL58x3Gbzz11Ndj; Sat, 28 Dec 2024 22:58:41 +0800 (CST) Received: from kwepemh100016.china.huawei.com (unknown [7.202.181.102]) by mail.maildlp.com (Postfix) with ESMTPS id 861CF1400DC; Sat, 28 Dec 2024 23:02:09 +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, 28 Dec 2024 23:02:05 +0800 From: Kaixiong Yu To: , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v4 -next 08/15] mm: nommu: move sysctl to mm/nommu.c Date: Sat, 28 Dec 2024 22:57:39 +0800 Message-ID: <20241228145746.2783627-9-yukaixiong@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241228145746.2783627-1-yukaixiong@huawei.com> References: <20241228145746.2783627-1-yukaixiong@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.113.32] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To kwepemh100016.china.huawei.com (7.202.181.102) X-Rspamd-Queue-Id: EDE8FC001B X-Stat-Signature: ywunjmjawyon3hax7pnrd841wsmmk1bt X-Rspam-User: X-Rspamd-Server: rspam11 X-HE-Tag: 1735398085-230716 X-HE-Meta: U2FsdGVkX1/udXEfF9tZNfBELpcfGRBfflYJvFhxIkrCPTPApzhASpOvSyXTFtrj+jyOydTHMuJXTKxddNR9+fhtN6VTpiU5RMrTNWvtuTKbYlS32x1/Tl/wjjOnnR5h8vV5Ut61ggivFF+P9epo3fCtX0aL7nPI8Moz4x4eBauctT4DrjER2fnHvsP6hQPD0VX1+Nz8+VbUubuuIU3CQwQ6g4s+IL0RtKZEzO/G8XHL1YkKQ7FA7PzrSOEWNxsHc71jSJGBWiK1s8U7Ca9OAZaAaA3uMaPnOI/2WfPg3E1pQY7vkocm4pp0HkBveczR3P2D46QQzTWgfUK1UznFaayIcWFzTBACrIC1qVAE8NrFwaiJx3mrmxWUqsp8iw+hHegqeVB+MnYUpUcdNfXbLuQvJChbMb+pTsBIWyrbU2qYsceZu4MB+dX+//iJKIBLtJ+MhXXoYg7Jr1ExDsdNQ8MoGp8HiVYJwZqy2ENlBZBTsGDCWgetSLUuVzRPCeRB+xzqP+OPctG69dJEGZcfyp6Iz7kSHhwlrjk2ON6zddEa7XC17d+orrSgi32xe1pDgTH61B34pHD8n0AklB8sjUTE064THl0K6tLNjQ1VbmeEq7fUbykuXF1m17cAE3j7YW2dYw1MstuvanI30vGCduyTVb4EWGk9dRJycib9g34Uziy1VEPLFhTpF6oJQ0pOtW8hjBBxh5vA6O4UlMvrIUGhmoR1ROdWQS4eopo0a7Gh81xrL/sC6R7X6imA+T8a/uj5k9f6vNIm2+uOus/KQiDzAnKbuufcPUKVs2bvPZB3uhjvdyrmCtJwUg5cGkT6Ki3I39E+do0Ec+K+wvL83X2KgBA31i54eybmok9MmNbHIMc0y7xYwwFIriUkk5SB/VmhNm0TLFdf8reDVuwF8b8CymqncdgpwVF5NdKG3rCX7qqe+aTe8Cr2tqcM5h+dVJIMf/ORsOTJa8XS04i GR81Hqi2 HgjcIQBBCDqIaYx/DtNfCmujWVLWcxi95FZnlM5JvmhMIg3nXiWbC/EbeulKndkjjkSqtHakyQdghdICCXY314cpy8NAig7Fr4pGpdzMBNlspy/oR0ePPFSkD9gqaDWPyr+vo8D98CaUxRgPA7KZNnXEDWRHpheNl9TlcWeY+W5hva5BgtCs7DPm5GRGeojLWLHVAxDm7WcAnP4+eTwOd2Xto772Z4A9aTYiXD3UAEpcLNIrAFQkiNJ2D+uAK0YglzFC9EIrti8+u4RI/HVnmvQxB4HXMW9fVL2KmwNegmiNAaxw= 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); } /*