diff options
Diffstat (limited to 'kernel')
-rw-r--r-- | kernel/Makefile | 4 | ||||
-rw-r--r-- | kernel/capability.c | 113 | ||||
-rw-r--r-- | kernel/exit.c | 3 | ||||
-rw-r--r-- | kernel/fork.c | 20 | ||||
-rw-r--r-- | kernel/hrtimer.c | 9 | ||||
-rw-r--r-- | kernel/latency.c | 280 | ||||
-rw-r--r-- | kernel/pm_qos_params.c | 425 | ||||
-rw-r--r-- | kernel/posix-timers.c | 9 | ||||
-rw-r--r-- | kernel/power/disk.c | 4 | ||||
-rw-r--r-- | kernel/power/snapshot.c | 4 | ||||
-rw-r--r-- | kernel/signal.c | 75 | ||||
-rw-r--r-- | kernel/sys.c | 15 | ||||
-rw-r--r-- | kernel/sys_ni.c | 7 | ||||
-rw-r--r-- | kernel/sysctl.c | 53 | ||||
-rw-r--r-- | kernel/sysctl_check.c | 7 |
15 files changed, 606 insertions, 422 deletions
diff --git a/kernel/Makefile b/kernel/Makefile index db9af707ff5b..135a1b943446 100644 --- a/kernel/Makefile +++ b/kernel/Makefile | |||
@@ -8,8 +8,8 @@ obj-y = sched.o fork.o exec_domain.o panic.o printk.o profile.o \ | |||
8 | signal.o sys.o kmod.o workqueue.o pid.o \ | 8 | signal.o sys.o kmod.o workqueue.o pid.o \ |
9 | rcupdate.o extable.o params.o posix-timers.o \ | 9 | rcupdate.o extable.o params.o posix-timers.o \ |
10 | kthread.o wait.o kfifo.o sys_ni.o posix-cpu-timers.o mutex.o \ | 10 | kthread.o wait.o kfifo.o sys_ni.o posix-cpu-timers.o mutex.o \ |
11 | hrtimer.o rwsem.o latency.o nsproxy.o srcu.o \ | 11 | hrtimer.o rwsem.o nsproxy.o srcu.o \ |
12 | utsname.o notifier.o ksysfs.o | 12 | utsname.o notifier.o ksysfs.o pm_qos_params.o |
13 | 13 | ||
14 | obj-$(CONFIG_SYSCTL) += sysctl_check.o | 14 | obj-$(CONFIG_SYSCTL) += sysctl_check.o |
15 | obj-$(CONFIG_STACKTRACE) += stacktrace.o | 15 | obj-$(CONFIG_STACKTRACE) += stacktrace.o |
diff --git a/kernel/capability.c b/kernel/capability.c index efbd9cdce132..39e8193b41ea 100644 --- a/kernel/capability.c +++ b/kernel/capability.c | |||
@@ -22,6 +22,37 @@ | |||
22 | static DEFINE_SPINLOCK(task_capability_lock); | 22 | static DEFINE_SPINLOCK(task_capability_lock); |
23 | 23 | ||
24 | /* | 24 | /* |
25 | * Leveraged for setting/resetting capabilities | ||
26 | */ | ||
27 | |||
28 | const kernel_cap_t __cap_empty_set = CAP_EMPTY_SET; | ||
29 | const kernel_cap_t __cap_full_set = CAP_FULL_SET; | ||
30 | const kernel_cap_t __cap_init_eff_set = CAP_INIT_EFF_SET; | ||
31 | |||
32 | EXPORT_SYMBOL(__cap_empty_set); | ||
33 | EXPORT_SYMBOL(__cap_full_set); | ||
34 | EXPORT_SYMBOL(__cap_init_eff_set); | ||
35 | |||
36 | /* | ||
37 | * More recent versions of libcap are available from: | ||
38 | * | ||
39 | * http://www.kernel.org/pub/linux/libs/security/linux-privs/ | ||
40 | */ | ||
41 | |||
42 | static void warn_legacy_capability_use(void) | ||
43 | { | ||
44 | static int warned; | ||
45 | if (!warned) { | ||
46 | char name[sizeof(current->comm)]; | ||
47 | |||
48 | printk(KERN_INFO "warning: `%s' uses 32-bit capabilities" | ||
49 | " (legacy support in use)\n", | ||
50 | get_task_comm(name, current)); | ||
51 | warned = 1; | ||
52 | } | ||
53 | } | ||
54 | |||
55 | /* | ||
25 | * For sys_getproccap() and sys_setproccap(), any of the three | 56 | * For sys_getproccap() and sys_setproccap(), any of the three |
26 | * capability set pointers may be NULL -- indicating that that set is | 57 | * capability set pointers may be NULL -- indicating that that set is |
27 | * uninteresting and/or not to be changed. | 58 | * uninteresting and/or not to be changed. |
@@ -42,12 +73,21 @@ asmlinkage long sys_capget(cap_user_header_t header, cap_user_data_t dataptr) | |||
42 | pid_t pid; | 73 | pid_t pid; |
43 | __u32 version; | 74 | __u32 version; |
44 | struct task_struct *target; | 75 | struct task_struct *target; |
45 | struct __user_cap_data_struct data; | 76 | unsigned tocopy; |
77 | kernel_cap_t pE, pI, pP; | ||
46 | 78 | ||
47 | if (get_user(version, &header->version)) | 79 | if (get_user(version, &header->version)) |
48 | return -EFAULT; | 80 | return -EFAULT; |
49 | 81 | ||
50 | if (version != _LINUX_CAPABILITY_VERSION) { | 82 | switch (version) { |
83 | case _LINUX_CAPABILITY_VERSION_1: | ||
84 | warn_legacy_capability_use(); | ||
85 | tocopy = _LINUX_CAPABILITY_U32S_1; | ||
86 | break; | ||
87 | case _LINUX_CAPABILITY_VERSION_2: | ||
88 | tocopy = _LINUX_CAPABILITY_U32S_2; | ||
89 | break; | ||
90 | default: | ||
51 | if (put_user(_LINUX_CAPABILITY_VERSION, &header->version)) | 91 | if (put_user(_LINUX_CAPABILITY_VERSION, &header->version)) |
52 | return -EFAULT; | 92 | return -EFAULT; |
53 | return -EINVAL; | 93 | return -EINVAL; |
@@ -71,14 +111,47 @@ asmlinkage long sys_capget(cap_user_header_t header, cap_user_data_t dataptr) | |||
71 | } else | 111 | } else |
72 | target = current; | 112 | target = current; |
73 | 113 | ||
74 | ret = security_capget(target, &data.effective, &data.inheritable, &data.permitted); | 114 | ret = security_capget(target, &pE, &pI, &pP); |
75 | 115 | ||
76 | out: | 116 | out: |
77 | read_unlock(&tasklist_lock); | 117 | read_unlock(&tasklist_lock); |
78 | spin_unlock(&task_capability_lock); | 118 | spin_unlock(&task_capability_lock); |
79 | 119 | ||
80 | if (!ret && copy_to_user(dataptr, &data, sizeof data)) | 120 | if (!ret) { |
81 | return -EFAULT; | 121 | struct __user_cap_data_struct kdata[_LINUX_CAPABILITY_U32S]; |
122 | unsigned i; | ||
123 | |||
124 | for (i = 0; i < tocopy; i++) { | ||
125 | kdata[i].effective = pE.cap[i]; | ||
126 | kdata[i].permitted = pP.cap[i]; | ||
127 | kdata[i].inheritable = pI.cap[i]; | ||
128 | } | ||
129 | |||
130 | /* | ||
131 | * Note, in the case, tocopy < _LINUX_CAPABILITY_U32S, | ||
132 | * we silently drop the upper capabilities here. This | ||
133 | * has the effect of making older libcap | ||
134 | * implementations implicitly drop upper capability | ||
135 | * bits when they perform a: capget/modify/capset | ||
136 | * sequence. | ||
137 | * | ||
138 | * This behavior is considered fail-safe | ||
139 | * behavior. Upgrading the application to a newer | ||
140 | * version of libcap will enable access to the newer | ||
141 | * capabilities. | ||
142 | * | ||
143 | * An alternative would be to return an error here | ||
144 | * (-ERANGE), but that causes legacy applications to | ||
145 | * unexpectidly fail; the capget/modify/capset aborts | ||
146 | * before modification is attempted and the application | ||
147 | * fails. | ||
148 | */ | ||
149 | |||
150 | if (copy_to_user(dataptr, kdata, tocopy | ||
151 | * sizeof(struct __user_cap_data_struct))) { | ||
152 | return -EFAULT; | ||
153 | } | ||
154 | } | ||
82 | 155 | ||
83 | return ret; | 156 | return ret; |
84 | } | 157 | } |
@@ -167,6 +240,8 @@ static inline int cap_set_all(kernel_cap_t *effective, | |||
167 | */ | 240 | */ |
168 | asmlinkage long sys_capset(cap_user_header_t header, const cap_user_data_t data) | 241 | asmlinkage long sys_capset(cap_user_header_t header, const cap_user_data_t data) |
169 | { | 242 | { |
243 | struct __user_cap_data_struct kdata[_LINUX_CAPABILITY_U32S]; | ||
244 | unsigned i, tocopy; | ||
170 | kernel_cap_t inheritable, permitted, effective; | 245 | kernel_cap_t inheritable, permitted, effective; |
171 | __u32 version; | 246 | __u32 version; |
172 | struct task_struct *target; | 247 | struct task_struct *target; |
@@ -176,7 +251,15 @@ asmlinkage long sys_capset(cap_user_header_t header, const cap_user_data_t data) | |||
176 | if (get_user(version, &header->version)) | 251 | if (get_user(version, &header->version)) |
177 | return -EFAULT; | 252 | return -EFAULT; |
178 | 253 | ||
179 | if (version != _LINUX_CAPABILITY_VERSION) { | 254 | switch (version) { |
255 | case _LINUX_CAPABILITY_VERSION_1: | ||
256 | warn_legacy_capability_use(); | ||
257 | tocopy = _LINUX_CAPABILITY_U32S_1; | ||
258 | break; | ||
259 | case _LINUX_CAPABILITY_VERSION_2: | ||
260 | tocopy = _LINUX_CAPABILITY_U32S_2; | ||
261 | break; | ||
262 | default: | ||
180 | if (put_user(_LINUX_CAPABILITY_VERSION, &header->version)) | 263 | if (put_user(_LINUX_CAPABILITY_VERSION, &header->version)) |
181 | return -EFAULT; | 264 | return -EFAULT; |
182 | return -EINVAL; | 265 | return -EINVAL; |
@@ -188,10 +271,22 @@ asmlinkage long sys_capset(cap_user_header_t header, const cap_user_data_t data) | |||
188 | if (pid && pid != task_pid_vnr(current) && !capable(CAP_SETPCAP)) | 271 | if (pid && pid != task_pid_vnr(current) && !capable(CAP_SETPCAP)) |
189 | return -EPERM; | 272 | return -EPERM; |
190 | 273 | ||
191 | if (copy_from_user(&effective, &data->effective, sizeof(effective)) || | 274 | if (copy_from_user(&kdata, data, tocopy |
192 | copy_from_user(&inheritable, &data->inheritable, sizeof(inheritable)) || | 275 | * sizeof(struct __user_cap_data_struct))) { |
193 | copy_from_user(&permitted, &data->permitted, sizeof(permitted))) | ||
194 | return -EFAULT; | 276 | return -EFAULT; |
277 | } | ||
278 | |||
279 | for (i = 0; i < tocopy; i++) { | ||
280 | effective.cap[i] = kdata[i].effective; | ||
281 | permitted.cap[i] = kdata[i].permitted; | ||
282 | inheritable.cap[i] = kdata[i].inheritable; | ||
283 | } | ||
284 | while (i < _LINUX_CAPABILITY_U32S) { | ||
285 | effective.cap[i] = 0; | ||
286 | permitted.cap[i] = 0; | ||
287 | inheritable.cap[i] = 0; | ||
288 | i++; | ||
289 | } | ||
195 | 290 | ||
196 | spin_lock(&task_capability_lock); | 291 | spin_lock(&task_capability_lock); |
197 | read_lock(&tasklist_lock); | 292 | read_lock(&tasklist_lock); |
diff --git a/kernel/exit.c b/kernel/exit.c index 9e459fefda77..9d3d0f0b27d9 100644 --- a/kernel/exit.c +++ b/kernel/exit.c | |||
@@ -1083,11 +1083,12 @@ do_group_exit(int exit_code) | |||
1083 | struct signal_struct *const sig = current->signal; | 1083 | struct signal_struct *const sig = current->signal; |
1084 | struct sighand_struct *const sighand = current->sighand; | 1084 | struct sighand_struct *const sighand = current->sighand; |
1085 | spin_lock_irq(&sighand->siglock); | 1085 | spin_lock_irq(&sighand->siglock); |
1086 | if (sig->flags & SIGNAL_GROUP_EXIT) | 1086 | if (signal_group_exit(sig)) |
1087 | /* Another thread got here before we took the lock. */ | 1087 | /* Another thread got here before we took the lock. */ |
1088 | exit_code = sig->group_exit_code; | 1088 | exit_code = sig->group_exit_code; |
1089 | else { | 1089 | else { |
1090 | sig->group_exit_code = exit_code; | 1090 | sig->group_exit_code = exit_code; |
1091 | sig->flags = SIGNAL_GROUP_EXIT; | ||
1091 | zap_other_threads(current); | 1092 | zap_other_threads(current); |
1092 | } | 1093 | } |
1093 | spin_unlock_irq(&sighand->siglock); | 1094 | spin_unlock_irq(&sighand->siglock); |
diff --git a/kernel/fork.c b/kernel/fork.c index 05e0b6f4365b..2b55b74cd999 100644 --- a/kernel/fork.c +++ b/kernel/fork.c | |||
@@ -325,7 +325,7 @@ static inline int mm_alloc_pgd(struct mm_struct * mm) | |||
325 | 325 | ||
326 | static inline void mm_free_pgd(struct mm_struct * mm) | 326 | static inline void mm_free_pgd(struct mm_struct * mm) |
327 | { | 327 | { |
328 | pgd_free(mm->pgd); | 328 | pgd_free(mm, mm->pgd); |
329 | } | 329 | } |
330 | #else | 330 | #else |
331 | #define dup_mmap(mm, oldmm) (0) | 331 | #define dup_mmap(mm, oldmm) (0) |
@@ -1118,6 +1118,7 @@ static struct task_struct *copy_process(unsigned long clone_flags, | |||
1118 | #ifdef CONFIG_SECURITY | 1118 | #ifdef CONFIG_SECURITY |
1119 | p->security = NULL; | 1119 | p->security = NULL; |
1120 | #endif | 1120 | #endif |
1121 | p->cap_bset = current->cap_bset; | ||
1121 | p->io_context = NULL; | 1122 | p->io_context = NULL; |
1122 | p->audit_context = NULL; | 1123 | p->audit_context = NULL; |
1123 | cgroup_fork(p); | 1124 | cgroup_fork(p); |
@@ -1450,6 +1451,23 @@ long do_fork(unsigned long clone_flags, | |||
1450 | int trace = 0; | 1451 | int trace = 0; |
1451 | long nr; | 1452 | long nr; |
1452 | 1453 | ||
1454 | /* | ||
1455 | * We hope to recycle these flags after 2.6.26 | ||
1456 | */ | ||
1457 | if (unlikely(clone_flags & CLONE_STOPPED)) { | ||
1458 | static int __read_mostly count = 100; | ||
1459 | |||
1460 | if (count > 0 && printk_ratelimit()) { | ||
1461 | char comm[TASK_COMM_LEN]; | ||
1462 | |||
1463 | count--; | ||
1464 | printk(KERN_INFO "fork(): process `%s' used deprecated " | ||
1465 | "clone flags 0x%lx\n", | ||
1466 | get_task_comm(comm, current), | ||
1467 | clone_flags & CLONE_STOPPED); | ||
1468 | } | ||
1469 | } | ||
1470 | |||
1453 | if (unlikely(current->ptrace)) { | 1471 | if (unlikely(current->ptrace)) { |
1454 | trace = fork_traceflag (clone_flags); | 1472 | trace = fork_traceflag (clone_flags); |
1455 | if (trace) | 1473 | if (trace) |
diff --git a/kernel/hrtimer.c b/kernel/hrtimer.c index 1069998fe25f..668f3967eb39 100644 --- a/kernel/hrtimer.c +++ b/kernel/hrtimer.c | |||
@@ -306,7 +306,7 @@ EXPORT_SYMBOL_GPL(ktime_sub_ns); | |||
306 | /* | 306 | /* |
307 | * Divide a ktime value by a nanosecond value | 307 | * Divide a ktime value by a nanosecond value |
308 | */ | 308 | */ |
309 | unsigned long ktime_divns(const ktime_t kt, s64 div) | 309 | u64 ktime_divns(const ktime_t kt, s64 div) |
310 | { | 310 | { |
311 | u64 dclc, inc, dns; | 311 | u64 dclc, inc, dns; |
312 | int sft = 0; | 312 | int sft = 0; |
@@ -321,7 +321,7 @@ unsigned long ktime_divns(const ktime_t kt, s64 div) | |||
321 | dclc >>= sft; | 321 | dclc >>= sft; |
322 | do_div(dclc, (unsigned long) div); | 322 | do_div(dclc, (unsigned long) div); |
323 | 323 | ||
324 | return (unsigned long) dclc; | 324 | return dclc; |
325 | } | 325 | } |
326 | #endif /* BITS_PER_LONG >= 64 */ | 326 | #endif /* BITS_PER_LONG >= 64 */ |
327 | 327 | ||
@@ -656,10 +656,9 @@ void unlock_hrtimer_base(const struct hrtimer *timer, unsigned long *flags) | |||
656 | * Forward the timer expiry so it will expire in the future. | 656 | * Forward the timer expiry so it will expire in the future. |
657 | * Returns the number of overruns. | 657 | * Returns the number of overruns. |
658 | */ | 658 | */ |
659 | unsigned long | 659 | u64 hrtimer_forward(struct hrtimer *timer, ktime_t now, ktime_t interval) |
660 | hrtimer_forward(struct hrtimer *timer, ktime_t now, ktime_t interval) | ||
661 | { | 660 | { |
662 | unsigned long orun = 1; | 661 | u64 orun = 1; |
663 | ktime_t delta; | 662 | ktime_t delta; |
664 | 663 | ||
665 | delta = ktime_sub(now, timer->expires); | 664 | delta = ktime_sub(now, timer->expires); |
diff --git a/kernel/latency.c b/kernel/latency.c deleted file mode 100644 index e63fcacb61a7..000000000000 --- a/kernel/latency.c +++ /dev/null | |||
@@ -1,280 +0,0 @@ | |||
1 | /* | ||
2 | * latency.c: Explicit system-wide latency-expectation infrastructure | ||
3 | * | ||
4 | * The purpose of this infrastructure is to allow device drivers to set | ||
5 | * latency constraint they have and to collect and summarize these | ||
6 | * expectations globally. The cummulated result can then be used by | ||
7 | * power management and similar users to make decisions that have | ||
8 | * tradoffs with a latency component. | ||
9 | * | ||
10 | * An example user of this are the x86 C-states; each higher C state saves | ||
11 | * more power, but has a higher exit latency. For the idle loop power | ||
12 | * code to make a good decision which C-state to use, information about | ||
13 | * acceptable latencies is required. | ||
14 | * | ||
15 | * An example announcer of latency is an audio driver that knowns it | ||
16 | * will get an interrupt when the hardware has 200 usec of samples | ||
17 | * left in the DMA buffer; in that case the driver can set a latency | ||
18 | * constraint of, say, 150 usec. | ||
19 | * | ||
20 | * Multiple drivers can each announce their maximum accepted latency, | ||
21 | * to keep these appart, a string based identifier is used. | ||
22 | * | ||
23 | * | ||
24 | * (C) Copyright 2006 Intel Corporation | ||
25 | * Author: Arjan van de Ven <arjan@linux.intel.com> | ||
26 | * | ||
27 | * This program is free software; you can redistribute it and/or | ||
28 | * modify it under the terms of the GNU General Public License | ||
29 | * as published by the Free Software Foundation; version 2 | ||
30 | * of the License. | ||
31 | */ | ||
32 | |||
33 | #include <linux/latency.h> | ||
34 | #include <linux/list.h> | ||
35 | #include <linux/spinlock.h> | ||
36 | #include <linux/slab.h> | ||
37 | #include <linux/module.h> | ||
38 | #include <linux/notifier.h> | ||
39 | #include <linux/jiffies.h> | ||
40 | #include <asm/atomic.h> | ||
41 | |||
42 | struct latency_info { | ||
43 | struct list_head list; | ||
44 | int usecs; | ||
45 | char *identifier; | ||
46 | }; | ||
47 | |||
48 | /* | ||
49 | * locking rule: all modifications to current_max_latency and | ||
50 | * latency_list need to be done while holding the latency_lock. | ||
51 | * latency_lock needs to be taken _irqsave. | ||
52 | */ | ||
53 | static atomic_t current_max_latency; | ||
54 | static DEFINE_SPINLOCK(latency_lock); | ||
55 | |||
56 | static LIST_HEAD(latency_list); | ||
57 | static BLOCKING_NOTIFIER_HEAD(latency_notifier); | ||
58 | |||
59 | /* | ||
60 | * This function returns the maximum latency allowed, which | ||
61 | * happens to be the minimum of all maximum latencies on the | ||
62 | * list. | ||
63 | */ | ||
64 | static int __find_max_latency(void) | ||
65 | { | ||
66 | int min = INFINITE_LATENCY; | ||
67 | struct latency_info *info; | ||
68 | |||
69 | list_for_each_entry(info, &latency_list, list) { | ||
70 | if (info->usecs < min) | ||
71 | min = info->usecs; | ||
72 | } | ||
73 | return min; | ||
74 | } | ||
75 | |||
76 | /** | ||
77 | * set_acceptable_latency - sets the maximum latency acceptable | ||
78 | * @identifier: string that identifies this driver | ||
79 | * @usecs: maximum acceptable latency for this driver | ||
80 | * | ||
81 | * This function informs the kernel that this device(driver) | ||
82 | * can accept at most usecs latency. This setting is used for | ||
83 | * power management and similar tradeoffs. | ||
84 | * | ||
85 | * This function sleeps and can only be called from process | ||
86 | * context. | ||
87 | * Calling this function with an existing identifier is valid | ||
88 | * and will cause the existing latency setting to be changed. | ||
89 | */ | ||
90 | void set_acceptable_latency(char *identifier, int usecs) | ||
91 | { | ||
92 | struct latency_info *info, *iter; | ||
93 | unsigned long flags; | ||
94 | int found_old = 0; | ||
95 | |||
96 | info = kzalloc(sizeof(struct latency_info), GFP_KERNEL); | ||
97 | if (!info) | ||
98 | return; | ||
99 | info->usecs = usecs; | ||
100 | info->identifier = kstrdup(identifier, GFP_KERNEL); | ||
101 | if (!info->identifier) | ||
102 | goto free_info; | ||
103 | |||
104 | spin_lock_irqsave(&latency_lock, flags); | ||
105 | list_for_each_entry(iter, &latency_list, list) { | ||
106 | if (strcmp(iter->identifier, identifier)==0) { | ||
107 | found_old = 1; | ||
108 | iter->usecs = usecs; | ||
109 | break; | ||
110 | } | ||
111 | } | ||
112 | if (!found_old) | ||
113 | list_add(&info->list, &latency_list); | ||
114 | |||
115 | if (usecs < atomic_read(¤t_max_latency)) | ||
116 | atomic_set(¤t_max_latency, usecs); | ||
117 | |||
118 | spin_unlock_irqrestore(&latency_lock, flags); | ||
119 | |||
120 | blocking_notifier_call_chain(&latency_notifier, | ||
121 | atomic_read(¤t_max_latency), NULL); | ||
122 | |||
123 | /* | ||
124 | * if we inserted the new one, we're done; otherwise there was | ||
125 | * an existing one so we need to free the redundant data | ||
126 | */ | ||
127 | if (!found_old) | ||
128 | return; | ||
129 | |||
130 | kfree(info->identifier); | ||
131 | free_info: | ||
132 | kfree(info); | ||
133 | } | ||
134 | EXPORT_SYMBOL_GPL(set_acceptable_latency); | ||
135 | |||
136 | /** | ||
137 | * modify_acceptable_latency - changes the maximum latency acceptable | ||
138 | * @identifier: string that identifies this driver | ||
139 | * @usecs: maximum acceptable latency for this driver | ||
140 | * | ||
141 | * This function informs the kernel that this device(driver) | ||
142 | * can accept at most usecs latency. This setting is used for | ||
143 | * power management and similar tradeoffs. | ||
144 | * | ||
145 | * This function does not sleep and can be called in any context. | ||
146 | * Trying to use a non-existing identifier silently gets ignored. | ||
147 | * | ||
148 | * Due to the atomic nature of this function, the modified latency | ||
149 | * value will only be used for future decisions; past decisions | ||
150 | * can still lead to longer latencies in the near future. | ||
151 | */ | ||
152 | void modify_acceptable_latency(char *identifier, int usecs) | ||
153 | { | ||
154 | struct latency_info *iter; | ||
155 | unsigned long flags; | ||
156 | |||
157 | spin_lock_irqsave(&latency_lock, flags); | ||
158 | list_for_each_entry(iter, &latency_list, list) { | ||
159 | if (strcmp(iter->identifier, identifier) == 0) { | ||
160 | iter->usecs = usecs; | ||
161 | break; | ||
162 | } | ||
163 | } | ||
164 | if (usecs < atomic_read(¤t_max_latency)) | ||
165 | atomic_set(¤t_max_latency, usecs); | ||
166 | spin_unlock_irqrestore(&latency_lock, flags); | ||
167 | } | ||
168 | EXPORT_SYMBOL_GPL(modify_acceptable_latency); | ||
169 | |||
170 | /** | ||
171 | * remove_acceptable_latency - removes the maximum latency acceptable | ||
172 | * @identifier: string that identifies this driver | ||
173 | * | ||
174 | * This function removes a previously set maximum latency setting | ||
175 | * for the driver and frees up any resources associated with the | ||
176 | * bookkeeping needed for this. | ||
177 | * | ||
178 | * This function does not sleep and can be called in any context. | ||
179 | * Trying to use a non-existing identifier silently gets ignored. | ||
180 | */ | ||
181 | void remove_acceptable_latency(char *identifier) | ||
182 | { | ||
183 | unsigned long flags; | ||
184 | int newmax = 0; | ||
185 | struct latency_info *iter, *temp; | ||
186 | |||
187 | spin_lock_irqsave(&latency_lock, flags); | ||
188 | |||
189 | list_for_each_entry_safe(iter, temp, &latency_list, list) { | ||
190 | if (strcmp(iter->identifier, identifier) == 0) { | ||
191 | list_del(&iter->list); | ||
192 | newmax = iter->usecs; | ||
193 | kfree(iter->identifier); | ||
194 | kfree(iter); | ||
195 | break; | ||
196 | } | ||
197 | } | ||
198 | |||
199 | /* If we just deleted the system wide value, we need to | ||
200 | * recalculate with a full search | ||
201 | */ | ||
202 | if (newmax == atomic_read(¤t_max_latency)) { | ||
203 | newmax = __find_max_latency(); | ||
204 | atomic_set(¤t_max_latency, newmax); | ||
205 | } | ||
206 | spin_unlock_irqrestore(&latency_lock, flags); | ||
207 | } | ||
208 | EXPORT_SYMBOL_GPL(remove_acceptable_latency); | ||
209 | |||
210 | /** | ||
211 | * system_latency_constraint - queries the system wide latency maximum | ||
212 | * | ||
213 | * This function returns the system wide maximum latency in | ||
214 | * microseconds. | ||
215 | * | ||
216 | * This function does not sleep and can be called in any context. | ||
217 | */ | ||
218 | int system_latency_constraint(void) | ||
219 | { | ||
220 | return atomic_read(¤t_max_latency); | ||
221 | } | ||
222 | EXPORT_SYMBOL_GPL(system_latency_constraint); | ||
223 | |||
224 | /** | ||
225 | * synchronize_acceptable_latency - recalculates all latency decisions | ||
226 | * | ||
227 | * This function will cause a callback to various kernel pieces that | ||
228 | * will make those pieces rethink their latency decisions. This implies | ||
229 | * that if there are overlong latencies in hardware state already, those | ||
230 | * latencies get taken right now. When this call completes no overlong | ||
231 | * latency decisions should be active anymore. | ||
232 | * | ||
233 | * Typical usecase of this is after a modify_acceptable_latency() call, | ||
234 | * which in itself is non-blocking and non-synchronizing. | ||
235 | * | ||
236 | * This function blocks and should not be called with locks held. | ||
237 | */ | ||
238 | |||
239 | void synchronize_acceptable_latency(void) | ||
240 | { | ||
241 | blocking_notifier_call_chain(&latency_notifier, | ||
242 | atomic_read(¤t_max_latency), NULL); | ||
243 | } | ||
244 | EXPORT_SYMBOL_GPL(synchronize_acceptable_latency); | ||
245 | |||
246 | /* | ||
247 | * Latency notifier: this notifier gets called when a non-atomic new | ||
248 | * latency value gets set. The expectation nof the caller of the | ||
249 | * non-atomic set is that when the call returns, future latencies | ||
250 | * are within bounds, so the functions on the notifier list are | ||
251 | * expected to take the overlong latencies immediately, inside the | ||
252 | * callback, and not make a overlong latency decision anymore. | ||
253 | * | ||
254 | * The callback gets called when the new latency value is made | ||
255 | * active so system_latency_constraint() returns the new latency. | ||
256 | */ | ||
257 | int register_latency_notifier(struct notifier_block * nb) | ||
258 | { | ||
259 | return blocking_notifier_chain_register(&latency_notifier, nb); | ||
260 | } | ||
261 | EXPORT_SYMBOL_GPL(register_latency_notifier); | ||
262 | |||
263 | int unregister_latency_notifier(struct notifier_block * nb) | ||
264 | { | ||
265 | return blocking_notifier_chain_unregister(&latency_notifier, nb); | ||
266 | } | ||
267 | EXPORT_SYMBOL_GPL(unregister_latency_notifier); | ||
268 | |||
269 | static __init int latency_init(void) | ||
270 | { | ||
271 | atomic_set(¤t_max_latency, INFINITE_LATENCY); | ||
272 | /* | ||
273 | * we don't want by default to have longer latencies than 2 ticks, | ||
274 | * since that would cause lost ticks | ||
275 | */ | ||
276 | set_acceptable_latency("kernel", 2*1000000/HZ); | ||
277 | return 0; | ||
278 | } | ||
279 | |||
280 | module_init(latency_init); | ||
diff --git a/kernel/pm_qos_params.c b/kernel/pm_qos_params.c new file mode 100644 index 000000000000..0afe32be4c85 --- /dev/null +++ b/kernel/pm_qos_params.c | |||
@@ -0,0 +1,425 @@ | |||
1 | /* | ||
2 | * This module exposes the interface to kernel space for specifying | ||
3 | * QoS dependencies. It provides infrastructure for registration of: | ||
4 | * | ||
5 | * Dependents on a QoS value : register requirements | ||
6 | * Watchers of QoS value : get notified when target QoS value changes | ||
7 | * | ||
8 | * This QoS design is best effort based. Dependents register their QoS needs. | ||
9 | * Watchers register to keep track of the current QoS needs of the system. | ||
10 | * | ||
11 | * There are 3 basic classes of QoS parameter: latency, timeout, throughput | ||
12 | * each have defined units: | ||
13 | * latency: usec | ||
14 | * timeout: usec <-- currently not used. | ||
15 | * throughput: kbs (kilo byte / sec) | ||
16 | * | ||
17 | * There are lists of pm_qos_objects each one wrapping requirements, notifiers | ||
18 | * | ||
19 | * User mode requirements on a QOS parameter register themselves to the | ||
20 | * subsystem by opening the device node /dev/... and writing there request to | ||
21 | * the node. As long as the process holds a file handle open to the node the | ||
22 | * client continues to be accounted for. Upon file release the usermode | ||
23 | * requirement is removed and a new qos target is computed. This way when the | ||
24 | * requirement that the application has is cleaned up when closes the file | ||
25 | * pointer or exits the pm_qos_object will get an opportunity to clean up. | ||
26 | * | ||
27 | * mark gross mgross@linux.intel.com | ||
28 | */ | ||
29 | |||
30 | #include <linux/pm_qos_params.h> | ||
31 | #include <linux/sched.h> | ||
32 | #include <linux/spinlock.h> | ||
33 | #include <linux/slab.h> | ||
34 | #include <linux/time.h> | ||
35 | #include <linux/fs.h> | ||
36 | #include <linux/device.h> | ||
37 | #include <linux/miscdevice.h> | ||
38 | #include <linux/string.h> | ||
39 | #include <linux/platform_device.h> | ||
40 | #include <linux/init.h> | ||
41 | |||
42 | #include <linux/uaccess.h> | ||
43 | |||
44 | /* | ||
45 | * locking rule: all changes to target_value or requirements or notifiers lists | ||
46 | * or pm_qos_object list and pm_qos_objects need to happen with pm_qos_lock | ||
47 | * held, taken with _irqsave. One lock to rule them all | ||
48 | */ | ||
49 | struct requirement_list { | ||
50 | struct list_head list; | ||
51 | union { | ||
52 | s32 value; | ||
53 | s32 usec; | ||
54 | s32 kbps; | ||
55 | }; | ||
56 | char *name; | ||
57 | }; | ||
58 | |||
59 | static s32 max_compare(s32 v1, s32 v2); | ||
60 | static s32 min_compare(s32 v1, s32 v2); | ||
61 | |||
62 | struct pm_qos_object { | ||
63 | struct requirement_list requirements; | ||
64 | struct blocking_notifier_head *notifiers; | ||
65 | struct miscdevice pm_qos_power_miscdev; | ||
66 | char *name; | ||
67 | s32 default_value; | ||
68 | s32 target_value; | ||
69 | s32 (*comparitor)(s32, s32); | ||
70 | }; | ||
71 | |||
72 | static struct pm_qos_object null_pm_qos; | ||
73 | static BLOCKING_NOTIFIER_HEAD(cpu_dma_lat_notifier); | ||
74 | static struct pm_qos_object cpu_dma_pm_qos = { | ||
75 | .requirements = {LIST_HEAD_INIT(cpu_dma_pm_qos.requirements.list)}, | ||
76 | .notifiers = &cpu_dma_lat_notifier, | ||
77 | .name = "cpu_dma_latency", | ||
78 | .default_value = 2000 * USEC_PER_SEC, | ||
79 | .target_value = 2000 * USEC_PER_SEC, | ||
80 | .comparitor = min_compare | ||
81 | }; | ||
82 | |||
83 | static BLOCKING_NOTIFIER_HEAD(network_lat_notifier); | ||
84 | static struct pm_qos_object network_lat_pm_qos = { | ||
85 | .requirements = {LIST_HEAD_INIT(network_lat_pm_qos.requirements.list)}, | ||
86 | .notifiers = &network_lat_notifier, | ||
87 | .name = "network_latency", | ||
88 | .default_value = 2000 * USEC_PER_SEC, | ||
89 | .target_value = 2000 * USEC_PER_SEC, | ||
90 | .comparitor = min_compare | ||
91 | }; | ||
92 | |||
93 | |||
94 | static BLOCKING_NOTIFIER_HEAD(network_throughput_notifier); | ||
95 | static struct pm_qos_object network_throughput_pm_qos = { | ||
96 | .requirements = | ||
97 | {LIST_HEAD_INIT(network_throughput_pm_qos.requirements.list)}, | ||
98 | .notifiers = &network_throughput_notifier, | ||
99 | .name = "network_throughput", | ||
100 | .default_value = 0, | ||
101 | .target_value = 0, | ||
102 | .comparitor = max_compare | ||
103 | }; | ||
104 | |||
105 | |||
106 | static struct pm_qos_object *pm_qos_array[] = { | ||
107 | &null_pm_qos, | ||
108 | &cpu_dma_pm_qos, | ||
109 | &network_lat_pm_qos, | ||
110 | &network_throughput_pm_qos | ||
111 | }; | ||
112 | |||
113 | static DEFINE_SPINLOCK(pm_qos_lock); | ||
114 | |||
115 | static ssize_t pm_qos_power_write(struct file *filp, const char __user *buf, | ||
116 | size_t count, loff_t *f_pos); | ||
117 | static int pm_qos_power_open(struct inode *inode, struct file *filp); | ||
118 | static int pm_qos_power_release(struct inode *inode, struct file *filp); | ||
119 | |||
120 | static const struct file_operations pm_qos_power_fops = { | ||
121 | .write = pm_qos_power_write, | ||
122 | .open = pm_qos_power_open, | ||
123 | .release = pm_qos_power_release, | ||
124 | }; | ||
125 | |||
126 | /* static helper functions */ | ||
127 | static s32 max_compare(s32 v1, s32 v2) | ||
128 | { | ||
129 | return max(v1, v2); | ||
130 | } | ||
131 | |||
132 | static s32 min_compare(s32 v1, s32 v2) | ||
133 | { | ||
134 | return min(v1, v2); | ||
135 | } | ||
136 | |||
137 | |||
138 | static void update_target(int target) | ||
139 | { | ||
140 | s32 extreme_value; | ||
141 | struct requirement_list *node; | ||
142 | unsigned long flags; | ||
143 | int call_notifier = 0; | ||
144 | |||
145 | spin_lock_irqsave(&pm_qos_lock, flags); | ||
146 | extreme_value = pm_qos_array[target]->default_value; | ||
147 | list_for_each_entry(node, | ||
148 | &pm_qos_array[target]->requirements.list, list) { | ||
149 | extreme_value = pm_qos_array[target]->comparitor( | ||
150 | extreme_value, node->value); | ||
151 | } | ||
152 | if (pm_qos_array[target]->target_value != extreme_value) { | ||
153 | call_notifier = 1; | ||
154 | pm_qos_array[target]->target_value = extreme_value; | ||
155 | pr_debug(KERN_ERR "new target for qos %d is %d\n", target, | ||
156 | pm_qos_array[target]->target_value); | ||
157 | } | ||
158 | spin_unlock_irqrestore(&pm_qos_lock, flags); | ||
159 | |||
160 | if (call_notifier) | ||
161 | blocking_notifier_call_chain(pm_qos_array[target]->notifiers, | ||
162 | (unsigned long) extreme_value, NULL); | ||
163 | } | ||
164 | |||
165 | static int register_pm_qos_misc(struct pm_qos_object *qos) | ||
166 | { | ||
167 | qos->pm_qos_power_miscdev.minor = MISC_DYNAMIC_MINOR; | ||
168 | qos->pm_qos_power_miscdev.name = qos->name; | ||
169 | qos->pm_qos_power_miscdev.fops = &pm_qos_power_fops; | ||
170 | |||
171 | return misc_register(&qos->pm_qos_power_miscdev); | ||
172 | } | ||
173 | |||
174 | static int find_pm_qos_object_by_minor(int minor) | ||
175 | { | ||
176 | int pm_qos_class; | ||
177 | |||
178 | for (pm_qos_class = 0; | ||
179 | pm_qos_class < PM_QOS_NUM_CLASSES; pm_qos_class++) { | ||
180 | if (minor == | ||
181 | pm_qos_array[pm_qos_class]->pm_qos_power_miscdev.minor) | ||
182 | return pm_qos_class; | ||
183 | } | ||
184 | return -1; | ||
185 | } | ||
186 | |||
187 | /** | ||
188 | * pm_qos_requirement - returns current system wide qos expectation | ||
189 | * @pm_qos_class: identification of which qos value is requested | ||
190 | * | ||
191 | * This function returns the current target value in an atomic manner. | ||
192 | */ | ||
193 | int pm_qos_requirement(int pm_qos_class) | ||
194 | { | ||
195 | int ret_val; | ||
196 | unsigned long flags; | ||
197 | |||
198 | spin_lock_irqsave(&pm_qos_lock, flags); | ||
199 | ret_val = pm_qos_array[pm_qos_class]->target_value; | ||
200 | spin_unlock_irqrestore(&pm_qos_lock, flags); | ||
201 | |||
202 | return ret_val; | ||
203 | } | ||
204 | EXPORT_SYMBOL_GPL(pm_qos_requirement); | ||
205 | |||
206 | /** | ||
207 | * pm_qos_add_requirement - inserts new qos request into the list | ||
208 | * @pm_qos_class: identifies which list of qos request to us | ||
209 | * @name: identifies the request | ||
210 | * @value: defines the qos request | ||
211 | * | ||
212 | * This function inserts a new entry in the pm_qos_class list of requested qos | ||
213 | * performance charactoistics. It recomputes the agregate QoS expectations for | ||
214 | * the pm_qos_class of parrameters. | ||
215 | */ | ||
216 | int pm_qos_add_requirement(int pm_qos_class, char *name, s32 value) | ||
217 | { | ||
218 | struct requirement_list *dep; | ||
219 | unsigned long flags; | ||
220 | |||
221 | dep = kzalloc(sizeof(struct requirement_list), GFP_KERNEL); | ||
222 | if (dep) { | ||
223 | if (value == PM_QOS_DEFAULT_VALUE) | ||
224 | dep->value = pm_qos_array[pm_qos_class]->default_value; | ||
225 | else | ||
226 | dep->value = value; | ||
227 | dep->name = kstrdup(name, GFP_KERNEL); | ||
228 | if (!dep->name) | ||
229 | goto cleanup; | ||
230 | |||
231 | spin_lock_irqsave(&pm_qos_lock, flags); | ||
232 | list_add(&dep->list, | ||
233 | &pm_qos_array[pm_qos_class]->requirements.list); | ||
234 | spin_unlock_irqrestore(&pm_qos_lock, flags); | ||
235 | update_target(pm_qos_class); | ||
236 | |||
237 | return 0; | ||
238 | } | ||
239 | |||
240 | cleanup: | ||
241 | kfree(dep); | ||
242 | return -ENOMEM; | ||
243 | } | ||
244 | EXPORT_SYMBOL_GPL(pm_qos_add_requirement); | ||
245 | |||
246 | /** | ||
247 | * pm_qos_update_requirement - modifies an existing qos request | ||
248 | * @pm_qos_class: identifies which list of qos request to us | ||
249 | * @name: identifies the request | ||
250 | * @value: defines the qos request | ||
251 | * | ||
252 | * Updates an existing qos requierement for the pm_qos_class of parameters along | ||
253 | * with updating the target pm_qos_class value. | ||
254 | * | ||
255 | * If the named request isn't in the lest then no change is made. | ||
256 | */ | ||
257 | int pm_qos_update_requirement(int pm_qos_class, char *name, s32 new_value) | ||
258 | { | ||
259 | unsigned long flags; | ||
260 | struct requirement_list *node; | ||
261 | int pending_update = 0; | ||
262 | |||
263 | spin_lock_irqsave(&pm_qos_lock, flags); | ||
264 | list_for_each_entry(node, | ||
265 | &pm_qos_array[pm_qos_class]->requirements.list, list) { | ||
266 | if (strcmp(node->name, name) == 0) { | ||
267 | if (new_value == PM_QOS_DEFAULT_VALUE) | ||
268 | node->value = | ||
269 | pm_qos_array[pm_qos_class]->default_value; | ||
270 | else | ||
271 | node->value = new_value; | ||
272 | pending_update = 1; | ||
273 | break; | ||
274 | } | ||
275 | } | ||
276 | spin_unlock_irqrestore(&pm_qos_lock, flags); | ||
277 | if (pending_update) | ||
278 | update_target(pm_qos_class); | ||
279 | |||
280 | return 0; | ||
281 | } | ||
282 | EXPORT_SYMBOL_GPL(pm_qos_update_requirement); | ||
283 | |||
284 | /** | ||
285 | * pm_qos_remove_requirement - modifies an existing qos request | ||
286 | * @pm_qos_class: identifies which list of qos request to us | ||
287 | * @name: identifies the request | ||
288 | * | ||
289 | * Will remove named qos request from pm_qos_class list of parrameters and | ||
290 | * recompute the current target value for the pm_qos_class. | ||
291 | */ | ||
292 | void pm_qos_remove_requirement(int pm_qos_class, char *name) | ||
293 | { | ||
294 | unsigned long flags; | ||
295 | struct requirement_list *node; | ||
296 | int pending_update = 0; | ||
297 | |||
298 | spin_lock_irqsave(&pm_qos_lock, flags); | ||
299 | list_for_each_entry(node, | ||
300 | &pm_qos_array[pm_qos_class]->requirements.list, list) { | ||
301 | if (strcmp(node->name, name) == 0) { | ||
302 | kfree(node->name); | ||
303 | list_del(&node->list); | ||
304 | kfree(node); | ||
305 | pending_update = 1; | ||
306 | break; | ||
307 | } | ||
308 | } | ||
309 | spin_unlock_irqrestore(&pm_qos_lock, flags); | ||
310 | if (pending_update) | ||
311 | update_target(pm_qos_class); | ||
312 | } | ||
313 | EXPORT_SYMBOL_GPL(pm_qos_remove_requirement); | ||
314 | |||
315 | /** | ||
316 | * pm_qos_add_notifier - sets notification entry for changes to target value | ||
317 | * @pm_qos_class: identifies which qos target changes should be notified. | ||
318 | * @notifier: notifier block managed by caller. | ||
319 | * | ||
320 | * will register the notifier into a notification chain that gets called | ||
321 | * uppon changes to the pm_qos_class target value. | ||
322 | */ | ||
323 | int pm_qos_add_notifier(int pm_qos_class, struct notifier_block *notifier) | ||
324 | { | ||
325 | int retval; | ||
326 | |||
327 | retval = blocking_notifier_chain_register( | ||
328 | pm_qos_array[pm_qos_class]->notifiers, notifier); | ||
329 | |||
330 | return retval; | ||
331 | } | ||
332 | EXPORT_SYMBOL_GPL(pm_qos_add_notifier); | ||
333 | |||
334 | /** | ||
335 | * pm_qos_remove_notifier - deletes notification entry from chain. | ||
336 | * @pm_qos_class: identifies which qos target changes are notified. | ||
337 | * @notifier: notifier block to be removed. | ||
338 | * | ||
339 | * will remove the notifier from the notification chain that gets called | ||
340 | * uppon changes to the pm_qos_class target value. | ||
341 | */ | ||
342 | int pm_qos_remove_notifier(int pm_qos_class, struct notifier_block *notifier) | ||
343 | { | ||
344 | int retval; | ||
345 | |||
346 | retval = blocking_notifier_chain_unregister( | ||
347 | pm_qos_array[pm_qos_class]->notifiers, notifier); | ||
348 | |||
349 | return retval; | ||
350 | } | ||
351 | EXPORT_SYMBOL_GPL(pm_qos_remove_notifier); | ||
352 | |||
353 | #define PID_NAME_LEN sizeof("process_1234567890") | ||
354 | static char name[PID_NAME_LEN]; | ||
355 | |||
356 | static int pm_qos_power_open(struct inode *inode, struct file *filp) | ||
357 | { | ||
358 | int ret; | ||
359 | long pm_qos_class; | ||
360 | |||
361 | pm_qos_class = find_pm_qos_object_by_minor(iminor(inode)); | ||
362 | if (pm_qos_class >= 0) { | ||
363 | filp->private_data = (void *)pm_qos_class; | ||
364 | sprintf(name, "process_%d", current->pid); | ||
365 | ret = pm_qos_add_requirement(pm_qos_class, name, | ||
366 | PM_QOS_DEFAULT_VALUE); | ||
367 | if (ret >= 0) | ||
368 | return 0; | ||
369 | } | ||
370 | |||
371 | return -EPERM; | ||
372 | } | ||
373 | |||
374 | static int pm_qos_power_release(struct inode *inode, struct file *filp) | ||
375 | { | ||
376 | int pm_qos_class; | ||
377 | |||
378 | pm_qos_class = (long)filp->private_data; | ||
379 | sprintf(name, "process_%d", current->pid); | ||
380 | pm_qos_remove_requirement(pm_qos_class, name); | ||
381 | |||
382 | return 0; | ||
383 | } | ||
384 | |||
385 | static ssize_t pm_qos_power_write(struct file *filp, const char __user *buf, | ||
386 | size_t count, loff_t *f_pos) | ||
387 | { | ||
388 | s32 value; | ||
389 | int pm_qos_class; | ||
390 | |||
391 | pm_qos_class = (long)filp->private_data; | ||
392 | if (count != sizeof(s32)) | ||
393 | return -EINVAL; | ||
394 | if (copy_from_user(&value, buf, sizeof(s32))) | ||
395 | return -EFAULT; | ||
396 | sprintf(name, "process_%d", current->pid); | ||
397 | pm_qos_update_requirement(pm_qos_class, name, value); | ||
398 | |||
399 | return sizeof(s32); | ||
400 | } | ||
401 | |||
402 | |||
403 | static int __init pm_qos_power_init(void) | ||
404 | { | ||
405 | int ret = 0; | ||
406 | |||
407 | ret = register_pm_qos_misc(&cpu_dma_pm_qos); | ||
408 | if (ret < 0) { | ||
409 | printk(KERN_ERR "pm_qos_param: cpu_dma_latency setup failed\n"); | ||
410 | return ret; | ||
411 | } | ||
412 | ret = register_pm_qos_misc(&network_lat_pm_qos); | ||
413 | if (ret < 0) { | ||
414 | printk(KERN_ERR "pm_qos_param: network_latency setup failed\n"); | ||
415 | return ret; | ||
416 | } | ||
417 | ret = register_pm_qos_misc(&network_throughput_pm_qos); | ||
418 | if (ret < 0) | ||
419 | printk(KERN_ERR | ||
420 | "pm_qos_param: network_throughput setup failed\n"); | ||
421 | |||
422 | return ret; | ||
423 | } | ||
424 | |||
425 | late_initcall(pm_qos_power_init); | ||
diff --git a/kernel/posix-timers.c b/kernel/posix-timers.c index 36d563fd9e3b..122d5c787fe2 100644 --- a/kernel/posix-timers.c +++ b/kernel/posix-timers.c | |||
@@ -256,8 +256,9 @@ static void schedule_next_timer(struct k_itimer *timr) | |||
256 | if (timr->it.real.interval.tv64 == 0) | 256 | if (timr->it.real.interval.tv64 == 0) |
257 | return; | 257 | return; |
258 | 258 | ||
259 | timr->it_overrun += hrtimer_forward(timer, timer->base->get_time(), | 259 | timr->it_overrun += (unsigned int) hrtimer_forward(timer, |
260 | timr->it.real.interval); | 260 | timer->base->get_time(), |
261 | timr->it.real.interval); | ||
261 | 262 | ||
262 | timr->it_overrun_last = timr->it_overrun; | 263 | timr->it_overrun_last = timr->it_overrun; |
263 | timr->it_overrun = -1; | 264 | timr->it_overrun = -1; |
@@ -386,7 +387,7 @@ static enum hrtimer_restart posix_timer_fn(struct hrtimer *timer) | |||
386 | now = ktime_add(now, kj); | 387 | now = ktime_add(now, kj); |
387 | } | 388 | } |
388 | #endif | 389 | #endif |
389 | timr->it_overrun += | 390 | timr->it_overrun += (unsigned int) |
390 | hrtimer_forward(timer, now, | 391 | hrtimer_forward(timer, now, |
391 | timr->it.real.interval); | 392 | timr->it.real.interval); |
392 | ret = HRTIMER_RESTART; | 393 | ret = HRTIMER_RESTART; |
@@ -662,7 +663,7 @@ common_timer_get(struct k_itimer *timr, struct itimerspec *cur_setting) | |||
662 | */ | 663 | */ |
663 | if (iv.tv64 && (timr->it_requeue_pending & REQUEUE_PENDING || | 664 | if (iv.tv64 && (timr->it_requeue_pending & REQUEUE_PENDING || |
664 | (timr->it_sigev_notify & ~SIGEV_THREAD_ID) == SIGEV_NONE)) | 665 | (timr->it_sigev_notify & ~SIGEV_THREAD_ID) == SIGEV_NONE)) |
665 | timr->it_overrun += hrtimer_forward(timer, now, iv); | 666 | timr->it_overrun += (unsigned int) hrtimer_forward(timer, now, iv); |
666 | 667 | ||
667 | remaining = ktime_sub(timer->expires, now); | 668 | remaining = ktime_sub(timer->expires, now); |
668 | /* Return 0 only, when the timer is expired and not pending */ | 669 | /* Return 0 only, when the timer is expired and not pending */ |
diff --git a/kernel/power/disk.c b/kernel/power/disk.c index d09da0895174..859a8e59773a 100644 --- a/kernel/power/disk.c +++ b/kernel/power/disk.c | |||
@@ -26,7 +26,7 @@ | |||
26 | 26 | ||
27 | 27 | ||
28 | static int noresume = 0; | 28 | static int noresume = 0; |
29 | char resume_file[256] = CONFIG_PM_STD_PARTITION; | 29 | static char resume_file[256] = CONFIG_PM_STD_PARTITION; |
30 | dev_t swsusp_resume_device; | 30 | dev_t swsusp_resume_device; |
31 | sector_t swsusp_resume_block; | 31 | sector_t swsusp_resume_block; |
32 | 32 | ||
@@ -185,7 +185,7 @@ static void platform_restore_cleanup(int platform_mode) | |||
185 | * reappears in this routine after a restore. | 185 | * reappears in this routine after a restore. |
186 | */ | 186 | */ |
187 | 187 | ||
188 | int create_image(int platform_mode) | 188 | static int create_image(int platform_mode) |
189 | { | 189 | { |
190 | int error; | 190 | int error; |
191 | 191 | ||
diff --git a/kernel/power/snapshot.c b/kernel/power/snapshot.c index f6a5df934f8d..95250d7c8d91 100644 --- a/kernel/power/snapshot.c +++ b/kernel/power/snapshot.c | |||
@@ -1203,7 +1203,7 @@ asmlinkage int swsusp_save(void) | |||
1203 | 1203 | ||
1204 | printk(KERN_INFO "PM: Creating hibernation image: \n"); | 1204 | printk(KERN_INFO "PM: Creating hibernation image: \n"); |
1205 | 1205 | ||
1206 | drain_local_pages(); | 1206 | drain_local_pages(NULL); |
1207 | nr_pages = count_data_pages(); | 1207 | nr_pages = count_data_pages(); |
1208 | nr_highmem = count_highmem_pages(); | 1208 | nr_highmem = count_highmem_pages(); |
1209 | printk(KERN_INFO "PM: Need to copy %u pages\n", nr_pages + nr_highmem); | 1209 | printk(KERN_INFO "PM: Need to copy %u pages\n", nr_pages + nr_highmem); |
@@ -1221,7 +1221,7 @@ asmlinkage int swsusp_save(void) | |||
1221 | /* During allocating of suspend pagedir, new cold pages may appear. | 1221 | /* During allocating of suspend pagedir, new cold pages may appear. |
1222 | * Kill them. | 1222 | * Kill them. |
1223 | */ | 1223 | */ |
1224 | drain_local_pages(); | 1224 | drain_local_pages(NULL); |
1225 | copy_data_pages(©_bm, &orig_bm); | 1225 | copy_data_pages(©_bm, &orig_bm); |
1226 | 1226 | ||
1227 | /* | 1227 | /* |
diff --git a/kernel/signal.c b/kernel/signal.c index 4333b6dbb424..6a5f97cd337a 100644 --- a/kernel/signal.c +++ b/kernel/signal.c | |||
@@ -911,27 +911,6 @@ __group_complete_signal(int sig, struct task_struct *p) | |||
911 | } while_each_thread(p, t); | 911 | } while_each_thread(p, t); |
912 | return; | 912 | return; |
913 | } | 913 | } |
914 | |||
915 | /* | ||
916 | * There will be a core dump. We make all threads other | ||
917 | * than the chosen one go into a group stop so that nothing | ||
918 | * happens until it gets scheduled, takes the signal off | ||
919 | * the shared queue, and does the core dump. This is a | ||
920 | * little more complicated than strictly necessary, but it | ||
921 | * keeps the signal state that winds up in the core dump | ||
922 | * unchanged from the death state, e.g. which thread had | ||
923 | * the core-dump signal unblocked. | ||
924 | */ | ||
925 | rm_from_queue(SIG_KERNEL_STOP_MASK, &t->pending); | ||
926 | rm_from_queue(SIG_KERNEL_STOP_MASK, &p->signal->shared_pending); | ||
927 | p->signal->group_stop_count = 0; | ||
928 | p->signal->group_exit_task = t; | ||
929 | p = t; | ||
930 | do { | ||
931 | p->signal->group_stop_count++; | ||
932 | signal_wake_up(t, t == p); | ||
933 | } while_each_thread(p, t); | ||
934 | return; | ||
935 | } | 914 | } |
936 | 915 | ||
937 | /* | 916 | /* |
@@ -978,7 +957,6 @@ void zap_other_threads(struct task_struct *p) | |||
978 | { | 957 | { |
979 | struct task_struct *t; | 958 | struct task_struct *t; |
980 | 959 | ||
981 | p->signal->flags = SIGNAL_GROUP_EXIT; | ||
982 | p->signal->group_stop_count = 0; | 960 | p->signal->group_stop_count = 0; |
983 | 961 | ||
984 | for (t = next_thread(p); t != p; t = next_thread(t)) { | 962 | for (t = next_thread(p); t != p; t = next_thread(t)) { |
@@ -1709,9 +1687,6 @@ static int do_signal_stop(int signr) | |||
1709 | struct signal_struct *sig = current->signal; | 1687 | struct signal_struct *sig = current->signal; |
1710 | int stop_count; | 1688 | int stop_count; |
1711 | 1689 | ||
1712 | if (!likely(sig->flags & SIGNAL_STOP_DEQUEUED)) | ||
1713 | return 0; | ||
1714 | |||
1715 | if (sig->group_stop_count > 0) { | 1690 | if (sig->group_stop_count > 0) { |
1716 | /* | 1691 | /* |
1717 | * There is a group stop in progress. We don't need to | 1692 | * There is a group stop in progress. We don't need to |
@@ -1719,12 +1694,15 @@ static int do_signal_stop(int signr) | |||
1719 | */ | 1694 | */ |
1720 | stop_count = --sig->group_stop_count; | 1695 | stop_count = --sig->group_stop_count; |
1721 | } else { | 1696 | } else { |
1697 | struct task_struct *t; | ||
1698 | |||
1699 | if (!likely(sig->flags & SIGNAL_STOP_DEQUEUED) || | ||
1700 | unlikely(sig->group_exit_task)) | ||
1701 | return 0; | ||
1722 | /* | 1702 | /* |
1723 | * There is no group stop already in progress. | 1703 | * There is no group stop already in progress. |
1724 | * We must initiate one now. | 1704 | * We must initiate one now. |
1725 | */ | 1705 | */ |
1726 | struct task_struct *t; | ||
1727 | |||
1728 | sig->group_exit_code = signr; | 1706 | sig->group_exit_code = signr; |
1729 | 1707 | ||
1730 | stop_count = 0; | 1708 | stop_count = 0; |
@@ -1752,47 +1730,6 @@ static int do_signal_stop(int signr) | |||
1752 | return 1; | 1730 | return 1; |
1753 | } | 1731 | } |
1754 | 1732 | ||
1755 | /* | ||
1756 | * Do appropriate magic when group_stop_count > 0. | ||
1757 | * We return nonzero if we stopped, after releasing the siglock. | ||
1758 | * We return zero if we still hold the siglock and should look | ||
1759 | * for another signal without checking group_stop_count again. | ||
1760 | */ | ||
1761 | static int handle_group_stop(void) | ||
1762 | { | ||
1763 | int stop_count; | ||
1764 | |||
1765 | if (current->signal->group_exit_task == current) { | ||
1766 | /* | ||
1767 | * Group stop is so we can do a core dump, | ||
1768 | * We are the initiating thread, so get on with it. | ||
1769 | */ | ||
1770 | current->signal->group_exit_task = NULL; | ||
1771 | return 0; | ||
1772 | } | ||
1773 | |||
1774 | if (current->signal->flags & SIGNAL_GROUP_EXIT) | ||
1775 | /* | ||
1776 | * Group stop is so another thread can do a core dump, | ||
1777 | * or else we are racing against a death signal. | ||
1778 | * Just punt the stop so we can get the next signal. | ||
1779 | */ | ||
1780 | return 0; | ||
1781 | |||
1782 | /* | ||
1783 | * There is a group stop in progress. We stop | ||
1784 | * without any associated signal being in our queue. | ||
1785 | */ | ||
1786 | stop_count = --current->signal->group_stop_count; | ||
1787 | if (stop_count == 0) | ||
1788 | current->signal->flags = SIGNAL_STOP_STOPPED; | ||
1789 | current->exit_code = current->signal->group_exit_code; | ||
1790 | set_current_state(TASK_STOPPED); | ||
1791 | spin_unlock_irq(¤t->sighand->siglock); | ||
1792 | finish_stop(stop_count); | ||
1793 | return 1; | ||
1794 | } | ||
1795 | |||
1796 | int get_signal_to_deliver(siginfo_t *info, struct k_sigaction *return_ka, | 1733 | int get_signal_to_deliver(siginfo_t *info, struct k_sigaction *return_ka, |
1797 | struct pt_regs *regs, void *cookie) | 1734 | struct pt_regs *regs, void *cookie) |
1798 | { | 1735 | { |
@@ -1807,7 +1744,7 @@ relock: | |||
1807 | struct k_sigaction *ka; | 1744 | struct k_sigaction *ka; |
1808 | 1745 | ||
1809 | if (unlikely(current->signal->group_stop_count > 0) && | 1746 | if (unlikely(current->signal->group_stop_count > 0) && |
1810 | handle_group_stop()) | 1747 | do_signal_stop(0)) |
1811 | goto relock; | 1748 | goto relock; |
1812 | 1749 | ||
1813 | signr = dequeue_signal(current, mask, info); | 1750 | signr = dequeue_signal(current, mask, info); |
diff --git a/kernel/sys.c b/kernel/sys.c index d1fe71eb4546..53de35fc8245 100644 --- a/kernel/sys.c +++ b/kernel/sys.c | |||
@@ -315,7 +315,7 @@ static void kernel_kexec(void) | |||
315 | #endif | 315 | #endif |
316 | } | 316 | } |
317 | 317 | ||
318 | void kernel_shutdown_prepare(enum system_states state) | 318 | static void kernel_shutdown_prepare(enum system_states state) |
319 | { | 319 | { |
320 | blocking_notifier_call_chain(&reboot_notifier_list, | 320 | blocking_notifier_call_chain(&reboot_notifier_list, |
321 | (state == SYSTEM_HALT)?SYS_HALT:SYS_POWER_OFF, NULL); | 321 | (state == SYSTEM_HALT)?SYS_HALT:SYS_POWER_OFF, NULL); |
@@ -1637,7 +1637,7 @@ asmlinkage long sys_umask(int mask) | |||
1637 | mask = xchg(¤t->fs->umask, mask & S_IRWXUGO); | 1637 | mask = xchg(¤t->fs->umask, mask & S_IRWXUGO); |
1638 | return mask; | 1638 | return mask; |
1639 | } | 1639 | } |
1640 | 1640 | ||
1641 | asmlinkage long sys_prctl(int option, unsigned long arg2, unsigned long arg3, | 1641 | asmlinkage long sys_prctl(int option, unsigned long arg2, unsigned long arg3, |
1642 | unsigned long arg4, unsigned long arg5) | 1642 | unsigned long arg4, unsigned long arg5) |
1643 | { | 1643 | { |
@@ -1742,6 +1742,17 @@ asmlinkage long sys_prctl(int option, unsigned long arg2, unsigned long arg3, | |||
1742 | error = prctl_set_seccomp(arg2); | 1742 | error = prctl_set_seccomp(arg2); |
1743 | break; | 1743 | break; |
1744 | 1744 | ||
1745 | case PR_CAPBSET_READ: | ||
1746 | if (!cap_valid(arg2)) | ||
1747 | return -EINVAL; | ||
1748 | return !!cap_raised(current->cap_bset, arg2); | ||
1749 | case PR_CAPBSET_DROP: | ||
1750 | #ifdef CONFIG_SECURITY_FILE_CAPABILITIES | ||
1751 | return cap_prctl_drop(arg2); | ||
1752 | #else | ||
1753 | return -EINVAL; | ||
1754 | #endif | ||
1755 | |||
1745 | default: | 1756 | default: |
1746 | error = -EINVAL; | 1757 | error = -EINVAL; |
1747 | break; | 1758 | break; |
diff --git a/kernel/sys_ni.c b/kernel/sys_ni.c index beee5b3b68a2..5b9b467de070 100644 --- a/kernel/sys_ni.c +++ b/kernel/sys_ni.c | |||
@@ -154,7 +154,10 @@ cond_syscall(sys_ioprio_get); | |||
154 | 154 | ||
155 | /* New file descriptors */ | 155 | /* New file descriptors */ |
156 | cond_syscall(sys_signalfd); | 156 | cond_syscall(sys_signalfd); |
157 | cond_syscall(sys_timerfd); | ||
158 | cond_syscall(compat_sys_signalfd); | 157 | cond_syscall(compat_sys_signalfd); |
159 | cond_syscall(compat_sys_timerfd); | 158 | cond_syscall(sys_timerfd_create); |
159 | cond_syscall(sys_timerfd_settime); | ||
160 | cond_syscall(sys_timerfd_gettime); | ||
161 | cond_syscall(compat_sys_timerfd_settime); | ||
162 | cond_syscall(compat_sys_timerfd_gettime); | ||
160 | cond_syscall(sys_eventfd); | 163 | cond_syscall(sys_eventfd); |
diff --git a/kernel/sysctl.c b/kernel/sysctl.c index 7cb1ac3e6fff..5e2ad5bf88e2 100644 --- a/kernel/sysctl.c +++ b/kernel/sysctl.c | |||
@@ -84,8 +84,11 @@ extern int sysctl_stat_interval; | |||
84 | extern int latencytop_enabled; | 84 | extern int latencytop_enabled; |
85 | 85 | ||
86 | /* Constants used for minimum and maximum */ | 86 | /* Constants used for minimum and maximum */ |
87 | #ifdef CONFIG_DETECT_SOFTLOCKUP | 87 | #if defined(CONFIG_DETECT_SOFTLOCKUP) || defined(CONFIG_HIGHMEM) |
88 | static int one = 1; | 88 | static int one = 1; |
89 | #endif | ||
90 | |||
91 | #ifdef CONFIG_DETECT_SOFTLOCKUP | ||
89 | static int sixty = 60; | 92 | static int sixty = 60; |
90 | #endif | 93 | #endif |
91 | 94 | ||
@@ -416,15 +419,6 @@ static struct ctl_table kern_table[] = { | |||
416 | .proc_handler = &proc_dointvec, | 419 | .proc_handler = &proc_dointvec, |
417 | }, | 420 | }, |
418 | #endif | 421 | #endif |
419 | #ifdef CONFIG_SECURITY_CAPABILITIES | ||
420 | { | ||
421 | .procname = "cap-bound", | ||
422 | .data = &cap_bset, | ||
423 | .maxlen = sizeof(kernel_cap_t), | ||
424 | .mode = 0600, | ||
425 | .proc_handler = &proc_dointvec_bset, | ||
426 | }, | ||
427 | #endif /* def CONFIG_SECURITY_CAPABILITIES */ | ||
428 | #ifdef CONFIG_BLK_DEV_INITRD | 422 | #ifdef CONFIG_BLK_DEV_INITRD |
429 | { | 423 | { |
430 | .ctl_name = KERN_REALROOTDEV, | 424 | .ctl_name = KERN_REALROOTDEV, |
@@ -1150,6 +1144,19 @@ static struct ctl_table vm_table[] = { | |||
1150 | .extra1 = &zero, | 1144 | .extra1 = &zero, |
1151 | }, | 1145 | }, |
1152 | #endif | 1146 | #endif |
1147 | #ifdef CONFIG_HIGHMEM | ||
1148 | { | ||
1149 | .ctl_name = CTL_UNNUMBERED, | ||
1150 | .procname = "highmem_is_dirtyable", | ||
1151 | .data = &vm_highmem_is_dirtyable, | ||
1152 | .maxlen = sizeof(vm_highmem_is_dirtyable), | ||
1153 | .mode = 0644, | ||
1154 | .proc_handler = &proc_dointvec_minmax, | ||
1155 | .strategy = &sysctl_intvec, | ||
1156 | .extra1 = &zero, | ||
1157 | .extra2 = &one, | ||
1158 | }, | ||
1159 | #endif | ||
1153 | /* | 1160 | /* |
1154 | * NOTE: do not add new entries to this table unless you have read | 1161 | * NOTE: do not add new entries to this table unless you have read |
1155 | * Documentation/sysctl/ctl_unnumbered.txt | 1162 | * Documentation/sysctl/ctl_unnumbered.txt |
@@ -2080,26 +2087,6 @@ static int do_proc_dointvec_bset_conv(int *negp, unsigned long *lvalp, | |||
2080 | return 0; | 2087 | return 0; |
2081 | } | 2088 | } |
2082 | 2089 | ||
2083 | #ifdef CONFIG_SECURITY_CAPABILITIES | ||
2084 | /* | ||
2085 | * init may raise the set. | ||
2086 | */ | ||
2087 | |||
2088 | int proc_dointvec_bset(struct ctl_table *table, int write, struct file *filp, | ||
2089 | void __user *buffer, size_t *lenp, loff_t *ppos) | ||
2090 | { | ||
2091 | int op; | ||
2092 | |||
2093 | if (write && !capable(CAP_SYS_MODULE)) { | ||
2094 | return -EPERM; | ||
2095 | } | ||
2096 | |||
2097 | op = is_global_init(current) ? OP_SET : OP_AND; | ||
2098 | return do_proc_dointvec(table,write,filp,buffer,lenp,ppos, | ||
2099 | do_proc_dointvec_bset_conv,&op); | ||
2100 | } | ||
2101 | #endif /* def CONFIG_SECURITY_CAPABILITIES */ | ||
2102 | |||
2103 | /* | 2090 | /* |
2104 | * Taint values can only be increased | 2091 | * Taint values can only be increased |
2105 | */ | 2092 | */ |
@@ -2513,12 +2500,6 @@ int proc_dointvec(struct ctl_table *table, int write, struct file *filp, | |||
2513 | return -ENOSYS; | 2500 | return -ENOSYS; |
2514 | } | 2501 | } |
2515 | 2502 | ||
2516 | int proc_dointvec_bset(struct ctl_table *table, int write, struct file *filp, | ||
2517 | void __user *buffer, size_t *lenp, loff_t *ppos) | ||
2518 | { | ||
2519 | return -ENOSYS; | ||
2520 | } | ||
2521 | |||
2522 | int proc_dointvec_minmax(struct ctl_table *table, int write, struct file *filp, | 2503 | int proc_dointvec_minmax(struct ctl_table *table, int write, struct file *filp, |
2523 | void __user *buffer, size_t *lenp, loff_t *ppos) | 2504 | void __user *buffer, size_t *lenp, loff_t *ppos) |
2524 | { | 2505 | { |
diff --git a/kernel/sysctl_check.c b/kernel/sysctl_check.c index c3206fa50048..006365b69eaf 100644 --- a/kernel/sysctl_check.c +++ b/kernel/sysctl_check.c | |||
@@ -37,10 +37,6 @@ static struct trans_ctl_table trans_kern_table[] = { | |||
37 | { KERN_NODENAME, "hostname" }, | 37 | { KERN_NODENAME, "hostname" }, |
38 | { KERN_DOMAINNAME, "domainname" }, | 38 | { KERN_DOMAINNAME, "domainname" }, |
39 | 39 | ||
40 | #ifdef CONFIG_SECURITY_CAPABILITIES | ||
41 | { KERN_CAP_BSET, "cap-bound" }, | ||
42 | #endif /* def CONFIG_SECURITY_CAPABILITIES */ | ||
43 | |||
44 | { KERN_PANIC, "panic" }, | 40 | { KERN_PANIC, "panic" }, |
45 | { KERN_REALROOTDEV, "real-root-dev" }, | 41 | { KERN_REALROOTDEV, "real-root-dev" }, |
46 | 42 | ||
@@ -1498,9 +1494,6 @@ int sysctl_check_table(struct nsproxy *namespaces, struct ctl_table *table) | |||
1498 | (table->strategy == sysctl_ms_jiffies) || | 1494 | (table->strategy == sysctl_ms_jiffies) || |
1499 | (table->proc_handler == proc_dostring) || | 1495 | (table->proc_handler == proc_dostring) || |
1500 | (table->proc_handler == proc_dointvec) || | 1496 | (table->proc_handler == proc_dointvec) || |
1501 | #ifdef CONFIG_SECURITY_CAPABILITIES | ||
1502 | (table->proc_handler == proc_dointvec_bset) || | ||
1503 | #endif /* def CONFIG_SECURITY_CAPABILITIES */ | ||
1504 | (table->proc_handler == proc_dointvec_minmax) || | 1497 | (table->proc_handler == proc_dointvec_minmax) || |
1505 | (table->proc_handler == proc_dointvec_jiffies) || | 1498 | (table->proc_handler == proc_dointvec_jiffies) || |
1506 | (table->proc_handler == proc_dointvec_userhz_jiffies) || | 1499 | (table->proc_handler == proc_dointvec_userhz_jiffies) || |