Message ID | 20230309170756.52927-4-cerasuolodomenico@gmail.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp423652wrd; Thu, 9 Mar 2023 09:40:55 -0800 (PST) X-Google-Smtp-Source: AK7set/qrw7Qq93KuwYcmGytAqPAkiR7McbB4VQKYfSnxjTIV9I7LLEtVg79/Un5EyA340tFHwTI X-Received: by 2002:a05:6a20:4320:b0:d0:45c0:1421 with SMTP id h32-20020a056a20432000b000d045c01421mr9166484pzk.48.1678383654963; Thu, 09 Mar 2023 09:40:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1678383654; cv=none; d=google.com; s=arc-20160816; b=dDxisqkhXCS0v15yJZVHFOxta0tet8ZCn/PdXtS+78j19kBb2foHl6kAE1H4EFII+b 0CrI1drtHFMXXk8c++rL+busICGw3twbupRJZexPmoo3IJXk2RN4zmuGi9VjjCS+oqhe if9Rtxrqs55OLtoWsWh94v8uSiJyBgu533i2gkqeiCRBp7oxglNb4+NtNELE4WxeyaDI S2KTM+bBqFq5Fp1EJU9E4BF7OgCSmAckdg3AKXAAXyEH58nrw+2s0weHq8fAMlV81PA6 iCYD0y0mUw1oZ9JMiOLgljIVrz5Rq5Nl3KJK2qipC7nIIUaxrJq3xztEHuhCW48hXRyc SFdg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=iBuKepBSNeui5B6FhWjCNCNf/8wtioatAM9zTb92L/k=; b=n1WC+0nu+mNIg4rM8bPyjtJ4CEnYbUVqhocjavYKPPyd/i9Tge9fmM+mw0R9uVeGbF JlZ7zViw2H/6t+hxR/3hD1/WD7Lh6wte5DWHMRZKOrFPIePIpGt6Zb6fjLt3V12pCoqn efKjDS+ncm4usmd7HAu67kEbtEUHpOam28E6Hwd2KBaWK6N8cTHbSXPZz65abTdwXb43 JvuaKl4LpSx7BUJt11WRmbV5/I38t0pzcUtNR9kZuM8mY8HeMrXnN0cNgmhxwAVCSzyi i/kiXJH7PqYKsllkcJJcP43JUrqd7WsY+yFHqEtXuL3ktUt1tDy1jnvxL5ESeSmb3fXG Khng== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=DWQnHIVg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v10-20020a63610a000000b00503015b772asi5209760pgb.743.2023.03.09.09.40.40; Thu, 09 Mar 2023 09:40:54 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=DWQnHIVg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229872AbjCIRK5 (ORCPT <rfc822;toshivichauhan@gmail.com> + 99 others); Thu, 9 Mar 2023 12:10:57 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39748 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231338AbjCIRKC (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Thu, 9 Mar 2023 12:10:02 -0500 Received: from mail-ed1-x52f.google.com (mail-ed1-x52f.google.com [IPv6:2a00:1450:4864:20::52f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1EAAB469D for <linux-kernel@vger.kernel.org>; Thu, 9 Mar 2023 09:08:06 -0800 (PST) Received: by mail-ed1-x52f.google.com with SMTP id ec29so9785246edb.6 for <linux-kernel@vger.kernel.org>; Thu, 09 Mar 2023 09:08:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1678381684; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=iBuKepBSNeui5B6FhWjCNCNf/8wtioatAM9zTb92L/k=; b=DWQnHIVggPRC4AMq5D2NHxoXXd86XqeZtMfb45iyddGQpsTxvtQiMIrsqFLXM7hB4B oR1iwPUseQ3YhpcGhCEoDUbW34yxZhdLlXi5keCAtZY8YHe8Z8CCAsrzo/XkfQOoHHl4 xTz6NRdfe1rRvNZRGUZRVx4Ny0nh2PSSxRLTZ5e2Ao0zbI5hkJto/28SzTe3i4VIotdd RHJh28lzS+NFZpqrqmyxK3x8GICkUZThCFj4d+Swo1yCl5uRoVXNka3HipXTUjUeuXTI USjY/jTKRxF65MTEHEq9rj/pAjV5XBFYGISOuJqPqYJunWWTWuWYIAWK5bW7dgHJVxwG Cp+g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678381684; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=iBuKepBSNeui5B6FhWjCNCNf/8wtioatAM9zTb92L/k=; b=n2hjyyTcoORprOKaqF6Svn0kROaAJNSbQdsHwdxwARhjJqN/fUljyY1a8X6BgkezG3 8WoffgXDOlNveVyqurcFGZAohNkLfXSMiMIAhRO1EvRWAQNZaKy5+Qk55Ds5L/YGCANB q5EMOR+1JmOYfKrBtp6pFWckWTw+RgMkSZ2Gps61sJgbNz6VkILcquURGPuvucqs2eIO MYMFfTesgZ2NcQUD1Q/HNpdGsY3aEJCQOQ1eBpeowywOQTSOZ64gToWxPW1VS0icbbQD mj70bdSI6SnaITRxtMJDfUEeDFw53+Alhlj8KUTPXfMD0bwcSuH+R33x2JfnV9SZP/rA euSA== X-Gm-Message-State: AO0yUKW7mhVWm3fRt6yy1bNg/fkjldOe1uHtkHIUCkMwcLN6FxWvdc/w KqsTX3AwXYJBcoKK3nftmN2wHQ9JJh8qiQ== X-Received: by 2002:a17:907:320a:b0:87a:ee05:f7b with SMTP id xg10-20020a170907320a00b0087aee050f7bmr26717111ejb.24.1678381684279; Thu, 09 Mar 2023 09:08:04 -0800 (PST) Received: from lelloman-5950.. (host-79-22-154-28.retail.telecomitalia.it. [79.22.154.28]) by smtp.gmail.com with ESMTPSA id bj8-20020a170906b04800b008d85435f914sm9154867ejb.98.2023.03.09.09.08.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Mar 2023 09:08:03 -0800 (PST) From: Domenico Cerasuolo <cerasuolodomenico@gmail.com> To: linux-kernel@vger.kernel.org Cc: peterz@infradead.org, surenb@google.com, brauner@kernel.org, chris@chrisdown.name, hannes@cmpxchg.org, Domenico Cerasuolo <cerasuolodomenico@gmail.com> Subject: [PATCH 3/4] sched/psi: extract update_triggers side effect Date: Thu, 9 Mar 2023 18:07:55 +0100 Message-Id: <20230309170756.52927-4-cerasuolodomenico@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230309170756.52927-1-cerasuolodomenico@gmail.com> References: <20230309170756.52927-1-cerasuolodomenico@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1759912819541530767?= X-GMAIL-MSGID: =?utf-8?q?1759912819541530767?= |
Series |
sched/psi: Allow unprivileged PSI polling
|
|
Commit Message
Domenico Cerasuolo
March 9, 2023, 5:07 p.m. UTC
The update of rtpoll_total inside update_triggers can be moved out of
the function since changed_states has the same information as the
update_total flag used in the function. Besides the simplification of
the function, with the next patch it would become an unwanted side
effect needed only for PSI_POLL.
Suggested-by: Johannes Weiner <hannes@cmpxchg.org>
Signed-off-by: Domenico Cerasuolo <cerasuolodomenico@gmail.com>
---
kernel/sched/psi.c | 20 +++++---------------
1 file changed, 5 insertions(+), 15 deletions(-)
Comments
On Thu, Mar 9, 2023 at 9:08 AM Domenico Cerasuolo <cerasuolodomenico@gmail.com> wrote: > > The update of rtpoll_total inside update_triggers can be moved out of > the function since changed_states has the same information as the > update_total flag used in the function. Besides the simplification of > the function, with the next patch it would become an unwanted side > effect needed only for PSI_POLL. (changed_states & group->rtpoll_states) and update_total flag are not really equivalent. update_total flag depends on the difference between group->polling_total[state] and group->total[PSI_POLL][state] while changed_states depends on the difference between groupc->times and groupc->times_prev. groupc->times_prev is updated every time collect_percpu_times() is called and there are 3 places where that happens: from psi_avgs_work(), from psi_poll_work() and from psi_show(). group->polling_total[state] is updated only from psi_poll_work(). Therefore the deltas between these values might not always be in-sync. Consider the following sequence as an example: psi_poll_work() ... psi_avgs_work()/psi_show() collect_percpu_times() // we detect a change in a monitored state ... psi_poll_work() collect_percpu_times() // this time no change in monitored states update_triggers() // group->polling_total[state] != group->total[PSI_POLL][state] In the last psi_poll_work() collect_percpu_times() recorded no change in monitored states, so (changed_states & group->rtpoll_states) == 0, however since the last time psi_poll_work() was called there was actually a change in monitored states recorded by the first collect_percpu_times(), therefore (group->polling_total[t->state] != total[t->state]) and we should update the totals. With your change we will miss that update. I think you can easily fix that by introducing update_triggers as an output parameter in window_update() like this: static u64 window_update(struct psi_window *win, u64 now, u64 value, bool *update_triggers) { *update_total = false; ... if (new_stall) { *update_total = true; ... } static void psi_rtpoll_work(struct psi_group *group) { + bool update_triggers; ... - if (now >= group->rtpoll_next_update) + if (now >= group->rtpoll_next_update) { group->rtpoll_next_update = update_triggers(group, now, &update_triggers); + if (update_triggers) + memcpy(group->rtpoll_total, group->total[PSI_POLL], + sizeof(group->rtpoll_total)); + } } > > Suggested-by: Johannes Weiner <hannes@cmpxchg.org> > Signed-off-by: Domenico Cerasuolo <cerasuolodomenico@gmail.com> > --- > kernel/sched/psi.c | 20 +++++--------------- > 1 file changed, 5 insertions(+), 15 deletions(-) > > diff --git a/kernel/sched/psi.c b/kernel/sched/psi.c > index a3d0b5cf797a..476941c1cbea 100644 > --- a/kernel/sched/psi.c > +++ b/kernel/sched/psi.c > @@ -433,7 +433,6 @@ static u64 window_update(struct psi_window *win, u64 now, u64 value) > static u64 update_triggers(struct psi_group *group, u64 now) > { > struct psi_trigger *t; > - bool update_total = false; > u64 *total = group->total[PSI_POLL]; > > /* > @@ -456,14 +455,6 @@ static u64 update_triggers(struct psi_group *group, u64 now) > * events without dropping any). > */ > if (new_stall) { > - /* > - * 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_total = true; > - > /* Calculate growth since last update */ > growth = window_update(&t->win, now, total[t->state]); > if (!t->pending_event) { > @@ -484,11 +475,6 @@ static u64 update_triggers(struct psi_group *group, u64 now) > /* Reset threshold breach flag once event got generated */ > t->pending_event = false; > } > - > - if (update_total) > - memcpy(group->rtpoll_total, total, > - sizeof(group->rtpoll_total)); > - > return now + group->rtpoll_min_period; > } > > @@ -686,8 +672,12 @@ static void psi_rtpoll_work(struct psi_group *group) > goto out; > } > > - if (now >= group->rtpoll_next_update) > + if (now >= group->rtpoll_next_update) { > group->rtpoll_next_update = update_triggers(group, now); > + if (changed_states & group->rtpoll_states) > + memcpy(group->rtpoll_total, group->total[PSI_POLL], > + sizeof(group->rtpoll_total)); > + } > > psi_schedule_rtpoll_work(group, > nsecs_to_jiffies(group->rtpoll_next_update - now) + 1, > -- > 2.34.1 >
On Tue, Mar 21, 2023 at 3:18 AM Domenico Cerasuolo <cerasuolodomenico@gmail.com> wrote: > > Hi Suren, thanks for all the feedback! This makes sense, I only have one doubt, if we set update_total flag to window_update() and update_triggers(), that flag would be ignored when the caller is psi_avgs_work(), this would be happening in the next patch in the set. I don't see why the update_triggers part should be conceptually different between RT and unprivileged triggers. Could you please explain? > What do you think if I just remove this change from the patchset and then work on a solution after the iterations on the main change are completed? This was in fact just an attempt to clean up. > I'll apply your suggested changes on the other patches, wait a bit for comments from someone else and then send V2. > > On Tue, Mar 21, 2023 at 12:00 AM Suren Baghdasaryan <surenb@google.com> wrote: >> >> On Thu, Mar 9, 2023 at 9:08 AM Domenico Cerasuolo >> <cerasuolodomenico@gmail.com> wrote: >> > >> > The update of rtpoll_total inside update_triggers can be moved out of >> > the function since changed_states has the same information as the >> > update_total flag used in the function. Besides the simplification of >> > the function, with the next patch it would become an unwanted side >> > effect needed only for PSI_POLL. >> >> (changed_states & group->rtpoll_states) and update_total flag are not >> really equivalent. update_total flag depends on the difference between >> group->polling_total[state] and group->total[PSI_POLL][state] while >> changed_states depends on the difference between groupc->times and >> groupc->times_prev. groupc->times_prev is updated every time >> collect_percpu_times() is called and there are 3 places where that >> happens: from psi_avgs_work(), from psi_poll_work() and from >> psi_show(). group->polling_total[state] is updated only from >> psi_poll_work(). Therefore the deltas between these values might not >> always be in-sync. >> >> Consider the following sequence as an example: >> >> psi_poll_work() >> ... >> psi_avgs_work()/psi_show() >> collect_percpu_times() // we detect a change in a monitored state >> ... >> psi_poll_work() >> collect_percpu_times() // this time no change in monitored states >> update_triggers() // group->polling_total[state] != >> group->total[PSI_POLL][state] >> >> In the last psi_poll_work() collect_percpu_times() recorded no change >> in monitored states, so (changed_states & group->rtpoll_states) == 0, >> however since the last time psi_poll_work() was called there was >> actually a change in monitored states recorded by the first >> collect_percpu_times(), therefore (group->polling_total[t->state] != >> total[t->state]) and we should update the totals. With your change we >> will miss that update. >> >> I think you can easily fix that by introducing update_triggers as an >> output parameter in window_update() like this: >> >> static u64 window_update(struct psi_window *win, u64 now, u64 value, >> bool *update_triggers) { >> *update_total = false; >> ... >> if (new_stall) { >> *update_total = true; >> ... >> } >> >> static void psi_rtpoll_work(struct psi_group *group) { >> + bool update_triggers; >> ... >> - if (now >= group->rtpoll_next_update) >> + if (now >= group->rtpoll_next_update) { >> group->rtpoll_next_update = update_triggers(group, >> now, &update_triggers); >> + if (update_triggers) >> + memcpy(group->rtpoll_total, group->total[PSI_POLL], >> + sizeof(group->rtpoll_total)); >> + } >> } >> >> >> > >> > Suggested-by: Johannes Weiner <hannes@cmpxchg.org> >> > Signed-off-by: Domenico Cerasuolo <cerasuolodomenico@gmail.com> >> > --- >> > kernel/sched/psi.c | 20 +++++--------------- >> > 1 file changed, 5 insertions(+), 15 deletions(-) >> > >> > diff --git a/kernel/sched/psi.c b/kernel/sched/psi.c >> > index a3d0b5cf797a..476941c1cbea 100644 >> > --- a/kernel/sched/psi.c >> > +++ b/kernel/sched/psi.c >> > @@ -433,7 +433,6 @@ static u64 window_update(struct psi_window *win, u64 now, u64 value) >> > static u64 update_triggers(struct psi_group *group, u64 now) >> > { >> > struct psi_trigger *t; >> > - bool update_total = false; >> > u64 *total = group->total[PSI_POLL]; >> > >> > /* >> > @@ -456,14 +455,6 @@ static u64 update_triggers(struct psi_group *group, u64 now) >> > * events without dropping any). >> > */ >> > if (new_stall) { >> > - /* >> > - * 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_total = true; >> > - >> > /* Calculate growth since last update */ >> > growth = window_update(&t->win, now, total[t->state]); >> > if (!t->pending_event) { >> > @@ -484,11 +475,6 @@ static u64 update_triggers(struct psi_group *group, u64 now) >> > /* Reset threshold breach flag once event got generated */ >> > t->pending_event = false; >> > } >> > - >> > - if (update_total) >> > - memcpy(group->rtpoll_total, total, >> > - sizeof(group->rtpoll_total)); >> > - >> > return now + group->rtpoll_min_period; >> > } >> > >> > @@ -686,8 +672,12 @@ static void psi_rtpoll_work(struct psi_group *group) >> > goto out; >> > } >> > >> > - if (now >= group->rtpoll_next_update) >> > + if (now >= group->rtpoll_next_update) { >> > group->rtpoll_next_update = update_triggers(group, now); >> > + if (changed_states & group->rtpoll_states) >> > + memcpy(group->rtpoll_total, group->total[PSI_POLL], >> > + sizeof(group->rtpoll_total)); >> > + } >> > >> > psi_schedule_rtpoll_work(group, >> > nsecs_to_jiffies(group->rtpoll_next_update - now) + 1, >> > -- >> > 2.34.1 >> >
On Wed, Mar 22, 2023 at 3:14 AM Domenico Cerasuolo <cerasuolodomenico@gmail.com> wrote: > > I'm not suggesting that update_triggers should be different, I agree that they should behave the same for both types of trigger. > The problem is that if we extract the update_total information out of update_triggers, that information will be ignored by psi_avgs_work because avg_total is always updated in update_averages, only psi_poll_work would use it to copy the total to polling_total. > If this is the only alternative to having `if (update_total && aggregator == PSI_POLL)` inside update_triggers, I'll add the argument to update_triggers, I'm just wondering if there could be another alternative. I suggest you post the V2 with suggested changes and this approach and it will be easier to decide whether this can be improved further. Also, please do not top-post (read through https://kernelnewbies.org/mailinglistguidelines for more hints). Thanks, Suren. > > On Wed, Mar 22, 2023 at 4:41 AM Suren Baghdasaryan <surenb@google.com> wrote: >> >> On Tue, Mar 21, 2023 at 3:18 AM Domenico Cerasuolo >> <cerasuolodomenico@gmail.com> wrote: >> > >> > Hi Suren, thanks for all the feedback! This makes sense, I only have one doubt, if we set update_total flag to window_update() and update_triggers(), that flag would be ignored when the caller is psi_avgs_work(), this would be happening in the next patch in the set. >> >> I don't see why the update_triggers part should be conceptually >> different between RT and unprivileged triggers. Could you please >> explain? >> >> > What do you think if I just remove this change from the patchset and then work on a solution after the iterations on the main change are completed? This was in fact just an attempt to clean up. >> > I'll apply your suggested changes on the other patches, wait a bit for comments from someone else and then send V2. >> > >> > On Tue, Mar 21, 2023 at 12:00 AM Suren Baghdasaryan <surenb@google.com> wrote: >> >> >> >> On Thu, Mar 9, 2023 at 9:08 AM Domenico Cerasuolo >> >> <cerasuolodomenico@gmail.com> wrote: >> >> > >> >> > The update of rtpoll_total inside update_triggers can be moved out of >> >> > the function since changed_states has the same information as the >> >> > update_total flag used in the function. Besides the simplification of >> >> > the function, with the next patch it would become an unwanted side >> >> > effect needed only for PSI_POLL. >> >> >> >> (changed_states & group->rtpoll_states) and update_total flag are not >> >> really equivalent. update_total flag depends on the difference between >> >> group->polling_total[state] and group->total[PSI_POLL][state] while >> >> changed_states depends on the difference between groupc->times and >> >> groupc->times_prev. groupc->times_prev is updated every time >> >> collect_percpu_times() is called and there are 3 places where that >> >> happens: from psi_avgs_work(), from psi_poll_work() and from >> >> psi_show(). group->polling_total[state] is updated only from >> >> psi_poll_work(). Therefore the deltas between these values might not >> >> always be in-sync. >> >> >> >> Consider the following sequence as an example: >> >> >> >> psi_poll_work() >> >> ... >> >> psi_avgs_work()/psi_show() >> >> collect_percpu_times() // we detect a change in a monitored state >> >> ... >> >> psi_poll_work() >> >> collect_percpu_times() // this time no change in monitored states >> >> update_triggers() // group->polling_total[state] != >> >> group->total[PSI_POLL][state] >> >> >> >> In the last psi_poll_work() collect_percpu_times() recorded no change >> >> in monitored states, so (changed_states & group->rtpoll_states) == 0, >> >> however since the last time psi_poll_work() was called there was >> >> actually a change in monitored states recorded by the first >> >> collect_percpu_times(), therefore (group->polling_total[t->state] != >> >> total[t->state]) and we should update the totals. With your change we >> >> will miss that update. >> >> >> >> I think you can easily fix that by introducing update_triggers as an >> >> output parameter in window_update() like this: >> >> >> >> static u64 window_update(struct psi_window *win, u64 now, u64 value, >> >> bool *update_triggers) { >> >> *update_total = false; >> >> ... >> >> if (new_stall) { >> >> *update_total = true; >> >> ... >> >> } >> >> >> >> static void psi_rtpoll_work(struct psi_group *group) { >> >> + bool update_triggers; >> >> ... >> >> - if (now >= group->rtpoll_next_update) >> >> + if (now >= group->rtpoll_next_update) { >> >> group->rtpoll_next_update = update_triggers(group, >> >> now, &update_triggers); >> >> + if (update_triggers) >> >> + memcpy(group->rtpoll_total, group->total[PSI_POLL], >> >> + sizeof(group->rtpoll_total)); >> >> + } >> >> } >> >> >> >> >> >> > >> >> > Suggested-by: Johannes Weiner <hannes@cmpxchg.org> >> >> > Signed-off-by: Domenico Cerasuolo <cerasuolodomenico@gmail.com> >> >> > --- >> >> > kernel/sched/psi.c | 20 +++++--------------- >> >> > 1 file changed, 5 insertions(+), 15 deletions(-) >> >> > >> >> > diff --git a/kernel/sched/psi.c b/kernel/sched/psi.c >> >> > index a3d0b5cf797a..476941c1cbea 100644 >> >> > --- a/kernel/sched/psi.c >> >> > +++ b/kernel/sched/psi.c >> >> > @@ -433,7 +433,6 @@ static u64 window_update(struct psi_window *win, u64 now, u64 value) >> >> > static u64 update_triggers(struct psi_group *group, u64 now) >> >> > { >> >> > struct psi_trigger *t; >> >> > - bool update_total = false; >> >> > u64 *total = group->total[PSI_POLL]; >> >> > >> >> > /* >> >> > @@ -456,14 +455,6 @@ static u64 update_triggers(struct psi_group *group, u64 now) >> >> > * events without dropping any). >> >> > */ >> >> > if (new_stall) { >> >> > - /* >> >> > - * 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_total = true; >> >> > - >> >> > /* Calculate growth since last update */ >> >> > growth = window_update(&t->win, now, total[t->state]); >> >> > if (!t->pending_event) { >> >> > @@ -484,11 +475,6 @@ static u64 update_triggers(struct psi_group *group, u64 now) >> >> > /* Reset threshold breach flag once event got generated */ >> >> > t->pending_event = false; >> >> > } >> >> > - >> >> > - if (update_total) >> >> > - memcpy(group->rtpoll_total, total, >> >> > - sizeof(group->rtpoll_total)); >> >> > - >> >> > return now + group->rtpoll_min_period; >> >> > } >> >> > >> >> > @@ -686,8 +672,12 @@ static void psi_rtpoll_work(struct psi_group *group) >> >> > goto out; >> >> > } >> >> > >> >> > - if (now >= group->rtpoll_next_update) >> >> > + if (now >= group->rtpoll_next_update) { >> >> > group->rtpoll_next_update = update_triggers(group, now); >> >> > + if (changed_states & group->rtpoll_states) >> >> > + memcpy(group->rtpoll_total, group->total[PSI_POLL], >> >> > + sizeof(group->rtpoll_total)); >> >> > + } >> >> > >> >> > psi_schedule_rtpoll_work(group, >> >> > nsecs_to_jiffies(group->rtpoll_next_update - now) + 1, >> >> > -- >> >> > 2.34.1 >> >> >
diff --git a/kernel/sched/psi.c b/kernel/sched/psi.c index a3d0b5cf797a..476941c1cbea 100644 --- a/kernel/sched/psi.c +++ b/kernel/sched/psi.c @@ -433,7 +433,6 @@ static u64 window_update(struct psi_window *win, u64 now, u64 value) static u64 update_triggers(struct psi_group *group, u64 now) { struct psi_trigger *t; - bool update_total = false; u64 *total = group->total[PSI_POLL]; /* @@ -456,14 +455,6 @@ static u64 update_triggers(struct psi_group *group, u64 now) * events without dropping any). */ if (new_stall) { - /* - * 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_total = true; - /* Calculate growth since last update */ growth = window_update(&t->win, now, total[t->state]); if (!t->pending_event) { @@ -484,11 +475,6 @@ static u64 update_triggers(struct psi_group *group, u64 now) /* Reset threshold breach flag once event got generated */ t->pending_event = false; } - - if (update_total) - memcpy(group->rtpoll_total, total, - sizeof(group->rtpoll_total)); - return now + group->rtpoll_min_period; } @@ -686,8 +672,12 @@ static void psi_rtpoll_work(struct psi_group *group) goto out; } - if (now >= group->rtpoll_next_update) + if (now >= group->rtpoll_next_update) { group->rtpoll_next_update = update_triggers(group, now); + if (changed_states & group->rtpoll_states) + memcpy(group->rtpoll_total, group->total[PSI_POLL], + sizeof(group->rtpoll_total)); + } psi_schedule_rtpoll_work(group, nsecs_to_jiffies(group->rtpoll_next_update - now) + 1,