diff options
Diffstat (limited to 'kernel')
-rw-r--r-- | kernel/Makefile | 1 | ||||
-rw-r--r-- | kernel/audit.c | 13 | ||||
-rw-r--r-- | kernel/auditfilter.c | 10 | ||||
-rw-r--r-- | kernel/auditsc.c | 4 | ||||
-rw-r--r-- | kernel/cgroup.c | 39 | ||||
-rw-r--r-- | kernel/cpu.c | 41 | ||||
-rw-r--r-- | kernel/cpuset.c | 71 | ||||
-rw-r--r-- | kernel/dma-coherent.c | 154 | ||||
-rw-r--r-- | kernel/fork.c | 3 | ||||
-rw-r--r-- | kernel/kgdb.c | 94 | ||||
-rw-r--r-- | kernel/marker.c | 12 | ||||
-rw-r--r-- | kernel/module.c | 33 | ||||
-rw-r--r-- | kernel/printk.c | 8 | ||||
-rw-r--r-- | kernel/rcuclassic.c | 4 | ||||
-rw-r--r-- | kernel/resource.c | 2 | ||||
-rw-r--r-- | kernel/sched.c | 22 | ||||
-rw-r--r-- | kernel/stop_machine.c | 288 | ||||
-rw-r--r-- | kernel/time/tick-common.c | 8 | ||||
-rw-r--r-- | kernel/trace/ftrace.c | 6 | ||||
-rw-r--r-- | kernel/trace/trace_sysprof.c | 4 | ||||
-rw-r--r-- | kernel/workqueue.c | 13 |
21 files changed, 537 insertions, 293 deletions
diff --git a/kernel/Makefile b/kernel/Makefile index 54f69837d35a..4e1d7df7c3e2 100644 --- a/kernel/Makefile +++ b/kernel/Makefile | |||
@@ -84,6 +84,7 @@ obj-$(CONFIG_TASK_DELAY_ACCT) += delayacct.o | |||
84 | obj-$(CONFIG_TASKSTATS) += taskstats.o tsacct.o | 84 | obj-$(CONFIG_TASKSTATS) += taskstats.o tsacct.o |
85 | obj-$(CONFIG_MARKERS) += marker.o | 85 | obj-$(CONFIG_MARKERS) += marker.o |
86 | obj-$(CONFIG_LATENCYTOP) += latencytop.o | 86 | obj-$(CONFIG_LATENCYTOP) += latencytop.o |
87 | obj-$(CONFIG_HAVE_GENERIC_DMA_COHERENT) += dma-coherent.o | ||
87 | obj-$(CONFIG_FTRACE) += trace/ | 88 | obj-$(CONFIG_FTRACE) += trace/ |
88 | obj-$(CONFIG_TRACING) += trace/ | 89 | obj-$(CONFIG_TRACING) += trace/ |
89 | obj-$(CONFIG_SMP) += sched_cpupri.o | 90 | obj-$(CONFIG_SMP) += sched_cpupri.o |
diff --git a/kernel/audit.c b/kernel/audit.c index e092f1c0ce30..4414e93d8750 100644 --- a/kernel/audit.c +++ b/kernel/audit.c | |||
@@ -707,12 +707,14 @@ static int audit_receive_msg(struct sk_buff *skb, struct nlmsghdr *nlh) | |||
707 | if (status_get->mask & AUDIT_STATUS_ENABLED) { | 707 | if (status_get->mask & AUDIT_STATUS_ENABLED) { |
708 | err = audit_set_enabled(status_get->enabled, | 708 | err = audit_set_enabled(status_get->enabled, |
709 | loginuid, sessionid, sid); | 709 | loginuid, sessionid, sid); |
710 | if (err < 0) return err; | 710 | if (err < 0) |
711 | return err; | ||
711 | } | 712 | } |
712 | if (status_get->mask & AUDIT_STATUS_FAILURE) { | 713 | if (status_get->mask & AUDIT_STATUS_FAILURE) { |
713 | err = audit_set_failure(status_get->failure, | 714 | err = audit_set_failure(status_get->failure, |
714 | loginuid, sessionid, sid); | 715 | loginuid, sessionid, sid); |
715 | if (err < 0) return err; | 716 | if (err < 0) |
717 | return err; | ||
716 | } | 718 | } |
717 | if (status_get->mask & AUDIT_STATUS_PID) { | 719 | if (status_get->mask & AUDIT_STATUS_PID) { |
718 | int new_pid = status_get->pid; | 720 | int new_pid = status_get->pid; |
@@ -725,9 +727,12 @@ static int audit_receive_msg(struct sk_buff *skb, struct nlmsghdr *nlh) | |||
725 | audit_pid = new_pid; | 727 | audit_pid = new_pid; |
726 | audit_nlk_pid = NETLINK_CB(skb).pid; | 728 | audit_nlk_pid = NETLINK_CB(skb).pid; |
727 | } | 729 | } |
728 | if (status_get->mask & AUDIT_STATUS_RATE_LIMIT) | 730 | if (status_get->mask & AUDIT_STATUS_RATE_LIMIT) { |
729 | err = audit_set_rate_limit(status_get->rate_limit, | 731 | err = audit_set_rate_limit(status_get->rate_limit, |
730 | loginuid, sessionid, sid); | 732 | loginuid, sessionid, sid); |
733 | if (err < 0) | ||
734 | return err; | ||
735 | } | ||
731 | if (status_get->mask & AUDIT_STATUS_BACKLOG_LIMIT) | 736 | if (status_get->mask & AUDIT_STATUS_BACKLOG_LIMIT) |
732 | err = audit_set_backlog_limit(status_get->backlog_limit, | 737 | err = audit_set_backlog_limit(status_get->backlog_limit, |
733 | loginuid, sessionid, sid); | 738 | loginuid, sessionid, sid); |
@@ -1366,7 +1371,7 @@ int audit_string_contains_control(const char *string, size_t len) | |||
1366 | { | 1371 | { |
1367 | const unsigned char *p; | 1372 | const unsigned char *p; |
1368 | for (p = string; p < (const unsigned char *)string + len && *p; p++) { | 1373 | for (p = string; p < (const unsigned char *)string + len && *p; p++) { |
1369 | if (*p == '"' || *p < 0x21 || *p > 0x7f) | 1374 | if (*p == '"' || *p < 0x21 || *p > 0x7e) |
1370 | return 1; | 1375 | return 1; |
1371 | } | 1376 | } |
1372 | return 0; | 1377 | return 0; |
diff --git a/kernel/auditfilter.c b/kernel/auditfilter.c index 98c50cc671bb..b7d354e2b0ef 100644 --- a/kernel/auditfilter.c +++ b/kernel/auditfilter.c | |||
@@ -1022,8 +1022,11 @@ static void audit_update_watch(struct audit_parent *parent, | |||
1022 | struct audit_buffer *ab; | 1022 | struct audit_buffer *ab; |
1023 | ab = audit_log_start(NULL, GFP_KERNEL, | 1023 | ab = audit_log_start(NULL, GFP_KERNEL, |
1024 | AUDIT_CONFIG_CHANGE); | 1024 | AUDIT_CONFIG_CHANGE); |
1025 | audit_log_format(ab, "auid=%u ses=%u", | ||
1026 | audit_get_loginuid(current), | ||
1027 | audit_get_sessionid(current)); | ||
1025 | audit_log_format(ab, | 1028 | audit_log_format(ab, |
1026 | "op=updated rules specifying path="); | 1029 | " op=updated rules specifying path="); |
1027 | audit_log_untrustedstring(ab, owatch->path); | 1030 | audit_log_untrustedstring(ab, owatch->path); |
1028 | audit_log_format(ab, " with dev=%u ino=%lu\n", | 1031 | audit_log_format(ab, " with dev=%u ino=%lu\n", |
1029 | dev, ino); | 1032 | dev, ino); |
@@ -1058,7 +1061,10 @@ static void audit_remove_parent_watches(struct audit_parent *parent) | |||
1058 | struct audit_buffer *ab; | 1061 | struct audit_buffer *ab; |
1059 | ab = audit_log_start(NULL, GFP_KERNEL, | 1062 | ab = audit_log_start(NULL, GFP_KERNEL, |
1060 | AUDIT_CONFIG_CHANGE); | 1063 | AUDIT_CONFIG_CHANGE); |
1061 | audit_log_format(ab, "op=remove rule path="); | 1064 | audit_log_format(ab, "auid=%u ses=%u", |
1065 | audit_get_loginuid(current), | ||
1066 | audit_get_sessionid(current)); | ||
1067 | audit_log_format(ab, " op=remove rule path="); | ||
1062 | audit_log_untrustedstring(ab, w->path); | 1068 | audit_log_untrustedstring(ab, w->path); |
1063 | if (r->filterkey) { | 1069 | if (r->filterkey) { |
1064 | audit_log_format(ab, " key="); | 1070 | audit_log_format(ab, " key="); |
diff --git a/kernel/auditsc.c b/kernel/auditsc.c index 4699950e65bd..496c3dd37276 100644 --- a/kernel/auditsc.c +++ b/kernel/auditsc.c | |||
@@ -610,7 +610,7 @@ static int audit_filter_rules(struct task_struct *tsk, | |||
610 | if (!result) | 610 | if (!result) |
611 | return 0; | 611 | return 0; |
612 | } | 612 | } |
613 | if (rule->filterkey) | 613 | if (rule->filterkey && ctx) |
614 | ctx->filterkey = kstrdup(rule->filterkey, GFP_ATOMIC); | 614 | ctx->filterkey = kstrdup(rule->filterkey, GFP_ATOMIC); |
615 | switch (rule->action) { | 615 | switch (rule->action) { |
616 | case AUDIT_NEVER: *state = AUDIT_DISABLED; break; | 616 | case AUDIT_NEVER: *state = AUDIT_DISABLED; break; |
@@ -2375,7 +2375,7 @@ int __audit_signal_info(int sig, struct task_struct *t) | |||
2375 | struct audit_context *ctx = tsk->audit_context; | 2375 | struct audit_context *ctx = tsk->audit_context; |
2376 | 2376 | ||
2377 | if (audit_pid && t->tgid == audit_pid) { | 2377 | if (audit_pid && t->tgid == audit_pid) { |
2378 | if (sig == SIGTERM || sig == SIGHUP || sig == SIGUSR1) { | 2378 | if (sig == SIGTERM || sig == SIGHUP || sig == SIGUSR1 || sig == SIGUSR2) { |
2379 | audit_sig_pid = tsk->pid; | 2379 | audit_sig_pid = tsk->pid; |
2380 | if (tsk->loginuid != -1) | 2380 | if (tsk->loginuid != -1) |
2381 | audit_sig_uid = tsk->loginuid; | 2381 | audit_sig_uid = tsk->loginuid; |
diff --git a/kernel/cgroup.c b/kernel/cgroup.c index 657f8f8d93a5..13932abde159 100644 --- a/kernel/cgroup.c +++ b/kernel/cgroup.c | |||
@@ -355,6 +355,17 @@ static struct css_set *find_existing_css_set( | |||
355 | return NULL; | 355 | return NULL; |
356 | } | 356 | } |
357 | 357 | ||
358 | static void free_cg_links(struct list_head *tmp) | ||
359 | { | ||
360 | struct cg_cgroup_link *link; | ||
361 | struct cg_cgroup_link *saved_link; | ||
362 | |||
363 | list_for_each_entry_safe(link, saved_link, tmp, cgrp_link_list) { | ||
364 | list_del(&link->cgrp_link_list); | ||
365 | kfree(link); | ||
366 | } | ||
367 | } | ||
368 | |||
358 | /* | 369 | /* |
359 | * allocate_cg_links() allocates "count" cg_cgroup_link structures | 370 | * allocate_cg_links() allocates "count" cg_cgroup_link structures |
360 | * and chains them on tmp through their cgrp_link_list fields. Returns 0 on | 371 | * and chains them on tmp through their cgrp_link_list fields. Returns 0 on |
@@ -363,17 +374,12 @@ static struct css_set *find_existing_css_set( | |||
363 | static int allocate_cg_links(int count, struct list_head *tmp) | 374 | static int allocate_cg_links(int count, struct list_head *tmp) |
364 | { | 375 | { |
365 | struct cg_cgroup_link *link; | 376 | struct cg_cgroup_link *link; |
366 | struct cg_cgroup_link *saved_link; | ||
367 | int i; | 377 | int i; |
368 | INIT_LIST_HEAD(tmp); | 378 | INIT_LIST_HEAD(tmp); |
369 | for (i = 0; i < count; i++) { | 379 | for (i = 0; i < count; i++) { |
370 | link = kmalloc(sizeof(*link), GFP_KERNEL); | 380 | link = kmalloc(sizeof(*link), GFP_KERNEL); |
371 | if (!link) { | 381 | if (!link) { |
372 | list_for_each_entry_safe(link, saved_link, tmp, | 382 | free_cg_links(tmp); |
373 | cgrp_link_list) { | ||
374 | list_del(&link->cgrp_link_list); | ||
375 | kfree(link); | ||
376 | } | ||
377 | return -ENOMEM; | 383 | return -ENOMEM; |
378 | } | 384 | } |
379 | list_add(&link->cgrp_link_list, tmp); | 385 | list_add(&link->cgrp_link_list, tmp); |
@@ -381,17 +387,6 @@ static int allocate_cg_links(int count, struct list_head *tmp) | |||
381 | return 0; | 387 | return 0; |
382 | } | 388 | } |
383 | 389 | ||
384 | static void free_cg_links(struct list_head *tmp) | ||
385 | { | ||
386 | struct cg_cgroup_link *link; | ||
387 | struct cg_cgroup_link *saved_link; | ||
388 | |||
389 | list_for_each_entry_safe(link, saved_link, tmp, cgrp_link_list) { | ||
390 | list_del(&link->cgrp_link_list); | ||
391 | kfree(link); | ||
392 | } | ||
393 | } | ||
394 | |||
395 | /* | 390 | /* |
396 | * find_css_set() takes an existing cgroup group and a | 391 | * find_css_set() takes an existing cgroup group and a |
397 | * cgroup object, and returns a css_set object that's | 392 | * cgroup object, and returns a css_set object that's |
@@ -956,7 +951,6 @@ static int cgroup_get_sb(struct file_system_type *fs_type, | |||
956 | struct super_block *sb; | 951 | struct super_block *sb; |
957 | struct cgroupfs_root *root; | 952 | struct cgroupfs_root *root; |
958 | struct list_head tmp_cg_links; | 953 | struct list_head tmp_cg_links; |
959 | INIT_LIST_HEAD(&tmp_cg_links); | ||
960 | 954 | ||
961 | /* First find the desired set of subsystems */ | 955 | /* First find the desired set of subsystems */ |
962 | ret = parse_cgroupfs_options(data, &opts); | 956 | ret = parse_cgroupfs_options(data, &opts); |
@@ -1424,14 +1418,17 @@ static ssize_t cgroup_write_string(struct cgroup *cgrp, struct cftype *cft, | |||
1424 | if (buffer == NULL) | 1418 | if (buffer == NULL) |
1425 | return -ENOMEM; | 1419 | return -ENOMEM; |
1426 | } | 1420 | } |
1427 | if (nbytes && copy_from_user(buffer, userbuf, nbytes)) | 1421 | if (nbytes && copy_from_user(buffer, userbuf, nbytes)) { |
1428 | return -EFAULT; | 1422 | retval = -EFAULT; |
1423 | goto out; | ||
1424 | } | ||
1429 | 1425 | ||
1430 | buffer[nbytes] = 0; /* nul-terminate */ | 1426 | buffer[nbytes] = 0; /* nul-terminate */ |
1431 | strstrip(buffer); | 1427 | strstrip(buffer); |
1432 | retval = cft->write_string(cgrp, cft, buffer); | 1428 | retval = cft->write_string(cgrp, cft, buffer); |
1433 | if (!retval) | 1429 | if (!retval) |
1434 | retval = nbytes; | 1430 | retval = nbytes; |
1431 | out: | ||
1435 | if (buffer != local_buffer) | 1432 | if (buffer != local_buffer) |
1436 | kfree(buffer); | 1433 | kfree(buffer); |
1437 | return retval; | 1434 | return retval; |
@@ -2371,7 +2368,7 @@ static int cgroup_mkdir(struct inode *dir, struct dentry *dentry, int mode) | |||
2371 | return cgroup_create(c_parent, dentry, mode | S_IFDIR); | 2368 | return cgroup_create(c_parent, dentry, mode | S_IFDIR); |
2372 | } | 2369 | } |
2373 | 2370 | ||
2374 | static inline int cgroup_has_css_refs(struct cgroup *cgrp) | 2371 | static int cgroup_has_css_refs(struct cgroup *cgrp) |
2375 | { | 2372 | { |
2376 | /* Check the reference count on each subsystem. Since we | 2373 | /* Check the reference count on each subsystem. Since we |
2377 | * already established that there are no tasks in the | 2374 | * already established that there are no tasks in the |
diff --git a/kernel/cpu.c b/kernel/cpu.c index 10ba5f1004a5..e202a68d1cc1 100644 --- a/kernel/cpu.c +++ b/kernel/cpu.c | |||
@@ -216,7 +216,6 @@ static int __ref take_cpu_down(void *_param) | |||
216 | static int __ref _cpu_down(unsigned int cpu, int tasks_frozen) | 216 | static int __ref _cpu_down(unsigned int cpu, int tasks_frozen) |
217 | { | 217 | { |
218 | int err, nr_calls = 0; | 218 | int err, nr_calls = 0; |
219 | struct task_struct *p; | ||
220 | cpumask_t old_allowed, tmp; | 219 | cpumask_t old_allowed, tmp; |
221 | void *hcpu = (void *)(long)cpu; | 220 | void *hcpu = (void *)(long)cpu; |
222 | unsigned long mod = tasks_frozen ? CPU_TASKS_FROZEN : 0; | 221 | unsigned long mod = tasks_frozen ? CPU_TASKS_FROZEN : 0; |
@@ -249,21 +248,18 @@ static int __ref _cpu_down(unsigned int cpu, int tasks_frozen) | |||
249 | cpus_setall(tmp); | 248 | cpus_setall(tmp); |
250 | cpu_clear(cpu, tmp); | 249 | cpu_clear(cpu, tmp); |
251 | set_cpus_allowed_ptr(current, &tmp); | 250 | set_cpus_allowed_ptr(current, &tmp); |
251 | tmp = cpumask_of_cpu(cpu); | ||
252 | 252 | ||
253 | p = __stop_machine_run(take_cpu_down, &tcd_param, cpu); | 253 | err = __stop_machine(take_cpu_down, &tcd_param, &tmp); |
254 | 254 | if (err) { | |
255 | if (IS_ERR(p) || cpu_online(cpu)) { | ||
256 | /* CPU didn't die: tell everyone. Can't complain. */ | 255 | /* CPU didn't die: tell everyone. Can't complain. */ |
257 | if (raw_notifier_call_chain(&cpu_chain, CPU_DOWN_FAILED | mod, | 256 | if (raw_notifier_call_chain(&cpu_chain, CPU_DOWN_FAILED | mod, |
258 | hcpu) == NOTIFY_BAD) | 257 | hcpu) == NOTIFY_BAD) |
259 | BUG(); | 258 | BUG(); |
260 | 259 | ||
261 | if (IS_ERR(p)) { | 260 | goto out_allowed; |
262 | err = PTR_ERR(p); | ||
263 | goto out_allowed; | ||
264 | } | ||
265 | goto out_thread; | ||
266 | } | 261 | } |
262 | BUG_ON(cpu_online(cpu)); | ||
267 | 263 | ||
268 | /* Wait for it to sleep (leaving idle task). */ | 264 | /* Wait for it to sleep (leaving idle task). */ |
269 | while (!idle_cpu(cpu)) | 265 | while (!idle_cpu(cpu)) |
@@ -279,8 +275,6 @@ static int __ref _cpu_down(unsigned int cpu, int tasks_frozen) | |||
279 | 275 | ||
280 | check_for_tasks(cpu); | 276 | check_for_tasks(cpu); |
281 | 277 | ||
282 | out_thread: | ||
283 | err = kthread_stop(p); | ||
284 | out_allowed: | 278 | out_allowed: |
285 | set_cpus_allowed_ptr(current, &old_allowed); | 279 | set_cpus_allowed_ptr(current, &old_allowed); |
286 | out_release: | 280 | out_release: |
@@ -461,3 +455,28 @@ out: | |||
461 | #endif /* CONFIG_PM_SLEEP_SMP */ | 455 | #endif /* CONFIG_PM_SLEEP_SMP */ |
462 | 456 | ||
463 | #endif /* CONFIG_SMP */ | 457 | #endif /* CONFIG_SMP */ |
458 | |||
459 | /* | ||
460 | * cpu_bit_bitmap[] is a special, "compressed" data structure that | ||
461 | * represents all NR_CPUS bits binary values of 1<<nr. | ||
462 | * | ||
463 | * It is used by cpumask_of_cpu() to get a constant address to a CPU | ||
464 | * mask value that has a single bit set only. | ||
465 | */ | ||
466 | |||
467 | /* cpu_bit_bitmap[0] is empty - so we can back into it */ | ||
468 | #define MASK_DECLARE_1(x) [x+1][0] = 1UL << (x) | ||
469 | #define MASK_DECLARE_2(x) MASK_DECLARE_1(x), MASK_DECLARE_1(x+1) | ||
470 | #define MASK_DECLARE_4(x) MASK_DECLARE_2(x), MASK_DECLARE_2(x+2) | ||
471 | #define MASK_DECLARE_8(x) MASK_DECLARE_4(x), MASK_DECLARE_4(x+4) | ||
472 | |||
473 | const unsigned long cpu_bit_bitmap[BITS_PER_LONG+1][BITS_TO_LONGS(NR_CPUS)] = { | ||
474 | |||
475 | MASK_DECLARE_8(0), MASK_DECLARE_8(8), | ||
476 | MASK_DECLARE_8(16), MASK_DECLARE_8(24), | ||
477 | #if BITS_PER_LONG > 32 | ||
478 | MASK_DECLARE_8(32), MASK_DECLARE_8(40), | ||
479 | MASK_DECLARE_8(48), MASK_DECLARE_8(56), | ||
480 | #endif | ||
481 | }; | ||
482 | EXPORT_SYMBOL_GPL(cpu_bit_bitmap); | ||
diff --git a/kernel/cpuset.c b/kernel/cpuset.c index 91cf85b36dd5..d5ab79cf516d 100644 --- a/kernel/cpuset.c +++ b/kernel/cpuset.c | |||
@@ -54,7 +54,6 @@ | |||
54 | #include <asm/uaccess.h> | 54 | #include <asm/uaccess.h> |
55 | #include <asm/atomic.h> | 55 | #include <asm/atomic.h> |
56 | #include <linux/mutex.h> | 56 | #include <linux/mutex.h> |
57 | #include <linux/kfifo.h> | ||
58 | #include <linux/workqueue.h> | 57 | #include <linux/workqueue.h> |
59 | #include <linux/cgroup.h> | 58 | #include <linux/cgroup.h> |
60 | 59 | ||
@@ -486,13 +485,38 @@ static int cpusets_overlap(struct cpuset *a, struct cpuset *b) | |||
486 | static void | 485 | static void |
487 | update_domain_attr(struct sched_domain_attr *dattr, struct cpuset *c) | 486 | update_domain_attr(struct sched_domain_attr *dattr, struct cpuset *c) |
488 | { | 487 | { |
489 | if (!dattr) | ||
490 | return; | ||
491 | if (dattr->relax_domain_level < c->relax_domain_level) | 488 | if (dattr->relax_domain_level < c->relax_domain_level) |
492 | dattr->relax_domain_level = c->relax_domain_level; | 489 | dattr->relax_domain_level = c->relax_domain_level; |
493 | return; | 490 | return; |
494 | } | 491 | } |
495 | 492 | ||
493 | static void | ||
494 | update_domain_attr_tree(struct sched_domain_attr *dattr, struct cpuset *c) | ||
495 | { | ||
496 | LIST_HEAD(q); | ||
497 | |||
498 | list_add(&c->stack_list, &q); | ||
499 | while (!list_empty(&q)) { | ||
500 | struct cpuset *cp; | ||
501 | struct cgroup *cont; | ||
502 | struct cpuset *child; | ||
503 | |||
504 | cp = list_first_entry(&q, struct cpuset, stack_list); | ||
505 | list_del(q.next); | ||
506 | |||
507 | if (cpus_empty(cp->cpus_allowed)) | ||
508 | continue; | ||
509 | |||
510 | if (is_sched_load_balance(cp)) | ||
511 | update_domain_attr(dattr, cp); | ||
512 | |||
513 | list_for_each_entry(cont, &cp->css.cgroup->children, sibling) { | ||
514 | child = cgroup_cs(cont); | ||
515 | list_add_tail(&child->stack_list, &q); | ||
516 | } | ||
517 | } | ||
518 | } | ||
519 | |||
496 | /* | 520 | /* |
497 | * rebuild_sched_domains() | 521 | * rebuild_sched_domains() |
498 | * | 522 | * |
@@ -532,7 +556,7 @@ update_domain_attr(struct sched_domain_attr *dattr, struct cpuset *c) | |||
532 | * So the reverse nesting would risk an ABBA deadlock. | 556 | * So the reverse nesting would risk an ABBA deadlock. |
533 | * | 557 | * |
534 | * The three key local variables below are: | 558 | * The three key local variables below are: |
535 | * q - a kfifo queue of cpuset pointers, used to implement a | 559 | * q - a linked-list queue of cpuset pointers, used to implement a |
536 | * top-down scan of all cpusets. This scan loads a pointer | 560 | * top-down scan of all cpusets. This scan loads a pointer |
537 | * to each cpuset marked is_sched_load_balance into the | 561 | * to each cpuset marked is_sched_load_balance into the |
538 | * array 'csa'. For our purposes, rebuilding the schedulers | 562 | * array 'csa'. For our purposes, rebuilding the schedulers |
@@ -567,7 +591,7 @@ update_domain_attr(struct sched_domain_attr *dattr, struct cpuset *c) | |||
567 | 591 | ||
568 | void rebuild_sched_domains(void) | 592 | void rebuild_sched_domains(void) |
569 | { | 593 | { |
570 | struct kfifo *q; /* queue of cpusets to be scanned */ | 594 | LIST_HEAD(q); /* queue of cpusets to be scanned*/ |
571 | struct cpuset *cp; /* scans q */ | 595 | struct cpuset *cp; /* scans q */ |
572 | struct cpuset **csa; /* array of all cpuset ptrs */ | 596 | struct cpuset **csa; /* array of all cpuset ptrs */ |
573 | int csn; /* how many cpuset ptrs in csa so far */ | 597 | int csn; /* how many cpuset ptrs in csa so far */ |
@@ -577,7 +601,6 @@ void rebuild_sched_domains(void) | |||
577 | int ndoms; /* number of sched domains in result */ | 601 | int ndoms; /* number of sched domains in result */ |
578 | int nslot; /* next empty doms[] cpumask_t slot */ | 602 | int nslot; /* next empty doms[] cpumask_t slot */ |
579 | 603 | ||
580 | q = NULL; | ||
581 | csa = NULL; | 604 | csa = NULL; |
582 | doms = NULL; | 605 | doms = NULL; |
583 | dattr = NULL; | 606 | dattr = NULL; |
@@ -591,35 +614,42 @@ void rebuild_sched_domains(void) | |||
591 | dattr = kmalloc(sizeof(struct sched_domain_attr), GFP_KERNEL); | 614 | dattr = kmalloc(sizeof(struct sched_domain_attr), GFP_KERNEL); |
592 | if (dattr) { | 615 | if (dattr) { |
593 | *dattr = SD_ATTR_INIT; | 616 | *dattr = SD_ATTR_INIT; |
594 | update_domain_attr(dattr, &top_cpuset); | 617 | update_domain_attr_tree(dattr, &top_cpuset); |
595 | } | 618 | } |
596 | *doms = top_cpuset.cpus_allowed; | 619 | *doms = top_cpuset.cpus_allowed; |
597 | goto rebuild; | 620 | goto rebuild; |
598 | } | 621 | } |
599 | 622 | ||
600 | q = kfifo_alloc(number_of_cpusets * sizeof(cp), GFP_KERNEL, NULL); | ||
601 | if (IS_ERR(q)) | ||
602 | goto done; | ||
603 | csa = kmalloc(number_of_cpusets * sizeof(cp), GFP_KERNEL); | 623 | csa = kmalloc(number_of_cpusets * sizeof(cp), GFP_KERNEL); |
604 | if (!csa) | 624 | if (!csa) |
605 | goto done; | 625 | goto done; |
606 | csn = 0; | 626 | csn = 0; |
607 | 627 | ||
608 | cp = &top_cpuset; | 628 | list_add(&top_cpuset.stack_list, &q); |
609 | __kfifo_put(q, (void *)&cp, sizeof(cp)); | 629 | while (!list_empty(&q)) { |
610 | while (__kfifo_get(q, (void *)&cp, sizeof(cp))) { | ||
611 | struct cgroup *cont; | 630 | struct cgroup *cont; |
612 | struct cpuset *child; /* scans child cpusets of cp */ | 631 | struct cpuset *child; /* scans child cpusets of cp */ |
613 | 632 | ||
633 | cp = list_first_entry(&q, struct cpuset, stack_list); | ||
634 | list_del(q.next); | ||
635 | |||
614 | if (cpus_empty(cp->cpus_allowed)) | 636 | if (cpus_empty(cp->cpus_allowed)) |
615 | continue; | 637 | continue; |
616 | 638 | ||
617 | if (is_sched_load_balance(cp)) | 639 | /* |
640 | * All child cpusets contain a subset of the parent's cpus, so | ||
641 | * just skip them, and then we call update_domain_attr_tree() | ||
642 | * to calc relax_domain_level of the corresponding sched | ||
643 | * domain. | ||
644 | */ | ||
645 | if (is_sched_load_balance(cp)) { | ||
618 | csa[csn++] = cp; | 646 | csa[csn++] = cp; |
647 | continue; | ||
648 | } | ||
619 | 649 | ||
620 | list_for_each_entry(cont, &cp->css.cgroup->children, sibling) { | 650 | list_for_each_entry(cont, &cp->css.cgroup->children, sibling) { |
621 | child = cgroup_cs(cont); | 651 | child = cgroup_cs(cont); |
622 | __kfifo_put(q, (void *)&child, sizeof(cp)); | 652 | list_add_tail(&child->stack_list, &q); |
623 | } | 653 | } |
624 | } | 654 | } |
625 | 655 | ||
@@ -686,7 +716,7 @@ restart: | |||
686 | cpus_or(*dp, *dp, b->cpus_allowed); | 716 | cpus_or(*dp, *dp, b->cpus_allowed); |
687 | b->pn = -1; | 717 | b->pn = -1; |
688 | if (dattr) | 718 | if (dattr) |
689 | update_domain_attr(dattr | 719 | update_domain_attr_tree(dattr |
690 | + nslot, b); | 720 | + nslot, b); |
691 | } | 721 | } |
692 | } | 722 | } |
@@ -702,8 +732,6 @@ rebuild: | |||
702 | put_online_cpus(); | 732 | put_online_cpus(); |
703 | 733 | ||
704 | done: | 734 | done: |
705 | if (q && !IS_ERR(q)) | ||
706 | kfifo_free(q); | ||
707 | kfree(csa); | 735 | kfree(csa); |
708 | /* Don't kfree(doms) -- partition_sched_domains() does that. */ | 736 | /* Don't kfree(doms) -- partition_sched_domains() does that. */ |
709 | /* Don't kfree(dattr) -- partition_sched_domains() does that. */ | 737 | /* Don't kfree(dattr) -- partition_sched_domains() does that. */ |
@@ -1833,24 +1861,21 @@ static void remove_tasks_in_empty_cpuset(struct cpuset *cs) | |||
1833 | */ | 1861 | */ |
1834 | static void scan_for_empty_cpusets(const struct cpuset *root) | 1862 | static void scan_for_empty_cpusets(const struct cpuset *root) |
1835 | { | 1863 | { |
1864 | LIST_HEAD(queue); | ||
1836 | struct cpuset *cp; /* scans cpusets being updated */ | 1865 | struct cpuset *cp; /* scans cpusets being updated */ |
1837 | struct cpuset *child; /* scans child cpusets of cp */ | 1866 | struct cpuset *child; /* scans child cpusets of cp */ |
1838 | struct list_head queue; | ||
1839 | struct cgroup *cont; | 1867 | struct cgroup *cont; |
1840 | nodemask_t oldmems; | 1868 | nodemask_t oldmems; |
1841 | 1869 | ||
1842 | INIT_LIST_HEAD(&queue); | ||
1843 | |||
1844 | list_add_tail((struct list_head *)&root->stack_list, &queue); | 1870 | list_add_tail((struct list_head *)&root->stack_list, &queue); |
1845 | 1871 | ||
1846 | while (!list_empty(&queue)) { | 1872 | while (!list_empty(&queue)) { |
1847 | cp = container_of(queue.next, struct cpuset, stack_list); | 1873 | cp = list_first_entry(&queue, struct cpuset, stack_list); |
1848 | list_del(queue.next); | 1874 | list_del(queue.next); |
1849 | list_for_each_entry(cont, &cp->css.cgroup->children, sibling) { | 1875 | list_for_each_entry(cont, &cp->css.cgroup->children, sibling) { |
1850 | child = cgroup_cs(cont); | 1876 | child = cgroup_cs(cont); |
1851 | list_add_tail(&child->stack_list, &queue); | 1877 | list_add_tail(&child->stack_list, &queue); |
1852 | } | 1878 | } |
1853 | cont = cp->css.cgroup; | ||
1854 | 1879 | ||
1855 | /* Continue past cpusets with all cpus, mems online */ | 1880 | /* Continue past cpusets with all cpus, mems online */ |
1856 | if (cpus_subset(cp->cpus_allowed, cpu_online_map) && | 1881 | if (cpus_subset(cp->cpus_allowed, cpu_online_map) && |
diff --git a/kernel/dma-coherent.c b/kernel/dma-coherent.c new file mode 100644 index 000000000000..7517115a8cce --- /dev/null +++ b/kernel/dma-coherent.c | |||
@@ -0,0 +1,154 @@ | |||
1 | /* | ||
2 | * Coherent per-device memory handling. | ||
3 | * Borrowed from i386 | ||
4 | */ | ||
5 | #include <linux/kernel.h> | ||
6 | #include <linux/dma-mapping.h> | ||
7 | |||
8 | struct dma_coherent_mem { | ||
9 | void *virt_base; | ||
10 | u32 device_base; | ||
11 | int size; | ||
12 | int flags; | ||
13 | unsigned long *bitmap; | ||
14 | }; | ||
15 | |||
16 | int dma_declare_coherent_memory(struct device *dev, dma_addr_t bus_addr, | ||
17 | dma_addr_t device_addr, size_t size, int flags) | ||
18 | { | ||
19 | void __iomem *mem_base = NULL; | ||
20 | int pages = size >> PAGE_SHIFT; | ||
21 | int bitmap_size = BITS_TO_LONGS(pages) * sizeof(long); | ||
22 | |||
23 | if ((flags & (DMA_MEMORY_MAP | DMA_MEMORY_IO)) == 0) | ||
24 | goto out; | ||
25 | if (!size) | ||
26 | goto out; | ||
27 | if (dev->dma_mem) | ||
28 | goto out; | ||
29 | |||
30 | /* FIXME: this routine just ignores DMA_MEMORY_INCLUDES_CHILDREN */ | ||
31 | |||
32 | mem_base = ioremap(bus_addr, size); | ||
33 | if (!mem_base) | ||
34 | goto out; | ||
35 | |||
36 | dev->dma_mem = kzalloc(sizeof(struct dma_coherent_mem), GFP_KERNEL); | ||
37 | if (!dev->dma_mem) | ||
38 | goto out; | ||
39 | dev->dma_mem->bitmap = kzalloc(bitmap_size, GFP_KERNEL); | ||
40 | if (!dev->dma_mem->bitmap) | ||
41 | goto free1_out; | ||
42 | |||
43 | dev->dma_mem->virt_base = mem_base; | ||
44 | dev->dma_mem->device_base = device_addr; | ||
45 | dev->dma_mem->size = pages; | ||
46 | dev->dma_mem->flags = flags; | ||
47 | |||
48 | if (flags & DMA_MEMORY_MAP) | ||
49 | return DMA_MEMORY_MAP; | ||
50 | |||
51 | return DMA_MEMORY_IO; | ||
52 | |||
53 | free1_out: | ||
54 | kfree(dev->dma_mem); | ||
55 | out: | ||
56 | if (mem_base) | ||
57 | iounmap(mem_base); | ||
58 | return 0; | ||
59 | } | ||
60 | EXPORT_SYMBOL(dma_declare_coherent_memory); | ||
61 | |||
62 | void dma_release_declared_memory(struct device *dev) | ||
63 | { | ||
64 | struct dma_coherent_mem *mem = dev->dma_mem; | ||
65 | |||
66 | if (!mem) | ||
67 | return; | ||
68 | dev->dma_mem = NULL; | ||
69 | iounmap(mem->virt_base); | ||
70 | kfree(mem->bitmap); | ||
71 | kfree(mem); | ||
72 | } | ||
73 | EXPORT_SYMBOL(dma_release_declared_memory); | ||
74 | |||
75 | void *dma_mark_declared_memory_occupied(struct device *dev, | ||
76 | dma_addr_t device_addr, size_t size) | ||
77 | { | ||
78 | struct dma_coherent_mem *mem = dev->dma_mem; | ||
79 | int pos, err; | ||
80 | int pages = (size + (device_addr & ~PAGE_MASK) + PAGE_SIZE - 1); | ||
81 | |||
82 | pages >>= PAGE_SHIFT; | ||
83 | |||
84 | if (!mem) | ||
85 | return ERR_PTR(-EINVAL); | ||
86 | |||
87 | pos = (device_addr - mem->device_base) >> PAGE_SHIFT; | ||
88 | err = bitmap_allocate_region(mem->bitmap, pos, get_order(pages)); | ||
89 | if (err != 0) | ||
90 | return ERR_PTR(err); | ||
91 | return mem->virt_base + (pos << PAGE_SHIFT); | ||
92 | } | ||
93 | EXPORT_SYMBOL(dma_mark_declared_memory_occupied); | ||
94 | |||
95 | /** | ||
96 | * Try to allocate memory from the per-device coherent area. | ||
97 | * | ||
98 | * @dev: device from which we allocate memory | ||
99 | * @size: size of requested memory area | ||
100 | * @dma_handle: This will be filled with the correct dma handle | ||
101 | * @ret: This pointer will be filled with the virtual address | ||
102 | * to allocated area. | ||
103 | * | ||
104 | * This function should be only called from per-arch %dma_alloc_coherent() | ||
105 | * to support allocation from per-device coherent memory pools. | ||
106 | * | ||
107 | * Returns 0 if dma_alloc_coherent should continue with allocating from | ||
108 | * generic memory areas, or !0 if dma_alloc_coherent should return %ret. | ||
109 | */ | ||
110 | int dma_alloc_from_coherent(struct device *dev, ssize_t size, | ||
111 | dma_addr_t *dma_handle, void **ret) | ||
112 | { | ||
113 | struct dma_coherent_mem *mem = dev ? dev->dma_mem : NULL; | ||
114 | int order = get_order(size); | ||
115 | |||
116 | if (mem) { | ||
117 | int page = bitmap_find_free_region(mem->bitmap, mem->size, | ||
118 | order); | ||
119 | if (page >= 0) { | ||
120 | *dma_handle = mem->device_base + (page << PAGE_SHIFT); | ||
121 | *ret = mem->virt_base + (page << PAGE_SHIFT); | ||
122 | memset(*ret, 0, size); | ||
123 | } else if (mem->flags & DMA_MEMORY_EXCLUSIVE) | ||
124 | *ret = NULL; | ||
125 | } | ||
126 | return (mem != NULL); | ||
127 | } | ||
128 | |||
129 | /** | ||
130 | * Try to free the memory allocated from per-device coherent memory pool. | ||
131 | * @dev: device from which the memory was allocated | ||
132 | * @order: the order of pages allocated | ||
133 | * @vaddr: virtual address of allocated pages | ||
134 | * | ||
135 | * This checks whether the memory was allocated from the per-device | ||
136 | * coherent memory pool and if so, releases that memory. | ||
137 | * | ||
138 | * Returns 1 if we correctly released the memory, or 0 if | ||
139 | * %dma_release_coherent() should proceed with releasing memory from | ||
140 | * generic pools. | ||
141 | */ | ||
142 | int dma_release_from_coherent(struct device *dev, int order, void *vaddr) | ||
143 | { | ||
144 | struct dma_coherent_mem *mem = dev ? dev->dma_mem : NULL; | ||
145 | |||
146 | if (mem && vaddr >= mem->virt_base && vaddr < | ||
147 | (mem->virt_base + (mem->size << PAGE_SHIFT))) { | ||
148 | int page = (vaddr - mem->virt_base) >> PAGE_SHIFT; | ||
149 | |||
150 | bitmap_release_region(mem->bitmap, page, order); | ||
151 | return 1; | ||
152 | } | ||
153 | return 0; | ||
154 | } | ||
diff --git a/kernel/fork.c b/kernel/fork.c index 8214ba7c8bb1..7ce2ebe84796 100644 --- a/kernel/fork.c +++ b/kernel/fork.c | |||
@@ -27,6 +27,7 @@ | |||
27 | #include <linux/key.h> | 27 | #include <linux/key.h> |
28 | #include <linux/binfmts.h> | 28 | #include <linux/binfmts.h> |
29 | #include <linux/mman.h> | 29 | #include <linux/mman.h> |
30 | #include <linux/mmu_notifier.h> | ||
30 | #include <linux/fs.h> | 31 | #include <linux/fs.h> |
31 | #include <linux/nsproxy.h> | 32 | #include <linux/nsproxy.h> |
32 | #include <linux/capability.h> | 33 | #include <linux/capability.h> |
@@ -414,6 +415,7 @@ static struct mm_struct * mm_init(struct mm_struct * mm, struct task_struct *p) | |||
414 | 415 | ||
415 | if (likely(!mm_alloc_pgd(mm))) { | 416 | if (likely(!mm_alloc_pgd(mm))) { |
416 | mm->def_flags = 0; | 417 | mm->def_flags = 0; |
418 | mmu_notifier_mm_init(mm); | ||
417 | return mm; | 419 | return mm; |
418 | } | 420 | } |
419 | 421 | ||
@@ -446,6 +448,7 @@ void __mmdrop(struct mm_struct *mm) | |||
446 | BUG_ON(mm == &init_mm); | 448 | BUG_ON(mm == &init_mm); |
447 | mm_free_pgd(mm); | 449 | mm_free_pgd(mm); |
448 | destroy_context(mm); | 450 | destroy_context(mm); |
451 | mmu_notifier_mm_destroy(mm); | ||
449 | free_mm(mm); | 452 | free_mm(mm); |
450 | } | 453 | } |
451 | EXPORT_SYMBOL_GPL(__mmdrop); | 454 | EXPORT_SYMBOL_GPL(__mmdrop); |
diff --git a/kernel/kgdb.c b/kernel/kgdb.c index 3ec23c3ec97f..eaa21fc9ad1d 100644 --- a/kernel/kgdb.c +++ b/kernel/kgdb.c | |||
@@ -56,12 +56,14 @@ | |||
56 | 56 | ||
57 | static int kgdb_break_asap; | 57 | static int kgdb_break_asap; |
58 | 58 | ||
59 | #define KGDB_MAX_THREAD_QUERY 17 | ||
59 | struct kgdb_state { | 60 | struct kgdb_state { |
60 | int ex_vector; | 61 | int ex_vector; |
61 | int signo; | 62 | int signo; |
62 | int err_code; | 63 | int err_code; |
63 | int cpu; | 64 | int cpu; |
64 | int pass_exception; | 65 | int pass_exception; |
66 | unsigned long thr_query; | ||
65 | unsigned long threadid; | 67 | unsigned long threadid; |
66 | long kgdb_usethreadid; | 68 | long kgdb_usethreadid; |
67 | struct pt_regs *linux_regs; | 69 | struct pt_regs *linux_regs; |
@@ -166,13 +168,6 @@ early_param("nokgdbroundup", opt_nokgdbroundup); | |||
166 | * Weak aliases for breakpoint management, | 168 | * Weak aliases for breakpoint management, |
167 | * can be overriden by architectures when needed: | 169 | * can be overriden by architectures when needed: |
168 | */ | 170 | */ |
169 | int __weak kgdb_validate_break_address(unsigned long addr) | ||
170 | { | ||
171 | char tmp_variable[BREAK_INSTR_SIZE]; | ||
172 | |||
173 | return probe_kernel_read(tmp_variable, (char *)addr, BREAK_INSTR_SIZE); | ||
174 | } | ||
175 | |||
176 | int __weak kgdb_arch_set_breakpoint(unsigned long addr, char *saved_instr) | 171 | int __weak kgdb_arch_set_breakpoint(unsigned long addr, char *saved_instr) |
177 | { | 172 | { |
178 | int err; | 173 | int err; |
@@ -191,6 +186,25 @@ int __weak kgdb_arch_remove_breakpoint(unsigned long addr, char *bundle) | |||
191 | (char *)bundle, BREAK_INSTR_SIZE); | 186 | (char *)bundle, BREAK_INSTR_SIZE); |
192 | } | 187 | } |
193 | 188 | ||
189 | int __weak kgdb_validate_break_address(unsigned long addr) | ||
190 | { | ||
191 | char tmp_variable[BREAK_INSTR_SIZE]; | ||
192 | int err; | ||
193 | /* Validate setting the breakpoint and then removing it. In the | ||
194 | * remove fails, the kernel needs to emit a bad message because we | ||
195 | * are deep trouble not being able to put things back the way we | ||
196 | * found them. | ||
197 | */ | ||
198 | err = kgdb_arch_set_breakpoint(addr, tmp_variable); | ||
199 | if (err) | ||
200 | return err; | ||
201 | err = kgdb_arch_remove_breakpoint(addr, tmp_variable); | ||
202 | if (err) | ||
203 | printk(KERN_ERR "KGDB: Critical breakpoint error, kernel " | ||
204 | "memory destroyed at: %lx", addr); | ||
205 | return err; | ||
206 | } | ||
207 | |||
194 | unsigned long __weak kgdb_arch_pc(int exception, struct pt_regs *regs) | 208 | unsigned long __weak kgdb_arch_pc(int exception, struct pt_regs *regs) |
195 | { | 209 | { |
196 | return instruction_pointer(regs); | 210 | return instruction_pointer(regs); |
@@ -433,9 +447,14 @@ int kgdb_hex2long(char **ptr, unsigned long *long_val) | |||
433 | { | 447 | { |
434 | int hex_val; | 448 | int hex_val; |
435 | int num = 0; | 449 | int num = 0; |
450 | int negate = 0; | ||
436 | 451 | ||
437 | *long_val = 0; | 452 | *long_val = 0; |
438 | 453 | ||
454 | if (**ptr == '-') { | ||
455 | negate = 1; | ||
456 | (*ptr)++; | ||
457 | } | ||
439 | while (**ptr) { | 458 | while (**ptr) { |
440 | hex_val = hex(**ptr); | 459 | hex_val = hex(**ptr); |
441 | if (hex_val < 0) | 460 | if (hex_val < 0) |
@@ -446,6 +465,9 @@ int kgdb_hex2long(char **ptr, unsigned long *long_val) | |||
446 | (*ptr)++; | 465 | (*ptr)++; |
447 | } | 466 | } |
448 | 467 | ||
468 | if (negate) | ||
469 | *long_val = -*long_val; | ||
470 | |||
449 | return num; | 471 | return num; |
450 | } | 472 | } |
451 | 473 | ||
@@ -515,10 +537,16 @@ static void int_to_threadref(unsigned char *id, int value) | |||
515 | static struct task_struct *getthread(struct pt_regs *regs, int tid) | 537 | static struct task_struct *getthread(struct pt_regs *regs, int tid) |
516 | { | 538 | { |
517 | /* | 539 | /* |
518 | * Non-positive TIDs are remapped idle tasks: | 540 | * Non-positive TIDs are remapped to the cpu shadow information |
519 | */ | 541 | */ |
520 | if (tid <= 0) | 542 | if (tid == 0 || tid == -1) |
521 | return idle_task(-tid); | 543 | tid = -atomic_read(&kgdb_active) - 2; |
544 | if (tid < 0) { | ||
545 | if (kgdb_info[-tid - 2].task) | ||
546 | return kgdb_info[-tid - 2].task; | ||
547 | else | ||
548 | return idle_task(-tid - 2); | ||
549 | } | ||
522 | 550 | ||
523 | /* | 551 | /* |
524 | * find_task_by_pid_ns() does not take the tasklist lock anymore | 552 | * find_task_by_pid_ns() does not take the tasklist lock anymore |
@@ -725,14 +753,15 @@ setundefined: | |||
725 | } | 753 | } |
726 | 754 | ||
727 | /* | 755 | /* |
728 | * Remap normal tasks to their real PID, idle tasks to -1 ... -NR_CPUs: | 756 | * Remap normal tasks to their real PID, |
757 | * CPU shadow threads are mapped to -CPU - 2 | ||
729 | */ | 758 | */ |
730 | static inline int shadow_pid(int realpid) | 759 | static inline int shadow_pid(int realpid) |
731 | { | 760 | { |
732 | if (realpid) | 761 | if (realpid) |
733 | return realpid; | 762 | return realpid; |
734 | 763 | ||
735 | return -1-raw_smp_processor_id(); | 764 | return -raw_smp_processor_id() - 2; |
736 | } | 765 | } |
737 | 766 | ||
738 | static char gdbmsgbuf[BUFMAX + 1]; | 767 | static char gdbmsgbuf[BUFMAX + 1]; |
@@ -826,7 +855,7 @@ static void gdb_cmd_getregs(struct kgdb_state *ks) | |||
826 | local_debuggerinfo = kgdb_info[ks->cpu].debuggerinfo; | 855 | local_debuggerinfo = kgdb_info[ks->cpu].debuggerinfo; |
827 | } else { | 856 | } else { |
828 | local_debuggerinfo = NULL; | 857 | local_debuggerinfo = NULL; |
829 | for (i = 0; i < NR_CPUS; i++) { | 858 | for_each_online_cpu(i) { |
830 | /* | 859 | /* |
831 | * Try to find the task on some other | 860 | * Try to find the task on some other |
832 | * or possibly this node if we do not | 861 | * or possibly this node if we do not |
@@ -960,10 +989,13 @@ static int gdb_cmd_reboot(struct kgdb_state *ks) | |||
960 | /* Handle the 'q' query packets */ | 989 | /* Handle the 'q' query packets */ |
961 | static void gdb_cmd_query(struct kgdb_state *ks) | 990 | static void gdb_cmd_query(struct kgdb_state *ks) |
962 | { | 991 | { |
963 | struct task_struct *thread; | 992 | struct task_struct *g; |
993 | struct task_struct *p; | ||
964 | unsigned char thref[8]; | 994 | unsigned char thref[8]; |
965 | char *ptr; | 995 | char *ptr; |
966 | int i; | 996 | int i; |
997 | int cpu; | ||
998 | int finished = 0; | ||
967 | 999 | ||
968 | switch (remcom_in_buffer[1]) { | 1000 | switch (remcom_in_buffer[1]) { |
969 | case 's': | 1001 | case 's': |
@@ -973,22 +1005,34 @@ static void gdb_cmd_query(struct kgdb_state *ks) | |||
973 | break; | 1005 | break; |
974 | } | 1006 | } |
975 | 1007 | ||
976 | if (remcom_in_buffer[1] == 'f') | 1008 | i = 0; |
977 | ks->threadid = 1; | ||
978 | |||
979 | remcom_out_buffer[0] = 'm'; | 1009 | remcom_out_buffer[0] = 'm'; |
980 | ptr = remcom_out_buffer + 1; | 1010 | ptr = remcom_out_buffer + 1; |
981 | 1011 | if (remcom_in_buffer[1] == 'f') { | |
982 | for (i = 0; i < 17; ks->threadid++) { | 1012 | /* Each cpu is a shadow thread */ |
983 | thread = getthread(ks->linux_regs, ks->threadid); | 1013 | for_each_online_cpu(cpu) { |
984 | if (thread) { | 1014 | ks->thr_query = 0; |
985 | int_to_threadref(thref, ks->threadid); | 1015 | int_to_threadref(thref, -cpu - 2); |
986 | pack_threadid(ptr, thref); | 1016 | pack_threadid(ptr, thref); |
987 | ptr += BUF_THREAD_ID_SIZE; | 1017 | ptr += BUF_THREAD_ID_SIZE; |
988 | *(ptr++) = ','; | 1018 | *(ptr++) = ','; |
989 | i++; | 1019 | i++; |
990 | } | 1020 | } |
991 | } | 1021 | } |
1022 | |||
1023 | do_each_thread(g, p) { | ||
1024 | if (i >= ks->thr_query && !finished) { | ||
1025 | int_to_threadref(thref, p->pid); | ||
1026 | pack_threadid(ptr, thref); | ||
1027 | ptr += BUF_THREAD_ID_SIZE; | ||
1028 | *(ptr++) = ','; | ||
1029 | ks->thr_query++; | ||
1030 | if (ks->thr_query % KGDB_MAX_THREAD_QUERY == 0) | ||
1031 | finished = 1; | ||
1032 | } | ||
1033 | i++; | ||
1034 | } while_each_thread(g, p); | ||
1035 | |||
992 | *(--ptr) = '\0'; | 1036 | *(--ptr) = '\0'; |
993 | break; | 1037 | break; |
994 | 1038 | ||
@@ -1011,15 +1055,15 @@ static void gdb_cmd_query(struct kgdb_state *ks) | |||
1011 | error_packet(remcom_out_buffer, -EINVAL); | 1055 | error_packet(remcom_out_buffer, -EINVAL); |
1012 | break; | 1056 | break; |
1013 | } | 1057 | } |
1014 | if (ks->threadid > 0) { | 1058 | if ((int)ks->threadid > 0) { |
1015 | kgdb_mem2hex(getthread(ks->linux_regs, | 1059 | kgdb_mem2hex(getthread(ks->linux_regs, |
1016 | ks->threadid)->comm, | 1060 | ks->threadid)->comm, |
1017 | remcom_out_buffer, 16); | 1061 | remcom_out_buffer, 16); |
1018 | } else { | 1062 | } else { |
1019 | static char tmpstr[23 + BUF_THREAD_ID_SIZE]; | 1063 | static char tmpstr[23 + BUF_THREAD_ID_SIZE]; |
1020 | 1064 | ||
1021 | sprintf(tmpstr, "Shadow task %d for pid 0", | 1065 | sprintf(tmpstr, "shadowCPU%d", |
1022 | (int)(-ks->threadid-1)); | 1066 | (int)(-ks->threadid - 2)); |
1023 | kgdb_mem2hex(tmpstr, remcom_out_buffer, strlen(tmpstr)); | 1067 | kgdb_mem2hex(tmpstr, remcom_out_buffer, strlen(tmpstr)); |
1024 | } | 1068 | } |
1025 | break; | 1069 | break; |
diff --git a/kernel/marker.c b/kernel/marker.c index 971da5317903..7d1faecd7a51 100644 --- a/kernel/marker.c +++ b/kernel/marker.c | |||
@@ -126,6 +126,11 @@ void marker_probe_cb(const struct marker *mdata, void *call_private, ...) | |||
126 | struct marker_probe_closure *multi; | 126 | struct marker_probe_closure *multi; |
127 | int i; | 127 | int i; |
128 | /* | 128 | /* |
129 | * Read mdata->ptype before mdata->multi. | ||
130 | */ | ||
131 | smp_rmb(); | ||
132 | multi = mdata->multi; | ||
133 | /* | ||
129 | * multi points to an array, therefore accessing the array | 134 | * multi points to an array, therefore accessing the array |
130 | * depends on reading multi. However, even in this case, | 135 | * depends on reading multi. However, even in this case, |
131 | * we must insure that the pointer is read _before_ the array | 136 | * we must insure that the pointer is read _before_ the array |
@@ -133,7 +138,6 @@ void marker_probe_cb(const struct marker *mdata, void *call_private, ...) | |||
133 | * in the fast path, so put the explicit barrier here. | 138 | * in the fast path, so put the explicit barrier here. |
134 | */ | 139 | */ |
135 | smp_read_barrier_depends(); | 140 | smp_read_barrier_depends(); |
136 | multi = mdata->multi; | ||
137 | for (i = 0; multi[i].func; i++) { | 141 | for (i = 0; multi[i].func; i++) { |
138 | va_start(args, call_private); | 142 | va_start(args, call_private); |
139 | multi[i].func(multi[i].probe_private, call_private, | 143 | multi[i].func(multi[i].probe_private, call_private, |
@@ -175,6 +179,11 @@ void marker_probe_cb_noarg(const struct marker *mdata, void *call_private, ...) | |||
175 | struct marker_probe_closure *multi; | 179 | struct marker_probe_closure *multi; |
176 | int i; | 180 | int i; |
177 | /* | 181 | /* |
182 | * Read mdata->ptype before mdata->multi. | ||
183 | */ | ||
184 | smp_rmb(); | ||
185 | multi = mdata->multi; | ||
186 | /* | ||
178 | * multi points to an array, therefore accessing the array | 187 | * multi points to an array, therefore accessing the array |
179 | * depends on reading multi. However, even in this case, | 188 | * depends on reading multi. However, even in this case, |
180 | * we must insure that the pointer is read _before_ the array | 189 | * we must insure that the pointer is read _before_ the array |
@@ -182,7 +191,6 @@ void marker_probe_cb_noarg(const struct marker *mdata, void *call_private, ...) | |||
182 | * in the fast path, so put the explicit barrier here. | 191 | * in the fast path, so put the explicit barrier here. |
183 | */ | 192 | */ |
184 | smp_read_barrier_depends(); | 193 | smp_read_barrier_depends(); |
185 | multi = mdata->multi; | ||
186 | for (i = 0; multi[i].func; i++) | 194 | for (i = 0; multi[i].func; i++) |
187 | multi[i].func(multi[i].probe_private, call_private, | 195 | multi[i].func(multi[i].probe_private, call_private, |
188 | mdata->format, &args); | 196 | mdata->format, &args); |
diff --git a/kernel/module.c b/kernel/module.c index d8b5605132a0..61d212120df4 100644 --- a/kernel/module.c +++ b/kernel/module.c | |||
@@ -325,18 +325,6 @@ static unsigned long find_symbol(const char *name, | |||
325 | return -ENOENT; | 325 | return -ENOENT; |
326 | } | 326 | } |
327 | 327 | ||
328 | /* lookup symbol in given range of kernel_symbols */ | ||
329 | static const struct kernel_symbol *lookup_symbol(const char *name, | ||
330 | const struct kernel_symbol *start, | ||
331 | const struct kernel_symbol *stop) | ||
332 | { | ||
333 | const struct kernel_symbol *ks = start; | ||
334 | for (; ks < stop; ks++) | ||
335 | if (strcmp(ks->name, name) == 0) | ||
336 | return ks; | ||
337 | return NULL; | ||
338 | } | ||
339 | |||
340 | /* Search for module by name: must hold module_mutex. */ | 328 | /* Search for module by name: must hold module_mutex. */ |
341 | static struct module *find_module(const char *name) | 329 | static struct module *find_module(const char *name) |
342 | { | 330 | { |
@@ -690,7 +678,7 @@ static int try_stop_module(struct module *mod, int flags, int *forced) | |||
690 | if (flags & O_NONBLOCK) { | 678 | if (flags & O_NONBLOCK) { |
691 | struct stopref sref = { mod, flags, forced }; | 679 | struct stopref sref = { mod, flags, forced }; |
692 | 680 | ||
693 | return stop_machine_run(__try_stop_module, &sref, NR_CPUS); | 681 | return stop_machine(__try_stop_module, &sref, NULL); |
694 | } else { | 682 | } else { |
695 | /* We don't need to stop the machine for this. */ | 683 | /* We don't need to stop the machine for this. */ |
696 | mod->state = MODULE_STATE_GOING; | 684 | mod->state = MODULE_STATE_GOING; |
@@ -1428,7 +1416,7 @@ static int __unlink_module(void *_mod) | |||
1428 | static void free_module(struct module *mod) | 1416 | static void free_module(struct module *mod) |
1429 | { | 1417 | { |
1430 | /* Delete from various lists */ | 1418 | /* Delete from various lists */ |
1431 | stop_machine_run(__unlink_module, mod, NR_CPUS); | 1419 | stop_machine(__unlink_module, mod, NULL); |
1432 | remove_notes_attrs(mod); | 1420 | remove_notes_attrs(mod); |
1433 | remove_sect_attrs(mod); | 1421 | remove_sect_attrs(mod); |
1434 | mod_kobject_remove(mod); | 1422 | mod_kobject_remove(mod); |
@@ -1703,6 +1691,19 @@ static void setup_modinfo(struct module *mod, Elf_Shdr *sechdrs, | |||
1703 | } | 1691 | } |
1704 | 1692 | ||
1705 | #ifdef CONFIG_KALLSYMS | 1693 | #ifdef CONFIG_KALLSYMS |
1694 | |||
1695 | /* lookup symbol in given range of kernel_symbols */ | ||
1696 | static const struct kernel_symbol *lookup_symbol(const char *name, | ||
1697 | const struct kernel_symbol *start, | ||
1698 | const struct kernel_symbol *stop) | ||
1699 | { | ||
1700 | const struct kernel_symbol *ks = start; | ||
1701 | for (; ks < stop; ks++) | ||
1702 | if (strcmp(ks->name, name) == 0) | ||
1703 | return ks; | ||
1704 | return NULL; | ||
1705 | } | ||
1706 | |||
1706 | static int is_exported(const char *name, const struct module *mod) | 1707 | static int is_exported(const char *name, const struct module *mod) |
1707 | { | 1708 | { |
1708 | if (!mod && lookup_symbol(name, __start___ksymtab, __stop___ksymtab)) | 1709 | if (!mod && lookup_symbol(name, __start___ksymtab, __stop___ksymtab)) |
@@ -2196,7 +2197,7 @@ static struct module *load_module(void __user *umod, | |||
2196 | /* Now sew it into the lists so we can get lockdep and oops | 2197 | /* Now sew it into the lists so we can get lockdep and oops |
2197 | * info during argument parsing. Noone should access us, since | 2198 | * info during argument parsing. Noone should access us, since |
2198 | * strong_try_module_get() will fail. */ | 2199 | * strong_try_module_get() will fail. */ |
2199 | stop_machine_run(__link_module, mod, NR_CPUS); | 2200 | stop_machine(__link_module, mod, NULL); |
2200 | 2201 | ||
2201 | /* Size of section 0 is 0, so this works well if no params */ | 2202 | /* Size of section 0 is 0, so this works well if no params */ |
2202 | err = parse_args(mod->name, mod->args, | 2203 | err = parse_args(mod->name, mod->args, |
@@ -2230,7 +2231,7 @@ static struct module *load_module(void __user *umod, | |||
2230 | return mod; | 2231 | return mod; |
2231 | 2232 | ||
2232 | unlink: | 2233 | unlink: |
2233 | stop_machine_run(__unlink_module, mod, NR_CPUS); | 2234 | stop_machine(__unlink_module, mod, NULL); |
2234 | module_arch_cleanup(mod); | 2235 | module_arch_cleanup(mod); |
2235 | cleanup: | 2236 | cleanup: |
2236 | kobject_del(&mod->mkobj.kobj); | 2237 | kobject_del(&mod->mkobj.kobj); |
diff --git a/kernel/printk.c b/kernel/printk.c index a7f7559c5f6c..b51b1567bb55 100644 --- a/kernel/printk.c +++ b/kernel/printk.c | |||
@@ -1309,14 +1309,14 @@ void tty_write_message(struct tty_struct *tty, char *msg) | |||
1309 | 1309 | ||
1310 | #if defined CONFIG_PRINTK | 1310 | #if defined CONFIG_PRINTK |
1311 | 1311 | ||
1312 | DEFINE_RATELIMIT_STATE(printk_ratelimit_state, 5 * HZ, 10); | ||
1313 | /* | 1312 | /* |
1314 | * printk rate limiting, lifted from the networking subsystem. | 1313 | * printk rate limiting, lifted from the networking subsystem. |
1315 | * | 1314 | * |
1316 | * This enforces a rate limit: not more than one kernel message | 1315 | * This enforces a rate limit: not more than 10 kernel messages |
1317 | * every printk_ratelimit_jiffies to make a denial-of-service | 1316 | * every 5s to make a denial-of-service attack impossible. |
1318 | * attack impossible. | ||
1319 | */ | 1317 | */ |
1318 | DEFINE_RATELIMIT_STATE(printk_ratelimit_state, 5 * HZ, 10); | ||
1319 | |||
1320 | int printk_ratelimit(void) | 1320 | int printk_ratelimit(void) |
1321 | { | 1321 | { |
1322 | return __ratelimit(&printk_ratelimit_state); | 1322 | return __ratelimit(&printk_ratelimit_state); |
diff --git a/kernel/rcuclassic.c b/kernel/rcuclassic.c index 6f8696c502f4..aad93cdc9f68 100644 --- a/kernel/rcuclassic.c +++ b/kernel/rcuclassic.c | |||
@@ -91,8 +91,8 @@ static void force_quiescent_state(struct rcu_data *rdp, | |||
91 | * rdp->cpu is the current cpu. | 91 | * rdp->cpu is the current cpu. |
92 | * | 92 | * |
93 | * cpu_online_map is updated by the _cpu_down() | 93 | * cpu_online_map is updated by the _cpu_down() |
94 | * using stop_machine_run(). Since we're in irqs disabled | 94 | * using __stop_machine(). Since we're in irqs disabled |
95 | * section, stop_machine_run() is not exectuting, hence | 95 | * section, __stop_machine() is not exectuting, hence |
96 | * the cpu_online_map is stable. | 96 | * the cpu_online_map is stable. |
97 | * | 97 | * |
98 | * However, a cpu might have been offlined _just_ before | 98 | * However, a cpu might have been offlined _just_ before |
diff --git a/kernel/resource.c b/kernel/resource.c index 74af2d7cb5a1..f5b518eabefe 100644 --- a/kernel/resource.c +++ b/kernel/resource.c | |||
@@ -490,7 +490,7 @@ resource_size_t resource_alignment(struct resource *res) | |||
490 | { | 490 | { |
491 | switch (res->flags & (IORESOURCE_SIZEALIGN | IORESOURCE_STARTALIGN)) { | 491 | switch (res->flags & (IORESOURCE_SIZEALIGN | IORESOURCE_STARTALIGN)) { |
492 | case IORESOURCE_SIZEALIGN: | 492 | case IORESOURCE_SIZEALIGN: |
493 | return res->end - res->start + 1; | 493 | return resource_size(res); |
494 | case IORESOURCE_STARTALIGN: | 494 | case IORESOURCE_STARTALIGN: |
495 | return res->start; | 495 | return res->start; |
496 | default: | 496 | default: |
diff --git a/kernel/sched.c b/kernel/sched.c index 0236958addcb..21f7da94662e 100644 --- a/kernel/sched.c +++ b/kernel/sched.c | |||
@@ -7671,34 +7671,34 @@ static ssize_t sched_power_savings_store(const char *buf, size_t count, int smt) | |||
7671 | } | 7671 | } |
7672 | 7672 | ||
7673 | #ifdef CONFIG_SCHED_MC | 7673 | #ifdef CONFIG_SCHED_MC |
7674 | static ssize_t sched_mc_power_savings_show(struct sys_device *dev, | 7674 | static ssize_t sched_mc_power_savings_show(struct sysdev_class *class, |
7675 | struct sysdev_attribute *attr, char *page) | 7675 | char *page) |
7676 | { | 7676 | { |
7677 | return sprintf(page, "%u\n", sched_mc_power_savings); | 7677 | return sprintf(page, "%u\n", sched_mc_power_savings); |
7678 | } | 7678 | } |
7679 | static ssize_t sched_mc_power_savings_store(struct sys_device *dev, | 7679 | static ssize_t sched_mc_power_savings_store(struct sysdev_class *class, |
7680 | struct sysdev_attribute *attr, | ||
7681 | const char *buf, size_t count) | 7680 | const char *buf, size_t count) |
7682 | { | 7681 | { |
7683 | return sched_power_savings_store(buf, count, 0); | 7682 | return sched_power_savings_store(buf, count, 0); |
7684 | } | 7683 | } |
7685 | static SYSDEV_ATTR(sched_mc_power_savings, 0644, sched_mc_power_savings_show, | 7684 | static SYSDEV_CLASS_ATTR(sched_mc_power_savings, 0644, |
7686 | sched_mc_power_savings_store); | 7685 | sched_mc_power_savings_show, |
7686 | sched_mc_power_savings_store); | ||
7687 | #endif | 7687 | #endif |
7688 | 7688 | ||
7689 | #ifdef CONFIG_SCHED_SMT | 7689 | #ifdef CONFIG_SCHED_SMT |
7690 | static ssize_t sched_smt_power_savings_show(struct sys_device *dev, | 7690 | static ssize_t sched_smt_power_savings_show(struct sysdev_class *dev, |
7691 | struct sysdev_attribute *attr, char *page) | 7691 | char *page) |
7692 | { | 7692 | { |
7693 | return sprintf(page, "%u\n", sched_smt_power_savings); | 7693 | return sprintf(page, "%u\n", sched_smt_power_savings); |
7694 | } | 7694 | } |
7695 | static ssize_t sched_smt_power_savings_store(struct sys_device *dev, | 7695 | static ssize_t sched_smt_power_savings_store(struct sysdev_class *dev, |
7696 | struct sysdev_attribute *attr, | ||
7697 | const char *buf, size_t count) | 7696 | const char *buf, size_t count) |
7698 | { | 7697 | { |
7699 | return sched_power_savings_store(buf, count, 1); | 7698 | return sched_power_savings_store(buf, count, 1); |
7700 | } | 7699 | } |
7701 | static SYSDEV_ATTR(sched_smt_power_savings, 0644, sched_smt_power_savings_show, | 7700 | static SYSDEV_CLASS_ATTR(sched_smt_power_savings, 0644, |
7701 | sched_smt_power_savings_show, | ||
7702 | sched_smt_power_savings_store); | 7702 | sched_smt_power_savings_store); |
7703 | #endif | 7703 | #endif |
7704 | 7704 | ||
diff --git a/kernel/stop_machine.c b/kernel/stop_machine.c index 738b411ff2d3..e446c7c7d6a9 100644 --- a/kernel/stop_machine.c +++ b/kernel/stop_machine.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* Copyright 2005 Rusty Russell rusty@rustcorp.com.au IBM Corporation. | 1 | /* Copyright 2008, 2005 Rusty Russell rusty@rustcorp.com.au IBM Corporation. |
2 | * GPL v2 and any later version. | 2 | * GPL v2 and any later version. |
3 | */ | 3 | */ |
4 | #include <linux/cpu.h> | 4 | #include <linux/cpu.h> |
@@ -13,204 +13,178 @@ | |||
13 | #include <asm/atomic.h> | 13 | #include <asm/atomic.h> |
14 | #include <asm/uaccess.h> | 14 | #include <asm/uaccess.h> |
15 | 15 | ||
16 | /* Since we effect priority and affinity (both of which are visible | 16 | /* This controls the threads on each CPU. */ |
17 | * to, and settable by outside processes) we do indirection via a | ||
18 | * kthread. */ | ||
19 | |||
20 | /* Thread to stop each CPU in user context. */ | ||
21 | enum stopmachine_state { | 17 | enum stopmachine_state { |
22 | STOPMACHINE_WAIT, | 18 | /* Dummy starting state for thread. */ |
19 | STOPMACHINE_NONE, | ||
20 | /* Awaiting everyone to be scheduled. */ | ||
23 | STOPMACHINE_PREPARE, | 21 | STOPMACHINE_PREPARE, |
22 | /* Disable interrupts. */ | ||
24 | STOPMACHINE_DISABLE_IRQ, | 23 | STOPMACHINE_DISABLE_IRQ, |
24 | /* Run the function */ | ||
25 | STOPMACHINE_RUN, | ||
26 | /* Exit */ | ||
25 | STOPMACHINE_EXIT, | 27 | STOPMACHINE_EXIT, |
26 | }; | 28 | }; |
29 | static enum stopmachine_state state; | ||
27 | 30 | ||
28 | static enum stopmachine_state stopmachine_state; | 31 | struct stop_machine_data { |
29 | static unsigned int stopmachine_num_threads; | 32 | int (*fn)(void *); |
30 | static atomic_t stopmachine_thread_ack; | 33 | void *data; |
31 | 34 | int fnret; | |
32 | static int stopmachine(void *cpu) | 35 | }; |
33 | { | ||
34 | int irqs_disabled = 0; | ||
35 | int prepared = 0; | ||
36 | cpumask_of_cpu_ptr(cpumask, (int)(long)cpu); | ||
37 | |||
38 | set_cpus_allowed_ptr(current, cpumask); | ||
39 | |||
40 | /* Ack: we are alive */ | ||
41 | smp_mb(); /* Theoretically the ack = 0 might not be on this CPU yet. */ | ||
42 | atomic_inc(&stopmachine_thread_ack); | ||
43 | |||
44 | /* Simple state machine */ | ||
45 | while (stopmachine_state != STOPMACHINE_EXIT) { | ||
46 | if (stopmachine_state == STOPMACHINE_DISABLE_IRQ | ||
47 | && !irqs_disabled) { | ||
48 | local_irq_disable(); | ||
49 | hard_irq_disable(); | ||
50 | irqs_disabled = 1; | ||
51 | /* Ack: irqs disabled. */ | ||
52 | smp_mb(); /* Must read state first. */ | ||
53 | atomic_inc(&stopmachine_thread_ack); | ||
54 | } else if (stopmachine_state == STOPMACHINE_PREPARE | ||
55 | && !prepared) { | ||
56 | /* Everyone is in place, hold CPU. */ | ||
57 | preempt_disable(); | ||
58 | prepared = 1; | ||
59 | smp_mb(); /* Must read state first. */ | ||
60 | atomic_inc(&stopmachine_thread_ack); | ||
61 | } | ||
62 | /* Yield in first stage: migration threads need to | ||
63 | * help our sisters onto their CPUs. */ | ||
64 | if (!prepared && !irqs_disabled) | ||
65 | yield(); | ||
66 | cpu_relax(); | ||
67 | } | ||
68 | |||
69 | /* Ack: we are exiting. */ | ||
70 | smp_mb(); /* Must read state first. */ | ||
71 | atomic_inc(&stopmachine_thread_ack); | ||
72 | |||
73 | if (irqs_disabled) | ||
74 | local_irq_enable(); | ||
75 | if (prepared) | ||
76 | preempt_enable(); | ||
77 | 36 | ||
78 | return 0; | 37 | /* Like num_online_cpus(), but hotplug cpu uses us, so we need this. */ |
79 | } | 38 | static unsigned int num_threads; |
39 | static atomic_t thread_ack; | ||
40 | static struct completion finished; | ||
41 | static DEFINE_MUTEX(lock); | ||
80 | 42 | ||
81 | /* Change the thread state */ | 43 | static void set_state(enum stopmachine_state newstate) |
82 | static void stopmachine_set_state(enum stopmachine_state state) | ||
83 | { | 44 | { |
84 | atomic_set(&stopmachine_thread_ack, 0); | 45 | /* Reset ack counter. */ |
46 | atomic_set(&thread_ack, num_threads); | ||
85 | smp_wmb(); | 47 | smp_wmb(); |
86 | stopmachine_state = state; | 48 | state = newstate; |
87 | while (atomic_read(&stopmachine_thread_ack) != stopmachine_num_threads) | ||
88 | cpu_relax(); | ||
89 | } | 49 | } |
90 | 50 | ||
91 | static int stop_machine(void) | 51 | /* Last one to ack a state moves to the next state. */ |
52 | static void ack_state(void) | ||
92 | { | 53 | { |
93 | int i, ret = 0; | 54 | if (atomic_dec_and_test(&thread_ack)) { |
94 | 55 | /* If we're the last one to ack the EXIT, we're finished. */ | |
95 | atomic_set(&stopmachine_thread_ack, 0); | 56 | if (state == STOPMACHINE_EXIT) |
96 | stopmachine_num_threads = 0; | 57 | complete(&finished); |
97 | stopmachine_state = STOPMACHINE_WAIT; | 58 | else |
98 | 59 | set_state(state + 1); | |
99 | for_each_online_cpu(i) { | ||
100 | if (i == raw_smp_processor_id()) | ||
101 | continue; | ||
102 | ret = kernel_thread(stopmachine, (void *)(long)i,CLONE_KERNEL); | ||
103 | if (ret < 0) | ||
104 | break; | ||
105 | stopmachine_num_threads++; | ||
106 | } | ||
107 | |||
108 | /* Wait for them all to come to life. */ | ||
109 | while (atomic_read(&stopmachine_thread_ack) != stopmachine_num_threads) { | ||
110 | yield(); | ||
111 | cpu_relax(); | ||
112 | } | 60 | } |
61 | } | ||
113 | 62 | ||
114 | /* If some failed, kill them all. */ | 63 | /* This is the actual thread which stops the CPU. It exits by itself rather |
115 | if (ret < 0) { | 64 | * than waiting for kthread_stop(), because it's easier for hotplug CPU. */ |
116 | stopmachine_set_state(STOPMACHINE_EXIT); | 65 | static int stop_cpu(struct stop_machine_data *smdata) |
117 | return ret; | 66 | { |
118 | } | 67 | enum stopmachine_state curstate = STOPMACHINE_NONE; |
68 | int uninitialized_var(ret); | ||
119 | 69 | ||
120 | /* Now they are all started, make them hold the CPUs, ready. */ | 70 | /* Simple state machine */ |
121 | preempt_disable(); | 71 | do { |
122 | stopmachine_set_state(STOPMACHINE_PREPARE); | 72 | /* Chill out and ensure we re-read stopmachine_state. */ |
73 | cpu_relax(); | ||
74 | if (state != curstate) { | ||
75 | curstate = state; | ||
76 | switch (curstate) { | ||
77 | case STOPMACHINE_DISABLE_IRQ: | ||
78 | local_irq_disable(); | ||
79 | hard_irq_disable(); | ||
80 | break; | ||
81 | case STOPMACHINE_RUN: | ||
82 | /* |= allows error detection if functions on | ||
83 | * multiple CPUs. */ | ||
84 | smdata->fnret |= smdata->fn(smdata->data); | ||
85 | break; | ||
86 | default: | ||
87 | break; | ||
88 | } | ||
89 | ack_state(); | ||
90 | } | ||
91 | } while (curstate != STOPMACHINE_EXIT); | ||
123 | 92 | ||
124 | /* Make them disable irqs. */ | 93 | local_irq_enable(); |
125 | local_irq_disable(); | 94 | do_exit(0); |
126 | hard_irq_disable(); | 95 | } |
127 | stopmachine_set_state(STOPMACHINE_DISABLE_IRQ); | ||
128 | 96 | ||
97 | /* Callback for CPUs which aren't supposed to do anything. */ | ||
98 | static int chill(void *unused) | ||
99 | { | ||
129 | return 0; | 100 | return 0; |
130 | } | 101 | } |
131 | 102 | ||
132 | static void restart_machine(void) | 103 | int __stop_machine(int (*fn)(void *), void *data, const cpumask_t *cpus) |
133 | { | 104 | { |
134 | stopmachine_set_state(STOPMACHINE_EXIT); | 105 | int i, err; |
135 | local_irq_enable(); | 106 | struct stop_machine_data active, idle; |
136 | preempt_enable_no_resched(); | 107 | struct task_struct **threads; |
137 | } | 108 | |
109 | active.fn = fn; | ||
110 | active.data = data; | ||
111 | active.fnret = 0; | ||
112 | idle.fn = chill; | ||
113 | idle.data = NULL; | ||
114 | |||
115 | /* This could be too big for stack on large machines. */ | ||
116 | threads = kcalloc(NR_CPUS, sizeof(threads[0]), GFP_KERNEL); | ||
117 | if (!threads) | ||
118 | return -ENOMEM; | ||
119 | |||
120 | /* Set up initial state. */ | ||
121 | mutex_lock(&lock); | ||
122 | init_completion(&finished); | ||
123 | num_threads = num_online_cpus(); | ||
124 | set_state(STOPMACHINE_PREPARE); | ||
138 | 125 | ||
139 | struct stop_machine_data { | 126 | for_each_online_cpu(i) { |
140 | int (*fn)(void *); | 127 | struct stop_machine_data *smdata = &idle; |
141 | void *data; | 128 | struct sched_param param = { .sched_priority = MAX_RT_PRIO-1 }; |
142 | struct completion done; | ||
143 | }; | ||
144 | 129 | ||
145 | static int do_stop(void *_smdata) | 130 | if (!cpus) { |
146 | { | 131 | if (i == first_cpu(cpu_online_map)) |
147 | struct stop_machine_data *smdata = _smdata; | 132 | smdata = &active; |
148 | int ret; | 133 | } else { |
134 | if (cpu_isset(i, *cpus)) | ||
135 | smdata = &active; | ||
136 | } | ||
149 | 137 | ||
150 | ret = stop_machine(); | 138 | threads[i] = kthread_create((void *)stop_cpu, smdata, "kstop%u", |
151 | if (ret == 0) { | 139 | i); |
152 | ret = smdata->fn(smdata->data); | 140 | if (IS_ERR(threads[i])) { |
153 | restart_machine(); | 141 | err = PTR_ERR(threads[i]); |
154 | } | 142 | threads[i] = NULL; |
143 | goto kill_threads; | ||
144 | } | ||
155 | 145 | ||
156 | /* We're done: you can kthread_stop us now */ | 146 | /* Place it onto correct cpu. */ |
157 | complete(&smdata->done); | 147 | kthread_bind(threads[i], i); |
158 | 148 | ||
159 | /* Wait for kthread_stop */ | 149 | /* Make it highest prio. */ |
160 | set_current_state(TASK_INTERRUPTIBLE); | 150 | if (sched_setscheduler_nocheck(threads[i], SCHED_FIFO, ¶m)) |
161 | while (!kthread_should_stop()) { | 151 | BUG(); |
162 | schedule(); | ||
163 | set_current_state(TASK_INTERRUPTIBLE); | ||
164 | } | 152 | } |
165 | __set_current_state(TASK_RUNNING); | ||
166 | return ret; | ||
167 | } | ||
168 | 153 | ||
169 | struct task_struct *__stop_machine_run(int (*fn)(void *), void *data, | 154 | /* We've created all the threads. Wake them all: hold this CPU so one |
170 | unsigned int cpu) | 155 | * doesn't hit this CPU until we're ready. */ |
171 | { | 156 | get_cpu(); |
172 | static DEFINE_MUTEX(stopmachine_mutex); | 157 | for_each_online_cpu(i) |
173 | struct stop_machine_data smdata; | 158 | wake_up_process(threads[i]); |
174 | struct task_struct *p; | ||
175 | 159 | ||
176 | smdata.fn = fn; | 160 | /* This will release the thread on our CPU. */ |
177 | smdata.data = data; | 161 | put_cpu(); |
178 | init_completion(&smdata.done); | 162 | wait_for_completion(&finished); |
163 | mutex_unlock(&lock); | ||
179 | 164 | ||
180 | mutex_lock(&stopmachine_mutex); | 165 | kfree(threads); |
181 | 166 | ||
182 | /* If they don't care which CPU fn runs on, bind to any online one. */ | 167 | return active.fnret; |
183 | if (cpu == NR_CPUS) | ||
184 | cpu = raw_smp_processor_id(); | ||
185 | 168 | ||
186 | p = kthread_create(do_stop, &smdata, "kstopmachine"); | 169 | kill_threads: |
187 | if (!IS_ERR(p)) { | 170 | for_each_online_cpu(i) |
188 | struct sched_param param = { .sched_priority = MAX_RT_PRIO-1 }; | 171 | if (threads[i]) |
172 | kthread_stop(threads[i]); | ||
173 | mutex_unlock(&lock); | ||
189 | 174 | ||
190 | /* One high-prio thread per cpu. We'll do this one. */ | 175 | kfree(threads); |
191 | sched_setscheduler_nocheck(p, SCHED_FIFO, ¶m); | 176 | return err; |
192 | kthread_bind(p, cpu); | ||
193 | wake_up_process(p); | ||
194 | wait_for_completion(&smdata.done); | ||
195 | } | ||
196 | mutex_unlock(&stopmachine_mutex); | ||
197 | return p; | ||
198 | } | 177 | } |
199 | 178 | ||
200 | int stop_machine_run(int (*fn)(void *), void *data, unsigned int cpu) | 179 | int stop_machine(int (*fn)(void *), void *data, const cpumask_t *cpus) |
201 | { | 180 | { |
202 | struct task_struct *p; | ||
203 | int ret; | 181 | int ret; |
204 | 182 | ||
205 | /* No CPUs can come up or down during this. */ | 183 | /* No CPUs can come up or down during this. */ |
206 | get_online_cpus(); | 184 | get_online_cpus(); |
207 | p = __stop_machine_run(fn, data, cpu); | 185 | ret = __stop_machine(fn, data, cpus); |
208 | if (!IS_ERR(p)) | ||
209 | ret = kthread_stop(p); | ||
210 | else | ||
211 | ret = PTR_ERR(p); | ||
212 | put_online_cpus(); | 186 | put_online_cpus(); |
213 | 187 | ||
214 | return ret; | 188 | return ret; |
215 | } | 189 | } |
216 | EXPORT_SYMBOL_GPL(stop_machine_run); | 190 | EXPORT_SYMBOL_GPL(stop_machine); |
diff --git a/kernel/time/tick-common.c b/kernel/time/tick-common.c index bf43284d6855..80c4336f4188 100644 --- a/kernel/time/tick-common.c +++ b/kernel/time/tick-common.c | |||
@@ -196,12 +196,10 @@ static int tick_check_new_device(struct clock_event_device *newdev) | |||
196 | struct tick_device *td; | 196 | struct tick_device *td; |
197 | int cpu, ret = NOTIFY_OK; | 197 | int cpu, ret = NOTIFY_OK; |
198 | unsigned long flags; | 198 | unsigned long flags; |
199 | cpumask_of_cpu_ptr_declare(cpumask); | ||
200 | 199 | ||
201 | spin_lock_irqsave(&tick_device_lock, flags); | 200 | spin_lock_irqsave(&tick_device_lock, flags); |
202 | 201 | ||
203 | cpu = smp_processor_id(); | 202 | cpu = smp_processor_id(); |
204 | cpumask_of_cpu_ptr_next(cpumask, cpu); | ||
205 | if (!cpu_isset(cpu, newdev->cpumask)) | 203 | if (!cpu_isset(cpu, newdev->cpumask)) |
206 | goto out_bc; | 204 | goto out_bc; |
207 | 205 | ||
@@ -209,7 +207,7 @@ static int tick_check_new_device(struct clock_event_device *newdev) | |||
209 | curdev = td->evtdev; | 207 | curdev = td->evtdev; |
210 | 208 | ||
211 | /* cpu local device ? */ | 209 | /* cpu local device ? */ |
212 | if (!cpus_equal(newdev->cpumask, *cpumask)) { | 210 | if (!cpus_equal(newdev->cpumask, cpumask_of_cpu(cpu))) { |
213 | 211 | ||
214 | /* | 212 | /* |
215 | * If the cpu affinity of the device interrupt can not | 213 | * If the cpu affinity of the device interrupt can not |
@@ -222,7 +220,7 @@ static int tick_check_new_device(struct clock_event_device *newdev) | |||
222 | * If we have a cpu local device already, do not replace it | 220 | * If we have a cpu local device already, do not replace it |
223 | * by a non cpu local device | 221 | * by a non cpu local device |
224 | */ | 222 | */ |
225 | if (curdev && cpus_equal(curdev->cpumask, *cpumask)) | 223 | if (curdev && cpus_equal(curdev->cpumask, cpumask_of_cpu(cpu))) |
226 | goto out_bc; | 224 | goto out_bc; |
227 | } | 225 | } |
228 | 226 | ||
@@ -254,7 +252,7 @@ static int tick_check_new_device(struct clock_event_device *newdev) | |||
254 | curdev = NULL; | 252 | curdev = NULL; |
255 | } | 253 | } |
256 | clockevents_exchange_device(curdev, newdev); | 254 | clockevents_exchange_device(curdev, newdev); |
257 | tick_setup_device(td, newdev, cpu, cpumask); | 255 | tick_setup_device(td, newdev, cpu, &cpumask_of_cpu(cpu)); |
258 | if (newdev->features & CLOCK_EVT_FEAT_ONESHOT) | 256 | if (newdev->features & CLOCK_EVT_FEAT_ONESHOT) |
259 | tick_oneshot_notify(); | 257 | tick_oneshot_notify(); |
260 | 258 | ||
diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c index 4231a3dc224a..f6e3af31b403 100644 --- a/kernel/trace/ftrace.c +++ b/kernel/trace/ftrace.c | |||
@@ -587,7 +587,7 @@ static int __ftrace_modify_code(void *data) | |||
587 | 587 | ||
588 | static void ftrace_run_update_code(int command) | 588 | static void ftrace_run_update_code(int command) |
589 | { | 589 | { |
590 | stop_machine_run(__ftrace_modify_code, &command, NR_CPUS); | 590 | stop_machine(__ftrace_modify_code, &command, NULL); |
591 | } | 591 | } |
592 | 592 | ||
593 | void ftrace_disable_daemon(void) | 593 | void ftrace_disable_daemon(void) |
@@ -787,7 +787,7 @@ static int ftrace_update_code(void) | |||
787 | !ftrace_enabled || !ftraced_trigger) | 787 | !ftrace_enabled || !ftraced_trigger) |
788 | return 0; | 788 | return 0; |
789 | 789 | ||
790 | stop_machine_run(__ftrace_update_code, NULL, NR_CPUS); | 790 | stop_machine(__ftrace_update_code, NULL, NULL); |
791 | 791 | ||
792 | return 1; | 792 | return 1; |
793 | } | 793 | } |
@@ -1564,7 +1564,7 @@ static int __init ftrace_dynamic_init(void) | |||
1564 | 1564 | ||
1565 | addr = (unsigned long)ftrace_record_ip; | 1565 | addr = (unsigned long)ftrace_record_ip; |
1566 | 1566 | ||
1567 | stop_machine_run(ftrace_dyn_arch_init, &addr, NR_CPUS); | 1567 | stop_machine(ftrace_dyn_arch_init, &addr, NULL); |
1568 | 1568 | ||
1569 | /* ftrace_dyn_arch_init places the return code in addr */ | 1569 | /* ftrace_dyn_arch_init places the return code in addr */ |
1570 | if (addr) { | 1570 | if (addr) { |
diff --git a/kernel/trace/trace_sysprof.c b/kernel/trace/trace_sysprof.c index ce2d723c10e1..bb948e52ce20 100644 --- a/kernel/trace/trace_sysprof.c +++ b/kernel/trace/trace_sysprof.c | |||
@@ -213,9 +213,7 @@ static void start_stack_timers(void) | |||
213 | int cpu; | 213 | int cpu; |
214 | 214 | ||
215 | for_each_online_cpu(cpu) { | 215 | for_each_online_cpu(cpu) { |
216 | cpumask_of_cpu_ptr(new_mask, cpu); | 216 | set_cpus_allowed_ptr(current, &cpumask_of_cpu(cpu)); |
217 | |||
218 | set_cpus_allowed_ptr(current, new_mask); | ||
219 | start_stack_timer(cpu); | 217 | start_stack_timer(cpu); |
220 | } | 218 | } |
221 | set_cpus_allowed_ptr(current, &saved_mask); | 219 | set_cpus_allowed_ptr(current, &saved_mask); |
diff --git a/kernel/workqueue.c b/kernel/workqueue.c index ec7e4f62aaff..4a26a1382df0 100644 --- a/kernel/workqueue.c +++ b/kernel/workqueue.c | |||
@@ -830,10 +830,21 @@ struct workqueue_struct *__create_workqueue_key(const char *name, | |||
830 | start_workqueue_thread(cwq, -1); | 830 | start_workqueue_thread(cwq, -1); |
831 | } else { | 831 | } else { |
832 | cpu_maps_update_begin(); | 832 | cpu_maps_update_begin(); |
833 | /* | ||
834 | * We must place this wq on list even if the code below fails. | ||
835 | * cpu_down(cpu) can remove cpu from cpu_populated_map before | ||
836 | * destroy_workqueue() takes the lock, in that case we leak | ||
837 | * cwq[cpu]->thread. | ||
838 | */ | ||
833 | spin_lock(&workqueue_lock); | 839 | spin_lock(&workqueue_lock); |
834 | list_add(&wq->list, &workqueues); | 840 | list_add(&wq->list, &workqueues); |
835 | spin_unlock(&workqueue_lock); | 841 | spin_unlock(&workqueue_lock); |
836 | 842 | /* | |
843 | * We must initialize cwqs for each possible cpu even if we | ||
844 | * are going to call destroy_workqueue() finally. Otherwise | ||
845 | * cpu_up() can hit the uninitialized cwq once we drop the | ||
846 | * lock. | ||
847 | */ | ||
837 | for_each_possible_cpu(cpu) { | 848 | for_each_possible_cpu(cpu) { |
838 | cwq = init_cpu_workqueue(wq, cpu); | 849 | cwq = init_cpu_workqueue(wq, cpu); |
839 | if (err || !cpu_online(cpu)) | 850 | if (err || !cpu_online(cpu)) |