From: Zhaoyang Huang <huangzhaoyang@gmail.com>
To: Johannes Weiner <hannes@cmpxchg.org>,
Zhaoyang Huang <zhaoyang.huang@unisoc.com>,
"open list:MEMORY MANAGEMENT" <linux-mm@kvack.org>,
LKML <linux-kernel@vger.kernel.org>,
Suren Baghdasaryan <surenb@google.com>
Subject: Re: [PATCH] psi: fix possible trigger missing in the window
Date: Sat, 18 Dec 2021 14:03:04 +0800 [thread overview]
Message-ID: <CAGWkznGdvLobshPvg2KY+D71Zh0625+V=WsAS9uExRspRFFjVQ@mail.gmail.com> (raw)
In-Reply-To: <1639721264-12294-1-git-send-email-huangzhaoyang@gmail.com>
loop Suren
On Fri, Dec 17, 2021 at 2:08 PM Huangzhaoyang <huangzhaoyang@gmail.com> wrote:
>
> From: Zhaoyang Huang <zhaoyang.huang@unisoc.com>
>
> There could be missing wake up if the rest of the window remain the
> same stall states as the polling_total updates for every polling_min_period.
>
> Signed-off-by: Zhaoyang Huang <zhaoyang.huang@unisoc.com>
> ---
> include/linux/psi_types.h | 2 ++
> kernel/sched/psi.c | 30 ++++++++++++++++++------------
> 2 files changed, 20 insertions(+), 12 deletions(-)
>
> diff --git a/include/linux/psi_types.h b/include/linux/psi_types.h
> index 0a23300..9533d2e 100644
> --- a/include/linux/psi_types.h
> +++ b/include/linux/psi_types.h
> @@ -132,6 +132,8 @@ struct psi_trigger {
>
> /* Refcounting to prevent premature destruction */
> struct kref refcount;
> +
> + bool new_stall;
> };
>
> struct psi_group {
> diff --git a/kernel/sched/psi.c b/kernel/sched/psi.c
> index 1652f2b..402718c 100644
> --- a/kernel/sched/psi.c
> +++ b/kernel/sched/psi.c
> @@ -458,9 +458,12 @@ static void psi_avgs_work(struct work_struct *work)
> static void window_reset(struct psi_window *win, u64 now, u64 value,
> u64 prev_growth)
> {
> + struct psi_trigger *t = container_of(win, struct psi_trigger, win);
> +
> win->start_time = now;
> win->start_value = value;
> win->prev_growth = prev_growth;
> + t->new_stall = false;
> }
>
> /*
> @@ -515,7 +518,6 @@ static void init_triggers(struct psi_group *group, u64 now)
> static u64 update_triggers(struct psi_group *group, u64 now)
> {
> struct psi_trigger *t;
> - bool new_stall = false;
> u64 *total = group->total[PSI_POLL];
>
> /*
> @@ -523,19 +525,26 @@ static u64 update_triggers(struct psi_group *group, u64 now)
> * watchers know when their specified thresholds are exceeded.
> */
> list_for_each_entry(t, &group->triggers, node) {
> - u64 growth;
> -
> /* Check for stall activity */
> if (group->polling_total[t->state] == total[t->state])
> continue;
>
> /*
> - * Multiple triggers might be looking at the same state,
> - * remember to update group->polling_total[] once we've
> - * been through all of them. Also remember to extend the
> - * polling time if we see new stall activity.
> + * update the trigger if there is new stall which will be
> + * reset when run out of the window
> */
> - new_stall = true;
> + t->new_stall = true;
> +
> + memcpy(&group->polling_total[t->state], &total[t->state],
> + sizeof(group->polling_total[t->state]));
> + }
> +
> + list_for_each_entry(t, &group->triggers, node) {
> + u64 growth;
> +
> + /* check if new stall happened during this window*/
> + if (!t->new_stall)
> + continue;
>
> /* Calculate growth since last update */
> growth = window_update(&t->win, now, total[t->state]);
> @@ -552,10 +561,6 @@ static u64 update_triggers(struct psi_group *group, u64 now)
> t->last_event_time = now;
> }
>
> - if (new_stall)
> - memcpy(group->polling_total, total,
> - sizeof(group->polling_total));
> -
> return now + group->poll_min_period;
> }
>
> @@ -1152,6 +1157,7 @@ struct psi_trigger *psi_trigger_create(struct psi_group *group,
> t->last_event_time = 0;
> init_waitqueue_head(&t->event_wait);
> kref_init(&t->refcount);
> + t->new_stall = false;
>
> mutex_lock(&group->trigger_lock);
>
> --
> 1.9.1
>
next prev parent reply other threads:[~2021-12-18 6:03 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-12-17 6:07 [PATCH] psi: fix possible trigger missing in the window Huangzhaoyang
2021-12-18 6:03 ` Zhaoyang Huang [this message]
2021-12-20 19:58 ` Suren Baghdasaryan
2021-12-21 1:56 ` Zhaoyang Huang
2021-12-21 2:30 ` Suren Baghdasaryan
2021-12-21 2:51 ` Zhaoyang Huang
2021-12-21 3:00 ` Suren Baghdasaryan
2021-12-21 3:07 ` Zhaoyang Huang
2021-12-21 6:37 ` Suren Baghdasaryan
2021-12-21 6:40 ` Suren Baghdasaryan
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='CAGWkznGdvLobshPvg2KY+D71Zh0625+V=WsAS9uExRspRFFjVQ@mail.gmail.com' \
--to=huangzhaoyang@gmail.com \
--cc=hannes@cmpxchg.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=surenb@google.com \
--cc=zhaoyang.huang@unisoc.com \
/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;
as well as URLs for NNTP newsgroup(s).