Possible Problem:
There may be a truncation error in kernel/sched.c triggered when the
nice value is negative. The affected code is used in the
TASK_INTERACTIVE macro.
The code is:
#define SCALE(v1,v1_max,v2_max) \
(v1) * (v2_max) / (v1_max)
which is used in this way:
SCALE(TASK_NICE(p), 40, MAX_BONUS)
Comments in the code says:
* This part scales the interactivity limit depending on niceness.
*
* We scale it linearly, offset by the INTERACTIVE_DELTA delta.
* Here are a few examples of different nice levels:
*
* TASK_INTERACTIVE(-20): [1,1,1,1,1,1,1,1,1,0,0]
* TASK_INTERACTIVE(-10): [1,1,1,1,1,1,1,0,0,0,0]
* TASK_INTERACTIVE( 0): [1,1,1,1,0,0,0,0,0,0,0]
* TASK_INTERACTIVE( 10): [1,1,0,0,0,0,0,0,0,0,0]
* TASK_INTERACTIVE( 19): [0,0,0,0,0,0,0,0,0,0,0]
*
* (the X axis represents the possible -5 ... 0 ... +5 dynamic
* priority range a task can explore, a value of '1' means the
* task is rated interactive.)
However, the current code does not scale it linearly and the result
differs from the given examples. If the mathematical function "floor" is
used when the nice value is negative instead of the truncation one gets
when using integer division, the result conforms to the documentation.
I belive that this is a bug. Is this correct or have i misunderstood
something?
/Martin Andersson
---
Output of TASK_INTERACTIVE when using the kernel code:
nice dynamic priorities
-20 1 1 1 1 1 1 1 1 1 0 0
-19 1 1 1 1 1 1 1 1 0 0 0
-18 1 1 1 1 1 1 1 1 0 0 0
-17 1 1 1 1 1 1 1 1 0 0 0
-16 1 1 1 1 1 1 1 1 0 0 0
-15 1 1 1 1 1 1 1 0 0 0 0
-14 1 1 1 1 1 1 1 0 0 0 0
-13 1 1 1 1 1 1 1 0 0 0 0
-12 1 1 1 1 1 1 1 0 0 0 0
-11 1 1 1 1 1 1 0 0 0 0 0
-10 1 1 1 1 1 1 0 0 0 0 0
-9 1 1 1 1 1 1 0 0 0 0 0
-8 1 1 1 1 1 1 0 0 0 0 0
-7 1 1 1 1 1 0 0 0 0 0 0
-6 1 1 1 1 1 0 0 0 0 0 0
-5 1 1 1 1 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0
-4 1 1 1 1 1 0 0 0 0 0 0
-3 1 1 1 1 1 0 0 0 0 0 0
-2 1 1 1 1 1 0 0 0 0 0 0
-1 1 1 1 1 1 0 0 0 0 0 0
0 1 1 1 1 0 0 0 0 0 0 0
1 1 1 1 1 0 0 0 0 0 0 0
2 1 1 1 1 0 0 0 0 0 0 0
3 1 1 1 1 0 0 0 0 0 0 0
4 1 1 1 0 0 0 0 0 0 0 0
5 1 1 1 0 0 0 0 0 0 0 0
6 1 1 1 0 0 0 0 0 0 0 0
7 1 1 1 0 0 0 0 0 0 0 0
8 1 1 0 0 0 0 0 0 0 0 0
9 1 1 0 0 0 0 0 0 0 0 0
10 1 1 0 0 0 0 0 0 0 0 0
11 1 1 0 0 0 0 0 0 0 0 0
12 1 0 0 0 0 0 0 0 0 0 0
13 1 0 0 0 0 0 0 0 0 0 0
14 1 0 0 0 0 0 0 0 0 0 0
15 1 0 0 0 0 0 0 0 0 0 0
16 0 0 0 0 0 0 0 0 0 0 0
17 0 0 0 0 0 0 0 0 0 0 0
18 0 0 0 0 0 0 0 0 0 0 0
19 0 0 0 0 0 0 0 0 0 0 0
-
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]