lkml.org 
[lkml]   [2023]   [Mar]   [21]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] fs/drop_caches: move drop_caches sysctls into its own file
On Tue, Mar 21, 2023 at 05:37:10PM +0300, Alexey Dobriyan wrote:
> > > +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...
>
> It is better to keep all sysctls in one preallocated structure
> for memory reasons:
>
> header = kzalloc(sizeof(struct ctl_table_header) +
> sizeof(struct ctl_node)*nr_entries, GFP_KERNEL_ACCOUNT);

For memory reasons we are actually phasing out the older APIs which
required an empty array at the end, which we then kmalloc for, and in
the future will just use ARRAY_SIZE(). In the end that will save us
an entry per each sysctl registered. The rationate for this commit log
sucks. It should be fixed to take into consideration other moves as can
be seen in older git log kernel/sysclt.c moves.

Luis

\
 
 \ /
  Last update: 2023-03-27 01:11    [W:0.055 / U:0.080 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site