From: dai.ngo@oracle.com
To: Chuck Lever III <chuck.lever@oracle.com>
Cc: Jeff Layton <jlayton@kernel.org>,
Linux NFS Mailing List <linux-nfs@vger.kernel.org>
Subject: Re: [PATCH v4 2/2] NFSD: add shrinker to reap courtesy clients on low memory condition
Date: Fri, 2 Sep 2022 09:44:07 -0700 [thread overview]
Message-ID: <eb197dde-8758-7ef4-8a7b-989273e09abc@oracle.com> (raw)
In-Reply-To: <7041D47D-ECB3-497E-9174-96E9E36FFBDE@oracle.com>
On 9/1/22 9:32 PM, Chuck Lever III wrote:
>
>> On Sep 1, 2022, at 9:56 PM, Dai Ngo <dai.ngo@oracle.com> wrote:
>>
>> Hi Chuck,
>>
>> On 8/31/22 7:30 AM, Chuck Lever III wrote:
>>>> struct list_head *pos, *next;
>>>> struct nfs4_client *clp;
>>>>
>>>> - maxreap = (atomic_read(&nn->nfs4_client_count) >= nn->nfs4_max_clients) ?
>>>> - NFSD_CLIENT_MAX_TRIM_PER_RUN : 0;
>>>> + cb_cnt = atomic_read(&nn->nfsd_client_shrinker_cb_count);
>>>> + if (atomic_read(&nn->nfs4_client_count) >= nn->nfs4_max_clients ||
>>>> + cb_cnt) {
>>>> + maxreap = NFSD_CLIENT_MAX_TRIM_PER_RUN;
>>>> + atomic_set(&nn->nfsd_client_shrinker_cb_count, 0);
>>>> + }
>>> I'm not terribly happy with this, but I don't have a better suggestion
>>> at the moment. Let me think about it.
>> Do you have any suggestion to improve this, I want to incorporate it
>> before sending out v5?
> Let's consider some broad outlines...
>
> With regards to parametrizing the reaplist behavior, you want
> a normal laundromat run to reap zero or more courtesy clients.
> You want a shrinker laundromat run to reap more than zero. I
> think you want a minreap variable as well as a maxreap variable
> in there to control how the reaplist is built. Making @minreap
> a function parameter rather than a global atomic would be a
> plus for me, but maybe that's not practical.
I'm not quite understand how the minreap is used, I think it
will make the code more complex.
>
> But I would prefer a more straightforward approach overall. The
> proposed approach seems tricky and brittle, and needs a lot of
> explaining to understand. Other subsystems seem to get away with
> something simpler.
>
> Can nfsd_courtesy_client_count() simply reduce
> nn->nfs4_max_clients, kick the laundromat, and then return 0?
> Then get rid of nfsd_courtesy_client_scan().
I need to think more about this approach. However at first glance,
nn->nfs4_max_clients is used to control how many clients, including
active and courtesy clients, are allowed in the system. If we lower
this count, it also prevent new clients from connecting to the
system. So now the shrinker mechanism does more than just getting
rid of unused resources, maybe that's ok?
>
> Or, nfsd_courtesy_client_count() could return
> nfsd_couresy_client_count. nfsd_courtesy_client_scan() could
> then look something like this:
>
> if ((sc->gfp_mask & GFP_KERNEL) != GFP_KERNEL)
> return SHRINK_STOP;
>
> nfsd_get_client_reaplist(nn, reaplist, lt);
> list_for_each_safe(pos, next, &reaplist) {
> clp = list_entry(pos, struct nfs4_client, cl_lru);
> trace_nfsd_clid_purged(&clp->cl_clientid);
> list_del_init(&clp->cl_lru);
> expire_client(clp);
> count++;
> }
> return count;
This does not work, we cannot expire clients on the context of
scan callback due to deadlock problem.
I will experiment with ways to get rid of the scan function to
make the logic simpler.
Thanks,
-Dai
>
> Obviously you would need to refactor common code into helper
> functions.
>
> --
> Chuck Lever
>
next prev parent reply other threads:[~2022-09-02 16:44 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-30 21:48 [PATCH v4 0/2] NFSD: memory shrinker for NFSv4 clients Dai Ngo
2022-08-30 21:48 ` [PATCH v4 1/2] NFSD: keep track of the number of courtesy clients in the system Dai Ngo
2022-08-31 14:30 ` Chuck Lever III
2022-08-30 21:48 ` [PATCH v4 2/2] NFSD: add shrinker to reap courtesy clients on low memory condition Dai Ngo
2022-08-31 14:30 ` Chuck Lever III
2022-09-02 1:56 ` dai.ngo
2022-09-02 4:32 ` Chuck Lever III
2022-09-02 16:44 ` dai.ngo [this message]
2022-09-02 17:58 ` Chuck Lever III
2022-09-02 19:34 ` dai.ngo
2022-09-03 1:26 ` Chuck Lever III
2022-09-03 17:03 ` dai.ngo
2022-09-03 17:29 ` Chuck Lever III
2022-09-03 17:59 ` dai.ngo
2022-09-06 13:00 ` J. Bruce Fields
2022-09-06 19:04 ` dai.ngo
2022-08-31 10:00 ` [PATCH v4 0/2] NFSD: memory shrinker for NFSv4 clients Jeff Layton
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=eb197dde-8758-7ef4-8a7b-989273e09abc@oracle.com \
--to=dai.ngo@oracle.com \
--cc=chuck.lever@oracle.com \
--cc=jlayton@kernel.org \
--cc=linux-nfs@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox