Re: [PATCH] fs/drop_caches: move drop_caches sysctls into its own file

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Mar 21, 2023 at 09:09:07PM +0800, Yangtao Li wrote:
> This moves the fs/drop_caches.c respective sysctls to its own file.
> 
> Signed-off-by: Yangtao Li <frank.li@xxxxxxxx>
> ---
>  fs/drop_caches.c   | 25 ++++++++++++++++++++++---
>  include/linux/mm.h |  6 ------
>  kernel/sysctl.c    |  9 ---------
>  3 files changed, 22 insertions(+), 18 deletions(-)
> 
> diff --git a/fs/drop_caches.c b/fs/drop_caches.c
> index e619c31b6bd9..3032b83ce6f2 100644
> --- a/fs/drop_caches.c
> +++ b/fs/drop_caches.c
> @@ -12,8 +12,7 @@
>  #include <linux/gfp.h>
>  #include "internal.h"
>  
> -/* A global variable is a bit ugly, but it keeps the code simple */
> -int sysctl_drop_caches;
> +static int sysctl_drop_caches;
>  
>  static void drop_pagecache_sb(struct super_block *sb, void *unused)
>  {
> @@ -47,7 +46,7 @@ static void drop_pagecache_sb(struct super_block *sb, void *unused)
>  	iput(toput_inode);
>  }
>  
> -int drop_caches_sysctl_handler(struct ctl_table *table, int write,
> +static int drop_caches_sysctl_handler(struct ctl_table *table, int write,
>  		void *buffer, size_t *length, loff_t *ppos)
>  {
>  	int ret;
> @@ -75,3 +74,23 @@ int drop_caches_sysctl_handler(struct ctl_table *table, int write,
>  	}
>  	return 0;
>  }
> +
> +static struct ctl_table drop_caches_table[] = {
> +	{
> +		.procname	= "drop_caches",
> +		.data		= &sysctl_drop_caches,
> +		.maxlen		= sizeof(int),
> +		.mode		= 0200,
> +		.proc_handler	= drop_caches_sysctl_handler,
> +		.extra1		= SYSCTL_ONE,
> +		.extra2		= SYSCTL_FOUR,
> +	},
> +	{}
> +};
> +
> +static int __init drop_cache_init(void)
> +{
> +	register_sysctl_init("vm", drop_caches_table);

Does this belong under mm/ or fs/?
And is it intended to be moved into a completely separate file?
Feels abit wasteful for 20 lines of code...



[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [NTFS 3]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [NTFS 3]     [Samba]     [Device Mapper]     [CEPH Development]

  Powered by Linux