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: <c9b56712763de62c90b71907323a6b0e5b61b249.1636906450.git.christophe.jaillet@wanadoo.fr>
Date:   Sun, 14 Nov 2021 17:16:05 +0100
From:   Christophe JAILLET <christophe.jaillet@...adoo.fr>
To:     mingo@...hat.com, peterz@...radead.org, juri.lelli@...hat.com,
        vincent.guittot@...aro.org, dietmar.eggemann@....com,
        rostedt@...dmis.org, bsegall@...gle.com, mgorman@...e.de,
        bristot@...hat.com
Cc:     linux-kernel@...r.kernel.org, kernel-janitors@...r.kernel.org,
        Christophe JAILLET <christophe.jaillet@...adoo.fr>
Subject: [PATCH] sched/rt: Slightly optimize 'init_rt_rq()'

'MAX_RT_PRIO' is 100. Instead of clearing bits in 'array->bitmap' one at a
time, use 'bitmap_clear()' which will do the same but much faster

Signed-off-by: Christophe JAILLET <christophe.jaillet@...adoo.fr>
---
Not sure that this patch is really of any use, but it is the occasion for
me to spot that there seems to be an off by one in the rt scheduler.

'array->bitmap' is MAX_RT_PRIO+1 long. (see [1])
The last bit seems to be reserved as a sentinel.

Shouldn't this sentinel, in the code above, be set as:
  __set_bit(MAX_RT_PRIO + 1, array->bitmap);
?

I don't know if it is an issue or not, but it looks odd to me.

[1]: https://elixir.bootlin.com/linux/latest/source/kernel/sched/sched.h#L254
---
 kernel/sched/rt.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/kernel/sched/rt.c b/kernel/sched/rt.c
index bb945f8faeca..fc2e9c5e874a 100644
--- a/kernel/sched/rt.c
+++ b/kernel/sched/rt.c
@@ -81,10 +81,9 @@ void init_rt_rq(struct rt_rq *rt_rq)
 	int i;
 
 	array = &rt_rq->active;
-	for (i = 0; i < MAX_RT_PRIO; i++) {
+	for (i = 0; i < MAX_RT_PRIO; i++)
 		INIT_LIST_HEAD(array->queue + i);
-		__clear_bit(i, array->bitmap);
-	}
+	bitmap_clear(array->bitmap, 0, MAX_RT_PRIO);
 	/* delimiter for bitsearch: */
 	__set_bit(MAX_RT_PRIO, array->bitmap);
 
-- 
2.30.2

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ