aboutsummaryrefslogtreecommitdiffstats
path: root/kernel
diff options
context:
space:
mode:
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-08-18 23:40:33 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-08-18 23:40:33 -0400
commit5bc0b123dcb2bb65b0b1ec57e591459dcf583d3d (patch)
tree6ee79d18fd716755d49d18c465c1b25fabc43597 /kernel
parenteefbc594abbb1b7e6e7eeadb65ae7c7538474210 (diff)
parentb36f4be3de1b123d8601de062e7dbfc904f305fb (diff)
Merge 3.11-rc6 into char-misc-next
We want these fixes in this tree. Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'kernel')
-rw-r--r--kernel/Makefile3
-rw-r--r--kernel/cgroup.c4
-rw-r--r--kernel/cpuset.c6
-rw-r--r--kernel/fork.c6
-rw-r--r--kernel/freezer.c2
-rw-r--r--kernel/mutex.c4
-rw-r--r--kernel/power/process.c11
-rw-r--r--kernel/power/qos.c20
-rw-r--r--kernel/printk/Makefile2
-rw-r--r--kernel/printk/braille.c49
-rw-r--r--kernel/printk/braille.h48
-rw-r--r--kernel/printk/console_cmdline.h14
-rw-r--r--kernel/printk/printk.c (renamed from kernel/printk.c)183
-rw-r--r--kernel/ptrace.c1
-rw-r--r--kernel/sched/core.c96
-rw-r--r--kernel/sched/cpupri.c4
-rw-r--r--kernel/sched/fair.c14
-rw-r--r--kernel/sysctl.c6
-rw-r--r--kernel/time/tick-sched.c9
-rw-r--r--kernel/trace/ftrace.c87
-rw-r--r--kernel/trace/trace.c27
-rw-r--r--kernel/trace/trace_events.c200
-rw-r--r--kernel/trace/trace_events_filter.c17
-rw-r--r--kernel/trace/trace_kprobe.c21
-rw-r--r--kernel/trace/trace_uprobe.c51
-rw-r--r--kernel/user_namespace.c17
-rw-r--r--kernel/workqueue.c44
27 files changed, 648 insertions, 298 deletions
diff --git a/kernel/Makefile b/kernel/Makefile
index 470839d1a30e..35ef1185e359 100644
--- a/kernel/Makefile
+++ b/kernel/Makefile
@@ -2,7 +2,7 @@
2# Makefile for the linux kernel. 2# Makefile for the linux kernel.
3# 3#
4 4
5obj-y = fork.o exec_domain.o panic.o printk.o \ 5obj-y = fork.o exec_domain.o panic.o \
6 cpu.o exit.o itimer.o time.o softirq.o resource.o \ 6 cpu.o exit.o itimer.o time.o softirq.o resource.o \
7 sysctl.o sysctl_binary.o capability.o ptrace.o timer.o user.o \ 7 sysctl.o sysctl_binary.o capability.o ptrace.o timer.o user.o \
8 signal.o sys.o kmod.o workqueue.o pid.o task_work.o \ 8 signal.o sys.o kmod.o workqueue.o pid.o task_work.o \
@@ -24,6 +24,7 @@ endif
24 24
25obj-y += sched/ 25obj-y += sched/
26obj-y += power/ 26obj-y += power/
27obj-y += printk/
27obj-y += cpu/ 28obj-y += cpu/
28 29
29obj-$(CONFIG_CHECKPOINT_RESTORE) += kcmp.o 30obj-$(CONFIG_CHECKPOINT_RESTORE) += kcmp.o
diff --git a/kernel/cgroup.c b/kernel/cgroup.c
index 789ec4683db3..781845a013ab 100644
--- a/kernel/cgroup.c
+++ b/kernel/cgroup.c
@@ -4335,8 +4335,10 @@ static long cgroup_create(struct cgroup *parent, struct dentry *dentry,
4335 } 4335 }
4336 4336
4337 err = percpu_ref_init(&css->refcnt, css_release); 4337 err = percpu_ref_init(&css->refcnt, css_release);
4338 if (err) 4338 if (err) {
4339 ss->css_free(cgrp);
4339 goto err_free_all; 4340 goto err_free_all;
4341 }
4340 4342
4341 init_cgroup_css(css, ss, cgrp); 4343 init_cgroup_css(css, ss, cgrp);
4342 4344
diff --git a/kernel/cpuset.c b/kernel/cpuset.c
index e5657788fedd..010a0083c0ae 100644
--- a/kernel/cpuset.c
+++ b/kernel/cpuset.c
@@ -1608,11 +1608,13 @@ static int cpuset_write_u64(struct cgroup *cgrp, struct cftype *cft, u64 val)
1608{ 1608{
1609 struct cpuset *cs = cgroup_cs(cgrp); 1609 struct cpuset *cs = cgroup_cs(cgrp);
1610 cpuset_filetype_t type = cft->private; 1610 cpuset_filetype_t type = cft->private;
1611 int retval = -ENODEV; 1611 int retval = 0;
1612 1612
1613 mutex_lock(&cpuset_mutex); 1613 mutex_lock(&cpuset_mutex);
1614 if (!is_cpuset_online(cs)) 1614 if (!is_cpuset_online(cs)) {
1615 retval = -ENODEV;
1615 goto out_unlock; 1616 goto out_unlock;
1617 }
1616 1618
1617 switch (type) { 1619 switch (type) {
1618 case FILE_CPU_EXCLUSIVE: 1620 case FILE_CPU_EXCLUSIVE:
diff --git a/kernel/fork.c b/kernel/fork.c
index 403d2bb8a968..e23bb19e2a3e 100644
--- a/kernel/fork.c
+++ b/kernel/fork.c
@@ -1679,6 +1679,12 @@ SYSCALL_DEFINE5(clone, unsigned long, newsp, unsigned long, clone_flags,
1679 int __user *, parent_tidptr, 1679 int __user *, parent_tidptr,
1680 int __user *, child_tidptr, 1680 int __user *, child_tidptr,
1681 int, tls_val) 1681 int, tls_val)
1682#elif defined(CONFIG_CLONE_BACKWARDS3)
1683SYSCALL_DEFINE6(clone, unsigned long, clone_flags, unsigned long, newsp,
1684 int, stack_size,
1685 int __user *, parent_tidptr,
1686 int __user *, child_tidptr,
1687 int, tls_val)
1682#else 1688#else
1683SYSCALL_DEFINE5(clone, unsigned long, clone_flags, unsigned long, newsp, 1689SYSCALL_DEFINE5(clone, unsigned long, clone_flags, unsigned long, newsp,
1684 int __user *, parent_tidptr, 1690 int __user *, parent_tidptr,
diff --git a/kernel/freezer.c b/kernel/freezer.c
index 8b2afc1c9df0..b462fa197517 100644
--- a/kernel/freezer.c
+++ b/kernel/freezer.c
@@ -33,7 +33,7 @@ static DEFINE_SPINLOCK(freezer_lock);
33 */ 33 */
34bool freezing_slow_path(struct task_struct *p) 34bool freezing_slow_path(struct task_struct *p)
35{ 35{
36 if (p->flags & PF_NOFREEZE) 36 if (p->flags & (PF_NOFREEZE | PF_SUSPEND_TASK))
37 return false; 37 return false;
38 38
39 if (pm_nosig_freezing || cgroup_freezing(p)) 39 if (pm_nosig_freezing || cgroup_freezing(p))
diff --git a/kernel/mutex.c b/kernel/mutex.c
index ff05f4bd86eb..a52ee7bb830d 100644
--- a/kernel/mutex.c
+++ b/kernel/mutex.c
@@ -686,7 +686,7 @@ __ww_mutex_lock(struct ww_mutex *lock, struct ww_acquire_ctx *ctx)
686 might_sleep(); 686 might_sleep();
687 ret = __mutex_lock_common(&lock->base, TASK_UNINTERRUPTIBLE, 687 ret = __mutex_lock_common(&lock->base, TASK_UNINTERRUPTIBLE,
688 0, &ctx->dep_map, _RET_IP_, ctx); 688 0, &ctx->dep_map, _RET_IP_, ctx);
689 if (!ret && ctx->acquired > 0) 689 if (!ret && ctx->acquired > 1)
690 return ww_mutex_deadlock_injection(lock, ctx); 690 return ww_mutex_deadlock_injection(lock, ctx);
691 691
692 return ret; 692 return ret;
@@ -702,7 +702,7 @@ __ww_mutex_lock_interruptible(struct ww_mutex *lock, struct ww_acquire_ctx *ctx)
702 ret = __mutex_lock_common(&lock->base, TASK_INTERRUPTIBLE, 702 ret = __mutex_lock_common(&lock->base, TASK_INTERRUPTIBLE,
703 0, &ctx->dep_map, _RET_IP_, ctx); 703 0, &ctx->dep_map, _RET_IP_, ctx);
704 704
705 if (!ret && ctx->acquired > 0) 705 if (!ret && ctx->acquired > 1)
706 return ww_mutex_deadlock_injection(lock, ctx); 706 return ww_mutex_deadlock_injection(lock, ctx);
707 707
708 return ret; 708 return ret;
diff --git a/kernel/power/process.c b/kernel/power/process.c
index fc0df8486449..06ec8869dbf1 100644
--- a/kernel/power/process.c
+++ b/kernel/power/process.c
@@ -109,6 +109,8 @@ static int try_to_freeze_tasks(bool user_only)
109 109
110/** 110/**
111 * freeze_processes - Signal user space processes to enter the refrigerator. 111 * freeze_processes - Signal user space processes to enter the refrigerator.
112 * The current thread will not be frozen. The same process that calls
113 * freeze_processes must later call thaw_processes.
112 * 114 *
113 * On success, returns 0. On failure, -errno and system is fully thawed. 115 * On success, returns 0. On failure, -errno and system is fully thawed.
114 */ 116 */
@@ -120,6 +122,9 @@ int freeze_processes(void)
120 if (error) 122 if (error)
121 return error; 123 return error;
122 124
125 /* Make sure this task doesn't get frozen */
126 current->flags |= PF_SUSPEND_TASK;
127
123 if (!pm_freezing) 128 if (!pm_freezing)
124 atomic_inc(&system_freezing_cnt); 129 atomic_inc(&system_freezing_cnt);
125 130
@@ -168,6 +173,7 @@ int freeze_kernel_threads(void)
168void thaw_processes(void) 173void thaw_processes(void)
169{ 174{
170 struct task_struct *g, *p; 175 struct task_struct *g, *p;
176 struct task_struct *curr = current;
171 177
172 if (pm_freezing) 178 if (pm_freezing)
173 atomic_dec(&system_freezing_cnt); 179 atomic_dec(&system_freezing_cnt);
@@ -182,10 +188,15 @@ void thaw_processes(void)
182 188
183 read_lock(&tasklist_lock); 189 read_lock(&tasklist_lock);
184 do_each_thread(g, p) { 190 do_each_thread(g, p) {
191 /* No other threads should have PF_SUSPEND_TASK set */
192 WARN_ON((p != curr) && (p->flags & PF_SUSPEND_TASK));
185 __thaw_task(p); 193 __thaw_task(p);
186 } while_each_thread(g, p); 194 } while_each_thread(g, p);
187 read_unlock(&tasklist_lock); 195 read_unlock(&tasklist_lock);
188 196
197 WARN_ON(!(curr->flags & PF_SUSPEND_TASK));
198 curr->flags &= ~PF_SUSPEND_TASK;
199
189 usermodehelper_enable(); 200 usermodehelper_enable();
190 201
191 schedule(); 202 schedule();
diff --git a/kernel/power/qos.c b/kernel/power/qos.c
index 06fe28589e9c..a394297f8b2f 100644
--- a/kernel/power/qos.c
+++ b/kernel/power/qos.c
@@ -296,6 +296,17 @@ int pm_qos_request_active(struct pm_qos_request *req)
296} 296}
297EXPORT_SYMBOL_GPL(pm_qos_request_active); 297EXPORT_SYMBOL_GPL(pm_qos_request_active);
298 298
299static void __pm_qos_update_request(struct pm_qos_request *req,
300 s32 new_value)
301{
302 trace_pm_qos_update_request(req->pm_qos_class, new_value);
303
304 if (new_value != req->node.prio)
305 pm_qos_update_target(
306 pm_qos_array[req->pm_qos_class]->constraints,
307 &req->node, PM_QOS_UPDATE_REQ, new_value);
308}
309
299/** 310/**
300 * pm_qos_work_fn - the timeout handler of pm_qos_update_request_timeout 311 * pm_qos_work_fn - the timeout handler of pm_qos_update_request_timeout
301 * @work: work struct for the delayed work (timeout) 312 * @work: work struct for the delayed work (timeout)
@@ -308,7 +319,7 @@ static void pm_qos_work_fn(struct work_struct *work)
308 struct pm_qos_request, 319 struct pm_qos_request,
309 work); 320 work);
310 321
311 pm_qos_update_request(req, PM_QOS_DEFAULT_VALUE); 322 __pm_qos_update_request(req, PM_QOS_DEFAULT_VALUE);
312} 323}
313 324
314/** 325/**
@@ -364,12 +375,7 @@ void pm_qos_update_request(struct pm_qos_request *req,
364 } 375 }
365 376
366 cancel_delayed_work_sync(&req->work); 377 cancel_delayed_work_sync(&req->work);
367 378 __pm_qos_update_request(req, new_value);
368 trace_pm_qos_update_request(req->pm_qos_class, new_value);
369 if (new_value != req->node.prio)
370 pm_qos_update_target(
371 pm_qos_array[req->pm_qos_class]->constraints,
372 &req->node, PM_QOS_UPDATE_REQ, new_value);
373} 379}
374EXPORT_SYMBOL_GPL(pm_qos_update_request); 380EXPORT_SYMBOL_GPL(pm_qos_update_request);
375 381
diff --git a/kernel/printk/Makefile b/kernel/printk/Makefile
new file mode 100644
index 000000000000..85405bdcf2b3
--- /dev/null
+++ b/kernel/printk/Makefile
@@ -0,0 +1,2 @@
1obj-y = printk.o
2obj-$(CONFIG_A11Y_BRAILLE_CONSOLE) += braille.o
diff --git a/kernel/printk/braille.c b/kernel/printk/braille.c
new file mode 100644
index 000000000000..276762f3a460
--- /dev/null
+++ b/kernel/printk/braille.c
@@ -0,0 +1,49 @@
1#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
2
3#include <linux/kernel.h>
4#include <linux/console.h>
5#include <linux/string.h>
6
7#include "console_cmdline.h"
8#include "braille.h"
9
10char *_braille_console_setup(char **str, char **brl_options)
11{
12 if (!memcmp(*str, "brl,", 4)) {
13 *brl_options = "";
14 *str += 4;
15 } else if (!memcmp(str, "brl=", 4)) {
16 *brl_options = *str + 4;
17 *str = strchr(*brl_options, ',');
18 if (!*str)
19 pr_err("need port name after brl=\n");
20 else
21 *((*str)++) = 0;
22 } else
23 return NULL;
24
25 return *str;
26}
27
28int
29_braille_register_console(struct console *console, struct console_cmdline *c)
30{
31 int rtn = 0;
32
33 if (c->brl_options) {
34 console->flags |= CON_BRL;
35 rtn = braille_register_console(console, c->index, c->options,
36 c->brl_options);
37 }
38
39 return rtn;
40}
41
42int
43_braille_unregister_console(struct console *console)
44{
45 if (console->flags & CON_BRL)
46 return braille_unregister_console(console);
47
48 return 0;
49}
diff --git a/kernel/printk/braille.h b/kernel/printk/braille.h
new file mode 100644
index 000000000000..769d771145c8
--- /dev/null
+++ b/kernel/printk/braille.h
@@ -0,0 +1,48 @@
1#ifndef _PRINTK_BRAILLE_H
2#define _PRINTK_BRAILLE_H
3
4#ifdef CONFIG_A11Y_BRAILLE_CONSOLE
5
6static inline void
7braille_set_options(struct console_cmdline *c, char *brl_options)
8{
9 c->brl_options = brl_options;
10}
11
12char *
13_braille_console_setup(char **str, char **brl_options);
14
15int
16_braille_register_console(struct console *console, struct console_cmdline *c);
17
18int
19_braille_unregister_console(struct console *console);
20
21#else
22
23static inline void
24braille_set_options(struct console_cmdline *c, char *brl_options)
25{
26}
27
28static inline char *
29_braille_console_setup(char **str, char **brl_options)
30{
31 return NULL;
32}
33
34static inline int
35_braille_register_console(struct console *console, struct console_cmdline *c)
36{
37 return 0;
38}
39
40static inline int
41_braille_unregister_console(struct console *console)
42{
43 return 0;
44}
45
46#endif
47
48#endif
diff --git a/kernel/printk/console_cmdline.h b/kernel/printk/console_cmdline.h
new file mode 100644
index 000000000000..cbd69d842341
--- /dev/null
+++ b/kernel/printk/console_cmdline.h
@@ -0,0 +1,14 @@
1#ifndef _CONSOLE_CMDLINE_H
2#define _CONSOLE_CMDLINE_H
3
4struct console_cmdline
5{
6 char name[8]; /* Name of the driver */
7 int index; /* Minor dev. to use */
8 char *options; /* Options for the driver */
9#ifdef CONFIG_A11Y_BRAILLE_CONSOLE
10 char *brl_options; /* Options for braille driver */
11#endif
12};
13
14#endif
diff --git a/kernel/printk.c b/kernel/printk/printk.c
index 69b0890ed7e5..5b5a7080e2a5 100644
--- a/kernel/printk.c
+++ b/kernel/printk/printk.c
@@ -51,6 +51,9 @@
51#define CREATE_TRACE_POINTS 51#define CREATE_TRACE_POINTS
52#include <trace/events/printk.h> 52#include <trace/events/printk.h>
53 53
54#include "console_cmdline.h"
55#include "braille.h"
56
54/* printk's without a loglevel use this.. */ 57/* printk's without a loglevel use this.. */
55#define DEFAULT_MESSAGE_LOGLEVEL CONFIG_DEFAULT_MESSAGE_LOGLEVEL 58#define DEFAULT_MESSAGE_LOGLEVEL CONFIG_DEFAULT_MESSAGE_LOGLEVEL
56 59
@@ -105,19 +108,11 @@ static struct console *exclusive_console;
105/* 108/*
106 * Array of consoles built from command line options (console=) 109 * Array of consoles built from command line options (console=)
107 */ 110 */
108struct console_cmdline
109{
110 char name[8]; /* Name of the driver */
111 int index; /* Minor dev. to use */
112 char *options; /* Options for the driver */
113#ifdef CONFIG_A11Y_BRAILLE_CONSOLE
114 char *brl_options; /* Options for braille driver */
115#endif
116};
117 111
118#define MAX_CMDLINECONSOLES 8 112#define MAX_CMDLINECONSOLES 8
119 113
120static struct console_cmdline console_cmdline[MAX_CMDLINECONSOLES]; 114static struct console_cmdline console_cmdline[MAX_CMDLINECONSOLES];
115
121static int selected_console = -1; 116static int selected_console = -1;
122static int preferred_console = -1; 117static int preferred_console = -1;
123int console_set_on_cmdline; 118int console_set_on_cmdline;
@@ -178,7 +173,7 @@ static int console_may_schedule;
178 * 67 "g" 173 * 67 "g"
179 * 0032 00 00 00 padding to next message header 174 * 0032 00 00 00 padding to next message header
180 * 175 *
181 * The 'struct log' buffer header must never be directly exported to 176 * The 'struct printk_log' buffer header must never be directly exported to
182 * userspace, it is a kernel-private implementation detail that might 177 * userspace, it is a kernel-private implementation detail that might
183 * need to be changed in the future, when the requirements change. 178 * need to be changed in the future, when the requirements change.
184 * 179 *
@@ -200,7 +195,7 @@ enum log_flags {
200 LOG_CONT = 8, /* text is a fragment of a continuation line */ 195 LOG_CONT = 8, /* text is a fragment of a continuation line */
201}; 196};
202 197
203struct log { 198struct printk_log {
204 u64 ts_nsec; /* timestamp in nanoseconds */ 199 u64 ts_nsec; /* timestamp in nanoseconds */
205 u16 len; /* length of entire record */ 200 u16 len; /* length of entire record */
206 u16 text_len; /* length of text buffer */ 201 u16 text_len; /* length of text buffer */
@@ -248,7 +243,7 @@ static u32 clear_idx;
248#if defined(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS) 243#if defined(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS)
249#define LOG_ALIGN 4 244#define LOG_ALIGN 4
250#else 245#else
251#define LOG_ALIGN __alignof__(struct log) 246#define LOG_ALIGN __alignof__(struct printk_log)
252#endif 247#endif
253#define __LOG_BUF_LEN (1 << CONFIG_LOG_BUF_SHIFT) 248#define __LOG_BUF_LEN (1 << CONFIG_LOG_BUF_SHIFT)
254static char __log_buf[__LOG_BUF_LEN] __aligned(LOG_ALIGN); 249static char __log_buf[__LOG_BUF_LEN] __aligned(LOG_ALIGN);
@@ -259,35 +254,35 @@ static u32 log_buf_len = __LOG_BUF_LEN;
259static volatile unsigned int logbuf_cpu = UINT_MAX; 254static volatile unsigned int logbuf_cpu = UINT_MAX;
260 255
261/* human readable text of the record */ 256/* human readable text of the record */
262static char *log_text(const struct log *msg) 257static char *log_text(const struct printk_log *msg)
263{ 258{
264 return (char *)msg + sizeof(struct log); 259 return (char *)msg + sizeof(struct printk_log);
265} 260}
266 261
267/* optional key/value pair dictionary attached to the record */ 262/* optional key/value pair dictionary attached to the record */
268static char *log_dict(const struct log *msg) 263static char *log_dict(const struct printk_log *msg)
269{ 264{
270 return (char *)msg + sizeof(struct log) + msg->text_len; 265 return (char *)msg + sizeof(struct printk_log) + msg->text_len;
271} 266}
272 267
273/* get record by index; idx must point to valid msg */ 268/* get record by index; idx must point to valid msg */
274static struct log *log_from_idx(u32 idx) 269static struct printk_log *log_from_idx(u32 idx)
275{ 270{
276 struct log *msg = (struct log *)(log_buf + idx); 271 struct printk_log *msg = (struct printk_log *)(log_buf + idx);
277 272
278 /* 273 /*
279 * A length == 0 record is the end of buffer marker. Wrap around and 274 * A length == 0 record is the end of buffer marker. Wrap around and
280 * read the message at the start of the buffer. 275 * read the message at the start of the buffer.
281 */ 276 */
282 if (!msg->len) 277 if (!msg->len)
283 return (struct log *)log_buf; 278 return (struct printk_log *)log_buf;
284 return msg; 279 return msg;
285} 280}
286 281
287/* get next record; idx must point to valid msg */ 282/* get next record; idx must point to valid msg */
288static u32 log_next(u32 idx) 283static u32 log_next(u32 idx)
289{ 284{
290 struct log *msg = (struct log *)(log_buf + idx); 285 struct printk_log *msg = (struct printk_log *)(log_buf + idx);
291 286
292 /* length == 0 indicates the end of the buffer; wrap */ 287 /* length == 0 indicates the end of the buffer; wrap */
293 /* 288 /*
@@ -296,7 +291,7 @@ static u32 log_next(u32 idx)
296 * return the one after that. 291 * return the one after that.
297 */ 292 */
298 if (!msg->len) { 293 if (!msg->len) {
299 msg = (struct log *)log_buf; 294 msg = (struct printk_log *)log_buf;
300 return msg->len; 295 return msg->len;
301 } 296 }
302 return idx + msg->len; 297 return idx + msg->len;
@@ -308,11 +303,11 @@ static void log_store(int facility, int level,
308 const char *dict, u16 dict_len, 303 const char *dict, u16 dict_len,
309 const char *text, u16 text_len) 304 const char *text, u16 text_len)
310{ 305{
311 struct log *msg; 306 struct printk_log *msg;
312 u32 size, pad_len; 307 u32 size, pad_len;
313 308
314 /* number of '\0' padding bytes to next message */ 309 /* number of '\0' padding bytes to next message */
315 size = sizeof(struct log) + text_len + dict_len; 310 size = sizeof(struct printk_log) + text_len + dict_len;
316 pad_len = (-size) & (LOG_ALIGN - 1); 311 pad_len = (-size) & (LOG_ALIGN - 1);
317 size += pad_len; 312 size += pad_len;
318 313
@@ -324,7 +319,7 @@ static void log_store(int facility, int level,
324 else 319 else
325 free = log_first_idx - log_next_idx; 320 free = log_first_idx - log_next_idx;
326 321
327 if (free > size + sizeof(struct log)) 322 if (free > size + sizeof(struct printk_log))
328 break; 323 break;
329 324
330 /* drop old messages until we have enough contiuous space */ 325 /* drop old messages until we have enough contiuous space */
@@ -332,18 +327,18 @@ static void log_store(int facility, int level,
332 log_first_seq++; 327 log_first_seq++;
333 } 328 }
334 329
335 if (log_next_idx + size + sizeof(struct log) >= log_buf_len) { 330 if (log_next_idx + size + sizeof(struct printk_log) >= log_buf_len) {
336 /* 331 /*
337 * This message + an additional empty header does not fit 332 * This message + an additional empty header does not fit
338 * at the end of the buffer. Add an empty header with len == 0 333 * at the end of the buffer. Add an empty header with len == 0
339 * to signify a wrap around. 334 * to signify a wrap around.
340 */ 335 */
341 memset(log_buf + log_next_idx, 0, sizeof(struct log)); 336 memset(log_buf + log_next_idx, 0, sizeof(struct printk_log));
342 log_next_idx = 0; 337 log_next_idx = 0;
343 } 338 }
344 339
345 /* fill message */ 340 /* fill message */
346 msg = (struct log *)(log_buf + log_next_idx); 341 msg = (struct printk_log *)(log_buf + log_next_idx);
347 memcpy(log_text(msg), text, text_len); 342 memcpy(log_text(msg), text, text_len);
348 msg->text_len = text_len; 343 msg->text_len = text_len;
349 memcpy(log_dict(msg), dict, dict_len); 344 memcpy(log_dict(msg), dict, dict_len);
@@ -356,7 +351,7 @@ static void log_store(int facility, int level,
356 else 351 else
357 msg->ts_nsec = local_clock(); 352 msg->ts_nsec = local_clock();
358 memset(log_dict(msg) + dict_len, 0, pad_len); 353 memset(log_dict(msg) + dict_len, 0, pad_len);
359 msg->len = sizeof(struct log) + text_len + dict_len + pad_len; 354 msg->len = sizeof(struct printk_log) + text_len + dict_len + pad_len;
360 355
361 /* insert message */ 356 /* insert message */
362 log_next_idx += msg->len; 357 log_next_idx += msg->len;
@@ -479,7 +474,7 @@ static ssize_t devkmsg_read(struct file *file, char __user *buf,
479 size_t count, loff_t *ppos) 474 size_t count, loff_t *ppos)
480{ 475{
481 struct devkmsg_user *user = file->private_data; 476 struct devkmsg_user *user = file->private_data;
482 struct log *msg; 477 struct printk_log *msg;
483 u64 ts_usec; 478 u64 ts_usec;
484 size_t i; 479 size_t i;
485 char cont = '-'; 480 char cont = '-';
@@ -724,14 +719,14 @@ void log_buf_kexec_setup(void)
724 VMCOREINFO_SYMBOL(log_first_idx); 719 VMCOREINFO_SYMBOL(log_first_idx);
725 VMCOREINFO_SYMBOL(log_next_idx); 720 VMCOREINFO_SYMBOL(log_next_idx);
726 /* 721 /*
727 * Export struct log size and field offsets. User space tools can 722 * Export struct printk_log size and field offsets. User space tools can
728 * parse it and detect any changes to structure down the line. 723 * parse it and detect any changes to structure down the line.
729 */ 724 */
730 VMCOREINFO_STRUCT_SIZE(log); 725 VMCOREINFO_STRUCT_SIZE(printk_log);
731 VMCOREINFO_OFFSET(log, ts_nsec); 726 VMCOREINFO_OFFSET(printk_log, ts_nsec);
732 VMCOREINFO_OFFSET(log, len); 727 VMCOREINFO_OFFSET(printk_log, len);
733 VMCOREINFO_OFFSET(log, text_len); 728 VMCOREINFO_OFFSET(printk_log, text_len);
734 VMCOREINFO_OFFSET(log, dict_len); 729 VMCOREINFO_OFFSET(printk_log, dict_len);
735} 730}
736#endif 731#endif
737 732
@@ -884,7 +879,7 @@ static size_t print_time(u64 ts, char *buf)
884 (unsigned long)ts, rem_nsec / 1000); 879 (unsigned long)ts, rem_nsec / 1000);
885} 880}
886 881
887static size_t print_prefix(const struct log *msg, bool syslog, char *buf) 882static size_t print_prefix(const struct printk_log *msg, bool syslog, char *buf)
888{ 883{
889 size_t len = 0; 884 size_t len = 0;
890 unsigned int prefix = (msg->facility << 3) | msg->level; 885 unsigned int prefix = (msg->facility << 3) | msg->level;
@@ -907,7 +902,7 @@ static size_t print_prefix(const struct log *msg, bool syslog, char *buf)
907 return len; 902 return len;
908} 903}
909 904
910static size_t msg_print_text(const struct log *msg, enum log_flags prev, 905static size_t msg_print_text(const struct printk_log *msg, enum log_flags prev,
911 bool syslog, char *buf, size_t size) 906 bool syslog, char *buf, size_t size)
912{ 907{
913 const char *text = log_text(msg); 908 const char *text = log_text(msg);
@@ -969,7 +964,7 @@ static size_t msg_print_text(const struct log *msg, enum log_flags prev,
969static int syslog_print(char __user *buf, int size) 964static int syslog_print(char __user *buf, int size)
970{ 965{
971 char *text; 966 char *text;
972 struct log *msg; 967 struct printk_log *msg;
973 int len = 0; 968 int len = 0;
974 969
975 text = kmalloc(LOG_LINE_MAX + PREFIX_MAX, GFP_KERNEL); 970 text = kmalloc(LOG_LINE_MAX + PREFIX_MAX, GFP_KERNEL);
@@ -1060,7 +1055,7 @@ static int syslog_print_all(char __user *buf, int size, bool clear)
1060 idx = clear_idx; 1055 idx = clear_idx;
1061 prev = 0; 1056 prev = 0;
1062 while (seq < log_next_seq) { 1057 while (seq < log_next_seq) {
1063 struct log *msg = log_from_idx(idx); 1058 struct printk_log *msg = log_from_idx(idx);
1064 1059
1065 len += msg_print_text(msg, prev, true, NULL, 0); 1060 len += msg_print_text(msg, prev, true, NULL, 0);
1066 prev = msg->flags; 1061 prev = msg->flags;
@@ -1073,7 +1068,7 @@ static int syslog_print_all(char __user *buf, int size, bool clear)
1073 idx = clear_idx; 1068 idx = clear_idx;
1074 prev = 0; 1069 prev = 0;
1075 while (len > size && seq < log_next_seq) { 1070 while (len > size && seq < log_next_seq) {
1076 struct log *msg = log_from_idx(idx); 1071 struct printk_log *msg = log_from_idx(idx);
1077 1072
1078 len -= msg_print_text(msg, prev, true, NULL, 0); 1073 len -= msg_print_text(msg, prev, true, NULL, 0);
1079 prev = msg->flags; 1074 prev = msg->flags;
@@ -1087,7 +1082,7 @@ static int syslog_print_all(char __user *buf, int size, bool clear)
1087 len = 0; 1082 len = 0;
1088 prev = 0; 1083 prev = 0;
1089 while (len >= 0 && seq < next_seq) { 1084 while (len >= 0 && seq < next_seq) {
1090 struct log *msg = log_from_idx(idx); 1085 struct printk_log *msg = log_from_idx(idx);
1091 int textlen; 1086 int textlen;
1092 1087
1093 textlen = msg_print_text(msg, prev, true, text, 1088 textlen = msg_print_text(msg, prev, true, text,
@@ -1233,7 +1228,7 @@ int do_syslog(int type, char __user *buf, int len, bool from_file)
1233 1228
1234 error = 0; 1229 error = 0;
1235 while (seq < log_next_seq) { 1230 while (seq < log_next_seq) {
1236 struct log *msg = log_from_idx(idx); 1231 struct printk_log *msg = log_from_idx(idx);
1237 1232
1238 error += msg_print_text(msg, prev, true, NULL, 0); 1233 error += msg_print_text(msg, prev, true, NULL, 0);
1239 idx = log_next(idx); 1234 idx = log_next(idx);
@@ -1719,10 +1714,10 @@ static struct cont {
1719 u8 level; 1714 u8 level;
1720 bool flushed:1; 1715 bool flushed:1;
1721} cont; 1716} cont;
1722static struct log *log_from_idx(u32 idx) { return NULL; } 1717static struct printk_log *log_from_idx(u32 idx) { return NULL; }
1723static u32 log_next(u32 idx) { return 0; } 1718static u32 log_next(u32 idx) { return 0; }
1724static void call_console_drivers(int level, const char *text, size_t len) {} 1719static void call_console_drivers(int level, const char *text, size_t len) {}
1725static size_t msg_print_text(const struct log *msg, enum log_flags prev, 1720static size_t msg_print_text(const struct printk_log *msg, enum log_flags prev,
1726 bool syslog, char *buf, size_t size) { return 0; } 1721 bool syslog, char *buf, size_t size) { return 0; }
1727static size_t cont_print_text(char *text, size_t size) { return 0; } 1722static size_t cont_print_text(char *text, size_t size) { return 0; }
1728 1723
@@ -1761,23 +1756,23 @@ static int __add_preferred_console(char *name, int idx, char *options,
1761 * See if this tty is not yet registered, and 1756 * See if this tty is not yet registered, and
1762 * if we have a slot free. 1757 * if we have a slot free.
1763 */ 1758 */
1764 for (i = 0; i < MAX_CMDLINECONSOLES && console_cmdline[i].name[0]; i++) 1759 for (i = 0, c = console_cmdline;
1765 if (strcmp(console_cmdline[i].name, name) == 0 && 1760 i < MAX_CMDLINECONSOLES && c->name[0];
1766 console_cmdline[i].index == idx) { 1761 i++, c++) {
1767 if (!brl_options) 1762 if (strcmp(c->name, name) == 0 && c->index == idx) {
1768 selected_console = i; 1763 if (!brl_options)
1769 return 0; 1764 selected_console = i;
1765 return 0;
1770 } 1766 }
1767 }
1771 if (i == MAX_CMDLINECONSOLES) 1768 if (i == MAX_CMDLINECONSOLES)
1772 return -E2BIG; 1769 return -E2BIG;
1773 if (!brl_options) 1770 if (!brl_options)
1774 selected_console = i; 1771 selected_console = i;
1775 c = &console_cmdline[i];
1776 strlcpy(c->name, name, sizeof(c->name)); 1772 strlcpy(c->name, name, sizeof(c->name));
1777 c->options = options; 1773 c->options = options;
1778#ifdef CONFIG_A11Y_BRAILLE_CONSOLE 1774 braille_set_options(c, brl_options);
1779 c->brl_options = brl_options; 1775
1780#endif
1781 c->index = idx; 1776 c->index = idx;
1782 return 0; 1777 return 0;
1783} 1778}
@@ -1790,20 +1785,8 @@ static int __init console_setup(char *str)
1790 char *s, *options, *brl_options = NULL; 1785 char *s, *options, *brl_options = NULL;
1791 int idx; 1786 int idx;
1792 1787
1793#ifdef CONFIG_A11Y_BRAILLE_CONSOLE 1788 if (_braille_console_setup(&str, &brl_options))
1794 if (!memcmp(str, "brl,", 4)) { 1789 return 1;
1795 brl_options = "";
1796 str += 4;
1797 } else if (!memcmp(str, "brl=", 4)) {
1798 brl_options = str + 4;
1799 str = strchr(brl_options, ',');
1800 if (!str) {
1801 printk(KERN_ERR "need port name after brl=\n");
1802 return 1;
1803 }
1804 *(str++) = 0;
1805 }
1806#endif
1807 1790
1808 /* 1791 /*
1809 * Decode str into name, index, options. 1792 * Decode str into name, index, options.
@@ -1858,15 +1841,15 @@ int update_console_cmdline(char *name, int idx, char *name_new, int idx_new, cha
1858 struct console_cmdline *c; 1841 struct console_cmdline *c;
1859 int i; 1842 int i;
1860 1843
1861 for (i = 0; i < MAX_CMDLINECONSOLES && console_cmdline[i].name[0]; i++) 1844 for (i = 0, c = console_cmdline;
1862 if (strcmp(console_cmdline[i].name, name) == 0 && 1845 i < MAX_CMDLINECONSOLES && c->name[0];
1863 console_cmdline[i].index == idx) { 1846 i++, c++)
1864 c = &console_cmdline[i]; 1847 if (strcmp(c->name, name) == 0 && c->index == idx) {
1865 strlcpy(c->name, name_new, sizeof(c->name)); 1848 strlcpy(c->name, name_new, sizeof(c->name));
1866 c->name[sizeof(c->name) - 1] = 0; 1849 c->name[sizeof(c->name) - 1] = 0;
1867 c->options = options; 1850 c->options = options;
1868 c->index = idx_new; 1851 c->index = idx_new;
1869 return i; 1852 return i;
1870 } 1853 }
1871 /* not found */ 1854 /* not found */
1872 return -1; 1855 return -1;
@@ -2046,7 +2029,7 @@ void console_unlock(void)
2046 console_cont_flush(text, sizeof(text)); 2029 console_cont_flush(text, sizeof(text));
2047again: 2030again:
2048 for (;;) { 2031 for (;;) {
2049 struct log *msg; 2032 struct printk_log *msg;
2050 size_t len; 2033 size_t len;
2051 int level; 2034 int level;
2052 2035
@@ -2241,6 +2224,7 @@ void register_console(struct console *newcon)
2241 int i; 2224 int i;
2242 unsigned long flags; 2225 unsigned long flags;
2243 struct console *bcon = NULL; 2226 struct console *bcon = NULL;
2227 struct console_cmdline *c;
2244 2228
2245 /* 2229 /*
2246 * before we register a new CON_BOOT console, make sure we don't 2230 * before we register a new CON_BOOT console, make sure we don't
@@ -2288,30 +2272,25 @@ void register_console(struct console *newcon)
2288 * See if this console matches one we selected on 2272 * See if this console matches one we selected on
2289 * the command line. 2273 * the command line.
2290 */ 2274 */
2291 for (i = 0; i < MAX_CMDLINECONSOLES && console_cmdline[i].name[0]; 2275 for (i = 0, c = console_cmdline;
2292 i++) { 2276 i < MAX_CMDLINECONSOLES && c->name[0];
2293 if (strcmp(console_cmdline[i].name, newcon->name) != 0) 2277 i++, c++) {
2278 if (strcmp(c->name, newcon->name) != 0)
2294 continue; 2279 continue;
2295 if (newcon->index >= 0 && 2280 if (newcon->index >= 0 &&
2296 newcon->index != console_cmdline[i].index) 2281 newcon->index != c->index)
2297 continue; 2282 continue;
2298 if (newcon->index < 0) 2283 if (newcon->index < 0)
2299 newcon->index = console_cmdline[i].index; 2284 newcon->index = c->index;
2300#ifdef CONFIG_A11Y_BRAILLE_CONSOLE 2285
2301 if (console_cmdline[i].brl_options) { 2286 if (_braille_register_console(newcon, c))
2302 newcon->flags |= CON_BRL;
2303 braille_register_console(newcon,
2304 console_cmdline[i].index,
2305 console_cmdline[i].options,
2306 console_cmdline[i].brl_options);
2307 return; 2287 return;
2308 } 2288
2309#endif
2310 if (newcon->setup && 2289 if (newcon->setup &&
2311 newcon->setup(newcon, console_cmdline[i].options) != 0) 2290 newcon->setup(newcon, console_cmdline[i].options) != 0)
2312 break; 2291 break;
2313 newcon->flags |= CON_ENABLED; 2292 newcon->flags |= CON_ENABLED;
2314 newcon->index = console_cmdline[i].index; 2293 newcon->index = c->index;
2315 if (i == selected_console) { 2294 if (i == selected_console) {
2316 newcon->flags |= CON_CONSDEV; 2295 newcon->flags |= CON_CONSDEV;
2317 preferred_console = selected_console; 2296 preferred_console = selected_console;
@@ -2394,13 +2373,13 @@ EXPORT_SYMBOL(register_console);
2394int unregister_console(struct console *console) 2373int unregister_console(struct console *console)
2395{ 2374{
2396 struct console *a, *b; 2375 struct console *a, *b;
2397 int res = 1; 2376 int res;
2398 2377
2399#ifdef CONFIG_A11Y_BRAILLE_CONSOLE 2378 res = _braille_unregister_console(console);
2400 if (console->flags & CON_BRL) 2379 if (res)
2401 return braille_unregister_console(console); 2380 return res;
2402#endif
2403 2381
2382 res = 1;
2404 console_lock(); 2383 console_lock();
2405 if (console_drivers == console) { 2384 if (console_drivers == console) {
2406 console_drivers=console->next; 2385 console_drivers=console->next;
@@ -2666,7 +2645,7 @@ void kmsg_dump(enum kmsg_dump_reason reason)
2666bool kmsg_dump_get_line_nolock(struct kmsg_dumper *dumper, bool syslog, 2645bool kmsg_dump_get_line_nolock(struct kmsg_dumper *dumper, bool syslog,
2667 char *line, size_t size, size_t *len) 2646 char *line, size_t size, size_t *len)
2668{ 2647{
2669 struct log *msg; 2648 struct printk_log *msg;
2670 size_t l = 0; 2649 size_t l = 0;
2671 bool ret = false; 2650 bool ret = false;
2672 2651
@@ -2778,7 +2757,7 @@ bool kmsg_dump_get_buffer(struct kmsg_dumper *dumper, bool syslog,
2778 idx = dumper->cur_idx; 2757 idx = dumper->cur_idx;
2779 prev = 0; 2758 prev = 0;
2780 while (seq < dumper->next_seq) { 2759 while (seq < dumper->next_seq) {
2781 struct log *msg = log_from_idx(idx); 2760 struct printk_log *msg = log_from_idx(idx);
2782 2761
2783 l += msg_print_text(msg, prev, true, NULL, 0); 2762 l += msg_print_text(msg, prev, true, NULL, 0);
2784 idx = log_next(idx); 2763 idx = log_next(idx);
@@ -2791,7 +2770,7 @@ bool kmsg_dump_get_buffer(struct kmsg_dumper *dumper, bool syslog,
2791 idx = dumper->cur_idx; 2770 idx = dumper->cur_idx;
2792 prev = 0; 2771 prev = 0;
2793 while (l > size && seq < dumper->next_seq) { 2772 while (l > size && seq < dumper->next_seq) {
2794 struct log *msg = log_from_idx(idx); 2773 struct printk_log *msg = log_from_idx(idx);
2795 2774
2796 l -= msg_print_text(msg, prev, true, NULL, 0); 2775 l -= msg_print_text(msg, prev, true, NULL, 0);
2797 idx = log_next(idx); 2776 idx = log_next(idx);
@@ -2806,7 +2785,7 @@ bool kmsg_dump_get_buffer(struct kmsg_dumper *dumper, bool syslog,
2806 l = 0; 2785 l = 0;
2807 prev = 0; 2786 prev = 0;
2808 while (seq < dumper->next_seq) { 2787 while (seq < dumper->next_seq) {
2809 struct log *msg = log_from_idx(idx); 2788 struct printk_log *msg = log_from_idx(idx);
2810 2789
2811 l += msg_print_text(msg, prev, syslog, buf + l, size - l); 2790 l += msg_print_text(msg, prev, syslog, buf + l, size - l);
2812 idx = log_next(idx); 2791 idx = log_next(idx);
diff --git a/kernel/ptrace.c b/kernel/ptrace.c
index 4041f5747e73..a146ee327f6a 100644
--- a/kernel/ptrace.c
+++ b/kernel/ptrace.c
@@ -469,7 +469,6 @@ static int ptrace_detach(struct task_struct *child, unsigned int data)
469 /* Architecture-specific hardware disable .. */ 469 /* Architecture-specific hardware disable .. */
470 ptrace_disable(child); 470 ptrace_disable(child);
471 clear_tsk_thread_flag(child, TIF_SYSCALL_TRACE); 471 clear_tsk_thread_flag(child, TIF_SYSCALL_TRACE);
472 flush_ptrace_hw_breakpoint(child);
473 472
474 write_lock_irq(&tasklist_lock); 473 write_lock_irq(&tasklist_lock);
475 /* 474 /*
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index b7c32cb7bfeb..05c39f030314 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -933,6 +933,8 @@ static int effective_prio(struct task_struct *p)
933/** 933/**
934 * task_curr - is this task currently executing on a CPU? 934 * task_curr - is this task currently executing on a CPU?
935 * @p: the task in question. 935 * @p: the task in question.
936 *
937 * Return: 1 if the task is currently executing. 0 otherwise.
936 */ 938 */
937inline int task_curr(const struct task_struct *p) 939inline int task_curr(const struct task_struct *p)
938{ 940{
@@ -1482,7 +1484,7 @@ static void ttwu_queue(struct task_struct *p, int cpu)
1482 * the simpler "current->state = TASK_RUNNING" to mark yourself 1484 * the simpler "current->state = TASK_RUNNING" to mark yourself
1483 * runnable without the overhead of this. 1485 * runnable without the overhead of this.
1484 * 1486 *
1485 * Returns %true if @p was woken up, %false if it was already running 1487 * Return: %true if @p was woken up, %false if it was already running.
1486 * or @state didn't match @p's state. 1488 * or @state didn't match @p's state.
1487 */ 1489 */
1488static int 1490static int
@@ -1491,7 +1493,13 @@ try_to_wake_up(struct task_struct *p, unsigned int state, int wake_flags)
1491 unsigned long flags; 1493 unsigned long flags;
1492 int cpu, success = 0; 1494 int cpu, success = 0;
1493 1495
1494 smp_wmb(); 1496 /*
1497 * If we are going to wake up a thread waiting for CONDITION we
1498 * need to ensure that CONDITION=1 done by the caller can not be
1499 * reordered with p->state check below. This pairs with mb() in
1500 * set_current_state() the waiting thread does.
1501 */
1502 smp_mb__before_spinlock();
1495 raw_spin_lock_irqsave(&p->pi_lock, flags); 1503 raw_spin_lock_irqsave(&p->pi_lock, flags);
1496 if (!(p->state & state)) 1504 if (!(p->state & state))
1497 goto out; 1505 goto out;
@@ -1577,8 +1585,9 @@ out:
1577 * @p: The process to be woken up. 1585 * @p: The process to be woken up.
1578 * 1586 *
1579 * Attempt to wake up the nominated process and move it to the set of runnable 1587 * Attempt to wake up the nominated process and move it to the set of runnable
1580 * processes. Returns 1 if the process was woken up, 0 if it was already 1588 * processes.
1581 * running. 1589 *
1590 * Return: 1 if the process was woken up, 0 if it was already running.
1582 * 1591 *
1583 * It may be assumed that this function implies a write memory barrier before 1592 * It may be assumed that this function implies a write memory barrier before
1584 * changing the task state if and only if any tasks are woken up. 1593 * changing the task state if and only if any tasks are woken up.
@@ -2191,6 +2200,8 @@ void scheduler_tick(void)
2191 * This makes sure that uptime, CFS vruntime, load 2200 * This makes sure that uptime, CFS vruntime, load
2192 * balancing, etc... continue to move forward, even 2201 * balancing, etc... continue to move forward, even
2193 * with a very low granularity. 2202 * with a very low granularity.
2203 *
2204 * Return: Maximum deferment in nanoseconds.
2194 */ 2205 */
2195u64 scheduler_tick_max_deferment(void) 2206u64 scheduler_tick_max_deferment(void)
2196{ 2207{
@@ -2394,6 +2405,12 @@ need_resched:
2394 if (sched_feat(HRTICK)) 2405 if (sched_feat(HRTICK))
2395 hrtick_clear(rq); 2406 hrtick_clear(rq);
2396 2407
2408 /*
2409 * Make sure that signal_pending_state()->signal_pending() below
2410 * can't be reordered with __set_current_state(TASK_INTERRUPTIBLE)
2411 * done by the caller to avoid the race with signal_wake_up().
2412 */
2413 smp_mb__before_spinlock();
2397 raw_spin_lock_irq(&rq->lock); 2414 raw_spin_lock_irq(&rq->lock);
2398 2415
2399 switch_count = &prev->nivcsw; 2416 switch_count = &prev->nivcsw;
@@ -2796,8 +2813,8 @@ EXPORT_SYMBOL(wait_for_completion);
2796 * specified timeout to expire. The timeout is in jiffies. It is not 2813 * specified timeout to expire. The timeout is in jiffies. It is not
2797 * interruptible. 2814 * interruptible.
2798 * 2815 *
2799 * The return value is 0 if timed out, and positive (at least 1, or number of 2816 * Return: 0 if timed out, and positive (at least 1, or number of jiffies left
2800 * jiffies left till timeout) if completed. 2817 * till timeout) if completed.
2801 */ 2818 */
2802unsigned long __sched 2819unsigned long __sched
2803wait_for_completion_timeout(struct completion *x, unsigned long timeout) 2820wait_for_completion_timeout(struct completion *x, unsigned long timeout)
@@ -2829,8 +2846,8 @@ EXPORT_SYMBOL(wait_for_completion_io);
2829 * specified timeout to expire. The timeout is in jiffies. It is not 2846 * specified timeout to expire. The timeout is in jiffies. It is not
2830 * interruptible. The caller is accounted as waiting for IO. 2847 * interruptible. The caller is accounted as waiting for IO.
2831 * 2848 *
2832 * The return value is 0 if timed out, and positive (at least 1, or number of 2849 * Return: 0 if timed out, and positive (at least 1, or number of jiffies left
2833 * jiffies left till timeout) if completed. 2850 * till timeout) if completed.
2834 */ 2851 */
2835unsigned long __sched 2852unsigned long __sched
2836wait_for_completion_io_timeout(struct completion *x, unsigned long timeout) 2853wait_for_completion_io_timeout(struct completion *x, unsigned long timeout)
@@ -2846,7 +2863,7 @@ EXPORT_SYMBOL(wait_for_completion_io_timeout);
2846 * This waits for completion of a specific task to be signaled. It is 2863 * This waits for completion of a specific task to be signaled. It is
2847 * interruptible. 2864 * interruptible.
2848 * 2865 *
2849 * The return value is -ERESTARTSYS if interrupted, 0 if completed. 2866 * Return: -ERESTARTSYS if interrupted, 0 if completed.
2850 */ 2867 */
2851int __sched wait_for_completion_interruptible(struct completion *x) 2868int __sched wait_for_completion_interruptible(struct completion *x)
2852{ 2869{
@@ -2865,8 +2882,8 @@ EXPORT_SYMBOL(wait_for_completion_interruptible);
2865 * This waits for either a completion of a specific task to be signaled or for a 2882 * This waits for either a completion of a specific task to be signaled or for a
2866 * specified timeout to expire. It is interruptible. The timeout is in jiffies. 2883 * specified timeout to expire. It is interruptible. The timeout is in jiffies.
2867 * 2884 *
2868 * The return value is -ERESTARTSYS if interrupted, 0 if timed out, 2885 * Return: -ERESTARTSYS if interrupted, 0 if timed out, positive (at least 1,
2869 * positive (at least 1, or number of jiffies left till timeout) if completed. 2886 * or number of jiffies left till timeout) if completed.
2870 */ 2887 */
2871long __sched 2888long __sched
2872wait_for_completion_interruptible_timeout(struct completion *x, 2889wait_for_completion_interruptible_timeout(struct completion *x,
@@ -2883,7 +2900,7 @@ EXPORT_SYMBOL(wait_for_completion_interruptible_timeout);
2883 * This waits to be signaled for completion of a specific task. It can be 2900 * This waits to be signaled for completion of a specific task. It can be
2884 * interrupted by a kill signal. 2901 * interrupted by a kill signal.
2885 * 2902 *
2886 * The return value is -ERESTARTSYS if interrupted, 0 if completed. 2903 * Return: -ERESTARTSYS if interrupted, 0 if completed.
2887 */ 2904 */
2888int __sched wait_for_completion_killable(struct completion *x) 2905int __sched wait_for_completion_killable(struct completion *x)
2889{ 2906{
@@ -2903,8 +2920,8 @@ EXPORT_SYMBOL(wait_for_completion_killable);
2903 * signaled or for a specified timeout to expire. It can be 2920 * signaled or for a specified timeout to expire. It can be
2904 * interrupted by a kill signal. The timeout is in jiffies. 2921 * interrupted by a kill signal. The timeout is in jiffies.
2905 * 2922 *
2906 * The return value is -ERESTARTSYS if interrupted, 0 if timed out, 2923 * Return: -ERESTARTSYS if interrupted, 0 if timed out, positive (at least 1,
2907 * positive (at least 1, or number of jiffies left till timeout) if completed. 2924 * or number of jiffies left till timeout) if completed.
2908 */ 2925 */
2909long __sched 2926long __sched
2910wait_for_completion_killable_timeout(struct completion *x, 2927wait_for_completion_killable_timeout(struct completion *x,
@@ -2918,7 +2935,7 @@ EXPORT_SYMBOL(wait_for_completion_killable_timeout);
2918 * try_wait_for_completion - try to decrement a completion without blocking 2935 * try_wait_for_completion - try to decrement a completion without blocking
2919 * @x: completion structure 2936 * @x: completion structure
2920 * 2937 *
2921 * Returns: 0 if a decrement cannot be done without blocking 2938 * Return: 0 if a decrement cannot be done without blocking
2922 * 1 if a decrement succeeded. 2939 * 1 if a decrement succeeded.
2923 * 2940 *
2924 * If a completion is being used as a counting completion, 2941 * If a completion is being used as a counting completion,
@@ -2945,7 +2962,7 @@ EXPORT_SYMBOL(try_wait_for_completion);
2945 * completion_done - Test to see if a completion has any waiters 2962 * completion_done - Test to see if a completion has any waiters
2946 * @x: completion structure 2963 * @x: completion structure
2947 * 2964 *
2948 * Returns: 0 if there are waiters (wait_for_completion() in progress) 2965 * Return: 0 if there are waiters (wait_for_completion() in progress)
2949 * 1 if there are no waiters. 2966 * 1 if there are no waiters.
2950 * 2967 *
2951 */ 2968 */
@@ -3182,7 +3199,7 @@ SYSCALL_DEFINE1(nice, int, increment)
3182 * task_prio - return the priority value of a given task. 3199 * task_prio - return the priority value of a given task.
3183 * @p: the task in question. 3200 * @p: the task in question.
3184 * 3201 *
3185 * This is the priority value as seen by users in /proc. 3202 * Return: The priority value as seen by users in /proc.
3186 * RT tasks are offset by -200. Normal tasks are centered 3203 * RT tasks are offset by -200. Normal tasks are centered
3187 * around 0, value goes from -16 to +15. 3204 * around 0, value goes from -16 to +15.
3188 */ 3205 */
@@ -3194,6 +3211,8 @@ int task_prio(const struct task_struct *p)
3194/** 3211/**
3195 * task_nice - return the nice value of a given task. 3212 * task_nice - return the nice value of a given task.
3196 * @p: the task in question. 3213 * @p: the task in question.
3214 *
3215 * Return: The nice value [ -20 ... 0 ... 19 ].
3197 */ 3216 */
3198int task_nice(const struct task_struct *p) 3217int task_nice(const struct task_struct *p)
3199{ 3218{
@@ -3204,6 +3223,8 @@ EXPORT_SYMBOL(task_nice);
3204/** 3223/**
3205 * idle_cpu - is a given cpu idle currently? 3224 * idle_cpu - is a given cpu idle currently?
3206 * @cpu: the processor in question. 3225 * @cpu: the processor in question.
3226 *
3227 * Return: 1 if the CPU is currently idle. 0 otherwise.
3207 */ 3228 */
3208int idle_cpu(int cpu) 3229int idle_cpu(int cpu)
3209{ 3230{
@@ -3226,6 +3247,8 @@ int idle_cpu(int cpu)
3226/** 3247/**
3227 * idle_task - return the idle task for a given cpu. 3248 * idle_task - return the idle task for a given cpu.
3228 * @cpu: the processor in question. 3249 * @cpu: the processor in question.
3250 *
3251 * Return: The idle task for the cpu @cpu.
3229 */ 3252 */
3230struct task_struct *idle_task(int cpu) 3253struct task_struct *idle_task(int cpu)
3231{ 3254{
@@ -3235,6 +3258,8 @@ struct task_struct *idle_task(int cpu)
3235/** 3258/**
3236 * find_process_by_pid - find a process with a matching PID value. 3259 * find_process_by_pid - find a process with a matching PID value.
3237 * @pid: the pid in question. 3260 * @pid: the pid in question.
3261 *
3262 * The task of @pid, if found. %NULL otherwise.
3238 */ 3263 */
3239static struct task_struct *find_process_by_pid(pid_t pid) 3264static struct task_struct *find_process_by_pid(pid_t pid)
3240{ 3265{
@@ -3432,6 +3457,8 @@ recheck:
3432 * @policy: new policy. 3457 * @policy: new policy.
3433 * @param: structure containing the new RT priority. 3458 * @param: structure containing the new RT priority.
3434 * 3459 *
3460 * Return: 0 on success. An error code otherwise.
3461 *
3435 * NOTE that the task may be already dead. 3462 * NOTE that the task may be already dead.
3436 */ 3463 */
3437int sched_setscheduler(struct task_struct *p, int policy, 3464int sched_setscheduler(struct task_struct *p, int policy,
@@ -3451,6 +3478,8 @@ EXPORT_SYMBOL_GPL(sched_setscheduler);
3451 * current context has permission. For example, this is needed in 3478 * current context has permission. For example, this is needed in
3452 * stop_machine(): we create temporary high priority worker threads, 3479 * stop_machine(): we create temporary high priority worker threads,
3453 * but our caller might not have that capability. 3480 * but our caller might not have that capability.
3481 *
3482 * Return: 0 on success. An error code otherwise.
3454 */ 3483 */
3455int sched_setscheduler_nocheck(struct task_struct *p, int policy, 3484int sched_setscheduler_nocheck(struct task_struct *p, int policy,
3456 const struct sched_param *param) 3485 const struct sched_param *param)
@@ -3485,6 +3514,8 @@ do_sched_setscheduler(pid_t pid, int policy, struct sched_param __user *param)
3485 * @pid: the pid in question. 3514 * @pid: the pid in question.
3486 * @policy: new policy. 3515 * @policy: new policy.
3487 * @param: structure containing the new RT priority. 3516 * @param: structure containing the new RT priority.
3517 *
3518 * Return: 0 on success. An error code otherwise.
3488 */ 3519 */
3489SYSCALL_DEFINE3(sched_setscheduler, pid_t, pid, int, policy, 3520SYSCALL_DEFINE3(sched_setscheduler, pid_t, pid, int, policy,
3490 struct sched_param __user *, param) 3521 struct sched_param __user *, param)
@@ -3500,6 +3531,8 @@ SYSCALL_DEFINE3(sched_setscheduler, pid_t, pid, int, policy,
3500 * sys_sched_setparam - set/change the RT priority of a thread 3531 * sys_sched_setparam - set/change the RT priority of a thread
3501 * @pid: the pid in question. 3532 * @pid: the pid in question.
3502 * @param: structure containing the new RT priority. 3533 * @param: structure containing the new RT priority.
3534 *
3535 * Return: 0 on success. An error code otherwise.
3503 */ 3536 */
3504SYSCALL_DEFINE2(sched_setparam, pid_t, pid, struct sched_param __user *, param) 3537SYSCALL_DEFINE2(sched_setparam, pid_t, pid, struct sched_param __user *, param)
3505{ 3538{
@@ -3509,6 +3542,9 @@ SYSCALL_DEFINE2(sched_setparam, pid_t, pid, struct sched_param __user *, param)
3509/** 3542/**
3510 * sys_sched_getscheduler - get the policy (scheduling class) of a thread 3543 * sys_sched_getscheduler - get the policy (scheduling class) of a thread
3511 * @pid: the pid in question. 3544 * @pid: the pid in question.
3545 *
3546 * Return: On success, the policy of the thread. Otherwise, a negative error
3547 * code.
3512 */ 3548 */
3513SYSCALL_DEFINE1(sched_getscheduler, pid_t, pid) 3549SYSCALL_DEFINE1(sched_getscheduler, pid_t, pid)
3514{ 3550{
@@ -3535,6 +3571,9 @@ SYSCALL_DEFINE1(sched_getscheduler, pid_t, pid)
3535 * sys_sched_getparam - get the RT priority of a thread 3571 * sys_sched_getparam - get the RT priority of a thread
3536 * @pid: the pid in question. 3572 * @pid: the pid in question.
3537 * @param: structure containing the RT priority. 3573 * @param: structure containing the RT priority.
3574 *
3575 * Return: On success, 0 and the RT priority is in @param. Otherwise, an error
3576 * code.
3538 */ 3577 */
3539SYSCALL_DEFINE2(sched_getparam, pid_t, pid, struct sched_param __user *, param) 3578SYSCALL_DEFINE2(sched_getparam, pid_t, pid, struct sched_param __user *, param)
3540{ 3579{
@@ -3659,6 +3698,8 @@ static int get_user_cpu_mask(unsigned long __user *user_mask_ptr, unsigned len,
3659 * @pid: pid of the process 3698 * @pid: pid of the process
3660 * @len: length in bytes of the bitmask pointed to by user_mask_ptr 3699 * @len: length in bytes of the bitmask pointed to by user_mask_ptr
3661 * @user_mask_ptr: user-space pointer to the new cpu mask 3700 * @user_mask_ptr: user-space pointer to the new cpu mask
3701 *
3702 * Return: 0 on success. An error code otherwise.
3662 */ 3703 */
3663SYSCALL_DEFINE3(sched_setaffinity, pid_t, pid, unsigned int, len, 3704SYSCALL_DEFINE3(sched_setaffinity, pid_t, pid, unsigned int, len,
3664 unsigned long __user *, user_mask_ptr) 3705 unsigned long __user *, user_mask_ptr)
@@ -3710,6 +3751,8 @@ out_unlock:
3710 * @pid: pid of the process 3751 * @pid: pid of the process
3711 * @len: length in bytes of the bitmask pointed to by user_mask_ptr 3752 * @len: length in bytes of the bitmask pointed to by user_mask_ptr
3712 * @user_mask_ptr: user-space pointer to hold the current cpu mask 3753 * @user_mask_ptr: user-space pointer to hold the current cpu mask
3754 *
3755 * Return: 0 on success. An error code otherwise.
3713 */ 3756 */
3714SYSCALL_DEFINE3(sched_getaffinity, pid_t, pid, unsigned int, len, 3757SYSCALL_DEFINE3(sched_getaffinity, pid_t, pid, unsigned int, len,
3715 unsigned long __user *, user_mask_ptr) 3758 unsigned long __user *, user_mask_ptr)
@@ -3744,6 +3787,8 @@ SYSCALL_DEFINE3(sched_getaffinity, pid_t, pid, unsigned int, len,
3744 * 3787 *
3745 * This function yields the current CPU to other tasks. If there are no 3788 * This function yields the current CPU to other tasks. If there are no
3746 * other threads running on this CPU then this function will return. 3789 * other threads running on this CPU then this function will return.
3790 *
3791 * Return: 0.
3747 */ 3792 */
3748SYSCALL_DEFINE0(sched_yield) 3793SYSCALL_DEFINE0(sched_yield)
3749{ 3794{
@@ -3869,7 +3914,7 @@ EXPORT_SYMBOL(yield);
3869 * It's the caller's job to ensure that the target task struct 3914 * It's the caller's job to ensure that the target task struct
3870 * can't go away on us before we can do any checks. 3915 * can't go away on us before we can do any checks.
3871 * 3916 *
3872 * Returns: 3917 * Return:
3873 * true (>0) if we indeed boosted the target task. 3918 * true (>0) if we indeed boosted the target task.
3874 * false (0) if we failed to boost the target. 3919 * false (0) if we failed to boost the target.
3875 * -ESRCH if there's no task to yield to. 3920 * -ESRCH if there's no task to yield to.
@@ -3972,8 +4017,9 @@ long __sched io_schedule_timeout(long timeout)
3972 * sys_sched_get_priority_max - return maximum RT priority. 4017 * sys_sched_get_priority_max - return maximum RT priority.
3973 * @policy: scheduling class. 4018 * @policy: scheduling class.
3974 * 4019 *
3975 * this syscall returns the maximum rt_priority that can be used 4020 * Return: On success, this syscall returns the maximum
3976 * by a given scheduling class. 4021 * rt_priority that can be used by a given scheduling class.
4022 * On failure, a negative error code is returned.
3977 */ 4023 */
3978SYSCALL_DEFINE1(sched_get_priority_max, int, policy) 4024SYSCALL_DEFINE1(sched_get_priority_max, int, policy)
3979{ 4025{
@@ -3997,8 +4043,9 @@ SYSCALL_DEFINE1(sched_get_priority_max, int, policy)
3997 * sys_sched_get_priority_min - return minimum RT priority. 4043 * sys_sched_get_priority_min - return minimum RT priority.
3998 * @policy: scheduling class. 4044 * @policy: scheduling class.
3999 * 4045 *
4000 * this syscall returns the minimum rt_priority that can be used 4046 * Return: On success, this syscall returns the minimum
4001 * by a given scheduling class. 4047 * rt_priority that can be used by a given scheduling class.
4048 * On failure, a negative error code is returned.
4002 */ 4049 */
4003SYSCALL_DEFINE1(sched_get_priority_min, int, policy) 4050SYSCALL_DEFINE1(sched_get_priority_min, int, policy)
4004{ 4051{
@@ -4024,6 +4071,9 @@ SYSCALL_DEFINE1(sched_get_priority_min, int, policy)
4024 * 4071 *
4025 * this syscall writes the default timeslice value of a given process 4072 * this syscall writes the default timeslice value of a given process
4026 * into the user-space timespec buffer. A value of '0' means infinity. 4073 * into the user-space timespec buffer. A value of '0' means infinity.
4074 *
4075 * Return: On success, 0 and the timeslice is in @interval. Otherwise,
4076 * an error code.
4027 */ 4077 */
4028SYSCALL_DEFINE2(sched_rr_get_interval, pid_t, pid, 4078SYSCALL_DEFINE2(sched_rr_get_interval, pid_t, pid,
4029 struct timespec __user *, interval) 4079 struct timespec __user *, interval)
@@ -6632,6 +6682,8 @@ void normalize_rt_tasks(void)
6632 * @cpu: the processor in question. 6682 * @cpu: the processor in question.
6633 * 6683 *
6634 * ONLY VALID WHEN THE WHOLE SYSTEM IS STOPPED! 6684 * ONLY VALID WHEN THE WHOLE SYSTEM IS STOPPED!
6685 *
6686 * Return: The current task for @cpu.
6635 */ 6687 */
6636struct task_struct *curr_task(int cpu) 6688struct task_struct *curr_task(int cpu)
6637{ 6689{
diff --git a/kernel/sched/cpupri.c b/kernel/sched/cpupri.c
index 1095e878a46f..8b836b376d91 100644
--- a/kernel/sched/cpupri.c
+++ b/kernel/sched/cpupri.c
@@ -62,7 +62,7 @@ static int convert_prio(int prio)
62 * any discrepancies created by racing against the uncertainty of the current 62 * any discrepancies created by racing against the uncertainty of the current
63 * priority configuration. 63 * priority configuration.
64 * 64 *
65 * Returns: (int)bool - CPUs were found 65 * Return: (int)bool - CPUs were found
66 */ 66 */
67int cpupri_find(struct cpupri *cp, struct task_struct *p, 67int cpupri_find(struct cpupri *cp, struct task_struct *p,
68 struct cpumask *lowest_mask) 68 struct cpumask *lowest_mask)
@@ -203,7 +203,7 @@ void cpupri_set(struct cpupri *cp, int cpu, int newpri)
203 * cpupri_init - initialize the cpupri structure 203 * cpupri_init - initialize the cpupri structure
204 * @cp: The cpupri context 204 * @cp: The cpupri context
205 * 205 *
206 * Returns: -ENOMEM if memory fails. 206 * Return: -ENOMEM on memory allocation failure.
207 */ 207 */
208int cpupri_init(struct cpupri *cp) 208int cpupri_init(struct cpupri *cp)
209{ 209{
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index bb456f44b7b1..68f1609ca149 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -851,7 +851,7 @@ void task_numa_fault(int node, int pages, bool migrated)
851{ 851{
852 struct task_struct *p = current; 852 struct task_struct *p = current;
853 853
854 if (!sched_feat_numa(NUMA)) 854 if (!numabalancing_enabled)
855 return; 855 return;
856 856
857 /* FIXME: Allocate task-specific structure for placement policy here */ 857 /* FIXME: Allocate task-specific structure for placement policy here */
@@ -2032,6 +2032,7 @@ entity_tick(struct cfs_rq *cfs_rq, struct sched_entity *curr, int queued)
2032 */ 2032 */
2033 update_entity_load_avg(curr, 1); 2033 update_entity_load_avg(curr, 1);
2034 update_cfs_rq_blocked_load(cfs_rq, 1); 2034 update_cfs_rq_blocked_load(cfs_rq, 1);
2035 update_cfs_shares(cfs_rq);
2035 2036
2036#ifdef CONFIG_SCHED_HRTICK 2037#ifdef CONFIG_SCHED_HRTICK
2037 /* 2038 /*
@@ -4280,6 +4281,8 @@ struct sg_lb_stats {
4280 * get_sd_load_idx - Obtain the load index for a given sched domain. 4281 * get_sd_load_idx - Obtain the load index for a given sched domain.
4281 * @sd: The sched_domain whose load_idx is to be obtained. 4282 * @sd: The sched_domain whose load_idx is to be obtained.
4282 * @idle: The Idle status of the CPU for whose sd load_icx is obtained. 4283 * @idle: The Idle status of the CPU for whose sd load_icx is obtained.
4284 *
4285 * Return: The load index.
4283 */ 4286 */
4284static inline int get_sd_load_idx(struct sched_domain *sd, 4287static inline int get_sd_load_idx(struct sched_domain *sd,
4285 enum cpu_idle_type idle) 4288 enum cpu_idle_type idle)
@@ -4574,6 +4577,9 @@ static inline void update_sg_lb_stats(struct lb_env *env,
4574 * 4577 *
4575 * Determine if @sg is a busier group than the previously selected 4578 * Determine if @sg is a busier group than the previously selected
4576 * busiest group. 4579 * busiest group.
4580 *
4581 * Return: %true if @sg is a busier group than the previously selected
4582 * busiest group. %false otherwise.
4577 */ 4583 */
4578static bool update_sd_pick_busiest(struct lb_env *env, 4584static bool update_sd_pick_busiest(struct lb_env *env,
4579 struct sd_lb_stats *sds, 4585 struct sd_lb_stats *sds,
@@ -4691,7 +4697,7 @@ static inline void update_sd_lb_stats(struct lb_env *env,
4691 * assuming lower CPU number will be equivalent to lower a SMT thread 4697 * assuming lower CPU number will be equivalent to lower a SMT thread
4692 * number. 4698 * number.
4693 * 4699 *
4694 * Returns 1 when packing is required and a task should be moved to 4700 * Return: 1 when packing is required and a task should be moved to
4695 * this CPU. The amount of the imbalance is returned in *imbalance. 4701 * this CPU. The amount of the imbalance is returned in *imbalance.
4696 * 4702 *
4697 * @env: The load balancing environment. 4703 * @env: The load balancing environment.
@@ -4869,7 +4875,7 @@ static inline void calculate_imbalance(struct lb_env *env, struct sd_lb_stats *s
4869 * @balance: Pointer to a variable indicating if this_cpu 4875 * @balance: Pointer to a variable indicating if this_cpu
4870 * is the appropriate cpu to perform load balancing at this_level. 4876 * is the appropriate cpu to perform load balancing at this_level.
4871 * 4877 *
4872 * Returns: - the busiest group if imbalance exists. 4878 * Return: - The busiest group if imbalance exists.
4873 * - If no imbalance and user has opted for power-savings balance, 4879 * - If no imbalance and user has opted for power-savings balance,
4874 * return the least loaded group whose CPUs can be 4880 * return the least loaded group whose CPUs can be
4875 * put to idle by rebalancing its tasks onto our group. 4881 * put to idle by rebalancing its tasks onto our group.
@@ -5786,7 +5792,7 @@ static void task_tick_fair(struct rq *rq, struct task_struct *curr, int queued)
5786 entity_tick(cfs_rq, se, queued); 5792 entity_tick(cfs_rq, se, queued);
5787 } 5793 }
5788 5794
5789 if (sched_feat_numa(NUMA)) 5795 if (numabalancing_enabled)
5790 task_tick_numa(rq, curr); 5796 task_tick_numa(rq, curr);
5791 5797
5792 update_rq_runnable_avg(rq, 1); 5798 update_rq_runnable_avg(rq, 1);
diff --git a/kernel/sysctl.c b/kernel/sysctl.c
index ac09d98490aa..07f6fc468e17 100644
--- a/kernel/sysctl.c
+++ b/kernel/sysctl.c
@@ -2346,7 +2346,11 @@ static int do_proc_dointvec_ms_jiffies_conv(bool *negp, unsigned long *lvalp,
2346 int write, void *data) 2346 int write, void *data)
2347{ 2347{
2348 if (write) { 2348 if (write) {
2349 *valp = msecs_to_jiffies(*negp ? -*lvalp : *lvalp); 2349 unsigned long jif = msecs_to_jiffies(*negp ? -*lvalp : *lvalp);
2350
2351 if (jif > INT_MAX)
2352 return 1;
2353 *valp = (int)jif;
2350 } else { 2354 } else {
2351 int val = *valp; 2355 int val = *valp;
2352 unsigned long lval; 2356 unsigned long lval;
diff --git a/kernel/time/tick-sched.c b/kernel/time/tick-sched.c
index e80183f4a6c4..e77edc97e036 100644
--- a/kernel/time/tick-sched.c
+++ b/kernel/time/tick-sched.c
@@ -827,13 +827,10 @@ void tick_nohz_irq_exit(void)
827{ 827{
828 struct tick_sched *ts = &__get_cpu_var(tick_cpu_sched); 828 struct tick_sched *ts = &__get_cpu_var(tick_cpu_sched);
829 829
830 if (ts->inidle) { 830 if (ts->inidle)
831 /* Cancel the timer because CPU already waken up from the C-states*/
832 menu_hrtimer_cancel();
833 __tick_nohz_idle_enter(ts); 831 __tick_nohz_idle_enter(ts);
834 } else { 832 else
835 tick_nohz_full_stop_tick(ts); 833 tick_nohz_full_stop_tick(ts);
836 }
837} 834}
838 835
839/** 836/**
@@ -931,8 +928,6 @@ void tick_nohz_idle_exit(void)
931 928
932 ts->inidle = 0; 929 ts->inidle = 0;
933 930
934 /* Cancel the timer because CPU already waken up from the C-states*/
935 menu_hrtimer_cancel();
936 if (ts->idle_active || ts->tick_stopped) 931 if (ts->idle_active || ts->tick_stopped)
937 now = ktime_get(); 932 now = ktime_get();
938 933
diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
index 8ce9eefc5bb4..a6d098c6df3f 100644
--- a/kernel/trace/ftrace.c
+++ b/kernel/trace/ftrace.c
@@ -2169,12 +2169,57 @@ static cycle_t ftrace_update_time;
2169static unsigned long ftrace_update_cnt; 2169static unsigned long ftrace_update_cnt;
2170unsigned long ftrace_update_tot_cnt; 2170unsigned long ftrace_update_tot_cnt;
2171 2171
2172static int ops_traces_mod(struct ftrace_ops *ops) 2172static inline int ops_traces_mod(struct ftrace_ops *ops)
2173{ 2173{
2174 struct ftrace_hash *hash; 2174 /*
2175 * Filter_hash being empty will default to trace module.
2176 * But notrace hash requires a test of individual module functions.
2177 */
2178 return ftrace_hash_empty(ops->filter_hash) &&
2179 ftrace_hash_empty(ops->notrace_hash);
2180}
2181
2182/*
2183 * Check if the current ops references the record.
2184 *
2185 * If the ops traces all functions, then it was already accounted for.
2186 * If the ops does not trace the current record function, skip it.
2187 * If the ops ignores the function via notrace filter, skip it.
2188 */
2189static inline bool
2190ops_references_rec(struct ftrace_ops *ops, struct dyn_ftrace *rec)
2191{
2192 /* If ops isn't enabled, ignore it */
2193 if (!(ops->flags & FTRACE_OPS_FL_ENABLED))
2194 return 0;
2195
2196 /* If ops traces all mods, we already accounted for it */
2197 if (ops_traces_mod(ops))
2198 return 0;
2199
2200 /* The function must be in the filter */
2201 if (!ftrace_hash_empty(ops->filter_hash) &&
2202 !ftrace_lookup_ip(ops->filter_hash, rec->ip))
2203 return 0;
2204
2205 /* If in notrace hash, we ignore it too */
2206 if (ftrace_lookup_ip(ops->notrace_hash, rec->ip))
2207 return 0;
2208
2209 return 1;
2210}
2211
2212static int referenced_filters(struct dyn_ftrace *rec)
2213{
2214 struct ftrace_ops *ops;
2215 int cnt = 0;
2175 2216
2176 hash = ops->filter_hash; 2217 for (ops = ftrace_ops_list; ops != &ftrace_list_end; ops = ops->next) {
2177 return ftrace_hash_empty(hash); 2218 if (ops_references_rec(ops, rec))
2219 cnt++;
2220 }
2221
2222 return cnt;
2178} 2223}
2179 2224
2180static int ftrace_update_code(struct module *mod) 2225static int ftrace_update_code(struct module *mod)
@@ -2183,6 +2228,7 @@ static int ftrace_update_code(struct module *mod)
2183 struct dyn_ftrace *p; 2228 struct dyn_ftrace *p;
2184 cycle_t start, stop; 2229 cycle_t start, stop;
2185 unsigned long ref = 0; 2230 unsigned long ref = 0;
2231 bool test = false;
2186 int i; 2232 int i;
2187 2233
2188 /* 2234 /*
@@ -2196,9 +2242,12 @@ static int ftrace_update_code(struct module *mod)
2196 2242
2197 for (ops = ftrace_ops_list; 2243 for (ops = ftrace_ops_list;
2198 ops != &ftrace_list_end; ops = ops->next) { 2244 ops != &ftrace_list_end; ops = ops->next) {
2199 if (ops->flags & FTRACE_OPS_FL_ENABLED && 2245 if (ops->flags & FTRACE_OPS_FL_ENABLED) {
2200 ops_traces_mod(ops)) 2246 if (ops_traces_mod(ops))
2201 ref++; 2247 ref++;
2248 else
2249 test = true;
2250 }
2202 } 2251 }
2203 } 2252 }
2204 2253
@@ -2208,12 +2257,16 @@ static int ftrace_update_code(struct module *mod)
2208 for (pg = ftrace_new_pgs; pg; pg = pg->next) { 2257 for (pg = ftrace_new_pgs; pg; pg = pg->next) {
2209 2258
2210 for (i = 0; i < pg->index; i++) { 2259 for (i = 0; i < pg->index; i++) {
2260 int cnt = ref;
2261
2211 /* If something went wrong, bail without enabling anything */ 2262 /* If something went wrong, bail without enabling anything */
2212 if (unlikely(ftrace_disabled)) 2263 if (unlikely(ftrace_disabled))
2213 return -1; 2264 return -1;
2214 2265
2215 p = &pg->records[i]; 2266 p = &pg->records[i];
2216 p->flags = ref; 2267 if (test)
2268 cnt += referenced_filters(p);
2269 p->flags = cnt;
2217 2270
2218 /* 2271 /*
2219 * Do the initial record conversion from mcount jump 2272 * Do the initial record conversion from mcount jump
@@ -2233,7 +2286,7 @@ static int ftrace_update_code(struct module *mod)
2233 * conversion puts the module to the correct state, thus 2286 * conversion puts the module to the correct state, thus
2234 * passing the ftrace_make_call check. 2287 * passing the ftrace_make_call check.
2235 */ 2288 */
2236 if (ftrace_start_up && ref) { 2289 if (ftrace_start_up && cnt) {
2237 int failed = __ftrace_replace_code(p, 1); 2290 int failed = __ftrace_replace_code(p, 1);
2238 if (failed) 2291 if (failed)
2239 ftrace_bug(failed, p->ip); 2292 ftrace_bug(failed, p->ip);
@@ -3384,6 +3437,12 @@ ftrace_match_addr(struct ftrace_hash *hash, unsigned long ip, int remove)
3384 return add_hash_entry(hash, ip); 3437 return add_hash_entry(hash, ip);
3385} 3438}
3386 3439
3440static void ftrace_ops_update_code(struct ftrace_ops *ops)
3441{
3442 if (ops->flags & FTRACE_OPS_FL_ENABLED && ftrace_enabled)
3443 ftrace_run_update_code(FTRACE_UPDATE_CALLS);
3444}
3445
3387static int 3446static int
3388ftrace_set_hash(struct ftrace_ops *ops, unsigned char *buf, int len, 3447ftrace_set_hash(struct ftrace_ops *ops, unsigned char *buf, int len,
3389 unsigned long ip, int remove, int reset, int enable) 3448 unsigned long ip, int remove, int reset, int enable)
@@ -3426,9 +3485,8 @@ ftrace_set_hash(struct ftrace_ops *ops, unsigned char *buf, int len,
3426 3485
3427 mutex_lock(&ftrace_lock); 3486 mutex_lock(&ftrace_lock);
3428 ret = ftrace_hash_move(ops, enable, orig_hash, hash); 3487 ret = ftrace_hash_move(ops, enable, orig_hash, hash);
3429 if (!ret && ops->flags & FTRACE_OPS_FL_ENABLED 3488 if (!ret)
3430 && ftrace_enabled) 3489 ftrace_ops_update_code(ops);
3431 ftrace_run_update_code(FTRACE_UPDATE_CALLS);
3432 3490
3433 mutex_unlock(&ftrace_lock); 3491 mutex_unlock(&ftrace_lock);
3434 3492
@@ -3655,9 +3713,8 @@ int ftrace_regex_release(struct inode *inode, struct file *file)
3655 mutex_lock(&ftrace_lock); 3713 mutex_lock(&ftrace_lock);
3656 ret = ftrace_hash_move(iter->ops, filter_hash, 3714 ret = ftrace_hash_move(iter->ops, filter_hash,
3657 orig_hash, iter->hash); 3715 orig_hash, iter->hash);
3658 if (!ret && (iter->ops->flags & FTRACE_OPS_FL_ENABLED) 3716 if (!ret)
3659 && ftrace_enabled) 3717 ftrace_ops_update_code(iter->ops);
3660 ftrace_run_update_code(FTRACE_UPDATE_CALLS);
3661 3718
3662 mutex_unlock(&ftrace_lock); 3719 mutex_unlock(&ftrace_lock);
3663 } 3720 }
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index 882ec1dd1515..496f94d57698 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -243,20 +243,25 @@ int filter_current_check_discard(struct ring_buffer *buffer,
243} 243}
244EXPORT_SYMBOL_GPL(filter_current_check_discard); 244EXPORT_SYMBOL_GPL(filter_current_check_discard);
245 245
246cycle_t ftrace_now(int cpu) 246cycle_t buffer_ftrace_now(struct trace_buffer *buf, int cpu)
247{ 247{
248 u64 ts; 248 u64 ts;
249 249
250 /* Early boot up does not have a buffer yet */ 250 /* Early boot up does not have a buffer yet */
251 if (!global_trace.trace_buffer.buffer) 251 if (!buf->buffer)
252 return trace_clock_local(); 252 return trace_clock_local();
253 253
254 ts = ring_buffer_time_stamp(global_trace.trace_buffer.buffer, cpu); 254 ts = ring_buffer_time_stamp(buf->buffer, cpu);
255 ring_buffer_normalize_time_stamp(global_trace.trace_buffer.buffer, cpu, &ts); 255 ring_buffer_normalize_time_stamp(buf->buffer, cpu, &ts);
256 256
257 return ts; 257 return ts;
258} 258}
259 259
260cycle_t ftrace_now(int cpu)
261{
262 return buffer_ftrace_now(&global_trace.trace_buffer, cpu);
263}
264
260/** 265/**
261 * tracing_is_enabled - Show if global_trace has been disabled 266 * tracing_is_enabled - Show if global_trace has been disabled
262 * 267 *
@@ -1211,7 +1216,7 @@ void tracing_reset_online_cpus(struct trace_buffer *buf)
1211 /* Make sure all commits have finished */ 1216 /* Make sure all commits have finished */
1212 synchronize_sched(); 1217 synchronize_sched();
1213 1218
1214 buf->time_start = ftrace_now(buf->cpu); 1219 buf->time_start = buffer_ftrace_now(buf, buf->cpu);
1215 1220
1216 for_each_online_cpu(cpu) 1221 for_each_online_cpu(cpu)
1217 ring_buffer_reset_cpu(buffer, cpu); 1222 ring_buffer_reset_cpu(buffer, cpu);
@@ -1219,11 +1224,6 @@ void tracing_reset_online_cpus(struct trace_buffer *buf)
1219 ring_buffer_record_enable(buffer); 1224 ring_buffer_record_enable(buffer);
1220} 1225}
1221 1226
1222void tracing_reset_current(int cpu)
1223{
1224 tracing_reset(&global_trace.trace_buffer, cpu);
1225}
1226
1227/* Must have trace_types_lock held */ 1227/* Must have trace_types_lock held */
1228void tracing_reset_all_online_cpus(void) 1228void tracing_reset_all_online_cpus(void)
1229{ 1229{
@@ -4151,6 +4151,7 @@ waitagain:
4151 memset(&iter->seq, 0, 4151 memset(&iter->seq, 0,
4152 sizeof(struct trace_iterator) - 4152 sizeof(struct trace_iterator) -
4153 offsetof(struct trace_iterator, seq)); 4153 offsetof(struct trace_iterator, seq));
4154 cpumask_clear(iter->started);
4154 iter->pos = -1; 4155 iter->pos = -1;
4155 4156
4156 trace_event_read_lock(); 4157 trace_event_read_lock();
@@ -4468,7 +4469,7 @@ tracing_free_buffer_release(struct inode *inode, struct file *filp)
4468 4469
4469 /* disable tracing ? */ 4470 /* disable tracing ? */
4470 if (trace_flags & TRACE_ITER_STOP_ON_FREE) 4471 if (trace_flags & TRACE_ITER_STOP_ON_FREE)
4471 tracing_off(); 4472 tracer_tracing_off(tr);
4472 /* resize the ring buffer to 0 */ 4473 /* resize the ring buffer to 0 */
4473 tracing_resize_ring_buffer(tr, 0, RING_BUFFER_ALL_CPUS); 4474 tracing_resize_ring_buffer(tr, 0, RING_BUFFER_ALL_CPUS);
4474 4475
@@ -4633,12 +4634,12 @@ static ssize_t tracing_clock_write(struct file *filp, const char __user *ubuf,
4633 * New clock may not be consistent with the previous clock. 4634 * New clock may not be consistent with the previous clock.
4634 * Reset the buffer so that it doesn't have incomparable timestamps. 4635 * Reset the buffer so that it doesn't have incomparable timestamps.
4635 */ 4636 */
4636 tracing_reset_online_cpus(&global_trace.trace_buffer); 4637 tracing_reset_online_cpus(&tr->trace_buffer);
4637 4638
4638#ifdef CONFIG_TRACER_MAX_TRACE 4639#ifdef CONFIG_TRACER_MAX_TRACE
4639 if (tr->flags & TRACE_ARRAY_FL_GLOBAL && tr->max_buffer.buffer) 4640 if (tr->flags & TRACE_ARRAY_FL_GLOBAL && tr->max_buffer.buffer)
4640 ring_buffer_set_clock(tr->max_buffer.buffer, trace_clocks[i].func); 4641 ring_buffer_set_clock(tr->max_buffer.buffer, trace_clocks[i].func);
4641 tracing_reset_online_cpus(&global_trace.max_buffer); 4642 tracing_reset_online_cpus(&tr->max_buffer);
4642#endif 4643#endif
4643 4644
4644 mutex_unlock(&trace_types_lock); 4645 mutex_unlock(&trace_types_lock);
diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c
index 898f868833f2..29a7ebcfb426 100644
--- a/kernel/trace/trace_events.c
+++ b/kernel/trace/trace_events.c
@@ -409,33 +409,42 @@ static void put_system(struct ftrace_subsystem_dir *dir)
409 mutex_unlock(&event_mutex); 409 mutex_unlock(&event_mutex);
410} 410}
411 411
412/* 412static void remove_subsystem(struct ftrace_subsystem_dir *dir)
413 * Open and update trace_array ref count.
414 * Must have the current trace_array passed to it.
415 */
416static int tracing_open_generic_file(struct inode *inode, struct file *filp)
417{ 413{
418 struct ftrace_event_file *file = inode->i_private; 414 if (!dir)
419 struct trace_array *tr = file->tr; 415 return;
420 int ret;
421 416
422 if (trace_array_get(tr) < 0) 417 if (!--dir->nr_events) {
423 return -ENODEV; 418 debugfs_remove_recursive(dir->entry);
419 list_del(&dir->list);
420 __put_system_dir(dir);
421 }
422}
424 423
425 ret = tracing_open_generic(inode, filp); 424static void *event_file_data(struct file *filp)
426 if (ret < 0) 425{
427 trace_array_put(tr); 426 return ACCESS_ONCE(file_inode(filp)->i_private);
428 return ret;
429} 427}
430 428
431static int tracing_release_generic_file(struct inode *inode, struct file *filp) 429static void remove_event_file_dir(struct ftrace_event_file *file)
432{ 430{
433 struct ftrace_event_file *file = inode->i_private; 431 struct dentry *dir = file->dir;
434 struct trace_array *tr = file->tr; 432 struct dentry *child;
435 433
436 trace_array_put(tr); 434 if (dir) {
435 spin_lock(&dir->d_lock); /* probably unneeded */
436 list_for_each_entry(child, &dir->d_subdirs, d_u.d_child) {
437 if (child->d_inode) /* probably unneeded */
438 child->d_inode->i_private = NULL;
439 }
440 spin_unlock(&dir->d_lock);
437 441
438 return 0; 442 debugfs_remove_recursive(dir);
443 }
444
445 list_del(&file->list);
446 remove_subsystem(file->system);
447 kmem_cache_free(file_cachep, file);
439} 448}
440 449
441/* 450/*
@@ -679,15 +688,25 @@ static ssize_t
679event_enable_read(struct file *filp, char __user *ubuf, size_t cnt, 688event_enable_read(struct file *filp, char __user *ubuf, size_t cnt,
680 loff_t *ppos) 689 loff_t *ppos)
681{ 690{
682 struct ftrace_event_file *file = filp->private_data; 691 struct ftrace_event_file *file;
692 unsigned long flags;
683 char buf[4] = "0"; 693 char buf[4] = "0";
684 694
685 if (file->flags & FTRACE_EVENT_FL_ENABLED && 695 mutex_lock(&event_mutex);
686 !(file->flags & FTRACE_EVENT_FL_SOFT_DISABLED)) 696 file = event_file_data(filp);
697 if (likely(file))
698 flags = file->flags;
699 mutex_unlock(&event_mutex);
700
701 if (!file)
702 return -ENODEV;
703
704 if (flags & FTRACE_EVENT_FL_ENABLED &&
705 !(flags & FTRACE_EVENT_FL_SOFT_DISABLED))
687 strcpy(buf, "1"); 706 strcpy(buf, "1");
688 707
689 if (file->flags & FTRACE_EVENT_FL_SOFT_DISABLED || 708 if (flags & FTRACE_EVENT_FL_SOFT_DISABLED ||
690 file->flags & FTRACE_EVENT_FL_SOFT_MODE) 709 flags & FTRACE_EVENT_FL_SOFT_MODE)
691 strcat(buf, "*"); 710 strcat(buf, "*");
692 711
693 strcat(buf, "\n"); 712 strcat(buf, "\n");
@@ -699,13 +718,10 @@ static ssize_t
699event_enable_write(struct file *filp, const char __user *ubuf, size_t cnt, 718event_enable_write(struct file *filp, const char __user *ubuf, size_t cnt,
700 loff_t *ppos) 719 loff_t *ppos)
701{ 720{
702 struct ftrace_event_file *file = filp->private_data; 721 struct ftrace_event_file *file;
703 unsigned long val; 722 unsigned long val;
704 int ret; 723 int ret;
705 724
706 if (!file)
707 return -EINVAL;
708
709 ret = kstrtoul_from_user(ubuf, cnt, 10, &val); 725 ret = kstrtoul_from_user(ubuf, cnt, 10, &val);
710 if (ret) 726 if (ret)
711 return ret; 727 return ret;
@@ -717,8 +733,11 @@ event_enable_write(struct file *filp, const char __user *ubuf, size_t cnt,
717 switch (val) { 733 switch (val) {
718 case 0: 734 case 0:
719 case 1: 735 case 1:
736 ret = -ENODEV;
720 mutex_lock(&event_mutex); 737 mutex_lock(&event_mutex);
721 ret = ftrace_event_enable_disable(file, val); 738 file = event_file_data(filp);
739 if (likely(file))
740 ret = ftrace_event_enable_disable(file, val);
722 mutex_unlock(&event_mutex); 741 mutex_unlock(&event_mutex);
723 break; 742 break;
724 743
@@ -825,7 +844,7 @@ enum {
825 844
826static void *f_next(struct seq_file *m, void *v, loff_t *pos) 845static void *f_next(struct seq_file *m, void *v, loff_t *pos)
827{ 846{
828 struct ftrace_event_call *call = m->private; 847 struct ftrace_event_call *call = event_file_data(m->private);
829 struct list_head *common_head = &ftrace_common_fields; 848 struct list_head *common_head = &ftrace_common_fields;
830 struct list_head *head = trace_get_fields(call); 849 struct list_head *head = trace_get_fields(call);
831 struct list_head *node = v; 850 struct list_head *node = v;
@@ -857,7 +876,7 @@ static void *f_next(struct seq_file *m, void *v, loff_t *pos)
857 876
858static int f_show(struct seq_file *m, void *v) 877static int f_show(struct seq_file *m, void *v)
859{ 878{
860 struct ftrace_event_call *call = m->private; 879 struct ftrace_event_call *call = event_file_data(m->private);
861 struct ftrace_event_field *field; 880 struct ftrace_event_field *field;
862 const char *array_descriptor; 881 const char *array_descriptor;
863 882
@@ -910,6 +929,11 @@ static void *f_start(struct seq_file *m, loff_t *pos)
910 void *p = (void *)FORMAT_HEADER; 929 void *p = (void *)FORMAT_HEADER;
911 loff_t l = 0; 930 loff_t l = 0;
912 931
932 /* ->stop() is called even if ->start() fails */
933 mutex_lock(&event_mutex);
934 if (!event_file_data(m->private))
935 return ERR_PTR(-ENODEV);
936
913 while (l < *pos && p) 937 while (l < *pos && p)
914 p = f_next(m, p, &l); 938 p = f_next(m, p, &l);
915 939
@@ -918,6 +942,7 @@ static void *f_start(struct seq_file *m, loff_t *pos)
918 942
919static void f_stop(struct seq_file *m, void *p) 943static void f_stop(struct seq_file *m, void *p)
920{ 944{
945 mutex_unlock(&event_mutex);
921} 946}
922 947
923static const struct seq_operations trace_format_seq_ops = { 948static const struct seq_operations trace_format_seq_ops = {
@@ -929,7 +954,6 @@ static const struct seq_operations trace_format_seq_ops = {
929 954
930static int trace_format_open(struct inode *inode, struct file *file) 955static int trace_format_open(struct inode *inode, struct file *file)
931{ 956{
932 struct ftrace_event_call *call = inode->i_private;
933 struct seq_file *m; 957 struct seq_file *m;
934 int ret; 958 int ret;
935 959
@@ -938,7 +962,7 @@ static int trace_format_open(struct inode *inode, struct file *file)
938 return ret; 962 return ret;
939 963
940 m = file->private_data; 964 m = file->private_data;
941 m->private = call; 965 m->private = file;
942 966
943 return 0; 967 return 0;
944} 968}
@@ -946,14 +970,18 @@ static int trace_format_open(struct inode *inode, struct file *file)
946static ssize_t 970static ssize_t
947event_id_read(struct file *filp, char __user *ubuf, size_t cnt, loff_t *ppos) 971event_id_read(struct file *filp, char __user *ubuf, size_t cnt, loff_t *ppos)
948{ 972{
949 struct ftrace_event_call *call = filp->private_data; 973 int id = (long)event_file_data(filp);
950 char buf[32]; 974 char buf[32];
951 int len; 975 int len;
952 976
953 if (*ppos) 977 if (*ppos)
954 return 0; 978 return 0;
955 979
956 len = sprintf(buf, "%d\n", call->event.type); 980 if (unlikely(!id))
981 return -ENODEV;
982
983 len = sprintf(buf, "%d\n", id);
984
957 return simple_read_from_buffer(ubuf, cnt, ppos, buf, len); 985 return simple_read_from_buffer(ubuf, cnt, ppos, buf, len);
958} 986}
959 987
@@ -961,21 +989,28 @@ static ssize_t
961event_filter_read(struct file *filp, char __user *ubuf, size_t cnt, 989event_filter_read(struct file *filp, char __user *ubuf, size_t cnt,
962 loff_t *ppos) 990 loff_t *ppos)
963{ 991{
964 struct ftrace_event_call *call = filp->private_data; 992 struct ftrace_event_call *call;
965 struct trace_seq *s; 993 struct trace_seq *s;
966 int r; 994 int r = -ENODEV;
967 995
968 if (*ppos) 996 if (*ppos)
969 return 0; 997 return 0;
970 998
971 s = kmalloc(sizeof(*s), GFP_KERNEL); 999 s = kmalloc(sizeof(*s), GFP_KERNEL);
1000
972 if (!s) 1001 if (!s)
973 return -ENOMEM; 1002 return -ENOMEM;
974 1003
975 trace_seq_init(s); 1004 trace_seq_init(s);
976 1005
977 print_event_filter(call, s); 1006 mutex_lock(&event_mutex);
978 r = simple_read_from_buffer(ubuf, cnt, ppos, s->buffer, s->len); 1007 call = event_file_data(filp);
1008 if (call)
1009 print_event_filter(call, s);
1010 mutex_unlock(&event_mutex);
1011
1012 if (call)
1013 r = simple_read_from_buffer(ubuf, cnt, ppos, s->buffer, s->len);
979 1014
980 kfree(s); 1015 kfree(s);
981 1016
@@ -986,9 +1021,9 @@ static ssize_t
986event_filter_write(struct file *filp, const char __user *ubuf, size_t cnt, 1021event_filter_write(struct file *filp, const char __user *ubuf, size_t cnt,
987 loff_t *ppos) 1022 loff_t *ppos)
988{ 1023{
989 struct ftrace_event_call *call = filp->private_data; 1024 struct ftrace_event_call *call;
990 char *buf; 1025 char *buf;
991 int err; 1026 int err = -ENODEV;
992 1027
993 if (cnt >= PAGE_SIZE) 1028 if (cnt >= PAGE_SIZE)
994 return -EINVAL; 1029 return -EINVAL;
@@ -1003,7 +1038,12 @@ event_filter_write(struct file *filp, const char __user *ubuf, size_t cnt,
1003 } 1038 }
1004 buf[cnt] = '\0'; 1039 buf[cnt] = '\0';
1005 1040
1006 err = apply_event_filter(call, buf); 1041 mutex_lock(&event_mutex);
1042 call = event_file_data(filp);
1043 if (call)
1044 err = apply_event_filter(call, buf);
1045 mutex_unlock(&event_mutex);
1046
1007 free_page((unsigned long) buf); 1047 free_page((unsigned long) buf);
1008 if (err < 0) 1048 if (err < 0)
1009 return err; 1049 return err;
@@ -1225,10 +1265,9 @@ static const struct file_operations ftrace_set_event_fops = {
1225}; 1265};
1226 1266
1227static const struct file_operations ftrace_enable_fops = { 1267static const struct file_operations ftrace_enable_fops = {
1228 .open = tracing_open_generic_file, 1268 .open = tracing_open_generic,
1229 .read = event_enable_read, 1269 .read = event_enable_read,
1230 .write = event_enable_write, 1270 .write = event_enable_write,
1231 .release = tracing_release_generic_file,
1232 .llseek = default_llseek, 1271 .llseek = default_llseek,
1233}; 1272};
1234 1273
@@ -1240,7 +1279,6 @@ static const struct file_operations ftrace_event_format_fops = {
1240}; 1279};
1241 1280
1242static const struct file_operations ftrace_event_id_fops = { 1281static const struct file_operations ftrace_event_id_fops = {
1243 .open = tracing_open_generic,
1244 .read = event_id_read, 1282 .read = event_id_read,
1245 .llseek = default_llseek, 1283 .llseek = default_llseek,
1246}; 1284};
@@ -1488,8 +1526,8 @@ event_create_dir(struct dentry *parent,
1488 1526
1489#ifdef CONFIG_PERF_EVENTS 1527#ifdef CONFIG_PERF_EVENTS
1490 if (call->event.type && call->class->reg) 1528 if (call->event.type && call->class->reg)
1491 trace_create_file("id", 0444, file->dir, call, 1529 trace_create_file("id", 0444, file->dir,
1492 id); 1530 (void *)(long)call->event.type, id);
1493#endif 1531#endif
1494 1532
1495 /* 1533 /*
@@ -1514,33 +1552,16 @@ event_create_dir(struct dentry *parent,
1514 return 0; 1552 return 0;
1515} 1553}
1516 1554
1517static void remove_subsystem(struct ftrace_subsystem_dir *dir)
1518{
1519 if (!dir)
1520 return;
1521
1522 if (!--dir->nr_events) {
1523 debugfs_remove_recursive(dir->entry);
1524 list_del(&dir->list);
1525 __put_system_dir(dir);
1526 }
1527}
1528
1529static void remove_event_from_tracers(struct ftrace_event_call *call) 1555static void remove_event_from_tracers(struct ftrace_event_call *call)
1530{ 1556{
1531 struct ftrace_event_file *file; 1557 struct ftrace_event_file *file;
1532 struct trace_array *tr; 1558 struct trace_array *tr;
1533 1559
1534 do_for_each_event_file_safe(tr, file) { 1560 do_for_each_event_file_safe(tr, file) {
1535
1536 if (file->event_call != call) 1561 if (file->event_call != call)
1537 continue; 1562 continue;
1538 1563
1539 list_del(&file->list); 1564 remove_event_file_dir(file);
1540 debugfs_remove_recursive(file->dir);
1541 remove_subsystem(file->system);
1542 kmem_cache_free(file_cachep, file);
1543
1544 /* 1565 /*
1545 * The do_for_each_event_file_safe() is 1566 * The do_for_each_event_file_safe() is
1546 * a double loop. After finding the call for this 1567 * a double loop. After finding the call for this
@@ -1692,16 +1713,53 @@ static void __trace_remove_event_call(struct ftrace_event_call *call)
1692 destroy_preds(call); 1713 destroy_preds(call);
1693} 1714}
1694 1715
1716static int probe_remove_event_call(struct ftrace_event_call *call)
1717{
1718 struct trace_array *tr;
1719 struct ftrace_event_file *file;
1720
1721#ifdef CONFIG_PERF_EVENTS
1722 if (call->perf_refcount)
1723 return -EBUSY;
1724#endif
1725 do_for_each_event_file(tr, file) {
1726 if (file->event_call != call)
1727 continue;
1728 /*
1729 * We can't rely on ftrace_event_enable_disable(enable => 0)
1730 * we are going to do, FTRACE_EVENT_FL_SOFT_MODE can suppress
1731 * TRACE_REG_UNREGISTER.
1732 */
1733 if (file->flags & FTRACE_EVENT_FL_ENABLED)
1734 return -EBUSY;
1735 /*
1736 * The do_for_each_event_file_safe() is
1737 * a double loop. After finding the call for this
1738 * trace_array, we use break to jump to the next
1739 * trace_array.
1740 */
1741 break;
1742 } while_for_each_event_file();
1743
1744 __trace_remove_event_call(call);
1745
1746 return 0;
1747}
1748
1695/* Remove an event_call */ 1749/* Remove an event_call */
1696void trace_remove_event_call(struct ftrace_event_call *call) 1750int trace_remove_event_call(struct ftrace_event_call *call)
1697{ 1751{
1752 int ret;
1753
1698 mutex_lock(&trace_types_lock); 1754 mutex_lock(&trace_types_lock);
1699 mutex_lock(&event_mutex); 1755 mutex_lock(&event_mutex);
1700 down_write(&trace_event_sem); 1756 down_write(&trace_event_sem);
1701 __trace_remove_event_call(call); 1757 ret = probe_remove_event_call(call);
1702 up_write(&trace_event_sem); 1758 up_write(&trace_event_sem);
1703 mutex_unlock(&event_mutex); 1759 mutex_unlock(&event_mutex);
1704 mutex_unlock(&trace_types_lock); 1760 mutex_unlock(&trace_types_lock);
1761
1762 return ret;
1705} 1763}
1706 1764
1707#define for_each_event(event, start, end) \ 1765#define for_each_event(event, start, end) \
@@ -2270,12 +2328,8 @@ __trace_remove_event_dirs(struct trace_array *tr)
2270{ 2328{
2271 struct ftrace_event_file *file, *next; 2329 struct ftrace_event_file *file, *next;
2272 2330
2273 list_for_each_entry_safe(file, next, &tr->events, list) { 2331 list_for_each_entry_safe(file, next, &tr->events, list)
2274 list_del(&file->list); 2332 remove_event_file_dir(file);
2275 debugfs_remove_recursive(file->dir);
2276 remove_subsystem(file->system);
2277 kmem_cache_free(file_cachep, file);
2278 }
2279} 2333}
2280 2334
2281static void 2335static void
diff --git a/kernel/trace/trace_events_filter.c b/kernel/trace/trace_events_filter.c
index 0c7b75a8acc8..97daa8cf958d 100644
--- a/kernel/trace/trace_events_filter.c
+++ b/kernel/trace/trace_events_filter.c
@@ -637,17 +637,15 @@ static void append_filter_err(struct filter_parse_state *ps,
637 free_page((unsigned long) buf); 637 free_page((unsigned long) buf);
638} 638}
639 639
640/* caller must hold event_mutex */
640void print_event_filter(struct ftrace_event_call *call, struct trace_seq *s) 641void print_event_filter(struct ftrace_event_call *call, struct trace_seq *s)
641{ 642{
642 struct event_filter *filter; 643 struct event_filter *filter = call->filter;
643 644
644 mutex_lock(&event_mutex);
645 filter = call->filter;
646 if (filter && filter->filter_string) 645 if (filter && filter->filter_string)
647 trace_seq_printf(s, "%s\n", filter->filter_string); 646 trace_seq_printf(s, "%s\n", filter->filter_string);
648 else 647 else
649 trace_seq_puts(s, "none\n"); 648 trace_seq_puts(s, "none\n");
650 mutex_unlock(&event_mutex);
651} 649}
652 650
653void print_subsystem_event_filter(struct event_subsystem *system, 651void print_subsystem_event_filter(struct event_subsystem *system,
@@ -1841,23 +1839,22 @@ static int create_system_filter(struct event_subsystem *system,
1841 return err; 1839 return err;
1842} 1840}
1843 1841
1842/* caller must hold event_mutex */
1844int apply_event_filter(struct ftrace_event_call *call, char *filter_string) 1843int apply_event_filter(struct ftrace_event_call *call, char *filter_string)
1845{ 1844{
1846 struct event_filter *filter; 1845 struct event_filter *filter;
1847 int err = 0; 1846 int err;
1848
1849 mutex_lock(&event_mutex);
1850 1847
1851 if (!strcmp(strstrip(filter_string), "0")) { 1848 if (!strcmp(strstrip(filter_string), "0")) {
1852 filter_disable(call); 1849 filter_disable(call);
1853 filter = call->filter; 1850 filter = call->filter;
1854 if (!filter) 1851 if (!filter)
1855 goto out_unlock; 1852 return 0;
1856 RCU_INIT_POINTER(call->filter, NULL); 1853 RCU_INIT_POINTER(call->filter, NULL);
1857 /* Make sure the filter is not being used */ 1854 /* Make sure the filter is not being used */
1858 synchronize_sched(); 1855 synchronize_sched();
1859 __free_filter(filter); 1856 __free_filter(filter);
1860 goto out_unlock; 1857 return 0;
1861 } 1858 }
1862 1859
1863 err = create_filter(call, filter_string, true, &filter); 1860 err = create_filter(call, filter_string, true, &filter);
@@ -1884,8 +1881,6 @@ int apply_event_filter(struct ftrace_event_call *call, char *filter_string)
1884 __free_filter(tmp); 1881 __free_filter(tmp);
1885 } 1882 }
1886 } 1883 }
1887out_unlock:
1888 mutex_unlock(&event_mutex);
1889 1884
1890 return err; 1885 return err;
1891} 1886}
diff --git a/kernel/trace/trace_kprobe.c b/kernel/trace/trace_kprobe.c
index 3811487e7a7a..243f6834d026 100644
--- a/kernel/trace/trace_kprobe.c
+++ b/kernel/trace/trace_kprobe.c
@@ -95,7 +95,7 @@ static __kprobes bool trace_probe_is_on_module(struct trace_probe *tp)
95} 95}
96 96
97static int register_probe_event(struct trace_probe *tp); 97static int register_probe_event(struct trace_probe *tp);
98static void unregister_probe_event(struct trace_probe *tp); 98static int unregister_probe_event(struct trace_probe *tp);
99 99
100static DEFINE_MUTEX(probe_lock); 100static DEFINE_MUTEX(probe_lock);
101static LIST_HEAD(probe_list); 101static LIST_HEAD(probe_list);
@@ -351,9 +351,12 @@ static int unregister_trace_probe(struct trace_probe *tp)
351 if (trace_probe_is_enabled(tp)) 351 if (trace_probe_is_enabled(tp))
352 return -EBUSY; 352 return -EBUSY;
353 353
354 /* Will fail if probe is being used by ftrace or perf */
355 if (unregister_probe_event(tp))
356 return -EBUSY;
357
354 __unregister_trace_probe(tp); 358 __unregister_trace_probe(tp);
355 list_del(&tp->list); 359 list_del(&tp->list);
356 unregister_probe_event(tp);
357 360
358 return 0; 361 return 0;
359} 362}
@@ -632,7 +635,9 @@ static int release_all_trace_probes(void)
632 /* TODO: Use batch unregistration */ 635 /* TODO: Use batch unregistration */
633 while (!list_empty(&probe_list)) { 636 while (!list_empty(&probe_list)) {
634 tp = list_entry(probe_list.next, struct trace_probe, list); 637 tp = list_entry(probe_list.next, struct trace_probe, list);
635 unregister_trace_probe(tp); 638 ret = unregister_trace_probe(tp);
639 if (ret)
640 goto end;
636 free_trace_probe(tp); 641 free_trace_probe(tp);
637 } 642 }
638 643
@@ -1247,11 +1252,15 @@ static int register_probe_event(struct trace_probe *tp)
1247 return ret; 1252 return ret;
1248} 1253}
1249 1254
1250static void unregister_probe_event(struct trace_probe *tp) 1255static int unregister_probe_event(struct trace_probe *tp)
1251{ 1256{
1257 int ret;
1258
1252 /* tp->event is unregistered in trace_remove_event_call() */ 1259 /* tp->event is unregistered in trace_remove_event_call() */
1253 trace_remove_event_call(&tp->call); 1260 ret = trace_remove_event_call(&tp->call);
1254 kfree(tp->call.print_fmt); 1261 if (!ret)
1262 kfree(tp->call.print_fmt);
1263 return ret;
1255} 1264}
1256 1265
1257/* Make a debugfs interface for controlling probe points */ 1266/* Make a debugfs interface for controlling probe points */
diff --git a/kernel/trace/trace_uprobe.c b/kernel/trace/trace_uprobe.c
index a23d2d71188e..272261b5f94f 100644
--- a/kernel/trace/trace_uprobe.c
+++ b/kernel/trace/trace_uprobe.c
@@ -70,7 +70,7 @@ struct trace_uprobe {
70 (sizeof(struct probe_arg) * (n))) 70 (sizeof(struct probe_arg) * (n)))
71 71
72static int register_uprobe_event(struct trace_uprobe *tu); 72static int register_uprobe_event(struct trace_uprobe *tu);
73static void unregister_uprobe_event(struct trace_uprobe *tu); 73static int unregister_uprobe_event(struct trace_uprobe *tu);
74 74
75static DEFINE_MUTEX(uprobe_lock); 75static DEFINE_MUTEX(uprobe_lock);
76static LIST_HEAD(uprobe_list); 76static LIST_HEAD(uprobe_list);
@@ -164,11 +164,17 @@ static struct trace_uprobe *find_probe_event(const char *event, const char *grou
164} 164}
165 165
166/* Unregister a trace_uprobe and probe_event: call with locking uprobe_lock */ 166/* Unregister a trace_uprobe and probe_event: call with locking uprobe_lock */
167static void unregister_trace_uprobe(struct trace_uprobe *tu) 167static int unregister_trace_uprobe(struct trace_uprobe *tu)
168{ 168{
169 int ret;
170
171 ret = unregister_uprobe_event(tu);
172 if (ret)
173 return ret;
174
169 list_del(&tu->list); 175 list_del(&tu->list);
170 unregister_uprobe_event(tu);
171 free_trace_uprobe(tu); 176 free_trace_uprobe(tu);
177 return 0;
172} 178}
173 179
174/* Register a trace_uprobe and probe_event */ 180/* Register a trace_uprobe and probe_event */
@@ -181,9 +187,12 @@ static int register_trace_uprobe(struct trace_uprobe *tu)
181 187
182 /* register as an event */ 188 /* register as an event */
183 old_tp = find_probe_event(tu->call.name, tu->call.class->system); 189 old_tp = find_probe_event(tu->call.name, tu->call.class->system);
184 if (old_tp) 190 if (old_tp) {
185 /* delete old event */ 191 /* delete old event */
186 unregister_trace_uprobe(old_tp); 192 ret = unregister_trace_uprobe(old_tp);
193 if (ret)
194 goto end;
195 }
187 196
188 ret = register_uprobe_event(tu); 197 ret = register_uprobe_event(tu);
189 if (ret) { 198 if (ret) {
@@ -256,6 +265,8 @@ static int create_trace_uprobe(int argc, char **argv)
256 group = UPROBE_EVENT_SYSTEM; 265 group = UPROBE_EVENT_SYSTEM;
257 266
258 if (is_delete) { 267 if (is_delete) {
268 int ret;
269
259 if (!event) { 270 if (!event) {
260 pr_info("Delete command needs an event name.\n"); 271 pr_info("Delete command needs an event name.\n");
261 return -EINVAL; 272 return -EINVAL;
@@ -269,9 +280,9 @@ static int create_trace_uprobe(int argc, char **argv)
269 return -ENOENT; 280 return -ENOENT;
270 } 281 }
271 /* delete an event */ 282 /* delete an event */
272 unregister_trace_uprobe(tu); 283 ret = unregister_trace_uprobe(tu);
273 mutex_unlock(&uprobe_lock); 284 mutex_unlock(&uprobe_lock);
274 return 0; 285 return ret;
275 } 286 }
276 287
277 if (argc < 2) { 288 if (argc < 2) {
@@ -408,16 +419,20 @@ fail_address_parse:
408 return ret; 419 return ret;
409} 420}
410 421
411static void cleanup_all_probes(void) 422static int cleanup_all_probes(void)
412{ 423{
413 struct trace_uprobe *tu; 424 struct trace_uprobe *tu;
425 int ret = 0;
414 426
415 mutex_lock(&uprobe_lock); 427 mutex_lock(&uprobe_lock);
416 while (!list_empty(&uprobe_list)) { 428 while (!list_empty(&uprobe_list)) {
417 tu = list_entry(uprobe_list.next, struct trace_uprobe, list); 429 tu = list_entry(uprobe_list.next, struct trace_uprobe, list);
418 unregister_trace_uprobe(tu); 430 ret = unregister_trace_uprobe(tu);
431 if (ret)
432 break;
419 } 433 }
420 mutex_unlock(&uprobe_lock); 434 mutex_unlock(&uprobe_lock);
435 return ret;
421} 436}
422 437
423/* Probes listing interfaces */ 438/* Probes listing interfaces */
@@ -462,8 +477,13 @@ static const struct seq_operations probes_seq_op = {
462 477
463static int probes_open(struct inode *inode, struct file *file) 478static int probes_open(struct inode *inode, struct file *file)
464{ 479{
465 if ((file->f_mode & FMODE_WRITE) && (file->f_flags & O_TRUNC)) 480 int ret;
466 cleanup_all_probes(); 481
482 if ((file->f_mode & FMODE_WRITE) && (file->f_flags & O_TRUNC)) {
483 ret = cleanup_all_probes();
484 if (ret)
485 return ret;
486 }
467 487
468 return seq_open(file, &probes_seq_op); 488 return seq_open(file, &probes_seq_op);
469} 489}
@@ -968,12 +988,17 @@ static int register_uprobe_event(struct trace_uprobe *tu)
968 return ret; 988 return ret;
969} 989}
970 990
971static void unregister_uprobe_event(struct trace_uprobe *tu) 991static int unregister_uprobe_event(struct trace_uprobe *tu)
972{ 992{
993 int ret;
994
973 /* tu->event is unregistered in trace_remove_event_call() */ 995 /* tu->event is unregistered in trace_remove_event_call() */
974 trace_remove_event_call(&tu->call); 996 ret = trace_remove_event_call(&tu->call);
997 if (ret)
998 return ret;
975 kfree(tu->call.print_fmt); 999 kfree(tu->call.print_fmt);
976 tu->call.print_fmt = NULL; 1000 tu->call.print_fmt = NULL;
1001 return 0;
977} 1002}
978 1003
979/* Make a trace interface for controling probe points */ 1004/* Make a trace interface for controling probe points */
diff --git a/kernel/user_namespace.c b/kernel/user_namespace.c
index d8c30db06c5b..9064b919a406 100644
--- a/kernel/user_namespace.c
+++ b/kernel/user_namespace.c
@@ -62,6 +62,9 @@ int create_user_ns(struct cred *new)
62 kgid_t group = new->egid; 62 kgid_t group = new->egid;
63 int ret; 63 int ret;
64 64
65 if (parent_ns->level > 32)
66 return -EUSERS;
67
65 /* 68 /*
66 * Verify that we can not violate the policy of which files 69 * Verify that we can not violate the policy of which files
67 * may be accessed that is specified by the root directory, 70 * may be accessed that is specified by the root directory,
@@ -92,6 +95,7 @@ int create_user_ns(struct cred *new)
92 atomic_set(&ns->count, 1); 95 atomic_set(&ns->count, 1);
93 /* Leave the new->user_ns reference with the new user namespace. */ 96 /* Leave the new->user_ns reference with the new user namespace. */
94 ns->parent = parent_ns; 97 ns->parent = parent_ns;
98 ns->level = parent_ns->level + 1;
95 ns->owner = owner; 99 ns->owner = owner;
96 ns->group = group; 100 ns->group = group;
97 101
@@ -105,16 +109,21 @@ int create_user_ns(struct cred *new)
105int unshare_userns(unsigned long unshare_flags, struct cred **new_cred) 109int unshare_userns(unsigned long unshare_flags, struct cred **new_cred)
106{ 110{
107 struct cred *cred; 111 struct cred *cred;
112 int err = -ENOMEM;
108 113
109 if (!(unshare_flags & CLONE_NEWUSER)) 114 if (!(unshare_flags & CLONE_NEWUSER))
110 return 0; 115 return 0;
111 116
112 cred = prepare_creds(); 117 cred = prepare_creds();
113 if (!cred) 118 if (cred) {
114 return -ENOMEM; 119 err = create_user_ns(cred);
120 if (err)
121 put_cred(cred);
122 else
123 *new_cred = cred;
124 }
115 125
116 *new_cred = cred; 126 return err;
117 return create_user_ns(cred);
118} 127}
119 128
120void free_user_ns(struct user_namespace *ns) 129void free_user_ns(struct user_namespace *ns)
diff --git a/kernel/workqueue.c b/kernel/workqueue.c
index 0b72e816b8d0..7f5d4be22034 100644
--- a/kernel/workqueue.c
+++ b/kernel/workqueue.c
@@ -2817,6 +2817,19 @@ already_gone:
2817 return false; 2817 return false;
2818} 2818}
2819 2819
2820static bool __flush_work(struct work_struct *work)
2821{
2822 struct wq_barrier barr;
2823
2824 if (start_flush_work(work, &barr)) {
2825 wait_for_completion(&barr.done);
2826 destroy_work_on_stack(&barr.work);
2827 return true;
2828 } else {
2829 return false;
2830 }
2831}
2832
2820/** 2833/**
2821 * flush_work - wait for a work to finish executing the last queueing instance 2834 * flush_work - wait for a work to finish executing the last queueing instance
2822 * @work: the work to flush 2835 * @work: the work to flush
@@ -2830,18 +2843,10 @@ already_gone:
2830 */ 2843 */
2831bool flush_work(struct work_struct *work) 2844bool flush_work(struct work_struct *work)
2832{ 2845{
2833 struct wq_barrier barr;
2834
2835 lock_map_acquire(&work->lockdep_map); 2846 lock_map_acquire(&work->lockdep_map);
2836 lock_map_release(&work->lockdep_map); 2847 lock_map_release(&work->lockdep_map);
2837 2848
2838 if (start_flush_work(work, &barr)) { 2849 return __flush_work(work);
2839 wait_for_completion(&barr.done);
2840 destroy_work_on_stack(&barr.work);
2841 return true;
2842 } else {
2843 return false;
2844 }
2845} 2850}
2846EXPORT_SYMBOL_GPL(flush_work); 2851EXPORT_SYMBOL_GPL(flush_work);
2847 2852
@@ -3411,6 +3416,12 @@ static void copy_workqueue_attrs(struct workqueue_attrs *to,
3411{ 3416{
3412 to->nice = from->nice; 3417 to->nice = from->nice;
3413 cpumask_copy(to->cpumask, from->cpumask); 3418 cpumask_copy(to->cpumask, from->cpumask);
3419 /*
3420 * Unlike hash and equality test, this function doesn't ignore
3421 * ->no_numa as it is used for both pool and wq attrs. Instead,
3422 * get_unbound_pool() explicitly clears ->no_numa after copying.
3423 */
3424 to->no_numa = from->no_numa;
3414} 3425}
3415 3426
3416/* hash value of the content of @attr */ 3427/* hash value of the content of @attr */
@@ -3578,6 +3589,12 @@ static struct worker_pool *get_unbound_pool(const struct workqueue_attrs *attrs)
3578 lockdep_set_subclass(&pool->lock, 1); /* see put_pwq() */ 3589 lockdep_set_subclass(&pool->lock, 1); /* see put_pwq() */
3579 copy_workqueue_attrs(pool->attrs, attrs); 3590 copy_workqueue_attrs(pool->attrs, attrs);
3580 3591
3592 /*
3593 * no_numa isn't a worker_pool attribute, always clear it. See
3594 * 'struct workqueue_attrs' comments for detail.
3595 */
3596 pool->attrs->no_numa = false;
3597
3581 /* if cpumask is contained inside a NUMA node, we belong to that node */ 3598 /* if cpumask is contained inside a NUMA node, we belong to that node */
3582 if (wq_numa_enabled) { 3599 if (wq_numa_enabled) {
3583 for_each_node(node) { 3600 for_each_node(node) {
@@ -4756,7 +4773,14 @@ long work_on_cpu(int cpu, long (*fn)(void *), void *arg)
4756 4773
4757 INIT_WORK_ONSTACK(&wfc.work, work_for_cpu_fn); 4774 INIT_WORK_ONSTACK(&wfc.work, work_for_cpu_fn);
4758 schedule_work_on(cpu, &wfc.work); 4775 schedule_work_on(cpu, &wfc.work);
4759 flush_work(&wfc.work); 4776
4777 /*
4778 * The work item is on-stack and can't lead to deadlock through
4779 * flushing. Use __flush_work() to avoid spurious lockdep warnings
4780 * when work_on_cpu()s are nested.
4781 */
4782 __flush_work(&wfc.work);
4783
4760 return wfc.ret; 4784 return wfc.ret;
4761} 4785}
4762EXPORT_SYMBOL_GPL(work_on_cpu); 4786EXPORT_SYMBOL_GPL(work_on_cpu);