From 72dec758064322ed674749ca38478c7ce08fe31b Mon Sep 17 00:00:00 2001 From: Arjan van de Ven Date: Mon, 1 Sep 2008 15:52:40 -0700 Subject: [PATCH] --- yaml --- r: 117608 b: refs/heads/master c: 6976675d94042fbd446231d1bd8b7de71a980ada h: refs/heads/master v: v3 --- [refs] | 2 +- trunk/include/linux/init_task.h | 1 + trunk/include/linux/prctl.h | 7 +++++++ trunk/include/linux/sched.h | 6 ++++++ trunk/kernel/fork.c | 2 ++ trunk/kernel/sys.c | 10 ++++++++++ 6 files changed, 27 insertions(+), 1 deletion(-) diff --git a/[refs] b/[refs] index acc96e4063ae..071bd3a7bd96 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 654c8e0b1c623b156c5b92f28d914ab38c9c2c90 +refs/heads/master: 6976675d94042fbd446231d1bd8b7de71a980ada diff --git a/trunk/include/linux/init_task.h b/trunk/include/linux/init_task.h index 021d8e720c79..23fd8909b9e5 100644 --- a/trunk/include/linux/init_task.h +++ b/trunk/include/linux/init_task.h @@ -170,6 +170,7 @@ extern struct group_info init_groups; .cpu_timers = INIT_CPU_TIMERS(tsk.cpu_timers), \ .fs_excl = ATOMIC_INIT(0), \ .pi_lock = __SPIN_LOCK_UNLOCKED(tsk.pi_lock), \ + .timer_slack_ns = 50000, /* 50 usec default slack */ \ .pids = { \ [PIDTYPE_PID] = INIT_PID_LINK(PIDTYPE_PID), \ [PIDTYPE_PGID] = INIT_PID_LINK(PIDTYPE_PGID), \ diff --git a/trunk/include/linux/prctl.h b/trunk/include/linux/prctl.h index 5ad79198d6f9..48d887e3c6e7 100644 --- a/trunk/include/linux/prctl.h +++ b/trunk/include/linux/prctl.h @@ -78,4 +78,11 @@ #define PR_GET_SECUREBITS 27 #define PR_SET_SECUREBITS 28 +/* + * Get/set the timerslack as used by poll/select/nanosleep + * A value of 0 means "use default" + */ +#define PR_SET_TIMERSLACK 29 +#define PR_GET_TIMERSLACK 30 + #endif /* _LINUX_PRCTL_H */ diff --git a/trunk/include/linux/sched.h b/trunk/include/linux/sched.h index 3d9120c5ad15..dcc03fd5a7f3 100644 --- a/trunk/include/linux/sched.h +++ b/trunk/include/linux/sched.h @@ -1301,6 +1301,12 @@ struct task_struct { int latency_record_count; struct latency_record latency_record[LT_SAVECOUNT]; #endif + /* + * time slack values; these are used to round up poll() and + * select() etc timeout values. These are in nanoseconds. + */ + unsigned long timer_slack_ns; + unsigned long default_timer_slack_ns; }; /* diff --git a/trunk/kernel/fork.c b/trunk/kernel/fork.c index 7ce2ebe84796..4308d75f0fa5 100644 --- a/trunk/kernel/fork.c +++ b/trunk/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/trunk/kernel/sys.c b/trunk/kernel/sys.c index 038a7bc0901d..1b96401a0576 100644 --- a/trunk/kernel/sys.c +++ b/trunk/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;