[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAJD7tkY8NwjOVeZX30Fc72kp5zRESBWRgXW3Ji-Owp0jjDuEbw@mail.gmail.com>
Date: Fri, 8 Apr 2022 10:21:09 -0700
From: Yosry Ahmed <yosryahmed@...gle.com>
To: Dan Schatzberg <schatzberg.dan@...il.com>
Cc: Johannes Weiner <hannes@...xchg.org>,
Michal Hocko <mhocko@...nel.org>,
Shakeel Butt <shakeelb@...gle.com>,
Andrew Morton <akpm@...ux-foundation.org>,
Roman Gushchin <roman.gushchin@...ux.dev>,
David Rientjes <rientjes@...gle.com>,
Tejun Heo <tj@...nel.org>, Zefan Li <lizefan.x@...edance.com>,
Jonathan Corbet <corbet@....net>,
Shuah Khan <shuah@...nel.org>, Yu Zhao <yuzhao@...gle.com>,
Dave Hansen <dave.hansen@...ux.intel.com>,
Wei Xu <weixugc@...gle.com>, Greg Thelen <gthelen@...gle.com>,
Chen Wandun <chenwandun@...wei.com>,
Vaibhav Jain <vaibhav@...ux.ibm.com>,
Michal Koutný <mkoutny@...e.com>,
Tim Chen <tim.c.chen@...ux.intel.com>, cgroups@...r.kernel.org,
linux-doc@...r.kernel.org,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
Linux-MM <linux-mm@...ck.org>, linux-kselftest@...r.kernel.org,
Michal Hocko <mhocko@...e.com>
Subject: Re: [PATCH v3 1/4] memcg: introduce per-memcg reclaim interface
On Fri, Apr 8, 2022 at 6:43 AM Dan Schatzberg <schatzberg.dan@...il.com> wrote:
>
> On Fri, Apr 08, 2022 at 04:57:40AM +0000, Yosry Ahmed wrote:
> > +static ssize_t memory_reclaim(struct kernfs_open_file *of, char *buf,
> > + size_t nbytes, loff_t off)
> > +{
> > + struct mem_cgroup *memcg = mem_cgroup_from_css(of_css(of));
> > + unsigned int nr_retries = MAX_RECLAIM_RETRIES;
> > + unsigned long nr_to_reclaim, nr_reclaimed = 0;
> > + int err;
> > +
> > + buf = strstrip(buf);
> > + err = page_counter_memparse(buf, "", &nr_to_reclaim);
>
> Is there a reason not to support "max"? Empty string seems odd to me
> here.
We can certainly support "max" to reclaim as much as we can with
MAX_RECLAIM_RETRIES, if there are no objections from the maintainers.
>
> > + if (err)
> > + return err;
> > +
> > + while (nr_reclaimed < nr_to_reclaim) {
> > + unsigned long reclaimed;
> > +
> > + if (signal_pending(current))
> > + break;
>
> I think this should be `return -EINTR;`
Yes this makes more sense. I think this was modeled after the if block
in memory_high_write(), but maybe it makes sense there to just report
success as the new high limit was set anyway.
Will change it in the next version.
>
> > +
> > + reclaimed = try_to_free_mem_cgroup_pages(memcg,
> > + nr_to_reclaim - nr_reclaimed,
> > + GFP_KERNEL, true);
> > +
> > + if (!reclaimed && !nr_retries--)
> > + break;
>
> Here you can just `return -EAGAIN;`
Will do.
>
> > +
> > + nr_reclaimed += reclaimed;
> > + }
> > +
> > + return nr_reclaimed < nr_to_reclaim ? -EAGAIN : nbytes;
>
> Then this can just be `return nbytes;`
Will do.
>
> I'm very much in favor of this new interface. Thanks for working on
> it!
Thanks so much for reviewing it!
Powered by blists - more mailing lists