Re: Assumably a BUG in Linux Kernel (scheduler part)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



* Andrey Gelman <[email protected]> wrote:

> Hello there !
> Assumably, I've discovered a bug in Linux kernel (version 2.6.16), at:
> kernel\sched.c   function set_user_nice()
[...]

> //-------------------------------------------------
> /*
> 	//BUGGED FORMULA : 5 lines
>         old_prio = p->prio;
>         new_prio = NICE_TO_PRIO(nice);
>         delta = new_prio - old_prio;
>         p->static_prio = NICE_TO_PRIO(nice);
>         p->prio += delta;
> */
>     //BUG FIX : 5 lines
>     old_prio = p->static_prio;
>     new_prio = NICE_TO_PRIO(nice);
>     delta = new_prio - old_prio;
>     p->static_prio = new_prio;
>     p->prio += delta;
> //-------------------------------------------------

you are right, this is a bug in the scheduler - good find.

I did accidentally fix it months ago via one of the PI-scheduling 
cleanups, and thus the fix is in the current -mm tree and is scheduled 
for 2.6.18 inclusion:

 http://kernel.org/pub/linux/kernel/people/akpm/patches/2.6/2.6.17-rc6/2.6.17-rc6-mm2/broken-out/pi-futex-scheduler-support-for-pi.patch

(see the adding of effective_prio() to set_user_nice(), instead of an 
open-coded calculation of the priority)

But i did not realize that this also fixed a bug. The effects of the bug 
are minor: a user can renice only 19 times (to go from 0 to +19), so 
there's a finite amount of extra timeslices a CPU hog might win due to 
this. I'd not include the effective_prio() change in 2.6.17 - it touches 
quite some code and we are close to the release of 2.6.17. Nevertheless 
kudos for finding and pointing out this bug!

Andrew, please add this to the changelog of
pi-futex-scheduler-support-for-pi.patch:

the effective_prio() cleanups also fix a priority-calculation bug 
pointed out by Andrey Gelman, in set_user_nice().

	Ingo
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux