summaryrefslogtreecommitdiffstats
path: root/kernel
diff options
context:
space:
mode:
authorArjan van de Ven <arjan@linux.intel.com>2008-09-01 15:52:40 -0700
committerArjan van de Ven <arjan@linux.intel.com>2008-09-05 21:35:30 -0700
commit6976675d94042fbd446231d1bd8b7de71a980ada (patch)
tree2d2acebb8078dd373115ecbdac5423f7d4fa7d72 /kernel
parent654c8e0b1c623b156c5b92f28d914ab38c9c2c90 (diff)
downloadlinux-6976675d94042fbd446231d1bd8b7de71a980ada.tar.gz
linux-6976675d94042fbd446231d1bd8b7de71a980ada.tar.bz2
linux-6976675d94042fbd446231d1bd8b7de71a980ada.zip
hrtimer: create a "timer_slack" field in the task struct
We want to be able to control the default "rounding" that is used by select() and poll() and friends. This is a per process property (so that we can have a "nice" like program to start certain programs with a looser or stricter rounding) that can be set/get via a prctl(). For this purpose, a field called "timer_slack_ns" is added to the task struct. In addition, a field called "default_timer_slack"ns" is added so that tasks easily can temporarily to a more/less accurate slack and then back to the default. The default value of the slack is set to 50 usec; this is significantly less than 2.6.27's average select() and poll() timing error but still allows the kernel to group timers somewhat to preserve power behavior. Applications and admins can override this via the prctl() Signed-off-by: Arjan van de Ven <arjan@linux.intel.com>
Diffstat (limited to 'kernel')
-rw-r--r--kernel/fork.c2
-rw-r--r--kernel/sys.c10
2 files changed, 12 insertions, 0 deletions
diff --git a/kernel/fork.c b/kernel/fork.c
index 7ce2ebe84796..4308d75f0fa5 100644
--- a/kernel/fork.c
+++ b/kernel/fork.c
@@ -987,6 +987,8 @@ static struct task_struct *copy_process(unsigned long clone_flags,
p->prev_utime = cputime_zero;
p->prev_stime = cputime_zero;
+ p->default_timer_slack_ns = current->timer_slack_ns;
+
#ifdef CONFIG_DETECT_SOFTLOCKUP
p->last_switch_count = 0;
p->last_switch_timestamp = 0;
diff --git a/kernel/sys.c b/kernel/sys.c
index 038a7bc0901d..1b96401a0576 100644
--- a/kernel/sys.c
+++ b/kernel/sys.c
@@ -1727,6 +1727,16 @@ asmlinkage long sys_prctl(int option, unsigned long arg2, unsigned long arg3,
case PR_SET_TSC:
error = SET_TSC_CTL(arg2);
break;
+ case PR_GET_TIMERSLACK:
+ error = current->timer_slack_ns;
+ break;
+ case PR_SET_TIMERSLACK:
+ if (arg2 <= 0)
+ current->timer_slack_ns =
+ current->default_timer_slack_ns;
+ else
+ current->timer_slack_ns = arg2;
+ break;
default:
error = -EINVAL;
break;