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 [thread overview]
Message-ID: <20230309170756.52927-4-cerasuolodomenico@gmail.com> (raw)
In-Reply-To: <20230309170756.52927-1-cerasuolodomenico@gmail.com>
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(-)
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
next prev parent reply other threads:[~2023-03-09 17:11 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-09 17:07 [PATCH 0/4] sched/psi: Allow unprivileged PSI polling Domenico Cerasuolo
2023-03-09 17:07 ` [PATCH 1/4] sched/psi: rearrange polling code in preparation Domenico Cerasuolo
2023-03-20 21:06 ` Suren Baghdasaryan
2023-03-09 17:07 ` [PATCH 2/4] sched/psi: rename existing poll members " Domenico Cerasuolo
2023-03-20 21:19 ` Suren Baghdasaryan
2023-03-09 17:07 ` Domenico Cerasuolo [this message]
2023-03-20 23:00 ` [PATCH 3/4] sched/psi: extract update_triggers side effect Suren Baghdasaryan
[not found] ` <CA+CLi1g=70ot=YFL+xug3jC4OXG727NGo+NXxmC45WcwaFpo8g@mail.gmail.com>
2023-03-22 3:40 ` Suren Baghdasaryan
[not found] ` <CA+CLi1gjKFFgoeHQs-sNn1knqk1w9rb73kaOqP9z8TUwwiqqFQ@mail.gmail.com>
2023-03-22 16:41 ` Suren Baghdasaryan
2023-03-09 17:07 ` [PATCH 4/4] sched/psi: allow unprivileged polling of N*2s period Domenico Cerasuolo
2023-03-20 23:17 ` Suren Baghdasaryan
2023-03-13 15:29 ` [PATCH 0/4] sched/psi: Allow unprivileged PSI polling Suren Baghdasaryan
2023-03-14 16:10 ` Johannes Weiner
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=20230309170756.52927-4-cerasuolodomenico@gmail.com \
--to=cerasuolodomenico@gmail.com \
--cc=brauner@kernel.org \
--cc=chris@chrisdown.name \
--cc=hannes@cmpxchg.org \
--cc=linux-kernel@vger.kernel.org \
--cc=peterz@infradead.org \
--cc=surenb@google.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
all inboxes | Powered by JetHome®