From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BF1C113A26D; Thu, 9 Jan 2025 02:26:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.187 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736389620; cv=none; b=PbxAsjR0jwImeehrqNuNvTpyHbT2x3p9mt14KXIV9b4+I3Mk2ZbfPeErJ3HpUA0/kA+o1hHr1jtdJImH6SPJEqzIJTejERUYOdL2fqzGMiajphKY9b5nUw6ADiS9vwAEAENsngENmmEIOZ94BTb52CRO+EyxcrMK/HWoLEBNLdU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736389620; c=relaxed/simple; bh=Mz0ho6wNcmmRUFppI5RY+Mgz0y94H2qe68tpL2oT7vQ=; h=Subject:To:References:CC:From:Message-ID:Date:MIME-Version: In-Reply-To:Content-Type; b=Pn5tNXSSu8GF83iP8nmpomOtoTMwILZl91QK4yB9+eYfj9hB8qX1TFo+5QgZat1ecWoNj8O3vqa3dW8kNe6hnPMLsBdU5SQ0FYMer0PoP2op8A0tEgCp4COSa85cvA/ZRidAfPLZPODEclmLHgxyZ5Jn8w26Pv1Z6HOWJokrslI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=45.249.212.187 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Received: from mail.maildlp.com (unknown [172.19.88.105]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4YT7qh6fqxzjYB7; Thu, 9 Jan 2025 10:23:12 +0800 (CST) Received: from kwepemh100016.china.huawei.com (unknown [7.202.181.102]) by mail.maildlp.com (Postfix) with ESMTPS id C86EE140382; Thu, 9 Jan 2025 10:26:55 +0800 (CST) Received: from [10.174.179.93] (10.174.179.93) 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, 9 Jan 2025 10:26:52 +0800 Subject: Re: [PATCH v4 -next 08/15] mm: nommu: move sysctl to mm/nommu.c To: Lorenzo Stoakes References: <20241223141550.638616-1-yukaixiong@huawei.com> <20241223141550.638616-9-yukaixiong@huawei.com> <93c2a55b-3f3b-488e-9156-0a7726f30be3@lucifer.local> CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , From: yukaixiong Message-ID: <1959b553-decd-7525-865e-425776841833@huawei.com> Date: Thu, 9 Jan 2025 10:26:51 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.7.1 Precedence: bulk X-Mailing-List: linux-nfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 In-Reply-To: <93c2a55b-3f3b-488e-9156-0a7726f30be3@lucifer.local> Content-Type: text/plain; charset="windows-1252"; format=flowed Content-Transfer-Encoding: 7bit X-ClientProxiedBy: dggpeml500006.china.huawei.com (7.185.36.76) To kwepemh100016.china.huawei.com (7.202.181.102) On 2025/1/2 22:09, Lorenzo Stoakes wrote: > On Mon, Dec 23, 2024 at 10:15:27PM +0800, Kaixiong Yu wrote: >> 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 > Looks good to me, > > Reviewed-by: Lorenzo Stoakes Thanks for your review ! Best ... >> --- >> 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 > Of course later on in the series you do what I asked in a previous commit :P Nice. > >> { >> .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); >> } >> >> /* >> -- >> 2.34.1 >> > . >