From patchwork Thu Oct 10 15:22:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: yukaixiong X-Patchwork-Id: 13830199 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 28FD9CF11F5 for ; Thu, 10 Oct 2024 14:12:05 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9B0106B009D; Thu, 10 Oct 2024 10:12:04 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 938F06B009E; Thu, 10 Oct 2024 10:12:04 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7D8B66B009F; Thu, 10 Oct 2024 10:12:04 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 58E986B009D for ; Thu, 10 Oct 2024 10:12:04 -0400 (EDT) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 39942AB863 for ; Thu, 10 Oct 2024 14:11:57 +0000 (UTC) X-FDA: 82657881768.22.91B9A8E Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by imf23.hostedemail.com (Postfix) with ESMTP id 03D76140012 for ; Thu, 10 Oct 2024 14:12:00 +0000 (UTC) Authentication-Results: imf23.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf23.hostedemail.com: domain of yukaixiong@huawei.com designates 45.249.212.188 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=1728569371; 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=8kQPIq4t81iBD7A+vL+4I0G39xoDgt4bSm/7VHQ/2+E=; b=06ByXv3TZH6uUVZS+Iec9ftA/X/++0rnA2KPC6vcFm0VeqY1yMa4bZ9HfD3de1z9le1lRW r1O1lHSiUJGM2mQ19/kIJlIy3xy91P3CDk6EdJcBtlAnjB67sD6Tzfp3DK661thW2vQJl8 DE5TR0zKEpJYeMx7oCHAiNCjfV/Ov6Q= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1728569371; a=rsa-sha256; cv=none; b=GiHWMZ/3lZufarJEhcCiaTDN7Y2+tBwmFIxd6g8ILono6d8HR2uNQrRMYAaOsSbmSdgJlg qES9rr2PE+ZDM6Qv+uLCo6xO0mNtkfFB77TMGPJ2TvnPVcocnJ31yknv9ENQOjmU5SqCqp pcMzAH9A/TezM0Y5P4CrRLPmMgHcQgY= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf23.hostedemail.com: domain of yukaixiong@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=yukaixiong@huawei.com Received: from mail.maildlp.com (unknown [172.19.163.174]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4XPWph1BJGzfdCv; Thu, 10 Oct 2024 22:09:32 +0800 (CST) Received: from kwepemh100016.china.huawei.com (unknown [7.202.181.102]) by mail.maildlp.com (Postfix) with ESMTPS id 6BB25140157; Thu, 10 Oct 2024 22:11:56 +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; Thu, 10 Oct 2024 22:11:53 +0800 From: Kaixiong Yu To: , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v3 -next 08/15] mm: nommu: move sysctl to mm/nommu.c Date: Thu, 10 Oct 2024 23:22:08 +0800 Message-ID: <20241010152215.3025842-9-yukaixiong@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241010152215.3025842-1-yukaixiong@huawei.com> References: <20241010152215.3025842-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-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 03D76140012 X-Stat-Signature: owu8h7cabbg85oco8dun9s1jugwcaz9a X-Rspam-User: X-HE-Tag: 1728569520-92454 X-HE-Meta: U2FsdGVkX1+K/px9Tht+UKyu++HknGPlTIA6d8wILSL4zKEK135iKYfG/95oyRvcs2G/SL9kE2ZGJcEzJ0dXrj++viO5T0pXjHijqs8GdXC5CW954/ppaxD5zi13iw/LNoyEot0uRHPBmtZTKxy3gE7w+yJk4aq8iO4OMrjUYQnxIWBvAOzLb2QEYe62BxuoOy2lAyAwqdf333y2J6aTt3vCpZ5nZkSdujlyYvrMpOL+lvndoTWCM6JnaJDsqF1mznv8z/eAuO4zbA8Xi8HqesMo76BFhbdpOeW0Mi64Oi9izCQnxHdwNYhKFJkLFMMny4KCo3oZx1JY9qELykTNM67zwYE4Pb5OiTC8zAX/7AxUazuTI39dpFlz5I2JWT+DM+Bmvh3VGXFPRk+/IIJ8Mrhy5gugM5LLEIajMwz6i8Y4RyuGZ2/+VgRsaxGctD1U8v5Zu9R2qc9Ce9K4vtAuURHSMyWmMX6GwKbfOsDHsOHUVTJUShcKqguU6/TCc1WOEg4DaEKuyDHQfKexXZberZi/xm7H2S8N/4FxrY7x6sYkqS4boWWLOGYlae4PVB/ayp+PghBiTuXe7XvCDH2Hy3trysPc4+aFyM4iD1MazPhl1FzBnMNku5X74GtMTRm5Eoey6C+yk620vkNb8YxwQZdDNdBuukKdmvg1GOscBLON/bikIOUc0Pn1XMWYiyq/edxQX7Bnt13R6xu6g43uTmD7Knh/OrhpsiZHuQGpVK3mHrAI99Bd1h2vwSc0f3PtF/LrcD3y2VDzrMFW2FML8PyumpsTEkJWsvJbB+Z98pQ0kuAZ7c3fK5VAM1vIi9VyyCu/tbO/s+tQXsO3i4oEFKQ2E7GIMvpgWZlENP/AnYV553CHIggYCJOieDyIp0KoBCoq535RemGbBn6XOmtvWM3yqJtxppoMsPLUVPHukAOWF9jKTVzCubNjSjY2zDqD3NCl/Rebks/w6yTSoQQ 84achFhW HCH/XPQ/DGo6N975YKNDKu7657+Padsi4hnQp7moqkGV4M1SwTSg4PlWzf6rXydekiHRVPxIBXPVf9IWEHUIHBJ5N3BIthNBAgaeO1iF72RokwQAwHwxZOhdRqgJdquEa+ZXt8Z4HiGsiyZKjEEbfJdvcpA== 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 --- 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 50f0069280f4..c7f73bf32024 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -4070,8 +4070,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 0c0bab3dad7d..d3de31ec74bf 100644 --- a/kernel/sysctl.c +++ b/kernel/sysctl.c @@ -2041,16 +2041,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 385b0c15add8..48b2812f492a 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 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); } /*