lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240226211237.48415-1-ppbuk5246@gmail.com>
Date: Mon, 26 Feb 2024 21:12:37 +0000
From: Levi Yun <ppbuk5246@...il.com>
To: hannes@...xchg.org,
	surenb@...gle.com,
	peterz@...radead.org,
	mingo@...hat.com,
	juri.lelli@...hat.com,
	vincent.guittot@...aro.org,
	dietmar.eggemann@....com,
	rostedt@...dmis.org,
	bsegall@...gle.com,
	mgorman@...e.de,
	bristot@...hat.com,
	vschneid@...hat.com
Cc: linux-kernel@...r.kernel.org,
	Levi Yun <ppbuk5246@...il.com>
Subject: [PATCH v2] psi: Fix avg trigger being fired unexpectedly.

commit 915a087e4c473("psi: Fix trigger being fired unexpectedly at initial")
fixes unexpected event fired when group->total accumulated for PSI_POLL.
But, for PSI_AVGS, win->value should be initialized with group->total[PSI_AVGS].
Moreover, to get exact initial value for win->value, it should be set
under each trigger lock to avoid concurrent changes to group->total[].

Signed-off-by: Levi Yun <ppbuk5246@...il.com>
Acked-by: Suren Baghdasaryan <surenb@...gle.com>
---
v2: Fix commit message.
---
 kernel/sched/psi.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/kernel/sched/psi.c b/kernel/sched/psi.c
index 7b4aa5809c0f..e7f66ab2ad3e 100644
--- a/kernel/sched/psi.c
+++ b/kernel/sched/psi.c
@@ -1323,9 +1323,6 @@ struct psi_trigger *psi_trigger_create(struct psi_group *group, char *buf,
 	t->state = state;
 	t->threshold = threshold_us * NSEC_PER_USEC;
 	t->win.size = window_us * NSEC_PER_USEC;
-	window_reset(&t->win, sched_clock(),
-			group->total[PSI_POLL][t->state], 0);
-
 	t->event = 0;
 	t->last_event_time = 0;
 	t->of = of;
@@ -1336,6 +1333,8 @@ struct psi_trigger *psi_trigger_create(struct psi_group *group, char *buf,

 	if (privileged) {
 		mutex_lock(&group->rtpoll_trigger_lock);
+		window_reset(&t->win, sched_clock(),
+				group->total[PSI_POLL][t->state], 0);

 		if (!rcu_access_pointer(group->rtpoll_task)) {
 			struct task_struct *task;
@@ -1361,6 +1360,9 @@ struct psi_trigger *psi_trigger_create(struct psi_group *group, char *buf,
 	} else {
 		mutex_lock(&group->avgs_lock);

+		window_reset(&t->win, sched_clock(),
+				group->total[PSI_AVGS][t->state], 0);
+
 		list_add(&t->node, &group->avg_triggers);
 		group->avg_nr_triggers[t->state]++;

--
2.39.2

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ