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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A8788ECAAD3 for ; Sat, 17 Sep 2022 07:31:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229572AbiIQHbf (ORCPT ); Sat, 17 Sep 2022 03:31:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38098 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229436AbiIQHbc (ORCPT ); Sat, 17 Sep 2022 03:31:32 -0400 Received: from mail-oa1-x2b.google.com (mail-oa1-x2b.google.com [IPv6:2001:4860:4864:20::2b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D94492A424 for ; Sat, 17 Sep 2022 00:31:27 -0700 (PDT) Received: by mail-oa1-x2b.google.com with SMTP id 586e51a60fabf-12c8312131fso5015325fac.4 for ; Sat, 17 Sep 2022 00:31:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=user-agent:in-reply-to:content-disposition:mime-version:references :message-id:subject:cc:to:from:date:from:to:cc:subject:date; bh=slXSPY5RoyJ7laPMVm01aNnZ8Mp073/8x97k9aBNJpk=; b=Bq+IETVZ5QjD/783Ud0vaAwsdWxYT7IsiDBXU/mSRDap658gGtN4HGRhXhqcQ8SeGM +HGp6JSXQAS2eObzhOJUnwDVdGoyP0fp6kUveAttO4zbqE2coKQxcwi/ZxTzWz9cyovJ qxp5UsZV100nQjricG65wNKjbXHhy4S5fzQNksFnbT038i/JuhQCXB67wg4hKRfngapL eSIxJoaQzbXUC5D9ygL8Hjz9qakOYlabFV2RYxs/8CHifz9yhcvcB9ieKY0Tt5aULC+K 3dL4GXg3TbpA2/ZX+4QGyp8pojUJrauH3wOxp1orB1GvpigmjVIl9z2b8pxWyS50MRUQ NcUw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=user-agent:in-reply-to:content-disposition:mime-version:references :message-id:subject:cc:to:from:date:x-gm-message-state:from:to:cc :subject:date; bh=slXSPY5RoyJ7laPMVm01aNnZ8Mp073/8x97k9aBNJpk=; b=RLpT5vQeo1aFPOmdwbIYVaKh+Q1WjL4PwPyETliu7pe1Ftd1V8c5VODi8kq9bM46+G dEOqe31zUIs9nwWrHYKc4O1mQ0QLNAzs5Pf+eJvupZJ6cmu19R+L8T6oEOifBNdJD+vt 4WehXh87OcO63DulnfmdrVKJNxvqVz9qYKCLPhVseLYU4O1rNODXiWXpwPf5NNNsU9GO EM/SL16kQ4wKP7Hplg3WqF0LnD/d16t9z4xdO5SEULubvXik8WDGPUej3U+2X+3llWhs kBWrpUIIIfbEdQoB9vGMk3zO8JZFBVedjbNg2Nw+ghFFnEwhdWi8vpUgg/TFpKMLMAbx 9ccA== X-Gm-Message-State: ACrzQf0I3PVah/0W6EPN9kw/kAfM23YwkTuc5WMsX4oWdmZcENUF9pxq VlbLBjnusqK7C3HUmT2pW3+ODhOnJPk= X-Google-Smtp-Source: AMsMyM578MR/gauQIpAf7VEk/bwBLXHx65IAn/S8Ti+fKNSU02Kp9G1px+2vlwmYXqgIDZsopSCeow== X-Received: by 2002:a05:6870:41ca:b0:12b:9637:1cda with SMTP id z10-20020a05687041ca00b0012b96371cdamr4752923oac.114.1663399887177; Sat, 17 Sep 2022 00:31:27 -0700 (PDT) Received: from haolee.io ([2600:3c00::f03c:91ff:fe02:b162]) by smtp.gmail.com with ESMTPSA id b41-20020a056870472900b0012c21a64a76sm4014068oaq.24.2022.09.17.00.31.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 17 Sep 2022 00:31:26 -0700 (PDT) Date: Sat, 17 Sep 2022 07:31:24 +0000 From: Hao Lee To: Suren Baghdasaryan Cc: Johannes Weiner , Peter Zijlstra , Zhaoyang Huang , LKML Subject: Re: [PATCH] psi: fix possible missing or delayed pending event Message-ID: <20220917073124.GA3483@haolee.io> References: <20220914092959.GA20640@haolee.io> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.12.1 (2019-06-15) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Sep 16, 2022 at 11:08:34PM -0700, Suren Baghdasaryan wrote: > On Wed, Sep 14, 2022 at 2:30 AM Hao Lee wrote: > > > > When a pending event exists and growth is less than the threshold, the > > current logic is to skip this trigger without generating event. However, > > from e6df4ead85d9 ("psi: fix possible trigger missing in the window"), > > our purpose is to generate event as long as pending event exists and the > > rate meets the limit. This patch fixes the possible pending-event > > missing or delay. > > > > Fixes: e6df4ead85d9 ("psi: fix possible trigger missing in the window") > > Signed-off-by: Hao Lee > > --- > > kernel/sched/psi.c | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/kernel/sched/psi.c b/kernel/sched/psi.c > > index 9711827e3..0bae4ee2b 100644 > > --- a/kernel/sched/psi.c > > +++ b/kernel/sched/psi.c > > @@ -539,7 +539,7 @@ static u64 update_triggers(struct psi_group *group, u64 now) > > > > /* Calculate growth since last update */ > > growth = window_update(&t->win, now, total[t->state]); > > - if (growth < t->threshold) > > + if (growth < t->threshold && !t->pending_event) > > I'm not sure how this additional condition changes things. Current > logic is to set t->pending_event=true whenever growth exceeds the > t->threshold. This patch will change this logic into setting > t->pending_event=true also when t->pending_event=true. This is right. > But why would > you want to set t->pending_event=true if it's already true? What am I > missing? If I expand this if-else branch and the pending_event statement to a more detailed snippet, it will be like this: if (growth < t->threshold && !t->pending_event) // under threshold && no pending event. Skip. continue; else if (growth >= t->threshold) // above threshold. Try to generate event. t->pending_event = true; else // under threshold && have pending events. Try to generate event. ; // pending_event is already true. do nothing The original code didn't handle the `else` condition properly. It will skip the trigger when its growth is under the threshold, even though it has a pending event. This patch handles this condition correctly. But I think assigning true to pending_event when it's already true doesn't have other side effects, so I eliminate the `else if` branch. Maybe we'd better make it explicit, like the above snippet? Thanks. > > > continue; > > > > t->pending_event = true; > > -- > > 2.21.0 > >