From patchwork Tue Sep 3 03:30:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: yukaixiong X-Patchwork-Id: 13787957 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 6D3E2CA101E for ; Tue, 3 Sep 2024 03:31:30 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id AD7D98D012E; Mon, 2 Sep 2024 23:31:27 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A88FB8D0119; Mon, 2 Sep 2024 23:31:27 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8B3978D012E; Mon, 2 Sep 2024 23:31:27 -0400 (EDT) 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 69A1B8D0119 for ; Mon, 2 Sep 2024 23:31:27 -0400 (EDT) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id EA181140110 for ; Tue, 3 Sep 2024 03:31:26 +0000 (UTC) X-FDA: 82522001772.09.9F6EB2E Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by imf22.hostedemail.com (Postfix) with ESMTP id 68017C000F for ; Tue, 3 Sep 2024 03:31:23 +0000 (UTC) Authentication-Results: imf22.hostedemail.com; dkim=none; spf=pass (imf22.hostedemail.com: domain of yukaixiong@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=yukaixiong@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1725334238; 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=2gJg9h+VjfAAtBgHCJbDMkNW8UhmZE/p1J3FKhMixXM=; b=PRoNMboCWhwnKYX/pNpXeJ7MfNZFus9vE937vgrV629qmlUsr9cC9Gjp+Jc9NsTucSRJWK E9Qr82QFnOfYxNrHL+/L4fKCOPeXJD/6kSJ4BLnf3DS+Fst8Np3bXC5o7z2oAOYKqbjVWf 9RWXYxBXczIiJnoYEJ9pljpgpzgPECY= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=none; spf=pass (imf22.hostedemail.com: domain of yukaixiong@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=yukaixiong@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1725334238; a=rsa-sha256; cv=none; b=3T6SDiBJ+I0iWF+gdVp2ZGvfHabzHHq4NT1AwPvY2Gn6fiuJlhtGcK1DZ1sJ5ws2GSN3vy YU3MenG4i7lTNfCuzDn1pUYKP+Fvh9kIMT6ZASSzWuxeKm9DvtOcvC1dZh/P6iXFzkLw1q 8dn1breoKbZI7BU4JDvFkflUOSLieUc= Received: from mail.maildlp.com (unknown [172.19.163.48]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4WyWLy2TBxzgYTY; Tue, 3 Sep 2024 11:29:14 +0800 (CST) Received: from kwepemh100016.china.huawei.com (unknown [7.202.181.102]) by mail.maildlp.com (Postfix) with ESMTPS id E61DD180087; Tue, 3 Sep 2024 11:31:20 +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; Tue, 3 Sep 2024 11:31:18 +0800 From: Kaixiong Yu To: , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v2 -next 08/15] mm: nommu: move sysctl to its own file Date: Tue, 3 Sep 2024 11:30:04 +0800 Message-ID: <20240903033011.2870608-9-yukaixiong@huawei.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240903033011.2870608-1-yukaixiong@huawei.com> References: <20240903033011.2870608-1-yukaixiong@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.113.32] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To kwepemh100016.china.huawei.com (7.202.181.102) X-Rspamd-Server: rspam03 X-Rspam-User: X-Rspamd-Queue-Id: 68017C000F X-Stat-Signature: kuws73uinqcqss47qxennns7w9fhmwra X-HE-Tag: 1725334283-369961 X-HE-Meta: U2FsdGVkX1+XT+mzHcCjuBxif3A4HFdellFHM/2WSkuaT91l0va/fV0d9+SRFm+OkoX+amdZ0pegR+H29HoVDC6M4xglE6CMEiwSbIZP+Sa5HECOhTfKlSbCpK1rT1uLYd43JzxM5zqQL8VqSvsLVmshj/yxrKrOfFBZzm+sxOyLQBpqs8ZYkW7x20+CTauFJBF0VM1Sjb7/vyLhIPeHrGNIwW4kN65G9ybHxOdCPBPdHglOnIHXfIcd9h7krutIsWAwShGTg03aRYLc5is8Khc/8UgrHLAHxmca7ss1YDS9uJP2+ohIAFV0vpTqe62d+pF5wMPUtzt0Aa4P08QGGzCYFybDMJ2cK0uwxkcmrcEnpI7uA+zdqPg/09F9l/iWyZvgZHbVwyyV96CLGTg7UTRLuhB8FJJu3hh/ssehnMG+/3FQI7RtXiAjmUDKFnKwI5LYOALoM7D61WR5s9JmPEgU3P8Qf8GZfyjdHm6sJluIbsoAoK9k0NKD2GczEj+IqadPEOERTZTUMp35aVvcvTApUlTbYhGPkoYBPnrSnUq8mpdJrRYGYoLqpERDG4CCrlSOm5aovE/A+kSYLFwKVoYTSql0kZT1X/ooVe/twe99fAw0rLrao2SHFN66q51l3aVEf4v/ySRZ7y+VstMf5VCeeRGihpngFBgQEZeyHsCndmgqGmixSTwjup1mHWnmQkis9ApjRLxGn6J6ij3Y7119o0ylZTGZWgWDBZsWCH//ttPBUiNcJjq7Gm94VIyRxgcQCSJlx9q1F2bUF+2hCOBalNDbOOWC4F7u5jlKRHm9UYLyz0/0Z3Z+HFfkHrrooAPJEEI7PftsaAVED9g0M/+KN6drSi6/twVuHWo+vKSEX6l+WNbk+IOousLqVKZpwoKHkrbCz4eVcUPTrzlNXhdoMDxKJgh2i52iJ38jRqVHBrmDGkXD0siMM80cPiFIuVn6o0uBA/VIrvA0Glo I03+0twl S65dr2WtKRQImgNHniZLQcccj5H7xwdFZzV1Jwh18kGnMqeHr26HXDtNy5I1ONjhJRrfuBv9bzuiQb8+Y10JcfG1j75/cE25t1TaXTh+nN/VjGgG8f+7JncV04PdkXlSgNVS7iLGAcfHJ44L//uq21Tgp7A== 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 into its own file from /kernel/sysctl.c. And remove the useless extern variable declaration from include/linux/mm.h Signed-off-by: Kaixiong Yu --- 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 93ae80146ee2..b7f12988237a 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -4044,8 +4044,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); } /*