lkml.org 
[lkml]   [2006]   [Feb]   [27]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectStrange interactivity behaviour
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 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-8 1 1 1 1 1 1 0 0 0 0 0
-7 1 1 1 1 1 1 0 0 0 0 0
-6 1 1 1 1 1 1 0 0 0 0 0
-5 1 1 1 1 1 1 0 0 0 0 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 majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2006-02-27 12:43    [W:0.191 / U:0.484 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site