From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6EEB4C433EF for ; Sat, 18 Dec 2021 06:03:46 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8C9B06B0072; Sat, 18 Dec 2021 01:03:35 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 879AE6B0073; Sat, 18 Dec 2021 01:03:35 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7694D6B0074; Sat, 18 Dec 2021 01:03:35 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0120.hostedemail.com [216.40.44.120]) by kanga.kvack.org (Postfix) with ESMTP id 6B4936B0072 for ; Sat, 18 Dec 2021 01:03:35 -0500 (EST) Received: from smtpin27.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 37E748C588 for ; Sat, 18 Dec 2021 06:03:25 +0000 (UTC) X-FDA: 78929872770.27.0FF8980 Received: from mail-qk1-f170.google.com (mail-qk1-f170.google.com [209.85.222.170]) by imf06.hostedemail.com (Postfix) with ESMTP id D6EFC180020 for ; Sat, 18 Dec 2021 06:03:23 +0000 (UTC) Received: by mail-qk1-f170.google.com with SMTP id t6so4386247qkg.1 for ; Fri, 17 Dec 2021 22:03:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=JkH82Y5mSBqKmWXWre7SqOOoFhR5WDoFjJYNZaqCJjU=; b=fnQATQtlokIbwbZKwvBtTPl5gtKIDf8rgl9Trcy/HIt7VimXJ5mF38W3tEevaz1blq ljFS3dom7VzkvhwXD+IYMY1AmSJcEkMlRWbo/SZQFSw4lhNtaVipD7HPK+8ENctRukiC DAJg+sunC05JDUakBNmyD+8z0j5UZKw53sZanj40UBhVmeP1eX5EBOHlDsuISr/XM+ip B0SzKcedT8EiDIA0gyMvYWAzO+O+0nc19SPKOPigso9A06uZIe/axbgU0DkuR2l3r+w3 gqyV5qfdX3kejorASSArarsw/BMxP/IwT72NsXngUKeBI9n5Z+V03Enutp2VOH+b3SBc ihBA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=JkH82Y5mSBqKmWXWre7SqOOoFhR5WDoFjJYNZaqCJjU=; b=5AOId2g294MI7C7qSKRy0DW8A2tpUOrnnILpSJ3hIMM8nh/+KLHBpVKR41s52eLdxT U+paO199JTABPmu3fCz+L+4NaRgoZy0D+p8InjW1cUq8g99mxQsAxsrmGVAUry2BgPp7 DykeUCWLWe2TNGw5iRXpnQV04TwtD/a75gNmSMlvnIohl6f6KX0it0Rp28D4TfqNbYPa XHeOpnxrlK5jcLISWV5BWF17Aqy89mtpjkYPz+bGNS2rUqRT9qEMkPKgFfzHE3WhlS2n MFvhWYM/6qwsPWsPjw+wSJ8GzhKOlUlCw1uCQvtIT+Jpj/zAlivnLL4AQHEuThutWdUd GXvw== X-Gm-Message-State: AOAM533+2IrmmQc/rY/np/KGcaJ1fctKXT4IY8Us23s61t4HF8d8tj/L zwpsdTmo3IGYe4yzpNgAA2nj2CbGT4S1FFu/6rE= X-Google-Smtp-Source: ABdhPJy8j3DUO3jo5bHvJpMUrHYMHtyKfmCM/5grz4jgJPYMfHOBkhofwLTSJu/WUbetOaml8FyrTVOXEOUut8ztlLg= X-Received: by 2002:a05:620a:1713:: with SMTP id az19mr3939566qkb.297.1639807404165; Fri, 17 Dec 2021 22:03:24 -0800 (PST) MIME-Version: 1.0 References: <1639721264-12294-1-git-send-email-huangzhaoyang@gmail.com> In-Reply-To: <1639721264-12294-1-git-send-email-huangzhaoyang@gmail.com> From: Zhaoyang Huang Date: Sat, 18 Dec 2021 14:03:04 +0800 Message-ID: Subject: Re: [PATCH] psi: fix possible trigger missing in the window To: Johannes Weiner , Zhaoyang Huang , "open list:MEMORY MANAGEMENT" , LKML , Suren Baghdasaryan Content-Type: text/plain; charset="UTF-8" Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=fnQATQtl; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf06.hostedemail.com: domain of huangzhaoyang@gmail.com designates 209.85.222.170 as permitted sender) smtp.mailfrom=huangzhaoyang@gmail.com X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: D6EFC180020 X-Stat-Signature: h917mdzk5e9j674qi75bufmp4zr3aoeu X-HE-Tag: 1639807403-300842 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000001, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: loop Suren On Fri, Dec 17, 2021 at 2:08 PM Huangzhaoyang wrote: > > From: Zhaoyang Huang > > 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 > --- > 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 >