Re: [PATCH v2] mm: memcg: Use larger batches for proactive reclaim

From: Yosry Ahmed
Date: Fri Feb 02 2024 - 17:36:01 EST


> > > diff --git a/mm/memcontrol.c b/mm/memcontrol.c
> > > index 46d8d02114cf..e6f921555e07 100644
> > > --- a/mm/memcontrol.c
> > > +++ b/mm/memcontrol.c
> > > @@ -6965,6 +6965,9 @@ static ssize_t memory_reclaim(struct kernfs_open_file *of, char *buf,
> > > while (nr_reclaimed < nr_to_reclaim) {
> > > unsigned long reclaimed;
> > >
> > > + /* Will converge on zero, but reclaim enforces a minimum */
> > > + unsigned long batch_size = (nr_to_reclaim - nr_reclaimed) / 4;
> > > +

I think it's clearer with no blank lines between declarations. Perhaps
add these two lines right above the declaration of "reclaimed"?

> > > if (signal_pending(current))
> > > return -EINTR;
> > >
> > > @@ -6977,7 +6980,7 @@ static ssize_t memory_reclaim(struct kernfs_open_file *of, char *buf,
> > > lru_add_drain_all();
> > >
> > > reclaimed = try_to_free_mem_cgroup_pages(memcg,
> > > - min(nr_to_reclaim - nr_reclaimed, SWAP_CLUSTER_MAX),
> > > + batch_size,
> > > GFP_KERNEL, reclaim_options);
> >
> > I think the above two lines should now fit into one.
>
> It goes out to 81 characters. I wasn't brave enough, even though the
> 80 char limit is no more. :)

Oh okay, I would leave it as-is or rename batch_size to something
slightly shorter. Not a big deal either way. Going to 81 chars is
probably fine too.