Re: [PATCH] sched/rt: Slightly optimize 'init_rt_rq()'
From: Steven Rostedt
Date: Tue Nov 16 2021 - 16:51:42 EST
On Sun, 14 Nov 2021 17:16:05 +0100
Christophe JAILLET <christophe.jaillet@xxxxxxxxxx> wrote:
> '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
I don't see this being an improvement as long as we need to keep the loop to
do the initialization of the list head.
> Signed-off-by: Christophe JAILLET <christophe.jaillet@xxxxxxxxxx>
> 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 )
> 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);
The first bit is zero. The last bit in the bitmask is MAX_RT_PRIO. The
bitmask has MAX_RT_PRIO + 1 bits. Your __set_bit() above would be an off by
one error in overwriting the size of the bitmask.