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 v4] kvfree_rcu: Release page cache under memory pressure
Date: Mon, 8 Feb 2021 14:02:48 +0100 [thread overview]
Message-ID: <20210208130248.GC1920@pc638.lan> (raw)
In-Reply-To: <20210207124432.10143-1-qiang.zhang@windriver.com>
Hello, Zqiang.
Thank you for your v4!
Some small nits see below:
> From: Zqiang <qiang.zhang@windriver.com>
>
> 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>
> Co-developed-by: Uladzislau Rezki (Sony) <urezki@gmail.com>
> ---
> v1->v2->v3->v4:
> During the test a page shrinker is pretty active, because of low memory
> condition. callback drains it whereas kvfree_rcu() part refill it right
> away making kind of vicious circle.
> Through Vlad Rezki suggestion, to avoid this, schedule a periodic delayed
> work with HZ, and it's easy to do that.
>
I think the commit message should be improved. Please add a clear
description how it works, i mean its connection with shrinker, etc.
> kernel/rcu/tree.c | 50 +++++++++++++++++++++++++++++++++++++++--------
> 1 file changed, 42 insertions(+), 8 deletions(-)
>
> diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c
> index c1ae1e52f638..f3b772eef468 100644
> --- a/kernel/rcu/tree.c
> +++ b/kernel/rcu/tree.c
> @@ -3139,7 +3139,7 @@ struct kfree_rcu_cpu {
> bool initialized;
> int count;
>
> - struct work_struct page_cache_work;
> + struct delayed_work page_cache_work;
> atomic_t work_in_progress;
> struct hrtimer hrtimer;
>
> @@ -3395,7 +3395,7 @@ schedule_page_work_fn(struct hrtimer *t)
> struct kfree_rcu_cpu *krcp =
> container_of(t, struct kfree_rcu_cpu, hrtimer);
>
> - queue_work(system_highpri_wq, &krcp->page_cache_work);
> + queue_delayed_work(system_highpri_wq, &krcp->page_cache_work, 0);
> return HRTIMER_NORESTART;
> }
>
> @@ -3404,7 +3404,7 @@ static void fill_page_cache_func(struct work_struct *work)
> struct kvfree_rcu_bulk_data *bnode;
> struct kfree_rcu_cpu *krcp =
> container_of(work, struct kfree_rcu_cpu,
> - page_cache_work);
> + page_cache_work.work);
> unsigned long flags;
> bool pushed;
> int i;
> @@ -3428,15 +3428,22 @@ static void fill_page_cache_func(struct work_struct *work)
> atomic_set(&krcp->work_in_progress, 0);
> }
>
> +static bool backoff_page_cache_fill;
> +
> static void
> run_page_cache_worker(struct kfree_rcu_cpu *krcp)
> {
> if (rcu_scheduler_active == RCU_SCHEDULER_RUNNING &&
> !atomic_xchg(&krcp->work_in_progress, 1)) {
> - hrtimer_init(&krcp->hrtimer, CLOCK_MONOTONIC,
> - HRTIMER_MODE_REL);
> - krcp->hrtimer.function = schedule_page_work_fn;
> - hrtimer_start(&krcp->hrtimer, 0, HRTIMER_MODE_REL);
> + if (READ_ONCE(backoff_page_cache_fill)) {
Can we just use xchg directly inside "if" statement? So we can
get rid of below WRITE_ONCE(). It is not considered as a "hot"
path, so it should not be an issue.
> + queue_delayed_work(system_highpri_wq, &krcp->page_cache_work, HZ);
> + WRITE_ONCE(backoff_page_cache_fill, false);
> + } else {
> + hrtimer_init(&krcp->hrtimer, CLOCK_MONOTONIC,
> + HRTIMER_MODE_REL);
> + krcp->hrtimer.function = schedule_page_work_fn;
> + hrtimer_start(&krcp->hrtimer, 0, HRTIMER_MODE_REL);
> + }
> }
> }
Thank you!
--
Vlad Rezki
prev parent reply other threads:[~2021-02-08 13:04 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-02-07 12:44 [PATCH v4] kvfree_rcu: Release page cache under memory pressure qiang.zhang
2021-02-08 13:02 ` 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=20210208130248.GC1920@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox