From: Uladzislau Rezki <urezki@gmail.com>
To: qiang.zhang@windriver.com
Cc: urezki@gmail.com, paulmck@kernel.org, joel@joelfernandes.org,
rcu@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] kvfree_rcu: Release page cache under memory pressure
Date: Thu, 28 Jan 2021 17:31:49 +0100 [thread overview]
Message-ID: <20210128163149.GA2397@pc638.lan> (raw)
In-Reply-To: <20210128130509.35489-1-qiang.zhang@windriver.com>
Hello, Zqiang.
See below some nits:
>
> Add free per-cpu existing krcp's page cache operation, when
> the system is under memory pressure.
>
> Signed-off-by: Zqiang <qiang.zhang@windriver.com>
> ---
> kernel/rcu/tree.c | 26 ++++++++++++++++++++++++++
> 1 file changed, 26 insertions(+)
>
> diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c
> index c1ae1e52f638..4e1c14b12bdd 100644
> --- a/kernel/rcu/tree.c
> +++ b/kernel/rcu/tree.c
> @@ -3571,17 +3571,41 @@ void kvfree_call_rcu(struct rcu_head *head, rcu_callback_t func)
> }
> EXPORT_SYMBOL_GPL(kvfree_call_rcu);
>
> +static inline int free_krc_page_cache(struct kfree_rcu_cpu *krcp)
Do we need it "inlined"?
> +{
> + unsigned long flags;
> + struct kvfree_rcu_bulk_data *bnode;
> + int i, num = 0;
> +
> + for (i = 0; i < rcu_min_cached_objs; i++) {
> + raw_spin_lock_irqsave(&krcp->lock, flags);
> + bnode = get_cached_bnode(krcp);
> + raw_spin_unlock_irqrestore(&krcp->lock, flags);
> + if (!bnode)
> + break;
> + free_page((unsigned long)bnode);
> + num++;
> + }
> +
> + return num;
Get rid of "num" and return i instead?
> +}
> +
> static unsigned long
> kfree_rcu_shrink_count(struct shrinker *shrink, struct shrink_control *sc)
> {
> int cpu;
> unsigned long count = 0;
> + unsigned long flags;
>
> /* Snapshot count of all CPUs */
> for_each_possible_cpu(cpu) {
> struct kfree_rcu_cpu *krcp = per_cpu_ptr(&krc, cpu);
>
> count += READ_ONCE(krcp->count);
> +
> + raw_spin_lock_irqsave(&krcp->lock, flags);
> + count += krcp->nr_bkv_objs;
> + raw_spin_unlock_irqrestore(&krcp->lock, flags);
> }
>
> return count;
> @@ -3604,6 +3628,8 @@ kfree_rcu_shrink_scan(struct shrinker *shrink, struct shrink_control *sc)
> else
> raw_spin_unlock_irqrestore(&krcp->lock, flags);
>
> + count += free_krc_page_cache(krcp);
Move it upper right after count = krcp->count;, so a "count" is set
in one place what i more readable and clear?
Thank you!
--
Vlad Rezki
prev parent reply other threads:[~2021-01-28 16:32 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-28 13:05 [PATCH] kvfree_rcu: Release page cache under memory pressure qiang.zhang
2021-01-28 16:31 ` Uladzislau Rezki [this message]
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=20210128163149.GA2397@pc638.lan \
--to=urezki@gmail.com \
--cc=joel@joelfernandes.org \
--cc=linux-kernel@vger.kernel.org \
--cc=paulmck@kernel.org \
--cc=qiang.zhang@windriver.com \
--cc=rcu@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.