mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-03-30 02:54:35 +00:00
hrtimer: fix signed/unsigned bug in slack estimator
the slack estimator used unsigned math; however for very short delay it's possible that by the time you calculate the timeout, it's already passed and you get a negative time/slack... in an unsigned variable... which then gets turned into a 100 msec delay rather than zero. This patch fixes this by using a signed typee in the right places. Signed-off-by: Arjan van de Ven <arjan@linux.intel.com>
This commit is contained in:
parent
704af52bd1
commit
96d2ab484e
1 changed files with 8 additions and 5 deletions
13
fs/select.c
13
fs/select.c
|
@ -41,9 +41,9 @@
|
||||||
* better solutions..
|
* better solutions..
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static unsigned long __estimate_accuracy(struct timespec *tv)
|
static long __estimate_accuracy(struct timespec *tv)
|
||||||
{
|
{
|
||||||
unsigned long slack;
|
long slack;
|
||||||
int divfactor = 1000;
|
int divfactor = 1000;
|
||||||
|
|
||||||
if (task_nice(current) > 0)
|
if (task_nice(current) > 0)
|
||||||
|
@ -54,10 +54,13 @@ static unsigned long __estimate_accuracy(struct timespec *tv)
|
||||||
|
|
||||||
if (slack > 100 * NSEC_PER_MSEC)
|
if (slack > 100 * NSEC_PER_MSEC)
|
||||||
slack = 100 * NSEC_PER_MSEC;
|
slack = 100 * NSEC_PER_MSEC;
|
||||||
|
|
||||||
|
if (slack < 0)
|
||||||
|
slack = 0;
|
||||||
return slack;
|
return slack;
|
||||||
}
|
}
|
||||||
|
|
||||||
static unsigned long estimate_accuracy(struct timespec *tv)
|
static long estimate_accuracy(struct timespec *tv)
|
||||||
{
|
{
|
||||||
unsigned long ret;
|
unsigned long ret;
|
||||||
struct timespec now;
|
struct timespec now;
|
||||||
|
@ -330,7 +333,7 @@ int do_select(int n, fd_set_bits *fds, struct timespec *end_time)
|
||||||
timed_out = 1;
|
timed_out = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (end_time)
|
if (end_time && !timed_out)
|
||||||
slack = estimate_accuracy(end_time);
|
slack = estimate_accuracy(end_time);
|
||||||
|
|
||||||
retval = 0;
|
retval = 0;
|
||||||
|
@ -656,7 +659,7 @@ static int do_poll(unsigned int nfds, struct poll_list *list,
|
||||||
timed_out = 1;
|
timed_out = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (end_time)
|
if (end_time && !timed_out)
|
||||||
slack = estimate_accuracy(end_time);
|
slack = estimate_accuracy(end_time);
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue