aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
Diffstat (limited to 'fs')
-rw-r--r--fs/select.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/fs/select.c b/fs/select.c
index 8084834e123e..a201fc370223 100644
--- a/fs/select.c
+++ b/fs/select.c
@@ -41,22 +41,28 @@
41 * better solutions.. 41 * better solutions..
42 */ 42 */
43 43
44#define MAX_SLACK (100 * NSEC_PER_MSEC)
45
44static long __estimate_accuracy(struct timespec *tv) 46static long __estimate_accuracy(struct timespec *tv)
45{ 47{
46 long slack; 48 long slack;
47 int divfactor = 1000; 49 int divfactor = 1000;
48 50
51 if (tv->tv_sec < 0)
52 return 0;
53
49 if (task_nice(current) > 0) 54 if (task_nice(current) > 0)
50 divfactor = divfactor / 5; 55 divfactor = divfactor / 5;
51 56
57 if (tv->tv_sec > MAX_SLACK / (NSEC_PER_SEC/divfactor))
58 return MAX_SLACK;
59
52 slack = tv->tv_nsec / divfactor; 60 slack = tv->tv_nsec / divfactor;
53 slack += tv->tv_sec * (NSEC_PER_SEC/divfactor); 61 slack += tv->tv_sec * (NSEC_PER_SEC/divfactor);
54 62
55 if (slack > 100 * NSEC_PER_MSEC) 63 if (slack > MAX_SLACK)
56 slack = 100 * NSEC_PER_MSEC; 64 return MAX_SLACK;
57 65
58 if (slack < 0)
59 slack = 0;
60 return slack; 66 return slack;
61} 67}
62 68