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 5278FC433F5 for ; Tue, 21 Dec 2021 01:57:08 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 38ABF6B0092; Mon, 20 Dec 2021 20:57:07 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 338C76B0093; Mon, 20 Dec 2021 20:57:07 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 233866B0095; Mon, 20 Dec 2021 20:57:07 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0221.hostedemail.com [216.40.44.221]) by kanga.kvack.org (Postfix) with ESMTP id 14BC36B0092 for ; Mon, 20 Dec 2021 20:57:07 -0500 (EST) Received: from smtpin25.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id CDB33181AC9C6 for ; Tue, 21 Dec 2021 01:57:06 +0000 (UTC) X-FDA: 78940138452.25.ABF1851 Received: from mail-qk1-f170.google.com (mail-qk1-f170.google.com [209.85.222.170]) by imf27.hostedemail.com (Postfix) with ESMTP id E887E40009 for ; Tue, 21 Dec 2021 01:57:05 +0000 (UTC) Received: by mail-qk1-f170.google.com with SMTP id e16so372892qkl.12 for ; Mon, 20 Dec 2021 17:57:06 -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 :cc; bh=5kGGZNA6AABEoxSURNI3DwDCVPmsZyAz/hG0EO01Rc0=; b=dx85LNEfgR1alPkW0MG24kKEKn1Mowf775AiiZt+x22oJIbufoQtrOZU0BZdmNbqhW 2Mo8VQl5cvCA5kisl9jvkN8TnxjI1xi2DG+HCbucRh+eJpA6uhOph6uiREBcrWcyvr0e fKrBxOagfQSc+a9EbUAW4LCZs7pyqg9JmDf0Pzl+lAHrHF7b5Tsa/VEvCw/bsUHxQlQL ZtfQosRx7Alpdbt4xJknSc6Vy60774tq9w0ivntJCyfI9CezR+GguglQ3gbgJl+hhXni 78A4TwSF3y2cROB3HlEFHlYf+dWEZb7KQBLsI75BQd5tpyybPqkwfiyrx9CTXOnTj04V 2R9Q== 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:cc; bh=5kGGZNA6AABEoxSURNI3DwDCVPmsZyAz/hG0EO01Rc0=; b=nPHtFwI1IoaBGSY3Yajixi5tUvhZY3teOnng8j8D6K1dZdefF6DP03fLwo6dUjdO/m xh9xwCFblGRctbXswsT1y47GPjxJrA6th4EFs8YcFPWs5AL81L8gRqYkHtryElbbelJH LdVh1ZCPE2aSdBsUOL5M9aUxuzJ0pvIxL91x8opW3CPymvga5wmBxzxERiPk3fLxIgBQ bVIUO3fwsjQ9THUpSl5ld3bonf8IoVwXdtkpoYPX79ZuIObq7a6Vle0+WxQeDPfNy5eV VkGDqAn+iw35Tku0WmZfjhO2SJUHYbra1PiXxvlCalWaF3LXmf3Hg2NAkhBuOMP23pMM 1B2Q== X-Gm-Message-State: AOAM533uuPBJuv9fxCVSx2FbaW+0KJMuRKQZUnc++BRMIvv2bTB+AxGJ bPRD4Onr38l7yD9KBUPrNFcdQKGiavgUSsFZxa0= X-Google-Smtp-Source: ABdhPJzBKKiOV2mJ9YbMyaKpDVwWh0kSy+6nMj3o/nNlJeIGpk0WFEK0TX2Af6fLNCw7YkWRAKWcXDt2JTJTOMLh3RE= X-Received: by 2002:a05:620a:1713:: with SMTP id az19mr678889qkb.297.1640051825786; Mon, 20 Dec 2021 17:57:05 -0800 (PST) MIME-Version: 1.0 References: <1639721264-12294-1-git-send-email-huangzhaoyang@gmail.com> In-Reply-To: From: Zhaoyang Huang Date: Tue, 21 Dec 2021 09:56:45 +0800 Message-ID: Subject: Re: [PATCH] psi: fix possible trigger missing in the window To: Suren Baghdasaryan Cc: Johannes Weiner , Zhaoyang Huang , "open list:MEMORY MANAGEMENT" , LKML Content-Type: text/plain; charset="UTF-8" X-Stat-Signature: ryqk1kgf3y1f14xbh66uthofbjb6ibhp X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: E887E40009 Authentication-Results: imf27.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=dx85LNEf; spf=pass (imf27.hostedemail.com: domain of huangzhaoyang@gmail.com designates 209.85.222.170 as permitted sender) smtp.mailfrom=huangzhaoyang@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-HE-Tag: 1640051825-152733 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: On Tue, Dec 21, 2021 at 3:58 AM Suren Baghdasaryan wrote: > > On Fri, Dec 17, 2021 at 10:03 PM Zhaoyang Huang wrote: > > > > loop Suren > > Thanks. > > > > > > 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. > > Could you please expand on this description? I'm unclear what the > problem is. I assume "polling_min_period" in this description refers > to the group->poll_min_period. > > From the code, looks like the change results in update_triggers() > calling window_update() once there was a new stall recorded for the > trigger state and until the tracking window is complete. I don't see > the point of calling window_update() if there was no stall change > since the last call to window_update(). The resulting growth will not > increase if there is no new stall. > Maybe what you want to achieve here is more than one trigger per > window if the stall limit was breached? If so, then this goes against > the design for psi triggers in which we want to rate-limit the number > of generated triggers per tracking window (see: > https://elixir.bootlin.com/linux/latest/source/kernel/sched/psi.c#L545). > Please clarify the issue and the intentions here. > Thanks! Please correct me if I am wrong. Imagine that there is a new stall during the 1st polling_min_period among 10 of them in the window and group->polling_total will be updated to total without trigger. If the rest of 9 polling_min_periods remain the same states, the trigger will be missed when window timing is reached. > > > > > > > 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 > > >