diff options
Diffstat (limited to 'kernel')
64 files changed, 894 insertions, 355 deletions
diff --git a/kernel/Makefile b/kernel/Makefile index 2d64cfcc8b42..eca595e2fd52 100644 --- a/kernel/Makefile +++ b/kernel/Makefile | |||
| @@ -10,7 +10,7 @@ obj-y = sched.o fork.o exec_domain.o panic.o printk.o \ | |||
| 10 | kthread.o wait.o kfifo.o sys_ni.o posix-cpu-timers.o mutex.o \ | 10 | kthread.o wait.o kfifo.o sys_ni.o posix-cpu-timers.o mutex.o \ |
| 11 | hrtimer.o rwsem.o nsproxy.o srcu.o semaphore.o \ | 11 | hrtimer.o rwsem.o nsproxy.o srcu.o semaphore.o \ |
| 12 | notifier.o ksysfs.o pm_qos_params.o sched_clock.o cred.o \ | 12 | notifier.o ksysfs.o pm_qos_params.o sched_clock.o cred.o \ |
| 13 | async.o range.o jump_label.o | 13 | async.o range.o |
| 14 | obj-y += groups.o | 14 | obj-y += groups.o |
| 15 | 15 | ||
| 16 | ifdef CONFIG_FUNCTION_TRACER | 16 | ifdef CONFIG_FUNCTION_TRACER |
| @@ -107,6 +107,7 @@ obj-$(CONFIG_PERF_EVENTS) += events/ | |||
| 107 | obj-$(CONFIG_USER_RETURN_NOTIFIER) += user-return-notifier.o | 107 | obj-$(CONFIG_USER_RETURN_NOTIFIER) += user-return-notifier.o |
| 108 | obj-$(CONFIG_PADATA) += padata.o | 108 | obj-$(CONFIG_PADATA) += padata.o |
| 109 | obj-$(CONFIG_CRASH_DUMP) += crash_dump.o | 109 | obj-$(CONFIG_CRASH_DUMP) += crash_dump.o |
| 110 | obj-$(CONFIG_JUMP_LABEL) += jump_label.o | ||
| 110 | 111 | ||
| 111 | ifneq ($(CONFIG_SCHED_OMIT_FRAME_POINTER),y) | 112 | ifneq ($(CONFIG_SCHED_OMIT_FRAME_POINTER),y) |
| 112 | # According to Alan Modra <alan@linuxcare.com.au>, the -fno-omit-frame-pointer is | 113 | # According to Alan Modra <alan@linuxcare.com.au>, the -fno-omit-frame-pointer is |
| @@ -125,11 +126,10 @@ targets += config_data.gz | |||
| 125 | $(obj)/config_data.gz: $(KCONFIG_CONFIG) FORCE | 126 | $(obj)/config_data.gz: $(KCONFIG_CONFIG) FORCE |
| 126 | $(call if_changed,gzip) | 127 | $(call if_changed,gzip) |
| 127 | 128 | ||
| 128 | quiet_cmd_ikconfiggz = IKCFG $@ | 129 | filechk_ikconfiggz = (echo "static const char kernel_config_data[] __used = MAGIC_START"; cat $< | scripts/bin2c; echo "MAGIC_END;") |
| 129 | cmd_ikconfiggz = (echo "static const char kernel_config_data[] __used = MAGIC_START"; cat $< | scripts/bin2c; echo "MAGIC_END;") > $@ | ||
| 130 | targets += config_data.h | 130 | targets += config_data.h |
| 131 | $(obj)/config_data.h: $(obj)/config_data.gz FORCE | 131 | $(obj)/config_data.h: $(obj)/config_data.gz FORCE |
| 132 | $(call if_changed,ikconfiggz) | 132 | $(call filechk,ikconfiggz) |
| 133 | 133 | ||
| 134 | $(obj)/time.o: $(obj)/timeconst.h | 134 | $(obj)/time.o: $(obj)/timeconst.h |
| 135 | 135 | ||
diff --git a/kernel/audit.c b/kernel/audit.c index 52501b5d4902..0a1355ca3d79 100644 --- a/kernel/audit.c +++ b/kernel/audit.c | |||
| @@ -43,7 +43,7 @@ | |||
| 43 | 43 | ||
| 44 | #include <linux/init.h> | 44 | #include <linux/init.h> |
| 45 | #include <asm/types.h> | 45 | #include <asm/types.h> |
| 46 | #include <asm/atomic.h> | 46 | #include <linux/atomic.h> |
| 47 | #include <linux/mm.h> | 47 | #include <linux/mm.h> |
| 48 | #include <linux/module.h> | 48 | #include <linux/module.h> |
| 49 | #include <linux/slab.h> | 49 | #include <linux/slab.h> |
diff --git a/kernel/auditsc.c b/kernel/auditsc.c index 00d79df03e76..ce4b054acee5 100644 --- a/kernel/auditsc.c +++ b/kernel/auditsc.c | |||
| @@ -44,7 +44,7 @@ | |||
| 44 | 44 | ||
| 45 | #include <linux/init.h> | 45 | #include <linux/init.h> |
| 46 | #include <asm/types.h> | 46 | #include <asm/types.h> |
| 47 | #include <asm/atomic.h> | 47 | #include <linux/atomic.h> |
| 48 | #include <linux/fs.h> | 48 | #include <linux/fs.h> |
| 49 | #include <linux/namei.h> | 49 | #include <linux/namei.h> |
| 50 | #include <linux/mm.h> | 50 | #include <linux/mm.h> |
diff --git a/kernel/cgroup.c b/kernel/cgroup.c index e1c72c0f512b..1d2b6ceea95d 100644 --- a/kernel/cgroup.c +++ b/kernel/cgroup.c | |||
| @@ -27,9 +27,11 @@ | |||
| 27 | */ | 27 | */ |
| 28 | 28 | ||
| 29 | #include <linux/cgroup.h> | 29 | #include <linux/cgroup.h> |
| 30 | #include <linux/cred.h> | ||
| 30 | #include <linux/ctype.h> | 31 | #include <linux/ctype.h> |
| 31 | #include <linux/errno.h> | 32 | #include <linux/errno.h> |
| 32 | #include <linux/fs.h> | 33 | #include <linux/fs.h> |
| 34 | #include <linux/init_task.h> | ||
| 33 | #include <linux/kernel.h> | 35 | #include <linux/kernel.h> |
| 34 | #include <linux/list.h> | 36 | #include <linux/list.h> |
| 35 | #include <linux/mm.h> | 37 | #include <linux/mm.h> |
| @@ -59,7 +61,7 @@ | |||
| 59 | #include <linux/poll.h> | 61 | #include <linux/poll.h> |
| 60 | #include <linux/flex_array.h> /* used in cgroup_attach_proc */ | 62 | #include <linux/flex_array.h> /* used in cgroup_attach_proc */ |
| 61 | 63 | ||
| 62 | #include <asm/atomic.h> | 64 | #include <linux/atomic.h> |
| 63 | 65 | ||
| 64 | static DEFINE_MUTEX(cgroup_mutex); | 66 | static DEFINE_MUTEX(cgroup_mutex); |
| 65 | 67 | ||
| @@ -1514,6 +1516,7 @@ static struct dentry *cgroup_mount(struct file_system_type *fs_type, | |||
| 1514 | struct cgroup *root_cgrp = &root->top_cgroup; | 1516 | struct cgroup *root_cgrp = &root->top_cgroup; |
| 1515 | struct inode *inode; | 1517 | struct inode *inode; |
| 1516 | struct cgroupfs_root *existing_root; | 1518 | struct cgroupfs_root *existing_root; |
| 1519 | const struct cred *cred; | ||
| 1517 | int i; | 1520 | int i; |
| 1518 | 1521 | ||
| 1519 | BUG_ON(sb->s_root != NULL); | 1522 | BUG_ON(sb->s_root != NULL); |
| @@ -1593,7 +1596,9 @@ static struct dentry *cgroup_mount(struct file_system_type *fs_type, | |||
| 1593 | BUG_ON(!list_empty(&root_cgrp->children)); | 1596 | BUG_ON(!list_empty(&root_cgrp->children)); |
| 1594 | BUG_ON(root->number_of_cgroups != 1); | 1597 | BUG_ON(root->number_of_cgroups != 1); |
| 1595 | 1598 | ||
| 1599 | cred = override_creds(&init_cred); | ||
| 1596 | cgroup_populate_dir(root_cgrp); | 1600 | cgroup_populate_dir(root_cgrp); |
| 1601 | revert_creds(cred); | ||
| 1597 | mutex_unlock(&cgroup_mutex); | 1602 | mutex_unlock(&cgroup_mutex); |
| 1598 | mutex_unlock(&inode->i_mutex); | 1603 | mutex_unlock(&inode->i_mutex); |
| 1599 | } else { | 1604 | } else { |
| @@ -1697,7 +1702,6 @@ int cgroup_path(const struct cgroup *cgrp, char *buf, int buflen) | |||
| 1697 | { | 1702 | { |
| 1698 | char *start; | 1703 | char *start; |
| 1699 | struct dentry *dentry = rcu_dereference_check(cgrp->dentry, | 1704 | struct dentry *dentry = rcu_dereference_check(cgrp->dentry, |
| 1700 | rcu_read_lock_held() || | ||
| 1701 | cgroup_lock_is_held()); | 1705 | cgroup_lock_is_held()); |
| 1702 | 1706 | ||
| 1703 | if (!dentry || cgrp == dummytop) { | 1707 | if (!dentry || cgrp == dummytop) { |
| @@ -1723,7 +1727,6 @@ int cgroup_path(const struct cgroup *cgrp, char *buf, int buflen) | |||
| 1723 | break; | 1727 | break; |
| 1724 | 1728 | ||
| 1725 | dentry = rcu_dereference_check(cgrp->dentry, | 1729 | dentry = rcu_dereference_check(cgrp->dentry, |
| 1726 | rcu_read_lock_held() || | ||
| 1727 | cgroup_lock_is_held()); | 1730 | cgroup_lock_is_held()); |
| 1728 | if (!cgrp->parent) | 1731 | if (!cgrp->parent) |
| 1729 | continue; | 1732 | continue; |
| @@ -4814,8 +4817,7 @@ unsigned short css_id(struct cgroup_subsys_state *css) | |||
| 4814 | * on this or this is under rcu_read_lock(). Once css->id is allocated, | 4817 | * on this or this is under rcu_read_lock(). Once css->id is allocated, |
| 4815 | * it's unchanged until freed. | 4818 | * it's unchanged until freed. |
| 4816 | */ | 4819 | */ |
| 4817 | cssid = rcu_dereference_check(css->id, | 4820 | cssid = rcu_dereference_check(css->id, atomic_read(&css->refcnt)); |
| 4818 | rcu_read_lock_held() || atomic_read(&css->refcnt)); | ||
| 4819 | 4821 | ||
| 4820 | if (cssid) | 4822 | if (cssid) |
| 4821 | return cssid->id; | 4823 | return cssid->id; |
| @@ -4827,8 +4829,7 @@ unsigned short css_depth(struct cgroup_subsys_state *css) | |||
| 4827 | { | 4829 | { |
| 4828 | struct css_id *cssid; | 4830 | struct css_id *cssid; |
| 4829 | 4831 | ||
| 4830 | cssid = rcu_dereference_check(css->id, | 4832 | cssid = rcu_dereference_check(css->id, atomic_read(&css->refcnt)); |
| 4831 | rcu_read_lock_held() || atomic_read(&css->refcnt)); | ||
| 4832 | 4833 | ||
| 4833 | if (cssid) | 4834 | if (cssid) |
| 4834 | return cssid->depth; | 4835 | return cssid->depth; |
diff --git a/kernel/compat.c b/kernel/compat.c index fc9eb093acd5..e2435ee9993a 100644 --- a/kernel/compat.c +++ b/kernel/compat.c | |||
| @@ -158,6 +158,7 @@ int put_compat_timespec(const struct timespec *ts, struct compat_timespec __user | |||
| 158 | __put_user(ts->tv_sec, &cts->tv_sec) || | 158 | __put_user(ts->tv_sec, &cts->tv_sec) || |
| 159 | __put_user(ts->tv_nsec, &cts->tv_nsec)) ? -EFAULT : 0; | 159 | __put_user(ts->tv_nsec, &cts->tv_nsec)) ? -EFAULT : 0; |
| 160 | } | 160 | } |
| 161 | EXPORT_SYMBOL_GPL(put_compat_timespec); | ||
| 161 | 162 | ||
| 162 | static long compat_nanosleep_restart(struct restart_block *restart) | 163 | static long compat_nanosleep_restart(struct restart_block *restart) |
| 163 | { | 164 | { |
| @@ -890,6 +891,7 @@ sigset_from_compat (sigset_t *set, compat_sigset_t *compat) | |||
| 890 | case 1: set->sig[0] = compat->sig[0] | (((long)compat->sig[1]) << 32 ); | 891 | case 1: set->sig[0] = compat->sig[0] | (((long)compat->sig[1]) << 32 ); |
| 891 | } | 892 | } |
| 892 | } | 893 | } |
| 894 | EXPORT_SYMBOL_GPL(sigset_from_compat); | ||
| 893 | 895 | ||
| 894 | asmlinkage long | 896 | asmlinkage long |
| 895 | compat_sys_rt_sigtimedwait (compat_sigset_t __user *uthese, | 897 | compat_sys_rt_sigtimedwait (compat_sigset_t __user *uthese, |
| @@ -991,11 +993,8 @@ asmlinkage long compat_sys_rt_sigsuspend(compat_sigset_t __user *unewset, compat | |||
| 991 | sigset_from_compat(&newset, &newset32); | 993 | sigset_from_compat(&newset, &newset32); |
| 992 | sigdelsetmask(&newset, sigmask(SIGKILL)|sigmask(SIGSTOP)); | 994 | sigdelsetmask(&newset, sigmask(SIGKILL)|sigmask(SIGSTOP)); |
| 993 | 995 | ||
| 994 | spin_lock_irq(¤t->sighand->siglock); | ||
| 995 | current->saved_sigmask = current->blocked; | 996 | current->saved_sigmask = current->blocked; |
| 996 | current->blocked = newset; | 997 | set_current_blocked(&newset); |
| 997 | recalc_sigpending(); | ||
| 998 | spin_unlock_irq(¤t->sighand->siglock); | ||
| 999 | 998 | ||
| 1000 | current->state = TASK_INTERRUPTIBLE; | 999 | current->state = TASK_INTERRUPTIBLE; |
| 1001 | schedule(); | 1000 | schedule(); |
diff --git a/kernel/configs.c b/kernel/configs.c index b4066b44a99d..42e8fa075eed 100644 --- a/kernel/configs.c +++ b/kernel/configs.c | |||
| @@ -92,8 +92,8 @@ static void __exit ikconfig_cleanup(void) | |||
| 92 | module_init(ikconfig_init); | 92 | module_init(ikconfig_init); |
| 93 | module_exit(ikconfig_cleanup); | 93 | module_exit(ikconfig_cleanup); |
| 94 | 94 | ||
| 95 | #endif /* CONFIG_IKCONFIG_PROC */ | ||
| 96 | |||
| 95 | MODULE_LICENSE("GPL"); | 97 | MODULE_LICENSE("GPL"); |
| 96 | MODULE_AUTHOR("Randy Dunlap"); | 98 | MODULE_AUTHOR("Randy Dunlap"); |
| 97 | MODULE_DESCRIPTION("Echo the kernel .config file used to build the kernel"); | 99 | MODULE_DESCRIPTION("Echo the kernel .config file used to build the kernel"); |
| 98 | |||
| 99 | #endif /* CONFIG_IKCONFIG_PROC */ | ||
diff --git a/kernel/cpuset.c b/kernel/cpuset.c index 9c9b7545c810..10131fdaff70 100644 --- a/kernel/cpuset.c +++ b/kernel/cpuset.c | |||
| @@ -55,7 +55,7 @@ | |||
| 55 | #include <linux/sort.h> | 55 | #include <linux/sort.h> |
| 56 | 56 | ||
| 57 | #include <asm/uaccess.h> | 57 | #include <asm/uaccess.h> |
| 58 | #include <asm/atomic.h> | 58 | #include <linux/atomic.h> |
| 59 | #include <linux/mutex.h> | 59 | #include <linux/mutex.h> |
| 60 | #include <linux/workqueue.h> | 60 | #include <linux/workqueue.h> |
| 61 | #include <linux/cgroup.h> | 61 | #include <linux/cgroup.h> |
| @@ -2460,11 +2460,19 @@ static int cpuset_spread_node(int *rotor) | |||
| 2460 | 2460 | ||
| 2461 | int cpuset_mem_spread_node(void) | 2461 | int cpuset_mem_spread_node(void) |
| 2462 | { | 2462 | { |
| 2463 | if (current->cpuset_mem_spread_rotor == NUMA_NO_NODE) | ||
| 2464 | current->cpuset_mem_spread_rotor = | ||
| 2465 | node_random(¤t->mems_allowed); | ||
| 2466 | |||
| 2463 | return cpuset_spread_node(¤t->cpuset_mem_spread_rotor); | 2467 | return cpuset_spread_node(¤t->cpuset_mem_spread_rotor); |
| 2464 | } | 2468 | } |
| 2465 | 2469 | ||
| 2466 | int cpuset_slab_spread_node(void) | 2470 | int cpuset_slab_spread_node(void) |
| 2467 | { | 2471 | { |
| 2472 | if (current->cpuset_slab_spread_rotor == NUMA_NO_NODE) | ||
| 2473 | current->cpuset_slab_spread_rotor = | ||
| 2474 | node_random(¤t->mems_allowed); | ||
| 2475 | |||
| 2468 | return cpuset_spread_node(¤t->cpuset_slab_spread_rotor); | 2476 | return cpuset_spread_node(¤t->cpuset_slab_spread_rotor); |
| 2469 | } | 2477 | } |
| 2470 | 2478 | ||
diff --git a/kernel/cred.c b/kernel/cred.c index 174fa84eca30..8ef31f53c44c 100644 --- a/kernel/cred.c +++ b/kernel/cred.c | |||
| @@ -508,10 +508,8 @@ int commit_creds(struct cred *new) | |||
| 508 | key_fsgid_changed(task); | 508 | key_fsgid_changed(task); |
| 509 | 509 | ||
| 510 | /* do it | 510 | /* do it |
| 511 | * - What if a process setreuid()'s and this brings the | 511 | * RLIMIT_NPROC limits on user->processes have already been checked |
| 512 | * new uid over his NPROC rlimit? We can check this now | 512 | * in set_user(). |
| 513 | * cheaply with the new uid cache, so if it matters | ||
| 514 | * we should be checking for it. -DaveM | ||
| 515 | */ | 513 | */ |
| 516 | alter_cred_subscribers(new, 2); | 514 | alter_cred_subscribers(new, 2); |
| 517 | if (new->user != old->user) | 515 | if (new->user != old->user) |
diff --git a/kernel/debug/debug_core.c b/kernel/debug/debug_core.c index bad6786dee88..0d7c08784efb 100644 --- a/kernel/debug/debug_core.c +++ b/kernel/debug/debug_core.c | |||
| @@ -51,7 +51,7 @@ | |||
| 51 | 51 | ||
| 52 | #include <asm/cacheflush.h> | 52 | #include <asm/cacheflush.h> |
| 53 | #include <asm/byteorder.h> | 53 | #include <asm/byteorder.h> |
| 54 | #include <asm/atomic.h> | 54 | #include <linux/atomic.h> |
| 55 | #include <asm/system.h> | 55 | #include <asm/system.h> |
| 56 | 56 | ||
| 57 | #include "debug_core.h" | 57 | #include "debug_core.h" |
diff --git a/kernel/debug/gdbstub.c b/kernel/debug/gdbstub.c index a11db956dd62..34872482315e 100644 --- a/kernel/debug/gdbstub.c +++ b/kernel/debug/gdbstub.c | |||
| @@ -42,6 +42,8 @@ | |||
| 42 | /* Our I/O buffers. */ | 42 | /* Our I/O buffers. */ |
| 43 | static char remcom_in_buffer[BUFMAX]; | 43 | static char remcom_in_buffer[BUFMAX]; |
| 44 | static char remcom_out_buffer[BUFMAX]; | 44 | static char remcom_out_buffer[BUFMAX]; |
| 45 | static int gdbstub_use_prev_in_buf; | ||
| 46 | static int gdbstub_prev_in_buf_pos; | ||
| 45 | 47 | ||
| 46 | /* Storage for the registers, in GDB format. */ | 48 | /* Storage for the registers, in GDB format. */ |
| 47 | static unsigned long gdb_regs[(NUMREGBYTES + | 49 | static unsigned long gdb_regs[(NUMREGBYTES + |
| @@ -58,6 +60,13 @@ static int gdbstub_read_wait(void) | |||
| 58 | int ret = -1; | 60 | int ret = -1; |
| 59 | int i; | 61 | int i; |
| 60 | 62 | ||
| 63 | if (unlikely(gdbstub_use_prev_in_buf)) { | ||
| 64 | if (gdbstub_prev_in_buf_pos < gdbstub_use_prev_in_buf) | ||
| 65 | return remcom_in_buffer[gdbstub_prev_in_buf_pos++]; | ||
| 66 | else | ||
| 67 | gdbstub_use_prev_in_buf = 0; | ||
| 68 | } | ||
| 69 | |||
| 61 | /* poll any additional I/O interfaces that are defined */ | 70 | /* poll any additional I/O interfaces that are defined */ |
| 62 | while (ret < 0) | 71 | while (ret < 0) |
| 63 | for (i = 0; kdb_poll_funcs[i] != NULL; i++) { | 72 | for (i = 0; kdb_poll_funcs[i] != NULL; i++) { |
| @@ -109,7 +118,6 @@ static void get_packet(char *buffer) | |||
| 109 | buffer[count] = ch; | 118 | buffer[count] = ch; |
| 110 | count = count + 1; | 119 | count = count + 1; |
| 111 | } | 120 | } |
| 112 | buffer[count] = 0; | ||
| 113 | 121 | ||
| 114 | if (ch == '#') { | 122 | if (ch == '#') { |
| 115 | xmitcsum = hex_to_bin(gdbstub_read_wait()) << 4; | 123 | xmitcsum = hex_to_bin(gdbstub_read_wait()) << 4; |
| @@ -124,6 +132,7 @@ static void get_packet(char *buffer) | |||
| 124 | if (dbg_io_ops->flush) | 132 | if (dbg_io_ops->flush) |
| 125 | dbg_io_ops->flush(); | 133 | dbg_io_ops->flush(); |
| 126 | } | 134 | } |
| 135 | buffer[count] = 0; | ||
| 127 | } while (checksum != xmitcsum); | 136 | } while (checksum != xmitcsum); |
| 128 | } | 137 | } |
| 129 | 138 | ||
| @@ -1082,12 +1091,11 @@ int gdbstub_state(struct kgdb_state *ks, char *cmd) | |||
| 1082 | case 'c': | 1091 | case 'c': |
| 1083 | strcpy(remcom_in_buffer, cmd); | 1092 | strcpy(remcom_in_buffer, cmd); |
| 1084 | return 0; | 1093 | return 0; |
| 1085 | case '?': | 1094 | case '$': |
| 1086 | gdb_cmd_status(ks); | 1095 | strcpy(remcom_in_buffer, cmd); |
| 1087 | break; | 1096 | gdbstub_use_prev_in_buf = strlen(remcom_in_buffer); |
| 1088 | case '\0': | 1097 | gdbstub_prev_in_buf_pos = 0; |
| 1089 | strcpy(remcom_out_buffer, ""); | 1098 | return 0; |
| 1090 | break; | ||
| 1091 | } | 1099 | } |
| 1092 | dbg_io_ops->write_char('+'); | 1100 | dbg_io_ops->write_char('+'); |
| 1093 | put_packet(remcom_out_buffer); | 1101 | put_packet(remcom_out_buffer); |
diff --git a/kernel/debug/kdb/kdb_bt.c b/kernel/debug/kdb/kdb_bt.c index 2f62fe85f16a..7179eac7b41c 100644 --- a/kernel/debug/kdb/kdb_bt.c +++ b/kernel/debug/kdb/kdb_bt.c | |||
| @@ -112,9 +112,8 @@ kdb_bt(int argc, const char **argv) | |||
| 112 | unsigned long addr; | 112 | unsigned long addr; |
| 113 | long offset; | 113 | long offset; |
| 114 | 114 | ||
| 115 | kdbgetintenv("BTARGS", &argcount); /* Arguments to print */ | 115 | /* Prompt after each proc in bta */ |
| 116 | kdbgetintenv("BTAPROMPT", &btaprompt); /* Prompt after each | 116 | kdbgetintenv("BTAPROMPT", &btaprompt); |
| 117 | * proc in bta */ | ||
| 118 | 117 | ||
| 119 | if (strcmp(argv[0], "bta") == 0) { | 118 | if (strcmp(argv[0], "bta") == 0) { |
| 120 | struct task_struct *g, *p; | 119 | struct task_struct *g, *p; |
diff --git a/kernel/debug/kdb/kdb_cmds b/kernel/debug/kdb/kdb_cmds index 56c88e4db309..9834ad303ab6 100644 --- a/kernel/debug/kdb/kdb_cmds +++ b/kernel/debug/kdb/kdb_cmds | |||
| @@ -18,16 +18,12 @@ defcmd dumpcommon "" "Common kdb debugging" | |||
| 18 | endefcmd | 18 | endefcmd |
| 19 | 19 | ||
| 20 | defcmd dumpall "" "First line debugging" | 20 | defcmd dumpall "" "First line debugging" |
| 21 | set BTSYMARG 1 | ||
| 22 | set BTARGS 9 | ||
| 23 | pid R | 21 | pid R |
| 24 | -dumpcommon | 22 | -dumpcommon |
| 25 | -bta | 23 | -bta |
| 26 | endefcmd | 24 | endefcmd |
| 27 | 25 | ||
| 28 | defcmd dumpcpu "" "Same as dumpall but only tasks on cpus" | 26 | defcmd dumpcpu "" "Same as dumpall but only tasks on cpus" |
| 29 | set BTSYMARG 1 | ||
| 30 | set BTARGS 9 | ||
| 31 | pid R | 27 | pid R |
| 32 | -dumpcommon | 28 | -dumpcommon |
| 33 | -btc | 29 | -btc |
diff --git a/kernel/debug/kdb/kdb_debugger.c b/kernel/debug/kdb/kdb_debugger.c index dd0b1b7dd02c..d9ca9aa481ec 100644 --- a/kernel/debug/kdb/kdb_debugger.c +++ b/kernel/debug/kdb/kdb_debugger.c | |||
| @@ -30,6 +30,8 @@ EXPORT_SYMBOL_GPL(kdb_poll_funcs); | |||
| 30 | int kdb_poll_idx = 1; | 30 | int kdb_poll_idx = 1; |
| 31 | EXPORT_SYMBOL_GPL(kdb_poll_idx); | 31 | EXPORT_SYMBOL_GPL(kdb_poll_idx); |
| 32 | 32 | ||
| 33 | static struct kgdb_state *kdb_ks; | ||
| 34 | |||
| 33 | int kdb_stub(struct kgdb_state *ks) | 35 | int kdb_stub(struct kgdb_state *ks) |
| 34 | { | 36 | { |
| 35 | int error = 0; | 37 | int error = 0; |
| @@ -39,6 +41,7 @@ int kdb_stub(struct kgdb_state *ks) | |||
| 39 | kdb_dbtrap_t db_result = KDB_DB_NOBPT; | 41 | kdb_dbtrap_t db_result = KDB_DB_NOBPT; |
| 40 | int i; | 42 | int i; |
| 41 | 43 | ||
| 44 | kdb_ks = ks; | ||
| 42 | if (KDB_STATE(REENTRY)) { | 45 | if (KDB_STATE(REENTRY)) { |
| 43 | reason = KDB_REASON_SWITCH; | 46 | reason = KDB_REASON_SWITCH; |
| 44 | KDB_STATE_CLEAR(REENTRY); | 47 | KDB_STATE_CLEAR(REENTRY); |
| @@ -123,20 +126,8 @@ int kdb_stub(struct kgdb_state *ks) | |||
| 123 | KDB_STATE_CLEAR(PAGER); | 126 | KDB_STATE_CLEAR(PAGER); |
| 124 | kdbnearsym_cleanup(); | 127 | kdbnearsym_cleanup(); |
| 125 | if (error == KDB_CMD_KGDB) { | 128 | if (error == KDB_CMD_KGDB) { |
| 126 | if (KDB_STATE(DOING_KGDB) || KDB_STATE(DOING_KGDB2)) { | 129 | if (KDB_STATE(DOING_KGDB)) |
| 127 | /* | ||
| 128 | * This inteface glue which allows kdb to transition in into | ||
| 129 | * the gdb stub. In order to do this the '?' or '' gdb serial | ||
| 130 | * packet response is processed here. And then control is | ||
| 131 | * passed to the gdbstub. | ||
| 132 | */ | ||
| 133 | if (KDB_STATE(DOING_KGDB)) | ||
| 134 | gdbstub_state(ks, "?"); | ||
| 135 | else | ||
| 136 | gdbstub_state(ks, ""); | ||
| 137 | KDB_STATE_CLEAR(DOING_KGDB); | 130 | KDB_STATE_CLEAR(DOING_KGDB); |
| 138 | KDB_STATE_CLEAR(DOING_KGDB2); | ||
| 139 | } | ||
| 140 | return DBG_PASS_EVENT; | 131 | return DBG_PASS_EVENT; |
| 141 | } | 132 | } |
| 142 | kdb_bp_install(ks->linux_regs); | 133 | kdb_bp_install(ks->linux_regs); |
| @@ -166,3 +157,7 @@ int kdb_stub(struct kgdb_state *ks) | |||
| 166 | return kgdb_info[ks->cpu].ret_state; | 157 | return kgdb_info[ks->cpu].ret_state; |
| 167 | } | 158 | } |
| 168 | 159 | ||
| 160 | void kdb_gdb_state_pass(char *buf) | ||
| 161 | { | ||
| 162 | gdbstub_state(kdb_ks, buf); | ||
| 163 | } | ||
diff --git a/kernel/debug/kdb/kdb_io.c b/kernel/debug/kdb/kdb_io.c index 96fdaac46a80..4802eb5840e1 100644 --- a/kernel/debug/kdb/kdb_io.c +++ b/kernel/debug/kdb/kdb_io.c | |||
| @@ -31,15 +31,21 @@ char kdb_prompt_str[CMD_BUFLEN]; | |||
| 31 | 31 | ||
| 32 | int kdb_trap_printk; | 32 | int kdb_trap_printk; |
| 33 | 33 | ||
| 34 | static void kgdb_transition_check(char *buffer) | 34 | static int kgdb_transition_check(char *buffer) |
| 35 | { | 35 | { |
| 36 | int slen = strlen(buffer); | 36 | if (buffer[0] != '+' && buffer[0] != '$') { |
| 37 | if (strncmp(buffer, "$?#3f", slen) != 0 && | ||
| 38 | strncmp(buffer, "$qSupported#37", slen) != 0 && | ||
| 39 | strncmp(buffer, "+$qSupported#37", slen) != 0) { | ||
| 40 | KDB_STATE_SET(KGDB_TRANS); | 37 | KDB_STATE_SET(KGDB_TRANS); |
| 41 | kdb_printf("%s", buffer); | 38 | kdb_printf("%s", buffer); |
| 39 | } else { | ||
| 40 | int slen = strlen(buffer); | ||
| 41 | if (slen > 3 && buffer[slen - 3] == '#') { | ||
| 42 | kdb_gdb_state_pass(buffer); | ||
| 43 | strcpy(buffer, "kgdb"); | ||
| 44 | KDB_STATE_SET(DOING_KGDB); | ||
| 45 | return 1; | ||
| 46 | } | ||
| 42 | } | 47 | } |
| 48 | return 0; | ||
| 43 | } | 49 | } |
| 44 | 50 | ||
| 45 | static int kdb_read_get_key(char *buffer, size_t bufsize) | 51 | static int kdb_read_get_key(char *buffer, size_t bufsize) |
| @@ -251,6 +257,10 @@ poll_again: | |||
| 251 | case 13: /* enter */ | 257 | case 13: /* enter */ |
| 252 | *lastchar++ = '\n'; | 258 | *lastchar++ = '\n'; |
| 253 | *lastchar++ = '\0'; | 259 | *lastchar++ = '\0'; |
| 260 | if (!KDB_STATE(KGDB_TRANS)) { | ||
| 261 | KDB_STATE_SET(KGDB_TRANS); | ||
| 262 | kdb_printf("%s", buffer); | ||
| 263 | } | ||
| 254 | kdb_printf("\n"); | 264 | kdb_printf("\n"); |
| 255 | return buffer; | 265 | return buffer; |
| 256 | case 4: /* Del */ | 266 | case 4: /* Del */ |
| @@ -382,22 +392,26 @@ poll_again: | |||
| 382 | * printed characters if we think that | 392 | * printed characters if we think that |
| 383 | * kgdb is connecting, until the check | 393 | * kgdb is connecting, until the check |
| 384 | * fails */ | 394 | * fails */ |
| 385 | if (!KDB_STATE(KGDB_TRANS)) | 395 | if (!KDB_STATE(KGDB_TRANS)) { |
| 386 | kgdb_transition_check(buffer); | 396 | if (kgdb_transition_check(buffer)) |
| 387 | else | 397 | return buffer; |
| 398 | } else { | ||
| 388 | kdb_printf("%c", key); | 399 | kdb_printf("%c", key); |
| 400 | } | ||
| 389 | } | 401 | } |
| 390 | /* Special escape to kgdb */ | 402 | /* Special escape to kgdb */ |
| 391 | if (lastchar - buffer >= 5 && | 403 | if (lastchar - buffer >= 5 && |
| 392 | strcmp(lastchar - 5, "$?#3f") == 0) { | 404 | strcmp(lastchar - 5, "$?#3f") == 0) { |
| 405 | kdb_gdb_state_pass(lastchar - 5); | ||
| 393 | strcpy(buffer, "kgdb"); | 406 | strcpy(buffer, "kgdb"); |
| 394 | KDB_STATE_SET(DOING_KGDB); | 407 | KDB_STATE_SET(DOING_KGDB); |
| 395 | return buffer; | 408 | return buffer; |
| 396 | } | 409 | } |
| 397 | if (lastchar - buffer >= 14 && | 410 | if (lastchar - buffer >= 11 && |
| 398 | strcmp(lastchar - 14, "$qSupported#37") == 0) { | 411 | strcmp(lastchar - 11, "$qSupported") == 0) { |
| 412 | kdb_gdb_state_pass(lastchar - 11); | ||
| 399 | strcpy(buffer, "kgdb"); | 413 | strcpy(buffer, "kgdb"); |
| 400 | KDB_STATE_SET(DOING_KGDB2); | 414 | KDB_STATE_SET(DOING_KGDB); |
| 401 | return buffer; | 415 | return buffer; |
| 402 | } | 416 | } |
| 403 | } | 417 | } |
diff --git a/kernel/debug/kdb/kdb_main.c b/kernel/debug/kdb/kdb_main.c index be14779bcef6..63786e71a3cd 100644 --- a/kernel/debug/kdb/kdb_main.c +++ b/kernel/debug/kdb/kdb_main.c | |||
| @@ -145,7 +145,6 @@ static char *__env[] = { | |||
| 145 | #endif | 145 | #endif |
| 146 | "RADIX=16", | 146 | "RADIX=16", |
| 147 | "MDCOUNT=8", /* lines of md output */ | 147 | "MDCOUNT=8", /* lines of md output */ |
| 148 | "BTARGS=9", /* 9 possible args in bt */ | ||
| 149 | KDB_PLATFORM_ENV, | 148 | KDB_PLATFORM_ENV, |
| 150 | "DTABCOUNT=30", | 149 | "DTABCOUNT=30", |
| 151 | "NOSECT=1", | 150 | "NOSECT=1", |
| @@ -172,6 +171,7 @@ static char *__env[] = { | |||
| 172 | (char *)0, | 171 | (char *)0, |
| 173 | (char *)0, | 172 | (char *)0, |
| 174 | (char *)0, | 173 | (char *)0, |
| 174 | (char *)0, | ||
| 175 | }; | 175 | }; |
| 176 | 176 | ||
| 177 | static const int __nenv = (sizeof(__env) / sizeof(char *)); | 177 | static const int __nenv = (sizeof(__env) / sizeof(char *)); |
| @@ -1386,7 +1386,7 @@ int kdb_main_loop(kdb_reason_t reason, kdb_reason_t reason2, int error, | |||
| 1386 | } | 1386 | } |
| 1387 | 1387 | ||
| 1388 | if (result == KDB_CMD_KGDB) { | 1388 | if (result == KDB_CMD_KGDB) { |
| 1389 | if (!(KDB_STATE(DOING_KGDB) || KDB_STATE(DOING_KGDB2))) | 1389 | if (!KDB_STATE(DOING_KGDB)) |
| 1390 | kdb_printf("Entering please attach debugger " | 1390 | kdb_printf("Entering please attach debugger " |
| 1391 | "or use $D#44+ or $3#33\n"); | 1391 | "or use $D#44+ or $3#33\n"); |
| 1392 | break; | 1392 | break; |
diff --git a/kernel/debug/kdb/kdb_private.h b/kernel/debug/kdb/kdb_private.h index 35d69ed1dfb5..e381d105b40b 100644 --- a/kernel/debug/kdb/kdb_private.h +++ b/kernel/debug/kdb/kdb_private.h | |||
| @@ -21,7 +21,6 @@ | |||
| 21 | #define KDB_CMD_SS (-1003) | 21 | #define KDB_CMD_SS (-1003) |
| 22 | #define KDB_CMD_SSB (-1004) | 22 | #define KDB_CMD_SSB (-1004) |
| 23 | #define KDB_CMD_KGDB (-1005) | 23 | #define KDB_CMD_KGDB (-1005) |
| 24 | #define KDB_CMD_KGDB2 (-1006) | ||
| 25 | 24 | ||
| 26 | /* Internal debug flags */ | 25 | /* Internal debug flags */ |
| 27 | #define KDB_DEBUG_FLAG_BP 0x0002 /* Breakpoint subsystem debug */ | 26 | #define KDB_DEBUG_FLAG_BP 0x0002 /* Breakpoint subsystem debug */ |
| @@ -146,7 +145,6 @@ extern int kdb_state; | |||
| 146 | * keyboard on this cpu */ | 145 | * keyboard on this cpu */ |
| 147 | #define KDB_STATE_KEXEC 0x00040000 /* kexec issued */ | 146 | #define KDB_STATE_KEXEC 0x00040000 /* kexec issued */ |
| 148 | #define KDB_STATE_DOING_KGDB 0x00080000 /* kgdb enter now issued */ | 147 | #define KDB_STATE_DOING_KGDB 0x00080000 /* kgdb enter now issued */ |
| 149 | #define KDB_STATE_DOING_KGDB2 0x00100000 /* kgdb enter now issued */ | ||
| 150 | #define KDB_STATE_KGDB_TRANS 0x00200000 /* Transition to kgdb */ | 148 | #define KDB_STATE_KGDB_TRANS 0x00200000 /* Transition to kgdb */ |
| 151 | #define KDB_STATE_ARCH 0xff000000 /* Reserved for arch | 149 | #define KDB_STATE_ARCH 0xff000000 /* Reserved for arch |
| 152 | * specific use */ | 150 | * specific use */ |
| @@ -218,6 +216,7 @@ extern void kdb_print_nameval(const char *name, unsigned long val); | |||
| 218 | extern void kdb_send_sig_info(struct task_struct *p, struct siginfo *info); | 216 | extern void kdb_send_sig_info(struct task_struct *p, struct siginfo *info); |
| 219 | extern void kdb_meminfo_proc_show(void); | 217 | extern void kdb_meminfo_proc_show(void); |
| 220 | extern char *kdb_getstr(char *, size_t, char *); | 218 | extern char *kdb_getstr(char *, size_t, char *); |
| 219 | extern void kdb_gdb_state_pass(char *buf); | ||
| 221 | 220 | ||
| 222 | /* Defines for kdb_symbol_print */ | 221 | /* Defines for kdb_symbol_print */ |
| 223 | #define KDB_SP_SPACEB 0x0001 /* Space before string */ | 222 | #define KDB_SP_SPACEB 0x0001 /* Space before string */ |
diff --git a/kernel/delayacct.c b/kernel/delayacct.c index ead9b610aa71..418b3f7053aa 100644 --- a/kernel/delayacct.c +++ b/kernel/delayacct.c | |||
| @@ -19,8 +19,10 @@ | |||
| 19 | #include <linux/time.h> | 19 | #include <linux/time.h> |
| 20 | #include <linux/sysctl.h> | 20 | #include <linux/sysctl.h> |
| 21 | #include <linux/delayacct.h> | 21 | #include <linux/delayacct.h> |
| 22 | #include <linux/module.h> | ||
| 22 | 23 | ||
| 23 | int delayacct_on __read_mostly = 1; /* Delay accounting turned on/off */ | 24 | int delayacct_on __read_mostly = 1; /* Delay accounting turned on/off */ |
| 25 | EXPORT_SYMBOL_GPL(delayacct_on); | ||
| 24 | struct kmem_cache *delayacct_cache; | 26 | struct kmem_cache *delayacct_cache; |
| 25 | 27 | ||
| 26 | static int __init delayacct_setup_disable(char *str) | 28 | static int __init delayacct_setup_disable(char *str) |
diff --git a/kernel/events/core.c b/kernel/events/core.c index b8785e26ee1c..0f857782d06f 100644 --- a/kernel/events/core.c +++ b/kernel/events/core.c | |||
| @@ -399,14 +399,54 @@ void perf_cgroup_switch(struct task_struct *task, int mode) | |||
| 399 | local_irq_restore(flags); | 399 | local_irq_restore(flags); |
| 400 | } | 400 | } |
| 401 | 401 | ||
| 402 | static inline void perf_cgroup_sched_out(struct task_struct *task) | 402 | static inline void perf_cgroup_sched_out(struct task_struct *task, |
| 403 | struct task_struct *next) | ||
| 403 | { | 404 | { |
| 404 | perf_cgroup_switch(task, PERF_CGROUP_SWOUT); | 405 | struct perf_cgroup *cgrp1; |
| 406 | struct perf_cgroup *cgrp2 = NULL; | ||
| 407 | |||
| 408 | /* | ||
| 409 | * we come here when we know perf_cgroup_events > 0 | ||
| 410 | */ | ||
| 411 | cgrp1 = perf_cgroup_from_task(task); | ||
| 412 | |||
| 413 | /* | ||
| 414 | * next is NULL when called from perf_event_enable_on_exec() | ||
| 415 | * that will systematically cause a cgroup_switch() | ||
| 416 | */ | ||
| 417 | if (next) | ||
| 418 | cgrp2 = perf_cgroup_from_task(next); | ||
| 419 | |||
| 420 | /* | ||
| 421 | * only schedule out current cgroup events if we know | ||
| 422 | * that we are switching to a different cgroup. Otherwise, | ||
| 423 | * do no touch the cgroup events. | ||
| 424 | */ | ||
| 425 | if (cgrp1 != cgrp2) | ||
| 426 | perf_cgroup_switch(task, PERF_CGROUP_SWOUT); | ||
| 405 | } | 427 | } |
| 406 | 428 | ||
| 407 | static inline void perf_cgroup_sched_in(struct task_struct *task) | 429 | static inline void perf_cgroup_sched_in(struct task_struct *prev, |
| 430 | struct task_struct *task) | ||
| 408 | { | 431 | { |
| 409 | perf_cgroup_switch(task, PERF_CGROUP_SWIN); | 432 | struct perf_cgroup *cgrp1; |
| 433 | struct perf_cgroup *cgrp2 = NULL; | ||
| 434 | |||
| 435 | /* | ||
| 436 | * we come here when we know perf_cgroup_events > 0 | ||
| 437 | */ | ||
| 438 | cgrp1 = perf_cgroup_from_task(task); | ||
| 439 | |||
| 440 | /* prev can never be NULL */ | ||
| 441 | cgrp2 = perf_cgroup_from_task(prev); | ||
| 442 | |||
| 443 | /* | ||
| 444 | * only need to schedule in cgroup events if we are changing | ||
| 445 | * cgroup during ctxsw. Cgroup events were not scheduled | ||
| 446 | * out of ctxsw out if that was not the case. | ||
| 447 | */ | ||
| 448 | if (cgrp1 != cgrp2) | ||
| 449 | perf_cgroup_switch(task, PERF_CGROUP_SWIN); | ||
| 410 | } | 450 | } |
| 411 | 451 | ||
| 412 | static inline int perf_cgroup_connect(int fd, struct perf_event *event, | 452 | static inline int perf_cgroup_connect(int fd, struct perf_event *event, |
| @@ -518,11 +558,13 @@ static inline void update_cgrp_time_from_cpuctx(struct perf_cpu_context *cpuctx) | |||
| 518 | { | 558 | { |
| 519 | } | 559 | } |
| 520 | 560 | ||
| 521 | static inline void perf_cgroup_sched_out(struct task_struct *task) | 561 | static inline void perf_cgroup_sched_out(struct task_struct *task, |
| 562 | struct task_struct *next) | ||
| 522 | { | 563 | { |
| 523 | } | 564 | } |
| 524 | 565 | ||
| 525 | static inline void perf_cgroup_sched_in(struct task_struct *task) | 566 | static inline void perf_cgroup_sched_in(struct task_struct *prev, |
| 567 | struct task_struct *task) | ||
| 526 | { | 568 | { |
| 527 | } | 569 | } |
| 528 | 570 | ||
| @@ -1988,7 +2030,7 @@ void __perf_event_task_sched_out(struct task_struct *task, | |||
| 1988 | * cgroup event are system-wide mode only | 2030 | * cgroup event are system-wide mode only |
| 1989 | */ | 2031 | */ |
| 1990 | if (atomic_read(&__get_cpu_var(perf_cgroup_events))) | 2032 | if (atomic_read(&__get_cpu_var(perf_cgroup_events))) |
| 1991 | perf_cgroup_sched_out(task); | 2033 | perf_cgroup_sched_out(task, next); |
| 1992 | } | 2034 | } |
| 1993 | 2035 | ||
| 1994 | static void task_ctx_sched_out(struct perf_event_context *ctx) | 2036 | static void task_ctx_sched_out(struct perf_event_context *ctx) |
| @@ -2153,7 +2195,8 @@ static void perf_event_context_sched_in(struct perf_event_context *ctx, | |||
| 2153 | * accessing the event control register. If a NMI hits, then it will | 2195 | * accessing the event control register. If a NMI hits, then it will |
| 2154 | * keep the event running. | 2196 | * keep the event running. |
| 2155 | */ | 2197 | */ |
| 2156 | void __perf_event_task_sched_in(struct task_struct *task) | 2198 | void __perf_event_task_sched_in(struct task_struct *prev, |
| 2199 | struct task_struct *task) | ||
| 2157 | { | 2200 | { |
| 2158 | struct perf_event_context *ctx; | 2201 | struct perf_event_context *ctx; |
| 2159 | int ctxn; | 2202 | int ctxn; |
| @@ -2171,7 +2214,7 @@ void __perf_event_task_sched_in(struct task_struct *task) | |||
| 2171 | * cgroup event are system-wide mode only | 2214 | * cgroup event are system-wide mode only |
| 2172 | */ | 2215 | */ |
| 2173 | if (atomic_read(&__get_cpu_var(perf_cgroup_events))) | 2216 | if (atomic_read(&__get_cpu_var(perf_cgroup_events))) |
| 2174 | perf_cgroup_sched_in(task); | 2217 | perf_cgroup_sched_in(prev, task); |
| 2175 | } | 2218 | } |
| 2176 | 2219 | ||
| 2177 | static u64 perf_calculate_period(struct perf_event *event, u64 nsec, u64 count) | 2220 | static u64 perf_calculate_period(struct perf_event *event, u64 nsec, u64 count) |
| @@ -2427,7 +2470,7 @@ static void perf_event_enable_on_exec(struct perf_event_context *ctx) | |||
| 2427 | * ctxswin cgroup events which are already scheduled | 2470 | * ctxswin cgroup events which are already scheduled |
| 2428 | * in. | 2471 | * in. |
| 2429 | */ | 2472 | */ |
| 2430 | perf_cgroup_sched_out(current); | 2473 | perf_cgroup_sched_out(current, NULL); |
| 2431 | 2474 | ||
| 2432 | raw_spin_lock(&ctx->lock); | 2475 | raw_spin_lock(&ctx->lock); |
| 2433 | task_ctx_sched_out(ctx); | 2476 | task_ctx_sched_out(ctx); |
| @@ -3353,8 +3396,8 @@ static int perf_event_index(struct perf_event *event) | |||
| 3353 | } | 3396 | } |
| 3354 | 3397 | ||
| 3355 | static void calc_timer_values(struct perf_event *event, | 3398 | static void calc_timer_values(struct perf_event *event, |
| 3356 | u64 *running, | 3399 | u64 *enabled, |
| 3357 | u64 *enabled) | 3400 | u64 *running) |
| 3358 | { | 3401 | { |
| 3359 | u64 now, ctx_time; | 3402 | u64 now, ctx_time; |
| 3360 | 3403 | ||
diff --git a/kernel/exit.c b/kernel/exit.c index 73bb192a3d32..2913b3509d42 100644 --- a/kernel/exit.c +++ b/kernel/exit.c | |||
| @@ -85,7 +85,6 @@ static void __exit_signal(struct task_struct *tsk) | |||
| 85 | struct tty_struct *uninitialized_var(tty); | 85 | struct tty_struct *uninitialized_var(tty); |
| 86 | 86 | ||
| 87 | sighand = rcu_dereference_check(tsk->sighand, | 87 | sighand = rcu_dereference_check(tsk->sighand, |
| 88 | rcu_read_lock_held() || | ||
| 89 | lockdep_tasklist_lock_is_held()); | 88 | lockdep_tasklist_lock_is_held()); |
| 90 | spin_lock(&sighand->siglock); | 89 | spin_lock(&sighand->siglock); |
| 91 | 90 | ||
| @@ -898,7 +897,6 @@ NORET_TYPE void do_exit(long code) | |||
| 898 | 897 | ||
| 899 | profile_task_exit(tsk); | 898 | profile_task_exit(tsk); |
| 900 | 899 | ||
| 901 | WARN_ON(atomic_read(&tsk->fs_excl)); | ||
| 902 | WARN_ON(blk_needs_flush_plug(tsk)); | 900 | WARN_ON(blk_needs_flush_plug(tsk)); |
| 903 | 901 | ||
| 904 | if (unlikely(in_interrupt())) | 902 | if (unlikely(in_interrupt())) |
| @@ -982,6 +980,7 @@ NORET_TYPE void do_exit(long code) | |||
| 982 | trace_sched_process_exit(tsk); | 980 | trace_sched_process_exit(tsk); |
| 983 | 981 | ||
| 984 | exit_sem(tsk); | 982 | exit_sem(tsk); |
| 983 | exit_shm(tsk); | ||
| 985 | exit_files(tsk); | 984 | exit_files(tsk); |
| 986 | exit_fs(tsk); | 985 | exit_fs(tsk); |
| 987 | check_stack_usage(); | 986 | check_stack_usage(); |
diff --git a/kernel/fork.c b/kernel/fork.c index aeae5b11b62e..8e6b6f4fb272 100644 --- a/kernel/fork.c +++ b/kernel/fork.c | |||
| @@ -80,7 +80,7 @@ | |||
| 80 | * Protected counters by write_lock_irq(&tasklist_lock) | 80 | * Protected counters by write_lock_irq(&tasklist_lock) |
| 81 | */ | 81 | */ |
| 82 | unsigned long total_forks; /* Handle normal Linux uptimes. */ | 82 | unsigned long total_forks; /* Handle normal Linux uptimes. */ |
| 83 | int nr_threads; /* The idle threads do not count.. */ | 83 | int nr_threads; /* The idle threads do not count.. */ |
| 84 | 84 | ||
| 85 | int max_threads; /* tunable limit on nr_threads */ | 85 | int max_threads; /* tunable limit on nr_threads */ |
| 86 | 86 | ||
| @@ -232,7 +232,7 @@ void __init fork_init(unsigned long mempages) | |||
| 232 | /* | 232 | /* |
| 233 | * we need to allow at least 20 threads to boot a system | 233 | * we need to allow at least 20 threads to boot a system |
| 234 | */ | 234 | */ |
| 235 | if(max_threads < 20) | 235 | if (max_threads < 20) |
| 236 | max_threads = 20; | 236 | max_threads = 20; |
| 237 | 237 | ||
| 238 | init_task.signal->rlim[RLIMIT_NPROC].rlim_cur = max_threads/2; | 238 | init_task.signal->rlim[RLIMIT_NPROC].rlim_cur = max_threads/2; |
| @@ -268,7 +268,7 @@ static struct task_struct *dup_task_struct(struct task_struct *orig) | |||
| 268 | return NULL; | 268 | return NULL; |
| 269 | } | 269 | } |
| 270 | 270 | ||
| 271 | err = arch_dup_task_struct(tsk, orig); | 271 | err = arch_dup_task_struct(tsk, orig); |
| 272 | if (err) | 272 | if (err) |
| 273 | goto out; | 273 | goto out; |
| 274 | 274 | ||
| @@ -288,9 +288,11 @@ static struct task_struct *dup_task_struct(struct task_struct *orig) | |||
| 288 | tsk->stack_canary = get_random_int(); | 288 | tsk->stack_canary = get_random_int(); |
| 289 | #endif | 289 | #endif |
| 290 | 290 | ||
| 291 | /* One for us, one for whoever does the "release_task()" (usually parent) */ | 291 | /* |
| 292 | atomic_set(&tsk->usage,2); | 292 | * One for us, one for whoever does the "release_task()" (usually |
| 293 | atomic_set(&tsk->fs_excl, 0); | 293 | * parent) |
| 294 | */ | ||
| 295 | atomic_set(&tsk->usage, 2); | ||
| 294 | #ifdef CONFIG_BLK_DEV_IO_TRACE | 296 | #ifdef CONFIG_BLK_DEV_IO_TRACE |
| 295 | tsk->btrace_seq = 0; | 297 | tsk->btrace_seq = 0; |
| 296 | #endif | 298 | #endif |
| @@ -438,7 +440,7 @@ fail_nomem: | |||
| 438 | goto out; | 440 | goto out; |
| 439 | } | 441 | } |
| 440 | 442 | ||
| 441 | static inline int mm_alloc_pgd(struct mm_struct * mm) | 443 | static inline int mm_alloc_pgd(struct mm_struct *mm) |
| 442 | { | 444 | { |
| 443 | mm->pgd = pgd_alloc(mm); | 445 | mm->pgd = pgd_alloc(mm); |
| 444 | if (unlikely(!mm->pgd)) | 446 | if (unlikely(!mm->pgd)) |
| @@ -446,7 +448,7 @@ static inline int mm_alloc_pgd(struct mm_struct * mm) | |||
| 446 | return 0; | 448 | return 0; |
| 447 | } | 449 | } |
| 448 | 450 | ||
| 449 | static inline void mm_free_pgd(struct mm_struct * mm) | 451 | static inline void mm_free_pgd(struct mm_struct *mm) |
| 450 | { | 452 | { |
| 451 | pgd_free(mm, mm->pgd); | 453 | pgd_free(mm, mm->pgd); |
| 452 | } | 454 | } |
| @@ -483,7 +485,7 @@ static void mm_init_aio(struct mm_struct *mm) | |||
| 483 | #endif | 485 | #endif |
| 484 | } | 486 | } |
| 485 | 487 | ||
| 486 | static struct mm_struct * mm_init(struct mm_struct * mm, struct task_struct *p) | 488 | static struct mm_struct *mm_init(struct mm_struct *mm, struct task_struct *p) |
| 487 | { | 489 | { |
| 488 | atomic_set(&mm->mm_users, 1); | 490 | atomic_set(&mm->mm_users, 1); |
| 489 | atomic_set(&mm->mm_count, 1); | 491 | atomic_set(&mm->mm_count, 1); |
| @@ -514,9 +516,9 @@ static struct mm_struct * mm_init(struct mm_struct * mm, struct task_struct *p) | |||
| 514 | /* | 516 | /* |
| 515 | * Allocate and initialize an mm_struct. | 517 | * Allocate and initialize an mm_struct. |
| 516 | */ | 518 | */ |
| 517 | struct mm_struct * mm_alloc(void) | 519 | struct mm_struct *mm_alloc(void) |
| 518 | { | 520 | { |
| 519 | struct mm_struct * mm; | 521 | struct mm_struct *mm; |
| 520 | 522 | ||
| 521 | mm = allocate_mm(); | 523 | mm = allocate_mm(); |
| 522 | if (!mm) | 524 | if (!mm) |
| @@ -584,7 +586,7 @@ void added_exe_file_vma(struct mm_struct *mm) | |||
| 584 | void removed_exe_file_vma(struct mm_struct *mm) | 586 | void removed_exe_file_vma(struct mm_struct *mm) |
| 585 | { | 587 | { |
| 586 | mm->num_exe_file_vmas--; | 588 | mm->num_exe_file_vmas--; |
| 587 | if ((mm->num_exe_file_vmas == 0) && mm->exe_file){ | 589 | if ((mm->num_exe_file_vmas == 0) && mm->exe_file) { |
| 588 | fput(mm->exe_file); | 590 | fput(mm->exe_file); |
| 589 | mm->exe_file = NULL; | 591 | mm->exe_file = NULL; |
| 590 | } | 592 | } |
| @@ -776,9 +778,9 @@ fail_nocontext: | |||
| 776 | return NULL; | 778 | return NULL; |
| 777 | } | 779 | } |
| 778 | 780 | ||
| 779 | static int copy_mm(unsigned long clone_flags, struct task_struct * tsk) | 781 | static int copy_mm(unsigned long clone_flags, struct task_struct *tsk) |
| 780 | { | 782 | { |
| 781 | struct mm_struct * mm, *oldmm; | 783 | struct mm_struct *mm, *oldmm; |
| 782 | int retval; | 784 | int retval; |
| 783 | 785 | ||
| 784 | tsk->min_flt = tsk->maj_flt = 0; | 786 | tsk->min_flt = tsk->maj_flt = 0; |
| @@ -845,7 +847,7 @@ static int copy_fs(unsigned long clone_flags, struct task_struct *tsk) | |||
| 845 | return 0; | 847 | return 0; |
| 846 | } | 848 | } |
| 847 | 849 | ||
| 848 | static int copy_files(unsigned long clone_flags, struct task_struct * tsk) | 850 | static int copy_files(unsigned long clone_flags, struct task_struct *tsk) |
| 849 | { | 851 | { |
| 850 | struct files_struct *oldf, *newf; | 852 | struct files_struct *oldf, *newf; |
| 851 | int error = 0; | 853 | int error = 0; |
| @@ -1109,6 +1111,7 @@ static struct task_struct *copy_process(unsigned long clone_flags, | |||
| 1109 | p->real_cred->user != INIT_USER) | 1111 | p->real_cred->user != INIT_USER) |
| 1110 | goto bad_fork_free; | 1112 | goto bad_fork_free; |
| 1111 | } | 1113 | } |
| 1114 | current->flags &= ~PF_NPROC_EXCEEDED; | ||
| 1112 | 1115 | ||
| 1113 | retval = copy_creds(p, clone_flags); | 1116 | retval = copy_creds(p, clone_flags); |
| 1114 | if (retval < 0) | 1117 | if (retval < 0) |
| @@ -1167,13 +1170,17 @@ static struct task_struct *copy_process(unsigned long clone_flags, | |||
| 1167 | cgroup_fork(p); | 1170 | cgroup_fork(p); |
| 1168 | #ifdef CONFIG_NUMA | 1171 | #ifdef CONFIG_NUMA |
| 1169 | p->mempolicy = mpol_dup(p->mempolicy); | 1172 | p->mempolicy = mpol_dup(p->mempolicy); |
| 1170 | if (IS_ERR(p->mempolicy)) { | 1173 | if (IS_ERR(p->mempolicy)) { |
| 1171 | retval = PTR_ERR(p->mempolicy); | 1174 | retval = PTR_ERR(p->mempolicy); |
| 1172 | p->mempolicy = NULL; | 1175 | p->mempolicy = NULL; |
| 1173 | goto bad_fork_cleanup_cgroup; | 1176 | goto bad_fork_cleanup_cgroup; |
| 1174 | } | 1177 | } |
| 1175 | mpol_fix_fork_child_flag(p); | 1178 | mpol_fix_fork_child_flag(p); |
| 1176 | #endif | 1179 | #endif |
| 1180 | #ifdef CONFIG_CPUSETS | ||
| 1181 | p->cpuset_mem_spread_rotor = NUMA_NO_NODE; | ||
| 1182 | p->cpuset_slab_spread_rotor = NUMA_NO_NODE; | ||
| 1183 | #endif | ||
| 1177 | #ifdef CONFIG_TRACE_IRQFLAGS | 1184 | #ifdef CONFIG_TRACE_IRQFLAGS |
| 1178 | p->irq_events = 0; | 1185 | p->irq_events = 0; |
| 1179 | #ifdef __ARCH_WANT_INTERRUPTS_ON_CTXSW | 1186 | #ifdef __ARCH_WANT_INTERRUPTS_ON_CTXSW |
| @@ -1213,25 +1220,33 @@ static struct task_struct *copy_process(unsigned long clone_flags, | |||
| 1213 | retval = perf_event_init_task(p); | 1220 | retval = perf_event_init_task(p); |
| 1214 | if (retval) | 1221 | if (retval) |
| 1215 | goto bad_fork_cleanup_policy; | 1222 | goto bad_fork_cleanup_policy; |
| 1216 | 1223 | retval = audit_alloc(p); | |
| 1217 | if ((retval = audit_alloc(p))) | 1224 | if (retval) |
| 1218 | goto bad_fork_cleanup_policy; | 1225 | goto bad_fork_cleanup_policy; |
| 1219 | /* copy all the process information */ | 1226 | /* copy all the process information */ |
| 1220 | if ((retval = copy_semundo(clone_flags, p))) | 1227 | retval = copy_semundo(clone_flags, p); |
| 1228 | if (retval) | ||
| 1221 | goto bad_fork_cleanup_audit; | 1229 | goto bad_fork_cleanup_audit; |
| 1222 | if ((retval = copy_files(clone_flags, p))) | 1230 | retval = copy_files(clone_flags, p); |
| 1231 | if (retval) | ||
| 1223 | goto bad_fork_cleanup_semundo; | 1232 | goto bad_fork_cleanup_semundo; |
| 1224 | if ((retval = copy_fs(clone_flags, p))) | 1233 | retval = copy_fs(clone_flags, p); |
| 1234 | if (retval) | ||
| 1225 | goto bad_fork_cleanup_files; | 1235 | goto bad_fork_cleanup_files; |
| 1226 | if ((retval = copy_sighand(clone_flags, p))) | 1236 | retval = copy_sighand(clone_flags, p); |
| 1237 | if (retval) | ||
| 1227 | goto bad_fork_cleanup_fs; | 1238 | goto bad_fork_cleanup_fs; |
| 1228 | if ((retval = copy_signal(clone_flags, p))) | 1239 | retval = copy_signal(clone_flags, p); |
| 1240 | if (retval) | ||
| 1229 | goto bad_fork_cleanup_sighand; | 1241 | goto bad_fork_cleanup_sighand; |
| 1230 | if ((retval = copy_mm(clone_flags, p))) | 1242 | retval = copy_mm(clone_flags, p); |
| 1243 | if (retval) | ||
| 1231 | goto bad_fork_cleanup_signal; | 1244 | goto bad_fork_cleanup_signal; |
| 1232 | if ((retval = copy_namespaces(clone_flags, p))) | 1245 | retval = copy_namespaces(clone_flags, p); |
| 1246 | if (retval) | ||
| 1233 | goto bad_fork_cleanup_mm; | 1247 | goto bad_fork_cleanup_mm; |
| 1234 | if ((retval = copy_io(clone_flags, p))) | 1248 | retval = copy_io(clone_flags, p); |
| 1249 | if (retval) | ||
| 1235 | goto bad_fork_cleanup_namespaces; | 1250 | goto bad_fork_cleanup_namespaces; |
| 1236 | retval = copy_thread(clone_flags, stack_start, stack_size, p, regs); | 1251 | retval = copy_thread(clone_flags, stack_start, stack_size, p, regs); |
| 1237 | if (retval) | 1252 | if (retval) |
| @@ -1253,7 +1268,7 @@ static struct task_struct *copy_process(unsigned long clone_flags, | |||
| 1253 | /* | 1268 | /* |
| 1254 | * Clear TID on mm_release()? | 1269 | * Clear TID on mm_release()? |
| 1255 | */ | 1270 | */ |
| 1256 | p->clear_child_tid = (clone_flags & CLONE_CHILD_CLEARTID) ? child_tidptr: NULL; | 1271 | p->clear_child_tid = (clone_flags & CLONE_CHILD_CLEARTID) ? child_tidptr : NULL; |
| 1257 | #ifdef CONFIG_BLOCK | 1272 | #ifdef CONFIG_BLOCK |
| 1258 | p->plug = NULL; | 1273 | p->plug = NULL; |
| 1259 | #endif | 1274 | #endif |
| @@ -1321,7 +1336,7 @@ static struct task_struct *copy_process(unsigned long clone_flags, | |||
| 1321 | * it's process group. | 1336 | * it's process group. |
| 1322 | * A fatal signal pending means that current will exit, so the new | 1337 | * A fatal signal pending means that current will exit, so the new |
| 1323 | * thread can't slip out of an OOM kill (or normal SIGKILL). | 1338 | * thread can't slip out of an OOM kill (or normal SIGKILL). |
| 1324 | */ | 1339 | */ |
| 1325 | recalc_sigpending(); | 1340 | recalc_sigpending(); |
| 1326 | if (signal_pending(current)) { | 1341 | if (signal_pending(current)) { |
| 1327 | spin_unlock(¤t->sighand->siglock); | 1342 | spin_unlock(¤t->sighand->siglock); |
| @@ -1682,12 +1697,14 @@ SYSCALL_DEFINE1(unshare, unsigned long, unshare_flags) | |||
| 1682 | */ | 1697 | */ |
| 1683 | if (unshare_flags & (CLONE_NEWIPC|CLONE_SYSVSEM)) | 1698 | if (unshare_flags & (CLONE_NEWIPC|CLONE_SYSVSEM)) |
| 1684 | do_sysvsem = 1; | 1699 | do_sysvsem = 1; |
| 1685 | if ((err = unshare_fs(unshare_flags, &new_fs))) | 1700 | err = unshare_fs(unshare_flags, &new_fs); |
| 1701 | if (err) | ||
| 1686 | goto bad_unshare_out; | 1702 | goto bad_unshare_out; |
| 1687 | if ((err = unshare_fd(unshare_flags, &new_fd))) | 1703 | err = unshare_fd(unshare_flags, &new_fd); |
| 1704 | if (err) | ||
| 1688 | goto bad_unshare_cleanup_fs; | 1705 | goto bad_unshare_cleanup_fs; |
| 1689 | if ((err = unshare_nsproxy_namespaces(unshare_flags, &new_nsproxy, | 1706 | err = unshare_nsproxy_namespaces(unshare_flags, &new_nsproxy, new_fs); |
| 1690 | new_fs))) | 1707 | if (err) |
| 1691 | goto bad_unshare_cleanup_fd; | 1708 | goto bad_unshare_cleanup_fd; |
| 1692 | 1709 | ||
| 1693 | if (new_fs || new_fd || do_sysvsem || new_nsproxy) { | 1710 | if (new_fs || new_fd || do_sysvsem || new_nsproxy) { |
diff --git a/kernel/futex.c b/kernel/futex.c index 3fbc76cbb9aa..11cbe052b2e8 100644 --- a/kernel/futex.c +++ b/kernel/futex.c | |||
| @@ -218,6 +218,8 @@ static void drop_futex_key_refs(union futex_key *key) | |||
| 218 | * @uaddr: virtual address of the futex | 218 | * @uaddr: virtual address of the futex |
| 219 | * @fshared: 0 for a PROCESS_PRIVATE futex, 1 for PROCESS_SHARED | 219 | * @fshared: 0 for a PROCESS_PRIVATE futex, 1 for PROCESS_SHARED |
| 220 | * @key: address where result is stored. | 220 | * @key: address where result is stored. |
| 221 | * @rw: mapping needs to be read/write (values: VERIFY_READ, | ||
| 222 | * VERIFY_WRITE) | ||
| 221 | * | 223 | * |
| 222 | * Returns a negative error code or 0 | 224 | * Returns a negative error code or 0 |
| 223 | * The key words are stored in *key on success. | 225 | * The key words are stored in *key on success. |
| @@ -229,12 +231,12 @@ static void drop_futex_key_refs(union futex_key *key) | |||
| 229 | * lock_page() might sleep, the caller should not hold a spinlock. | 231 | * lock_page() might sleep, the caller should not hold a spinlock. |
| 230 | */ | 232 | */ |
| 231 | static int | 233 | static int |
| 232 | get_futex_key(u32 __user *uaddr, int fshared, union futex_key *key) | 234 | get_futex_key(u32 __user *uaddr, int fshared, union futex_key *key, int rw) |
| 233 | { | 235 | { |
| 234 | unsigned long address = (unsigned long)uaddr; | 236 | unsigned long address = (unsigned long)uaddr; |
| 235 | struct mm_struct *mm = current->mm; | 237 | struct mm_struct *mm = current->mm; |
| 236 | struct page *page, *page_head; | 238 | struct page *page, *page_head; |
| 237 | int err; | 239 | int err, ro = 0; |
| 238 | 240 | ||
| 239 | /* | 241 | /* |
| 240 | * The futex address must be "naturally" aligned. | 242 | * The futex address must be "naturally" aligned. |
| @@ -262,8 +264,18 @@ get_futex_key(u32 __user *uaddr, int fshared, union futex_key *key) | |||
| 262 | 264 | ||
| 263 | again: | 265 | again: |
| 264 | err = get_user_pages_fast(address, 1, 1, &page); | 266 | err = get_user_pages_fast(address, 1, 1, &page); |
| 267 | /* | ||
| 268 | * If write access is not required (eg. FUTEX_WAIT), try | ||
| 269 | * and get read-only access. | ||
| 270 | */ | ||
| 271 | if (err == -EFAULT && rw == VERIFY_READ) { | ||
| 272 | err = get_user_pages_fast(address, 1, 0, &page); | ||
| 273 | ro = 1; | ||
| 274 | } | ||
| 265 | if (err < 0) | 275 | if (err < 0) |
| 266 | return err; | 276 | return err; |
| 277 | else | ||
| 278 | err = 0; | ||
| 267 | 279 | ||
| 268 | #ifdef CONFIG_TRANSPARENT_HUGEPAGE | 280 | #ifdef CONFIG_TRANSPARENT_HUGEPAGE |
| 269 | page_head = page; | 281 | page_head = page; |
| @@ -305,6 +317,13 @@ again: | |||
| 305 | if (!page_head->mapping) { | 317 | if (!page_head->mapping) { |
| 306 | unlock_page(page_head); | 318 | unlock_page(page_head); |
| 307 | put_page(page_head); | 319 | put_page(page_head); |
| 320 | /* | ||
| 321 | * ZERO_PAGE pages don't have a mapping. Avoid a busy loop | ||
| 322 | * trying to find one. RW mapping would have COW'd (and thus | ||
| 323 | * have a mapping) so this page is RO and won't ever change. | ||
| 324 | */ | ||
| 325 | if ((page_head == ZERO_PAGE(address))) | ||
| 326 | return -EFAULT; | ||
| 308 | goto again; | 327 | goto again; |
| 309 | } | 328 | } |
| 310 | 329 | ||
| @@ -316,6 +335,15 @@ again: | |||
| 316 | * the object not the particular process. | 335 | * the object not the particular process. |
| 317 | */ | 336 | */ |
| 318 | if (PageAnon(page_head)) { | 337 | if (PageAnon(page_head)) { |
| 338 | /* | ||
| 339 | * A RO anonymous page will never change and thus doesn't make | ||
| 340 | * sense for futex operations. | ||
| 341 | */ | ||
| 342 | if (ro) { | ||
| 343 | err = -EFAULT; | ||
| 344 | goto out; | ||
| 345 | } | ||
| 346 | |||
| 319 | key->both.offset |= FUT_OFF_MMSHARED; /* ref taken on mm */ | 347 | key->both.offset |= FUT_OFF_MMSHARED; /* ref taken on mm */ |
| 320 | key->private.mm = mm; | 348 | key->private.mm = mm; |
| 321 | key->private.address = address; | 349 | key->private.address = address; |
| @@ -327,9 +355,10 @@ again: | |||
| 327 | 355 | ||
| 328 | get_futex_key_refs(key); | 356 | get_futex_key_refs(key); |
| 329 | 357 | ||
| 358 | out: | ||
| 330 | unlock_page(page_head); | 359 | unlock_page(page_head); |
| 331 | put_page(page_head); | 360 | put_page(page_head); |
| 332 | return 0; | 361 | return err; |
| 333 | } | 362 | } |
| 334 | 363 | ||
| 335 | static inline void put_futex_key(union futex_key *key) | 364 | static inline void put_futex_key(union futex_key *key) |
| @@ -355,8 +384,8 @@ static int fault_in_user_writeable(u32 __user *uaddr) | |||
| 355 | int ret; | 384 | int ret; |
| 356 | 385 | ||
| 357 | down_read(&mm->mmap_sem); | 386 | down_read(&mm->mmap_sem); |
| 358 | ret = get_user_pages(current, mm, (unsigned long)uaddr, | 387 | ret = fixup_user_fault(current, mm, (unsigned long)uaddr, |
| 359 | 1, 1, 0, NULL, NULL); | 388 | FAULT_FLAG_WRITE); |
| 360 | up_read(&mm->mmap_sem); | 389 | up_read(&mm->mmap_sem); |
| 361 | 390 | ||
| 362 | return ret < 0 ? ret : 0; | 391 | return ret < 0 ? ret : 0; |
| @@ -940,7 +969,7 @@ futex_wake(u32 __user *uaddr, unsigned int flags, int nr_wake, u32 bitset) | |||
| 940 | if (!bitset) | 969 | if (!bitset) |
| 941 | return -EINVAL; | 970 | return -EINVAL; |
| 942 | 971 | ||
| 943 | ret = get_futex_key(uaddr, flags & FLAGS_SHARED, &key); | 972 | ret = get_futex_key(uaddr, flags & FLAGS_SHARED, &key, VERIFY_READ); |
| 944 | if (unlikely(ret != 0)) | 973 | if (unlikely(ret != 0)) |
| 945 | goto out; | 974 | goto out; |
| 946 | 975 | ||
| @@ -986,10 +1015,10 @@ futex_wake_op(u32 __user *uaddr1, unsigned int flags, u32 __user *uaddr2, | |||
| 986 | int ret, op_ret; | 1015 | int ret, op_ret; |
| 987 | 1016 | ||
| 988 | retry: | 1017 | retry: |
| 989 | ret = get_futex_key(uaddr1, flags & FLAGS_SHARED, &key1); | 1018 | ret = get_futex_key(uaddr1, flags & FLAGS_SHARED, &key1, VERIFY_READ); |
| 990 | if (unlikely(ret != 0)) | 1019 | if (unlikely(ret != 0)) |
| 991 | goto out; | 1020 | goto out; |
| 992 | ret = get_futex_key(uaddr2, flags & FLAGS_SHARED, &key2); | 1021 | ret = get_futex_key(uaddr2, flags & FLAGS_SHARED, &key2, VERIFY_WRITE); |
| 993 | if (unlikely(ret != 0)) | 1022 | if (unlikely(ret != 0)) |
| 994 | goto out_put_key1; | 1023 | goto out_put_key1; |
| 995 | 1024 | ||
| @@ -1243,10 +1272,11 @@ retry: | |||
| 1243 | pi_state = NULL; | 1272 | pi_state = NULL; |
| 1244 | } | 1273 | } |
| 1245 | 1274 | ||
| 1246 | ret = get_futex_key(uaddr1, flags & FLAGS_SHARED, &key1); | 1275 | ret = get_futex_key(uaddr1, flags & FLAGS_SHARED, &key1, VERIFY_READ); |
| 1247 | if (unlikely(ret != 0)) | 1276 | if (unlikely(ret != 0)) |
| 1248 | goto out; | 1277 | goto out; |
| 1249 | ret = get_futex_key(uaddr2, flags & FLAGS_SHARED, &key2); | 1278 | ret = get_futex_key(uaddr2, flags & FLAGS_SHARED, &key2, |
| 1279 | requeue_pi ? VERIFY_WRITE : VERIFY_READ); | ||
| 1250 | if (unlikely(ret != 0)) | 1280 | if (unlikely(ret != 0)) |
| 1251 | goto out_put_key1; | 1281 | goto out_put_key1; |
| 1252 | 1282 | ||
| @@ -1790,7 +1820,7 @@ static int futex_wait_setup(u32 __user *uaddr, u32 val, unsigned int flags, | |||
| 1790 | * while the syscall executes. | 1820 | * while the syscall executes. |
| 1791 | */ | 1821 | */ |
| 1792 | retry: | 1822 | retry: |
| 1793 | ret = get_futex_key(uaddr, flags & FLAGS_SHARED, &q->key); | 1823 | ret = get_futex_key(uaddr, flags & FLAGS_SHARED, &q->key, VERIFY_READ); |
| 1794 | if (unlikely(ret != 0)) | 1824 | if (unlikely(ret != 0)) |
| 1795 | return ret; | 1825 | return ret; |
| 1796 | 1826 | ||
| @@ -1941,7 +1971,7 @@ static int futex_lock_pi(u32 __user *uaddr, unsigned int flags, int detect, | |||
| 1941 | } | 1971 | } |
| 1942 | 1972 | ||
| 1943 | retry: | 1973 | retry: |
| 1944 | ret = get_futex_key(uaddr, flags & FLAGS_SHARED, &q.key); | 1974 | ret = get_futex_key(uaddr, flags & FLAGS_SHARED, &q.key, VERIFY_WRITE); |
| 1945 | if (unlikely(ret != 0)) | 1975 | if (unlikely(ret != 0)) |
| 1946 | goto out; | 1976 | goto out; |
| 1947 | 1977 | ||
| @@ -2060,7 +2090,7 @@ retry: | |||
| 2060 | if ((uval & FUTEX_TID_MASK) != vpid) | 2090 | if ((uval & FUTEX_TID_MASK) != vpid) |
| 2061 | return -EPERM; | 2091 | return -EPERM; |
| 2062 | 2092 | ||
| 2063 | ret = get_futex_key(uaddr, flags & FLAGS_SHARED, &key); | 2093 | ret = get_futex_key(uaddr, flags & FLAGS_SHARED, &key, VERIFY_WRITE); |
| 2064 | if (unlikely(ret != 0)) | 2094 | if (unlikely(ret != 0)) |
| 2065 | goto out; | 2095 | goto out; |
| 2066 | 2096 | ||
| @@ -2249,7 +2279,7 @@ static int futex_wait_requeue_pi(u32 __user *uaddr, unsigned int flags, | |||
| 2249 | debug_rt_mutex_init_waiter(&rt_waiter); | 2279 | debug_rt_mutex_init_waiter(&rt_waiter); |
| 2250 | rt_waiter.task = NULL; | 2280 | rt_waiter.task = NULL; |
| 2251 | 2281 | ||
| 2252 | ret = get_futex_key(uaddr2, flags & FLAGS_SHARED, &key2); | 2282 | ret = get_futex_key(uaddr2, flags & FLAGS_SHARED, &key2, VERIFY_WRITE); |
| 2253 | if (unlikely(ret != 0)) | 2283 | if (unlikely(ret != 0)) |
| 2254 | goto out; | 2284 | goto out; |
| 2255 | 2285 | ||
diff --git a/kernel/gcov/Kconfig b/kernel/gcov/Kconfig index 5bf924d80b5c..a92028196cc1 100644 --- a/kernel/gcov/Kconfig +++ b/kernel/gcov/Kconfig | |||
| @@ -3,7 +3,7 @@ menu "GCOV-based kernel profiling" | |||
| 3 | config GCOV_KERNEL | 3 | config GCOV_KERNEL |
| 4 | bool "Enable gcov-based kernel profiling" | 4 | bool "Enable gcov-based kernel profiling" |
| 5 | depends on DEBUG_FS | 5 | depends on DEBUG_FS |
| 6 | select CONSTRUCTORS | 6 | select CONSTRUCTORS if !UML |
| 7 | default n | 7 | default n |
| 8 | ---help--- | 8 | ---help--- |
| 9 | This option enables gcov-based code profiling (e.g. for code coverage | 9 | This option enables gcov-based code profiling (e.g. for code coverage |
diff --git a/kernel/irq/Kconfig b/kernel/irq/Kconfig index d1d051b38e0b..5a38bf4de641 100644 --- a/kernel/irq/Kconfig +++ b/kernel/irq/Kconfig | |||
| @@ -52,6 +52,10 @@ config IRQ_EDGE_EOI_HANDLER | |||
| 52 | config GENERIC_IRQ_CHIP | 52 | config GENERIC_IRQ_CHIP |
| 53 | bool | 53 | bool |
| 54 | 54 | ||
| 55 | # Generic irq_domain hw <--> linux irq number translation | ||
| 56 | config IRQ_DOMAIN | ||
| 57 | bool | ||
| 58 | |||
| 55 | # Support forced irq threading | 59 | # Support forced irq threading |
| 56 | config IRQ_FORCED_THREADING | 60 | config IRQ_FORCED_THREADING |
| 57 | bool | 61 | bool |
diff --git a/kernel/irq/Makefile b/kernel/irq/Makefile index 73290056cfb6..fff17381f0af 100644 --- a/kernel/irq/Makefile +++ b/kernel/irq/Makefile | |||
| @@ -2,6 +2,7 @@ | |||
| 2 | obj-y := irqdesc.o handle.o manage.o spurious.o resend.o chip.o dummychip.o devres.o | 2 | obj-y := irqdesc.o handle.o manage.o spurious.o resend.o chip.o dummychip.o devres.o |
| 3 | obj-$(CONFIG_GENERIC_IRQ_CHIP) += generic-chip.o | 3 | obj-$(CONFIG_GENERIC_IRQ_CHIP) += generic-chip.o |
| 4 | obj-$(CONFIG_GENERIC_IRQ_PROBE) += autoprobe.o | 4 | obj-$(CONFIG_GENERIC_IRQ_PROBE) += autoprobe.o |
| 5 | obj-$(CONFIG_IRQ_DOMAIN) += irqdomain.o | ||
| 5 | obj-$(CONFIG_PROC_FS) += proc.o | 6 | obj-$(CONFIG_PROC_FS) += proc.o |
| 6 | obj-$(CONFIG_GENERIC_PENDING_IRQ) += migration.o | 7 | obj-$(CONFIG_GENERIC_PENDING_IRQ) += migration.o |
| 7 | obj-$(CONFIG_PM_SLEEP) += pm.o | 8 | obj-$(CONFIG_PM_SLEEP) += pm.o |
diff --git a/kernel/irq/chip.c b/kernel/irq/chip.c index d5a3009da71a..dc5114b4c16c 100644 --- a/kernel/irq/chip.c +++ b/kernel/irq/chip.c | |||
| @@ -178,7 +178,7 @@ void irq_shutdown(struct irq_desc *desc) | |||
| 178 | desc->depth = 1; | 178 | desc->depth = 1; |
| 179 | if (desc->irq_data.chip->irq_shutdown) | 179 | if (desc->irq_data.chip->irq_shutdown) |
| 180 | desc->irq_data.chip->irq_shutdown(&desc->irq_data); | 180 | desc->irq_data.chip->irq_shutdown(&desc->irq_data); |
| 181 | if (desc->irq_data.chip->irq_disable) | 181 | else if (desc->irq_data.chip->irq_disable) |
| 182 | desc->irq_data.chip->irq_disable(&desc->irq_data); | 182 | desc->irq_data.chip->irq_disable(&desc->irq_data); |
| 183 | else | 183 | else |
| 184 | desc->irq_data.chip->irq_mask(&desc->irq_data); | 184 | desc->irq_data.chip->irq_mask(&desc->irq_data); |
diff --git a/kernel/irq/devres.c b/kernel/irq/devres.c index 1ef4ffcdfa55..bd8e788d71e0 100644 --- a/kernel/irq/devres.c +++ b/kernel/irq/devres.c | |||
| @@ -87,8 +87,8 @@ void devm_free_irq(struct device *dev, unsigned int irq, void *dev_id) | |||
| 87 | { | 87 | { |
| 88 | struct irq_devres match_data = { irq, dev_id }; | 88 | struct irq_devres match_data = { irq, dev_id }; |
| 89 | 89 | ||
| 90 | free_irq(irq, dev_id); | ||
| 91 | WARN_ON(devres_destroy(dev, devm_irq_release, devm_irq_match, | 90 | WARN_ON(devres_destroy(dev, devm_irq_release, devm_irq_match, |
| 92 | &match_data)); | 91 | &match_data)); |
| 92 | free_irq(irq, dev_id); | ||
| 93 | } | 93 | } |
| 94 | EXPORT_SYMBOL(devm_free_irq); | 94 | EXPORT_SYMBOL(devm_free_irq); |
diff --git a/kernel/irq/generic-chip.c b/kernel/irq/generic-chip.c index 3a2cab407b93..e38544dddb18 100644 --- a/kernel/irq/generic-chip.c +++ b/kernel/irq/generic-chip.c | |||
| @@ -246,7 +246,7 @@ void irq_setup_generic_chip(struct irq_chip_generic *gc, u32 msk, | |||
| 246 | gc->mask_cache = irq_reg_readl(gc->reg_base + ct->regs.mask); | 246 | gc->mask_cache = irq_reg_readl(gc->reg_base + ct->regs.mask); |
| 247 | 247 | ||
| 248 | for (i = gc->irq_base; msk; msk >>= 1, i++) { | 248 | for (i = gc->irq_base; msk; msk >>= 1, i++) { |
| 249 | if (!msk & 0x01) | 249 | if (!(msk & 0x01)) |
| 250 | continue; | 250 | continue; |
| 251 | 251 | ||
| 252 | if (flags & IRQ_GC_INIT_NESTED_LOCK) | 252 | if (flags & IRQ_GC_INIT_NESTED_LOCK) |
| @@ -301,7 +301,7 @@ void irq_remove_generic_chip(struct irq_chip_generic *gc, u32 msk, | |||
| 301 | raw_spin_unlock(&gc_lock); | 301 | raw_spin_unlock(&gc_lock); |
| 302 | 302 | ||
| 303 | for (; msk; msk >>= 1, i++) { | 303 | for (; msk; msk >>= 1, i++) { |
| 304 | if (!msk & 0x01) | 304 | if (!(msk & 0x01)) |
| 305 | continue; | 305 | continue; |
| 306 | 306 | ||
| 307 | /* Remove handler first. That will mask the irq line */ | 307 | /* Remove handler first. That will mask the irq line */ |
diff --git a/kernel/irq/irqdesc.c b/kernel/irq/irqdesc.c index 4c60a50e66b2..039b889ea053 100644 --- a/kernel/irq/irqdesc.c +++ b/kernel/irq/irqdesc.c | |||
| @@ -70,7 +70,8 @@ static inline void desc_smp_init(struct irq_desc *desc, int node) { } | |||
| 70 | static inline int desc_node(struct irq_desc *desc) { return 0; } | 70 | static inline int desc_node(struct irq_desc *desc) { return 0; } |
| 71 | #endif | 71 | #endif |
| 72 | 72 | ||
| 73 | static void desc_set_defaults(unsigned int irq, struct irq_desc *desc, int node) | 73 | static void desc_set_defaults(unsigned int irq, struct irq_desc *desc, int node, |
| 74 | struct module *owner) | ||
| 74 | { | 75 | { |
| 75 | int cpu; | 76 | int cpu; |
| 76 | 77 | ||
| @@ -86,6 +87,7 @@ static void desc_set_defaults(unsigned int irq, struct irq_desc *desc, int node) | |||
| 86 | desc->irq_count = 0; | 87 | desc->irq_count = 0; |
| 87 | desc->irqs_unhandled = 0; | 88 | desc->irqs_unhandled = 0; |
| 88 | desc->name = NULL; | 89 | desc->name = NULL; |
| 90 | desc->owner = owner; | ||
| 89 | for_each_possible_cpu(cpu) | 91 | for_each_possible_cpu(cpu) |
| 90 | *per_cpu_ptr(desc->kstat_irqs, cpu) = 0; | 92 | *per_cpu_ptr(desc->kstat_irqs, cpu) = 0; |
| 91 | desc_smp_init(desc, node); | 93 | desc_smp_init(desc, node); |
| @@ -128,7 +130,7 @@ static void free_masks(struct irq_desc *desc) | |||
| 128 | static inline void free_masks(struct irq_desc *desc) { } | 130 | static inline void free_masks(struct irq_desc *desc) { } |
| 129 | #endif | 131 | #endif |
| 130 | 132 | ||
| 131 | static struct irq_desc *alloc_desc(int irq, int node) | 133 | static struct irq_desc *alloc_desc(int irq, int node, struct module *owner) |
| 132 | { | 134 | { |
| 133 | struct irq_desc *desc; | 135 | struct irq_desc *desc; |
| 134 | gfp_t gfp = GFP_KERNEL; | 136 | gfp_t gfp = GFP_KERNEL; |
| @@ -147,7 +149,7 @@ static struct irq_desc *alloc_desc(int irq, int node) | |||
| 147 | raw_spin_lock_init(&desc->lock); | 149 | raw_spin_lock_init(&desc->lock); |
| 148 | lockdep_set_class(&desc->lock, &irq_desc_lock_class); | 150 | lockdep_set_class(&desc->lock, &irq_desc_lock_class); |
| 149 | 151 | ||
| 150 | desc_set_defaults(irq, desc, node); | 152 | desc_set_defaults(irq, desc, node, owner); |
| 151 | 153 | ||
| 152 | return desc; | 154 | return desc; |
| 153 | 155 | ||
| @@ -173,13 +175,14 @@ static void free_desc(unsigned int irq) | |||
| 173 | kfree(desc); | 175 | kfree(desc); |
| 174 | } | 176 | } |
| 175 | 177 | ||
| 176 | static int alloc_descs(unsigned int start, unsigned int cnt, int node) | 178 | static int alloc_descs(unsigned int start, unsigned int cnt, int node, |
| 179 | struct module *owner) | ||
| 177 | { | 180 | { |
| 178 | struct irq_desc *desc; | 181 | struct irq_desc *desc; |
| 179 | int i; | 182 | int i; |
| 180 | 183 | ||
| 181 | for (i = 0; i < cnt; i++) { | 184 | for (i = 0; i < cnt; i++) { |
| 182 | desc = alloc_desc(start + i, node); | 185 | desc = alloc_desc(start + i, node, owner); |
| 183 | if (!desc) | 186 | if (!desc) |
| 184 | goto err; | 187 | goto err; |
| 185 | mutex_lock(&sparse_irq_lock); | 188 | mutex_lock(&sparse_irq_lock); |
| @@ -227,7 +230,7 @@ int __init early_irq_init(void) | |||
| 227 | nr_irqs = initcnt; | 230 | nr_irqs = initcnt; |
| 228 | 231 | ||
| 229 | for (i = 0; i < initcnt; i++) { | 232 | for (i = 0; i < initcnt; i++) { |
| 230 | desc = alloc_desc(i, node); | 233 | desc = alloc_desc(i, node, NULL); |
| 231 | set_bit(i, allocated_irqs); | 234 | set_bit(i, allocated_irqs); |
| 232 | irq_insert_desc(i, desc); | 235 | irq_insert_desc(i, desc); |
| 233 | } | 236 | } |
| @@ -261,7 +264,7 @@ int __init early_irq_init(void) | |||
| 261 | alloc_masks(&desc[i], GFP_KERNEL, node); | 264 | alloc_masks(&desc[i], GFP_KERNEL, node); |
| 262 | raw_spin_lock_init(&desc[i].lock); | 265 | raw_spin_lock_init(&desc[i].lock); |
| 263 | lockdep_set_class(&desc[i].lock, &irq_desc_lock_class); | 266 | lockdep_set_class(&desc[i].lock, &irq_desc_lock_class); |
| 264 | desc_set_defaults(i, &desc[i], node); | 267 | desc_set_defaults(i, &desc[i], node, NULL); |
| 265 | } | 268 | } |
| 266 | return arch_early_irq_init(); | 269 | return arch_early_irq_init(); |
| 267 | } | 270 | } |
| @@ -276,8 +279,16 @@ static void free_desc(unsigned int irq) | |||
| 276 | dynamic_irq_cleanup(irq); | 279 | dynamic_irq_cleanup(irq); |
| 277 | } | 280 | } |
| 278 | 281 | ||
| 279 | static inline int alloc_descs(unsigned int start, unsigned int cnt, int node) | 282 | static inline int alloc_descs(unsigned int start, unsigned int cnt, int node, |
| 283 | struct module *owner) | ||
| 280 | { | 284 | { |
| 285 | u32 i; | ||
| 286 | |||
| 287 | for (i = 0; i < cnt; i++) { | ||
| 288 | struct irq_desc *desc = irq_to_desc(start + i); | ||
| 289 | |||
| 290 | desc->owner = owner; | ||
| 291 | } | ||
| 281 | return start; | 292 | return start; |
| 282 | } | 293 | } |
| 283 | 294 | ||
| @@ -333,11 +344,13 @@ EXPORT_SYMBOL_GPL(irq_free_descs); | |||
| 333 | * @from: Start the search from this irq number | 344 | * @from: Start the search from this irq number |
| 334 | * @cnt: Number of consecutive irqs to allocate. | 345 | * @cnt: Number of consecutive irqs to allocate. |
| 335 | * @node: Preferred node on which the irq descriptor should be allocated | 346 | * @node: Preferred node on which the irq descriptor should be allocated |
| 347 | * @owner: Owning module (can be NULL) | ||
| 336 | * | 348 | * |
| 337 | * Returns the first irq number or error code | 349 | * Returns the first irq number or error code |
| 338 | */ | 350 | */ |
| 339 | int __ref | 351 | int __ref |
| 340 | irq_alloc_descs(int irq, unsigned int from, unsigned int cnt, int node) | 352 | __irq_alloc_descs(int irq, unsigned int from, unsigned int cnt, int node, |
| 353 | struct module *owner) | ||
| 341 | { | 354 | { |
| 342 | int start, ret; | 355 | int start, ret; |
| 343 | 356 | ||
| @@ -366,13 +379,13 @@ irq_alloc_descs(int irq, unsigned int from, unsigned int cnt, int node) | |||
| 366 | 379 | ||
| 367 | bitmap_set(allocated_irqs, start, cnt); | 380 | bitmap_set(allocated_irqs, start, cnt); |
| 368 | mutex_unlock(&sparse_irq_lock); | 381 | mutex_unlock(&sparse_irq_lock); |
| 369 | return alloc_descs(start, cnt, node); | 382 | return alloc_descs(start, cnt, node, owner); |
| 370 | 383 | ||
| 371 | err: | 384 | err: |
| 372 | mutex_unlock(&sparse_irq_lock); | 385 | mutex_unlock(&sparse_irq_lock); |
| 373 | return ret; | 386 | return ret; |
| 374 | } | 387 | } |
| 375 | EXPORT_SYMBOL_GPL(irq_alloc_descs); | 388 | EXPORT_SYMBOL_GPL(__irq_alloc_descs); |
| 376 | 389 | ||
| 377 | /** | 390 | /** |
| 378 | * irq_reserve_irqs - mark irqs allocated | 391 | * irq_reserve_irqs - mark irqs allocated |
| @@ -440,7 +453,7 @@ void dynamic_irq_cleanup(unsigned int irq) | |||
| 440 | unsigned long flags; | 453 | unsigned long flags; |
| 441 | 454 | ||
| 442 | raw_spin_lock_irqsave(&desc->lock, flags); | 455 | raw_spin_lock_irqsave(&desc->lock, flags); |
| 443 | desc_set_defaults(irq, desc, desc_node(desc)); | 456 | desc_set_defaults(irq, desc, desc_node(desc), NULL); |
| 444 | raw_spin_unlock_irqrestore(&desc->lock, flags); | 457 | raw_spin_unlock_irqrestore(&desc->lock, flags); |
| 445 | } | 458 | } |
| 446 | 459 | ||
diff --git a/kernel/irq/irqdomain.c b/kernel/irq/irqdomain.c new file mode 100644 index 000000000000..b57a3776de44 --- /dev/null +++ b/kernel/irq/irqdomain.c | |||
| @@ -0,0 +1,184 @@ | |||
| 1 | #include <linux/irq.h> | ||
| 2 | #include <linux/irqdomain.h> | ||
| 3 | #include <linux/module.h> | ||
| 4 | #include <linux/mutex.h> | ||
| 5 | #include <linux/of.h> | ||
| 6 | #include <linux/of_address.h> | ||
| 7 | #include <linux/slab.h> | ||
| 8 | |||
| 9 | static LIST_HEAD(irq_domain_list); | ||
| 10 | static DEFINE_MUTEX(irq_domain_mutex); | ||
| 11 | |||
| 12 | /** | ||
| 13 | * irq_domain_add() - Register an irq_domain | ||
| 14 | * @domain: ptr to initialized irq_domain structure | ||
| 15 | * | ||
| 16 | * Registers an irq_domain structure. The irq_domain must at a minimum be | ||
| 17 | * initialized with an ops structure pointer, and either a ->to_irq hook or | ||
| 18 | * a valid irq_base value. Everything else is optional. | ||
| 19 | */ | ||
| 20 | void irq_domain_add(struct irq_domain *domain) | ||
| 21 | { | ||
| 22 | struct irq_data *d; | ||
| 23 | int hwirq; | ||
| 24 | |||
| 25 | /* | ||
| 26 | * This assumes that the irq_domain owner has already allocated | ||
| 27 | * the irq_descs. This block will be removed when support for dynamic | ||
| 28 | * allocation of irq_descs is added to irq_domain. | ||
| 29 | */ | ||
| 30 | for (hwirq = 0; hwirq < domain->nr_irq; hwirq++) { | ||
| 31 | d = irq_get_irq_data(irq_domain_to_irq(domain, hwirq)); | ||
| 32 | if (!d) { | ||
| 33 | WARN(1, "error: assigning domain to non existant irq_desc"); | ||
| 34 | return; | ||
| 35 | } | ||
| 36 | if (d->domain) { | ||
| 37 | /* things are broken; just report, don't clean up */ | ||
| 38 | WARN(1, "error: irq_desc already assigned to a domain"); | ||
| 39 | return; | ||
| 40 | } | ||
| 41 | d->domain = domain; | ||
| 42 | d->hwirq = hwirq; | ||
| 43 | } | ||
| 44 | |||
| 45 | mutex_lock(&irq_domain_mutex); | ||
| 46 | list_add(&domain->list, &irq_domain_list); | ||
| 47 | mutex_unlock(&irq_domain_mutex); | ||
| 48 | } | ||
| 49 | |||
| 50 | /** | ||
| 51 | * irq_domain_del() - Unregister an irq_domain | ||
| 52 | * @domain: ptr to registered irq_domain. | ||
| 53 | */ | ||
| 54 | void irq_domain_del(struct irq_domain *domain) | ||
| 55 | { | ||
| 56 | struct irq_data *d; | ||
| 57 | int hwirq; | ||
| 58 | |||
| 59 | mutex_lock(&irq_domain_mutex); | ||
| 60 | list_del(&domain->list); | ||
| 61 | mutex_unlock(&irq_domain_mutex); | ||
| 62 | |||
| 63 | /* Clear the irq_domain assignments */ | ||
| 64 | for (hwirq = 0; hwirq < domain->nr_irq; hwirq++) { | ||
| 65 | d = irq_get_irq_data(irq_domain_to_irq(domain, hwirq)); | ||
| 66 | d->domain = NULL; | ||
| 67 | } | ||
| 68 | } | ||
| 69 | |||
| 70 | #if defined(CONFIG_OF_IRQ) | ||
| 71 | /** | ||
| 72 | * irq_create_of_mapping() - Map a linux irq number from a DT interrupt spec | ||
| 73 | * | ||
| 74 | * Used by the device tree interrupt mapping code to translate a device tree | ||
| 75 | * interrupt specifier to a valid linux irq number. Returns either a valid | ||
| 76 | * linux IRQ number or 0. | ||
| 77 | * | ||
| 78 | * When the caller no longer need the irq number returned by this function it | ||
| 79 | * should arrange to call irq_dispose_mapping(). | ||
| 80 | */ | ||
| 81 | unsigned int irq_create_of_mapping(struct device_node *controller, | ||
| 82 | const u32 *intspec, unsigned int intsize) | ||
| 83 | { | ||
| 84 | struct irq_domain *domain; | ||
| 85 | unsigned long hwirq; | ||
| 86 | unsigned int irq, type; | ||
| 87 | int rc = -EINVAL; | ||
| 88 | |||
| 89 | /* Find a domain which can translate the irq spec */ | ||
| 90 | mutex_lock(&irq_domain_mutex); | ||
| 91 | list_for_each_entry(domain, &irq_domain_list, list) { | ||
| 92 | if (!domain->ops->dt_translate) | ||
| 93 | continue; | ||
| 94 | rc = domain->ops->dt_translate(domain, controller, | ||
| 95 | intspec, intsize, &hwirq, &type); | ||
| 96 | if (rc == 0) | ||
| 97 | break; | ||
| 98 | } | ||
| 99 | mutex_unlock(&irq_domain_mutex); | ||
| 100 | |||
| 101 | if (rc != 0) | ||
| 102 | return 0; | ||
| 103 | |||
| 104 | irq = irq_domain_to_irq(domain, hwirq); | ||
| 105 | if (type != IRQ_TYPE_NONE) | ||
| 106 | irq_set_irq_type(irq, type); | ||
| 107 | pr_debug("%s: mapped hwirq=%i to irq=%i, flags=%x\n", | ||
| 108 | controller->full_name, (int)hwirq, irq, type); | ||
| 109 | return irq; | ||
| 110 | } | ||
| 111 | EXPORT_SYMBOL_GPL(irq_create_of_mapping); | ||
| 112 | |||
| 113 | /** | ||
| 114 | * irq_dispose_mapping() - Discard a mapping created by irq_create_of_mapping() | ||
| 115 | * @irq: linux irq number to be discarded | ||
| 116 | * | ||
| 117 | * Calling this function indicates the caller no longer needs a reference to | ||
| 118 | * the linux irq number returned by a prior call to irq_create_of_mapping(). | ||
| 119 | */ | ||
| 120 | void irq_dispose_mapping(unsigned int irq) | ||
| 121 | { | ||
| 122 | /* | ||
| 123 | * nothing yet; will be filled when support for dynamic allocation of | ||
| 124 | * irq_descs is added to irq_domain | ||
| 125 | */ | ||
| 126 | } | ||
| 127 | EXPORT_SYMBOL_GPL(irq_dispose_mapping); | ||
| 128 | |||
| 129 | int irq_domain_simple_dt_translate(struct irq_domain *d, | ||
| 130 | struct device_node *controller, | ||
| 131 | const u32 *intspec, unsigned int intsize, | ||
| 132 | unsigned long *out_hwirq, unsigned int *out_type) | ||
| 133 | { | ||
| 134 | if (d->of_node != controller) | ||
| 135 | return -EINVAL; | ||
| 136 | if (intsize < 1) | ||
| 137 | return -EINVAL; | ||
| 138 | |||
| 139 | *out_hwirq = intspec[0]; | ||
| 140 | *out_type = IRQ_TYPE_NONE; | ||
| 141 | if (intsize > 1) | ||
| 142 | *out_type = intspec[1] & IRQ_TYPE_SENSE_MASK; | ||
| 143 | return 0; | ||
| 144 | } | ||
| 145 | |||
| 146 | struct irq_domain_ops irq_domain_simple_ops = { | ||
| 147 | .dt_translate = irq_domain_simple_dt_translate, | ||
| 148 | }; | ||
| 149 | EXPORT_SYMBOL_GPL(irq_domain_simple_ops); | ||
| 150 | |||
| 151 | /** | ||
| 152 | * irq_domain_create_simple() - Set up a 'simple' translation range | ||
| 153 | */ | ||
| 154 | void irq_domain_add_simple(struct device_node *controller, int irq_base) | ||
| 155 | { | ||
| 156 | struct irq_domain *domain; | ||
| 157 | |||
| 158 | domain = kzalloc(sizeof(*domain), GFP_KERNEL); | ||
| 159 | if (!domain) { | ||
| 160 | WARN_ON(1); | ||
| 161 | return; | ||
| 162 | } | ||
| 163 | |||
| 164 | domain->irq_base = irq_base; | ||
| 165 | domain->of_node = of_node_get(controller); | ||
| 166 | domain->ops = &irq_domain_simple_ops; | ||
| 167 | irq_domain_add(domain); | ||
| 168 | } | ||
| 169 | EXPORT_SYMBOL_GPL(irq_domain_add_simple); | ||
| 170 | |||
| 171 | void irq_domain_generate_simple(const struct of_device_id *match, | ||
| 172 | u64 phys_base, unsigned int irq_start) | ||
| 173 | { | ||
| 174 | struct device_node *node; | ||
| 175 | pr_info("looking for phys_base=%llx, irq_start=%i\n", | ||
| 176 | (unsigned long long) phys_base, (int) irq_start); | ||
| 177 | node = of_find_matching_node_by_address(NULL, match, phys_base); | ||
| 178 | if (node) | ||
| 179 | irq_domain_add_simple(node, irq_start); | ||
| 180 | else | ||
| 181 | pr_info("no node found\n"); | ||
| 182 | } | ||
| 183 | EXPORT_SYMBOL_GPL(irq_domain_generate_simple); | ||
| 184 | #endif /* CONFIG_OF_IRQ */ | ||
diff --git a/kernel/irq/manage.c b/kernel/irq/manage.c index 0a7840aeb0fb..9b956fa20308 100644 --- a/kernel/irq/manage.c +++ b/kernel/irq/manage.c | |||
| @@ -883,6 +883,8 @@ __setup_irq(unsigned int irq, struct irq_desc *desc, struct irqaction *new) | |||
| 883 | 883 | ||
| 884 | if (desc->irq_data.chip == &no_irq_chip) | 884 | if (desc->irq_data.chip == &no_irq_chip) |
| 885 | return -ENOSYS; | 885 | return -ENOSYS; |
| 886 | if (!try_module_get(desc->owner)) | ||
| 887 | return -ENODEV; | ||
| 886 | /* | 888 | /* |
| 887 | * Some drivers like serial.c use request_irq() heavily, | 889 | * Some drivers like serial.c use request_irq() heavily, |
| 888 | * so we have to be careful not to interfere with a | 890 | * so we have to be careful not to interfere with a |
| @@ -906,8 +908,10 @@ __setup_irq(unsigned int irq, struct irq_desc *desc, struct irqaction *new) | |||
| 906 | */ | 908 | */ |
| 907 | nested = irq_settings_is_nested_thread(desc); | 909 | nested = irq_settings_is_nested_thread(desc); |
| 908 | if (nested) { | 910 | if (nested) { |
| 909 | if (!new->thread_fn) | 911 | if (!new->thread_fn) { |
| 910 | return -EINVAL; | 912 | ret = -EINVAL; |
| 913 | goto out_mput; | ||
| 914 | } | ||
| 911 | /* | 915 | /* |
| 912 | * Replace the primary handler which was provided from | 916 | * Replace the primary handler which was provided from |
| 913 | * the driver for non nested interrupt handling by the | 917 | * the driver for non nested interrupt handling by the |
| @@ -929,8 +933,10 @@ __setup_irq(unsigned int irq, struct irq_desc *desc, struct irqaction *new) | |||
| 929 | 933 | ||
| 930 | t = kthread_create(irq_thread, new, "irq/%d-%s", irq, | 934 | t = kthread_create(irq_thread, new, "irq/%d-%s", irq, |
| 931 | new->name); | 935 | new->name); |
| 932 | if (IS_ERR(t)) | 936 | if (IS_ERR(t)) { |
| 933 | return PTR_ERR(t); | 937 | ret = PTR_ERR(t); |
| 938 | goto out_mput; | ||
| 939 | } | ||
| 934 | /* | 940 | /* |
| 935 | * We keep the reference to the task struct even if | 941 | * We keep the reference to the task struct even if |
| 936 | * the thread dies to avoid that the interrupt code | 942 | * the thread dies to avoid that the interrupt code |
| @@ -1095,6 +1101,8 @@ out_thread: | |||
| 1095 | kthread_stop(t); | 1101 | kthread_stop(t); |
| 1096 | put_task_struct(t); | 1102 | put_task_struct(t); |
| 1097 | } | 1103 | } |
| 1104 | out_mput: | ||
| 1105 | module_put(desc->owner); | ||
| 1098 | return ret; | 1106 | return ret; |
| 1099 | } | 1107 | } |
| 1100 | 1108 | ||
| @@ -1203,6 +1211,7 @@ static struct irqaction *__free_irq(unsigned int irq, void *dev_id) | |||
| 1203 | put_task_struct(action->thread); | 1211 | put_task_struct(action->thread); |
| 1204 | } | 1212 | } |
| 1205 | 1213 | ||
| 1214 | module_put(desc->owner); | ||
| 1206 | return action; | 1215 | return action; |
| 1207 | } | 1216 | } |
| 1208 | 1217 | ||
diff --git a/kernel/kexec.c b/kernel/kexec.c index 8d814cbc8109..296fbc84d659 100644 --- a/kernel/kexec.c +++ b/kernel/kexec.c | |||
| @@ -1095,7 +1095,7 @@ size_t crash_get_memory_size(void) | |||
| 1095 | size_t size = 0; | 1095 | size_t size = 0; |
| 1096 | mutex_lock(&kexec_mutex); | 1096 | mutex_lock(&kexec_mutex); |
| 1097 | if (crashk_res.end != crashk_res.start) | 1097 | if (crashk_res.end != crashk_res.start) |
| 1098 | size = crashk_res.end - crashk_res.start + 1; | 1098 | size = resource_size(&crashk_res); |
| 1099 | mutex_unlock(&kexec_mutex); | 1099 | mutex_unlock(&kexec_mutex); |
| 1100 | return size; | 1100 | return size; |
| 1101 | } | 1101 | } |
diff --git a/kernel/kmod.c b/kernel/kmod.c index 47613dfb7b28..ddc7644c1305 100644 --- a/kernel/kmod.c +++ b/kernel/kmod.c | |||
| @@ -274,7 +274,7 @@ static void __call_usermodehelper(struct work_struct *work) | |||
| 274 | * (used for preventing user land processes from being created after the user | 274 | * (used for preventing user land processes from being created after the user |
| 275 | * land has been frozen during a system-wide hibernation or suspend operation). | 275 | * land has been frozen during a system-wide hibernation or suspend operation). |
| 276 | */ | 276 | */ |
| 277 | static int usermodehelper_disabled; | 277 | static int usermodehelper_disabled = 1; |
| 278 | 278 | ||
| 279 | /* Number of helpers running */ | 279 | /* Number of helpers running */ |
| 280 | static atomic_t running_helpers = ATOMIC_INIT(0); | 280 | static atomic_t running_helpers = ATOMIC_INIT(0); |
diff --git a/kernel/lockdep.c b/kernel/lockdep.c index 3956f5149e25..91d67ce3a8d5 100644 --- a/kernel/lockdep.c +++ b/kernel/lockdep.c | |||
| @@ -2468,7 +2468,7 @@ mark_held_locks(struct task_struct *curr, enum mark_type mark) | |||
| 2468 | 2468 | ||
| 2469 | BUG_ON(usage_bit >= LOCK_USAGE_STATES); | 2469 | BUG_ON(usage_bit >= LOCK_USAGE_STATES); |
| 2470 | 2470 | ||
| 2471 | if (hlock_class(hlock)->key == &__lockdep_no_validate__) | 2471 | if (hlock_class(hlock)->key == __lockdep_no_validate__.subkeys) |
| 2472 | continue; | 2472 | continue; |
| 2473 | 2473 | ||
| 2474 | if (!mark_lock(curr, hlock, usage_bit)) | 2474 | if (!mark_lock(curr, hlock, usage_bit)) |
| @@ -2485,23 +2485,9 @@ static void __trace_hardirqs_on_caller(unsigned long ip) | |||
| 2485 | { | 2485 | { |
| 2486 | struct task_struct *curr = current; | 2486 | struct task_struct *curr = current; |
| 2487 | 2487 | ||
| 2488 | if (DEBUG_LOCKS_WARN_ON(unlikely(early_boot_irqs_disabled))) | ||
| 2489 | return; | ||
| 2490 | |||
| 2491 | if (unlikely(curr->hardirqs_enabled)) { | ||
| 2492 | /* | ||
| 2493 | * Neither irq nor preemption are disabled here | ||
| 2494 | * so this is racy by nature but losing one hit | ||
| 2495 | * in a stat is not a big deal. | ||
| 2496 | */ | ||
| 2497 | __debug_atomic_inc(redundant_hardirqs_on); | ||
| 2498 | return; | ||
| 2499 | } | ||
| 2500 | /* we'll do an OFF -> ON transition: */ | 2488 | /* we'll do an OFF -> ON transition: */ |
| 2501 | curr->hardirqs_enabled = 1; | 2489 | curr->hardirqs_enabled = 1; |
| 2502 | 2490 | ||
| 2503 | if (DEBUG_LOCKS_WARN_ON(current->hardirq_context)) | ||
| 2504 | return; | ||
| 2505 | /* | 2491 | /* |
| 2506 | * We are going to turn hardirqs on, so set the | 2492 | * We are going to turn hardirqs on, so set the |
| 2507 | * usage bit for all held locks: | 2493 | * usage bit for all held locks: |
| @@ -2529,9 +2515,25 @@ void trace_hardirqs_on_caller(unsigned long ip) | |||
| 2529 | if (unlikely(!debug_locks || current->lockdep_recursion)) | 2515 | if (unlikely(!debug_locks || current->lockdep_recursion)) |
| 2530 | return; | 2516 | return; |
| 2531 | 2517 | ||
| 2518 | if (unlikely(current->hardirqs_enabled)) { | ||
| 2519 | /* | ||
| 2520 | * Neither irq nor preemption are disabled here | ||
| 2521 | * so this is racy by nature but losing one hit | ||
| 2522 | * in a stat is not a big deal. | ||
| 2523 | */ | ||
| 2524 | __debug_atomic_inc(redundant_hardirqs_on); | ||
| 2525 | return; | ||
| 2526 | } | ||
| 2527 | |||
| 2532 | if (DEBUG_LOCKS_WARN_ON(!irqs_disabled())) | 2528 | if (DEBUG_LOCKS_WARN_ON(!irqs_disabled())) |
| 2533 | return; | 2529 | return; |
| 2534 | 2530 | ||
| 2531 | if (DEBUG_LOCKS_WARN_ON(unlikely(early_boot_irqs_disabled))) | ||
| 2532 | return; | ||
| 2533 | |||
| 2534 | if (DEBUG_LOCKS_WARN_ON(current->hardirq_context)) | ||
| 2535 | return; | ||
| 2536 | |||
| 2535 | current->lockdep_recursion = 1; | 2537 | current->lockdep_recursion = 1; |
| 2536 | __trace_hardirqs_on_caller(ip); | 2538 | __trace_hardirqs_on_caller(ip); |
| 2537 | current->lockdep_recursion = 0; | 2539 | current->lockdep_recursion = 0; |
| @@ -2872,10 +2874,7 @@ static int mark_lock(struct task_struct *curr, struct held_lock *this, | |||
| 2872 | void lockdep_init_map(struct lockdep_map *lock, const char *name, | 2874 | void lockdep_init_map(struct lockdep_map *lock, const char *name, |
| 2873 | struct lock_class_key *key, int subclass) | 2875 | struct lock_class_key *key, int subclass) |
| 2874 | { | 2876 | { |
| 2875 | int i; | 2877 | memset(lock, 0, sizeof(*lock)); |
| 2876 | |||
| 2877 | for (i = 0; i < NR_LOCKDEP_CACHING_CLASSES; i++) | ||
| 2878 | lock->class_cache[i] = NULL; | ||
| 2879 | 2878 | ||
| 2880 | #ifdef CONFIG_LOCK_STAT | 2879 | #ifdef CONFIG_LOCK_STAT |
| 2881 | lock->cpu = raw_smp_processor_id(); | 2880 | lock->cpu = raw_smp_processor_id(); |
| @@ -3112,7 +3111,13 @@ static int match_held_lock(struct held_lock *hlock, struct lockdep_map *lock) | |||
| 3112 | if (!class) | 3111 | if (!class) |
| 3113 | class = look_up_lock_class(lock, 0); | 3112 | class = look_up_lock_class(lock, 0); |
| 3114 | 3113 | ||
| 3115 | if (DEBUG_LOCKS_WARN_ON(!class)) | 3114 | /* |
| 3115 | * If look_up_lock_class() failed to find a class, we're trying | ||
| 3116 | * to test if we hold a lock that has never yet been acquired. | ||
| 3117 | * Clearly if the lock hasn't been acquired _ever_, we're not | ||
| 3118 | * holding it either, so report failure. | ||
| 3119 | */ | ||
| 3120 | if (!class) | ||
| 3116 | return 0; | 3121 | return 0; |
| 3117 | 3122 | ||
| 3118 | if (DEBUG_LOCKS_WARN_ON(!hlock->nest_lock)) | 3123 | if (DEBUG_LOCKS_WARN_ON(!hlock->nest_lock)) |
diff --git a/kernel/module.c b/kernel/module.c index 795bdc7f5c3f..04379f92f843 100644 --- a/kernel/module.c +++ b/kernel/module.c | |||
| @@ -545,9 +545,9 @@ static void setup_modinfo_##field(struct module *mod, const char *s) \ | |||
| 545 | mod->field = kstrdup(s, GFP_KERNEL); \ | 545 | mod->field = kstrdup(s, GFP_KERNEL); \ |
| 546 | } \ | 546 | } \ |
| 547 | static ssize_t show_modinfo_##field(struct module_attribute *mattr, \ | 547 | static ssize_t show_modinfo_##field(struct module_attribute *mattr, \ |
| 548 | struct module *mod, char *buffer) \ | 548 | struct module_kobject *mk, char *buffer) \ |
| 549 | { \ | 549 | { \ |
| 550 | return sprintf(buffer, "%s\n", mod->field); \ | 550 | return sprintf(buffer, "%s\n", mk->mod->field); \ |
| 551 | } \ | 551 | } \ |
| 552 | static int modinfo_##field##_exists(struct module *mod) \ | 552 | static int modinfo_##field##_exists(struct module *mod) \ |
| 553 | { \ | 553 | { \ |
| @@ -902,9 +902,9 @@ void symbol_put_addr(void *addr) | |||
| 902 | EXPORT_SYMBOL_GPL(symbol_put_addr); | 902 | EXPORT_SYMBOL_GPL(symbol_put_addr); |
| 903 | 903 | ||
| 904 | static ssize_t show_refcnt(struct module_attribute *mattr, | 904 | static ssize_t show_refcnt(struct module_attribute *mattr, |
| 905 | struct module *mod, char *buffer) | 905 | struct module_kobject *mk, char *buffer) |
| 906 | { | 906 | { |
| 907 | return sprintf(buffer, "%u\n", module_refcount(mod)); | 907 | return sprintf(buffer, "%u\n", module_refcount(mk->mod)); |
| 908 | } | 908 | } |
| 909 | 909 | ||
| 910 | static struct module_attribute refcnt = { | 910 | static struct module_attribute refcnt = { |
| @@ -952,11 +952,11 @@ static inline int module_unload_init(struct module *mod) | |||
| 952 | #endif /* CONFIG_MODULE_UNLOAD */ | 952 | #endif /* CONFIG_MODULE_UNLOAD */ |
| 953 | 953 | ||
| 954 | static ssize_t show_initstate(struct module_attribute *mattr, | 954 | static ssize_t show_initstate(struct module_attribute *mattr, |
| 955 | struct module *mod, char *buffer) | 955 | struct module_kobject *mk, char *buffer) |
| 956 | { | 956 | { |
| 957 | const char *state = "unknown"; | 957 | const char *state = "unknown"; |
| 958 | 958 | ||
| 959 | switch (mod->state) { | 959 | switch (mk->mod->state) { |
| 960 | case MODULE_STATE_LIVE: | 960 | case MODULE_STATE_LIVE: |
| 961 | state = "live"; | 961 | state = "live"; |
| 962 | break; | 962 | break; |
| @@ -975,10 +975,27 @@ static struct module_attribute initstate = { | |||
| 975 | .show = show_initstate, | 975 | .show = show_initstate, |
| 976 | }; | 976 | }; |
| 977 | 977 | ||
| 978 | static ssize_t store_uevent(struct module_attribute *mattr, | ||
| 979 | struct module_kobject *mk, | ||
| 980 | const char *buffer, size_t count) | ||
| 981 | { | ||
| 982 | enum kobject_action action; | ||
| 983 | |||
| 984 | if (kobject_action_type(buffer, count, &action) == 0) | ||
| 985 | kobject_uevent(&mk->kobj, action); | ||
| 986 | return count; | ||
| 987 | } | ||
| 988 | |||
| 989 | struct module_attribute module_uevent = { | ||
| 990 | .attr = { .name = "uevent", .mode = 0200 }, | ||
| 991 | .store = store_uevent, | ||
| 992 | }; | ||
| 993 | |||
| 978 | static struct module_attribute *modinfo_attrs[] = { | 994 | static struct module_attribute *modinfo_attrs[] = { |
| 979 | &modinfo_version, | 995 | &modinfo_version, |
| 980 | &modinfo_srcversion, | 996 | &modinfo_srcversion, |
| 981 | &initstate, | 997 | &initstate, |
| 998 | &module_uevent, | ||
| 982 | #ifdef CONFIG_MODULE_UNLOAD | 999 | #ifdef CONFIG_MODULE_UNLOAD |
| 983 | &refcnt, | 1000 | &refcnt, |
| 984 | #endif | 1001 | #endif |
| @@ -1187,7 +1204,7 @@ struct module_sect_attrs | |||
| 1187 | }; | 1204 | }; |
| 1188 | 1205 | ||
| 1189 | static ssize_t module_sect_show(struct module_attribute *mattr, | 1206 | static ssize_t module_sect_show(struct module_attribute *mattr, |
| 1190 | struct module *mod, char *buf) | 1207 | struct module_kobject *mk, char *buf) |
| 1191 | { | 1208 | { |
| 1192 | struct module_sect_attr *sattr = | 1209 | struct module_sect_attr *sattr = |
| 1193 | container_of(mattr, struct module_sect_attr, mattr); | 1210 | container_of(mattr, struct module_sect_attr, mattr); |
| @@ -1697,6 +1714,15 @@ static void unset_module_core_ro_nx(struct module *mod) { } | |||
| 1697 | static void unset_module_init_ro_nx(struct module *mod) { } | 1714 | static void unset_module_init_ro_nx(struct module *mod) { } |
| 1698 | #endif | 1715 | #endif |
| 1699 | 1716 | ||
| 1717 | void __weak module_free(struct module *mod, void *module_region) | ||
| 1718 | { | ||
| 1719 | vfree(module_region); | ||
| 1720 | } | ||
| 1721 | |||
| 1722 | void __weak module_arch_cleanup(struct module *mod) | ||
| 1723 | { | ||
| 1724 | } | ||
| 1725 | |||
| 1700 | /* Free a module, remove from lists, etc. */ | 1726 | /* Free a module, remove from lists, etc. */ |
| 1701 | static void free_module(struct module *mod) | 1727 | static void free_module(struct module *mod) |
| 1702 | { | 1728 | { |
| @@ -1851,6 +1877,26 @@ static int simplify_symbols(struct module *mod, const struct load_info *info) | |||
| 1851 | return ret; | 1877 | return ret; |
| 1852 | } | 1878 | } |
| 1853 | 1879 | ||
| 1880 | int __weak apply_relocate(Elf_Shdr *sechdrs, | ||
| 1881 | const char *strtab, | ||
| 1882 | unsigned int symindex, | ||
| 1883 | unsigned int relsec, | ||
| 1884 | struct module *me) | ||
| 1885 | { | ||
| 1886 | pr_err("module %s: REL relocation unsupported\n", me->name); | ||
| 1887 | return -ENOEXEC; | ||
| 1888 | } | ||
| 1889 | |||
| 1890 | int __weak apply_relocate_add(Elf_Shdr *sechdrs, | ||
| 1891 | const char *strtab, | ||
| 1892 | unsigned int symindex, | ||
| 1893 | unsigned int relsec, | ||
| 1894 | struct module *me) | ||
| 1895 | { | ||
| 1896 | pr_err("module %s: RELA relocation unsupported\n", me->name); | ||
| 1897 | return -ENOEXEC; | ||
| 1898 | } | ||
| 1899 | |||
| 1854 | static int apply_relocations(struct module *mod, const struct load_info *info) | 1900 | static int apply_relocations(struct module *mod, const struct load_info *info) |
| 1855 | { | 1901 | { |
| 1856 | unsigned int i; | 1902 | unsigned int i; |
| @@ -2235,6 +2281,11 @@ static void dynamic_debug_remove(struct _ddebug *debug) | |||
| 2235 | ddebug_remove_module(debug->modname); | 2281 | ddebug_remove_module(debug->modname); |
| 2236 | } | 2282 | } |
| 2237 | 2283 | ||
| 2284 | void * __weak module_alloc(unsigned long size) | ||
| 2285 | { | ||
| 2286 | return size == 0 ? NULL : vmalloc_exec(size); | ||
| 2287 | } | ||
| 2288 | |||
| 2238 | static void *module_alloc_update_bounds(unsigned long size) | 2289 | static void *module_alloc_update_bounds(unsigned long size) |
| 2239 | { | 2290 | { |
| 2240 | void *ret = module_alloc(size); | 2291 | void *ret = module_alloc(size); |
| @@ -2645,6 +2696,14 @@ static void flush_module_icache(const struct module *mod) | |||
| 2645 | set_fs(old_fs); | 2696 | set_fs(old_fs); |
| 2646 | } | 2697 | } |
| 2647 | 2698 | ||
| 2699 | int __weak module_frob_arch_sections(Elf_Ehdr *hdr, | ||
| 2700 | Elf_Shdr *sechdrs, | ||
| 2701 | char *secstrings, | ||
| 2702 | struct module *mod) | ||
| 2703 | { | ||
| 2704 | return 0; | ||
| 2705 | } | ||
| 2706 | |||
| 2648 | static struct module *layout_and_allocate(struct load_info *info) | 2707 | static struct module *layout_and_allocate(struct load_info *info) |
| 2649 | { | 2708 | { |
| 2650 | /* Module within temporary copy. */ | 2709 | /* Module within temporary copy. */ |
| @@ -2716,6 +2775,13 @@ static void module_deallocate(struct module *mod, struct load_info *info) | |||
| 2716 | module_free(mod, mod->module_core); | 2775 | module_free(mod, mod->module_core); |
| 2717 | } | 2776 | } |
| 2718 | 2777 | ||
| 2778 | int __weak module_finalize(const Elf_Ehdr *hdr, | ||
| 2779 | const Elf_Shdr *sechdrs, | ||
| 2780 | struct module *me) | ||
| 2781 | { | ||
| 2782 | return 0; | ||
| 2783 | } | ||
| 2784 | |||
| 2719 | static int post_relocation(struct module *mod, const struct load_info *info) | 2785 | static int post_relocation(struct module *mod, const struct load_info *info) |
| 2720 | { | 2786 | { |
| 2721 | /* Sort exception table now relocations are done. */ | 2787 | /* Sort exception table now relocations are done. */ |
diff --git a/kernel/notifier.c b/kernel/notifier.c index 2488ba7eb568..8d7b435806c9 100644 --- a/kernel/notifier.c +++ b/kernel/notifier.c | |||
| @@ -525,37 +525,6 @@ void srcu_init_notifier_head(struct srcu_notifier_head *nh) | |||
| 525 | } | 525 | } |
| 526 | EXPORT_SYMBOL_GPL(srcu_init_notifier_head); | 526 | EXPORT_SYMBOL_GPL(srcu_init_notifier_head); |
| 527 | 527 | ||
| 528 | /** | ||
| 529 | * register_reboot_notifier - Register function to be called at reboot time | ||
| 530 | * @nb: Info about notifier function to be called | ||
| 531 | * | ||
| 532 | * Registers a function with the list of functions | ||
| 533 | * to be called at reboot time. | ||
| 534 | * | ||
| 535 | * Currently always returns zero, as blocking_notifier_chain_register() | ||
| 536 | * always returns zero. | ||
| 537 | */ | ||
| 538 | int register_reboot_notifier(struct notifier_block *nb) | ||
| 539 | { | ||
| 540 | return blocking_notifier_chain_register(&reboot_notifier_list, nb); | ||
| 541 | } | ||
| 542 | EXPORT_SYMBOL(register_reboot_notifier); | ||
| 543 | |||
| 544 | /** | ||
| 545 | * unregister_reboot_notifier - Unregister previously registered reboot notifier | ||
| 546 | * @nb: Hook to be unregistered | ||
| 547 | * | ||
| 548 | * Unregisters a previously registered reboot | ||
| 549 | * notifier function. | ||
| 550 | * | ||
| 551 | * Returns zero on success, or %-ENOENT on failure. | ||
| 552 | */ | ||
| 553 | int unregister_reboot_notifier(struct notifier_block *nb) | ||
| 554 | { | ||
| 555 | return blocking_notifier_chain_unregister(&reboot_notifier_list, nb); | ||
| 556 | } | ||
| 557 | EXPORT_SYMBOL(unregister_reboot_notifier); | ||
| 558 | |||
| 559 | static ATOMIC_NOTIFIER_HEAD(die_chain); | 528 | static ATOMIC_NOTIFIER_HEAD(die_chain); |
| 560 | 529 | ||
| 561 | int notrace __kprobes notify_die(enum die_val val, const char *str, | 530 | int notrace __kprobes notify_die(enum die_val val, const char *str, |
diff --git a/kernel/panic.c b/kernel/panic.c index 69231670eb95..d7bb6974efb5 100644 --- a/kernel/panic.c +++ b/kernel/panic.c | |||
| @@ -119,6 +119,8 @@ NORET_TYPE void panic(const char * fmt, ...) | |||
| 119 | } | 119 | } |
| 120 | mdelay(PANIC_TIMER_STEP); | 120 | mdelay(PANIC_TIMER_STEP); |
| 121 | } | 121 | } |
| 122 | } | ||
| 123 | if (panic_timeout != 0) { | ||
| 122 | /* | 124 | /* |
| 123 | * This will not be a clean reboot, with everything | 125 | * This will not be a clean reboot, with everything |
| 124 | * shutting down. But if there is a chance of | 126 | * shutting down. But if there is a chance of |
diff --git a/kernel/params.c b/kernel/params.c index ed72e1330862..22df3e0d142a 100644 --- a/kernel/params.c +++ b/kernel/params.c | |||
| @@ -225,8 +225,8 @@ int parse_args(const char *name, | |||
| 225 | int ret; \ | 225 | int ret; \ |
| 226 | \ | 226 | \ |
| 227 | ret = strtolfn(val, 0, &l); \ | 227 | ret = strtolfn(val, 0, &l); \ |
| 228 | if (ret == -EINVAL || ((type)l != l)) \ | 228 | if (ret < 0 || ((type)l != l)) \ |
| 229 | return -EINVAL; \ | 229 | return ret < 0 ? ret : -EINVAL; \ |
| 230 | *((type *)kp->arg) = l; \ | 230 | *((type *)kp->arg) = l; \ |
| 231 | return 0; \ | 231 | return 0; \ |
| 232 | } \ | 232 | } \ |
| @@ -511,7 +511,7 @@ struct module_param_attrs | |||
| 511 | #define to_param_attr(n) container_of(n, struct param_attribute, mattr) | 511 | #define to_param_attr(n) container_of(n, struct param_attribute, mattr) |
| 512 | 512 | ||
| 513 | static ssize_t param_attr_show(struct module_attribute *mattr, | 513 | static ssize_t param_attr_show(struct module_attribute *mattr, |
| 514 | struct module *mod, char *buf) | 514 | struct module_kobject *mk, char *buf) |
| 515 | { | 515 | { |
| 516 | int count; | 516 | int count; |
| 517 | struct param_attribute *attribute = to_param_attr(mattr); | 517 | struct param_attribute *attribute = to_param_attr(mattr); |
| @@ -531,7 +531,7 @@ static ssize_t param_attr_show(struct module_attribute *mattr, | |||
| 531 | 531 | ||
| 532 | /* sysfs always hands a nul-terminated string in buf. We rely on that. */ | 532 | /* sysfs always hands a nul-terminated string in buf. We rely on that. */ |
| 533 | static ssize_t param_attr_store(struct module_attribute *mattr, | 533 | static ssize_t param_attr_store(struct module_attribute *mattr, |
| 534 | struct module *owner, | 534 | struct module_kobject *km, |
| 535 | const char *buf, size_t len) | 535 | const char *buf, size_t len) |
| 536 | { | 536 | { |
| 537 | int err; | 537 | int err; |
| @@ -730,6 +730,10 @@ static struct module_kobject * __init locate_module_kobject(const char *name) | |||
| 730 | mk->kobj.kset = module_kset; | 730 | mk->kobj.kset = module_kset; |
| 731 | err = kobject_init_and_add(&mk->kobj, &module_ktype, NULL, | 731 | err = kobject_init_and_add(&mk->kobj, &module_ktype, NULL, |
| 732 | "%s", name); | 732 | "%s", name); |
| 733 | #ifdef CONFIG_MODULES | ||
| 734 | if (!err) | ||
| 735 | err = sysfs_create_file(&mk->kobj, &module_uevent.attr); | ||
| 736 | #endif | ||
| 733 | if (err) { | 737 | if (err) { |
| 734 | kobject_put(&mk->kobj); | 738 | kobject_put(&mk->kobj); |
| 735 | printk(KERN_ERR | 739 | printk(KERN_ERR |
| @@ -807,7 +811,7 @@ static void __init param_sysfs_builtin(void) | |||
| 807 | } | 811 | } |
| 808 | 812 | ||
| 809 | ssize_t __modver_version_show(struct module_attribute *mattr, | 813 | ssize_t __modver_version_show(struct module_attribute *mattr, |
| 810 | struct module *mod, char *buf) | 814 | struct module_kobject *mk, char *buf) |
| 811 | { | 815 | { |
| 812 | struct module_version_attribute *vattr = | 816 | struct module_version_attribute *vattr = |
| 813 | container_of(mattr, struct module_version_attribute, mattr); | 817 | container_of(mattr, struct module_version_attribute, mattr); |
| @@ -852,7 +856,7 @@ static ssize_t module_attr_show(struct kobject *kobj, | |||
| 852 | if (!attribute->show) | 856 | if (!attribute->show) |
| 853 | return -EIO; | 857 | return -EIO; |
| 854 | 858 | ||
| 855 | ret = attribute->show(attribute, mk->mod, buf); | 859 | ret = attribute->show(attribute, mk, buf); |
| 856 | 860 | ||
| 857 | return ret; | 861 | return ret; |
| 858 | } | 862 | } |
| @@ -871,7 +875,7 @@ static ssize_t module_attr_store(struct kobject *kobj, | |||
| 871 | if (!attribute->store) | 875 | if (!attribute->store) |
| 872 | return -EIO; | 876 | return -EIO; |
| 873 | 877 | ||
| 874 | ret = attribute->store(attribute, mk->mod, buf, len); | 878 | ret = attribute->store(attribute, mk, buf, len); |
| 875 | 879 | ||
| 876 | return ret; | 880 | return ret; |
| 877 | } | 881 | } |
diff --git a/kernel/pid.c b/kernel/pid.c index 57a8346a270e..e432057f3b21 100644 --- a/kernel/pid.c +++ b/kernel/pid.c | |||
| @@ -405,7 +405,6 @@ struct task_struct *pid_task(struct pid *pid, enum pid_type type) | |||
| 405 | if (pid) { | 405 | if (pid) { |
| 406 | struct hlist_node *first; | 406 | struct hlist_node *first; |
| 407 | first = rcu_dereference_check(hlist_first_rcu(&pid->tasks[type]), | 407 | first = rcu_dereference_check(hlist_first_rcu(&pid->tasks[type]), |
| 408 | rcu_read_lock_held() || | ||
| 409 | lockdep_tasklist_lock_is_held()); | 408 | lockdep_tasklist_lock_is_held()); |
| 410 | if (first) | 409 | if (first) |
| 411 | result = hlist_entry(first, struct task_struct, pids[(type)].node); | 410 | result = hlist_entry(first, struct task_struct, pids[(type)].node); |
diff --git a/kernel/posix-cpu-timers.c b/kernel/posix-cpu-timers.c index 58f405b581e7..c8008dd58ef2 100644 --- a/kernel/posix-cpu-timers.c +++ b/kernel/posix-cpu-timers.c | |||
| @@ -250,7 +250,7 @@ void thread_group_cputime(struct task_struct *tsk, struct task_cputime *times) | |||
| 250 | do { | 250 | do { |
| 251 | times->utime = cputime_add(times->utime, t->utime); | 251 | times->utime = cputime_add(times->utime, t->utime); |
| 252 | times->stime = cputime_add(times->stime, t->stime); | 252 | times->stime = cputime_add(times->stime, t->stime); |
| 253 | times->sum_exec_runtime += t->se.sum_exec_runtime; | 253 | times->sum_exec_runtime += task_sched_runtime(t); |
| 254 | } while_each_thread(tsk, t); | 254 | } while_each_thread(tsk, t); |
| 255 | out: | 255 | out: |
| 256 | rcu_read_unlock(); | 256 | rcu_read_unlock(); |
| @@ -312,7 +312,8 @@ static int cpu_clock_sample_group(const clockid_t which_clock, | |||
| 312 | cpu->cpu = cputime.utime; | 312 | cpu->cpu = cputime.utime; |
| 313 | break; | 313 | break; |
| 314 | case CPUCLOCK_SCHED: | 314 | case CPUCLOCK_SCHED: |
| 315 | cpu->sched = thread_group_sched_runtime(p); | 315 | thread_group_cputime(p, &cputime); |
| 316 | cpu->sched = cputime.sum_exec_runtime; | ||
| 316 | break; | 317 | break; |
| 317 | } | 318 | } |
| 318 | return 0; | 319 | return 0; |
diff --git a/kernel/power/Kconfig b/kernel/power/Kconfig index 7b856b3458d2..3744c594b19b 100644 --- a/kernel/power/Kconfig +++ b/kernel/power/Kconfig | |||
| @@ -193,8 +193,8 @@ config APM_EMULATION | |||
| 193 | notification of APM "events" (e.g. battery status change). | 193 | notification of APM "events" (e.g. battery status change). |
| 194 | 194 | ||
| 195 | In order to use APM, you will need supporting software. For location | 195 | In order to use APM, you will need supporting software. For location |
| 196 | and more information, read <file:Documentation/power/pm.txt> and the | 196 | and more information, read <file:Documentation/power/apm-acpi.txt> |
| 197 | Battery Powered Linux mini-HOWTO, available from | 197 | and the Battery Powered Linux mini-HOWTO, available from |
| 198 | <http://www.tldp.org/docs.html#howto>. | 198 | <http://www.tldp.org/docs.html#howto>. |
| 199 | 199 | ||
| 200 | This driver does not spin down disk drives (see the hdparm(8) | 200 | This driver does not spin down disk drives (see the hdparm(8) |
| @@ -231,3 +231,7 @@ config PM_CLK | |||
| 231 | config PM_GENERIC_DOMAINS | 231 | config PM_GENERIC_DOMAINS |
| 232 | bool | 232 | bool |
| 233 | depends on PM | 233 | depends on PM |
| 234 | |||
| 235 | config PM_GENERIC_DOMAINS_RUNTIME | ||
| 236 | def_bool y | ||
| 237 | depends on PM_RUNTIME && PM_GENERIC_DOMAINS | ||
diff --git a/kernel/printk.c b/kernel/printk.c index 37dff3429adb..28a40d8171b8 100644 --- a/kernel/printk.c +++ b/kernel/printk.c | |||
| @@ -318,8 +318,10 @@ static int check_syslog_permissions(int type, bool from_file) | |||
| 318 | return 0; | 318 | return 0; |
| 319 | /* For historical reasons, accept CAP_SYS_ADMIN too, with a warning */ | 319 | /* For historical reasons, accept CAP_SYS_ADMIN too, with a warning */ |
| 320 | if (capable(CAP_SYS_ADMIN)) { | 320 | if (capable(CAP_SYS_ADMIN)) { |
| 321 | WARN_ONCE(1, "Attempt to access syslog with CAP_SYS_ADMIN " | 321 | printk_once(KERN_WARNING "%s (%d): " |
| 322 | "but no CAP_SYSLOG (deprecated).\n"); | 322 | "Attempt to access syslog with CAP_SYS_ADMIN " |
| 323 | "but no CAP_SYSLOG (deprecated).\n", | ||
| 324 | current->comm, task_pid_nr(current)); | ||
| 323 | return 0; | 325 | return 0; |
| 324 | } | 326 | } |
| 325 | return -EPERM; | 327 | return -EPERM; |
| @@ -1602,7 +1604,7 @@ static int __init printk_late_init(void) | |||
| 1602 | struct console *con; | 1604 | struct console *con; |
| 1603 | 1605 | ||
| 1604 | for_each_console(con) { | 1606 | for_each_console(con) { |
| 1605 | if (con->flags & CON_BOOT) { | 1607 | if (!keep_bootcon && con->flags & CON_BOOT) { |
| 1606 | printk(KERN_INFO "turn off boot console %s%d\n", | 1608 | printk(KERN_INFO "turn off boot console %s%d\n", |
| 1607 | con->name, con->index); | 1609 | con->name, con->index); |
| 1608 | unregister_console(con); | 1610 | unregister_console(con); |
diff --git a/kernel/ptrace.c b/kernel/ptrace.c index 9de3ecfd20f9..a70d2a5d8c7b 100644 --- a/kernel/ptrace.c +++ b/kernel/ptrace.c | |||
| @@ -744,20 +744,17 @@ int ptrace_request(struct task_struct *child, long request, | |||
| 744 | break; | 744 | break; |
| 745 | 745 | ||
| 746 | si = child->last_siginfo; | 746 | si = child->last_siginfo; |
| 747 | if (unlikely(!si || si->si_code >> 8 != PTRACE_EVENT_STOP)) | 747 | if (likely(si && (si->si_code >> 8) == PTRACE_EVENT_STOP)) { |
| 748 | break; | 748 | child->jobctl |= JOBCTL_LISTENING; |
| 749 | 749 | /* | |
| 750 | child->jobctl |= JOBCTL_LISTENING; | 750 | * If NOTIFY is set, it means event happened between |
| 751 | 751 | * start of this trap and now. Trigger re-trap. | |
| 752 | /* | 752 | */ |
| 753 | * If NOTIFY is set, it means event happened between start | 753 | if (child->jobctl & JOBCTL_TRAP_NOTIFY) |
| 754 | * of this trap and now. Trigger re-trap immediately. | 754 | signal_wake_up(child, true); |
| 755 | */ | 755 | ret = 0; |
| 756 | if (child->jobctl & JOBCTL_TRAP_NOTIFY) | 756 | } |
| 757 | signal_wake_up(child, true); | ||
| 758 | |||
| 759 | unlock_task_sighand(child, &flags); | 757 | unlock_task_sighand(child, &flags); |
| 760 | ret = 0; | ||
| 761 | break; | 758 | break; |
| 762 | 759 | ||
| 763 | case PTRACE_DETACH: /* detach a process that was attached. */ | 760 | case PTRACE_DETACH: /* detach a process that was attached. */ |
diff --git a/kernel/rcupdate.c b/kernel/rcupdate.c index 7784bd216b6a..ddddb320be61 100644 --- a/kernel/rcupdate.c +++ b/kernel/rcupdate.c | |||
| @@ -37,7 +37,7 @@ | |||
| 37 | #include <linux/smp.h> | 37 | #include <linux/smp.h> |
| 38 | #include <linux/interrupt.h> | 38 | #include <linux/interrupt.h> |
| 39 | #include <linux/sched.h> | 39 | #include <linux/sched.h> |
| 40 | #include <asm/atomic.h> | 40 | #include <linux/atomic.h> |
| 41 | #include <linux/bitops.h> | 41 | #include <linux/bitops.h> |
| 42 | #include <linux/percpu.h> | 42 | #include <linux/percpu.h> |
| 43 | #include <linux/notifier.h> | 43 | #include <linux/notifier.h> |
diff --git a/kernel/rcutorture.c b/kernel/rcutorture.c index 2e138db03382..98f51b13bb7e 100644 --- a/kernel/rcutorture.c +++ b/kernel/rcutorture.c | |||
| @@ -33,7 +33,7 @@ | |||
| 33 | #include <linux/rcupdate.h> | 33 | #include <linux/rcupdate.h> |
| 34 | #include <linux/interrupt.h> | 34 | #include <linux/interrupt.h> |
| 35 | #include <linux/sched.h> | 35 | #include <linux/sched.h> |
| 36 | #include <asm/atomic.h> | 36 | #include <linux/atomic.h> |
| 37 | #include <linux/bitops.h> | 37 | #include <linux/bitops.h> |
| 38 | #include <linux/completion.h> | 38 | #include <linux/completion.h> |
| 39 | #include <linux/moduleparam.h> | 39 | #include <linux/moduleparam.h> |
| @@ -941,7 +941,6 @@ static void rcu_torture_timer(unsigned long unused) | |||
| 941 | idx = cur_ops->readlock(); | 941 | idx = cur_ops->readlock(); |
| 942 | completed = cur_ops->completed(); | 942 | completed = cur_ops->completed(); |
| 943 | p = rcu_dereference_check(rcu_torture_current, | 943 | p = rcu_dereference_check(rcu_torture_current, |
| 944 | rcu_read_lock_held() || | ||
| 945 | rcu_read_lock_bh_held() || | 944 | rcu_read_lock_bh_held() || |
| 946 | rcu_read_lock_sched_held() || | 945 | rcu_read_lock_sched_held() || |
| 947 | srcu_read_lock_held(&srcu_ctl)); | 946 | srcu_read_lock_held(&srcu_ctl)); |
| @@ -1002,7 +1001,6 @@ rcu_torture_reader(void *arg) | |||
| 1002 | idx = cur_ops->readlock(); | 1001 | idx = cur_ops->readlock(); |
| 1003 | completed = cur_ops->completed(); | 1002 | completed = cur_ops->completed(); |
| 1004 | p = rcu_dereference_check(rcu_torture_current, | 1003 | p = rcu_dereference_check(rcu_torture_current, |
| 1005 | rcu_read_lock_held() || | ||
| 1006 | rcu_read_lock_bh_held() || | 1004 | rcu_read_lock_bh_held() || |
| 1007 | rcu_read_lock_sched_held() || | 1005 | rcu_read_lock_sched_held() || |
| 1008 | srcu_read_lock_held(&srcu_ctl)); | 1006 | srcu_read_lock_held(&srcu_ctl)); |
diff --git a/kernel/rcutree_trace.c b/kernel/rcutree_trace.c index 4e144876dc68..3b0c0986afc0 100644 --- a/kernel/rcutree_trace.c +++ b/kernel/rcutree_trace.c | |||
| @@ -31,7 +31,7 @@ | |||
| 31 | #include <linux/rcupdate.h> | 31 | #include <linux/rcupdate.h> |
| 32 | #include <linux/interrupt.h> | 32 | #include <linux/interrupt.h> |
| 33 | #include <linux/sched.h> | 33 | #include <linux/sched.h> |
| 34 | #include <asm/atomic.h> | 34 | #include <linux/atomic.h> |
| 35 | #include <linux/bitops.h> | 35 | #include <linux/bitops.h> |
| 36 | #include <linux/module.h> | 36 | #include <linux/module.h> |
| 37 | #include <linux/completion.h> | 37 | #include <linux/completion.h> |
diff --git a/kernel/resource.c b/kernel/resource.c index 3ff40178dce7..c8dc249da5ce 100644 --- a/kernel/resource.c +++ b/kernel/resource.c | |||
| @@ -419,6 +419,9 @@ static int __find_resource(struct resource *root, struct resource *old, | |||
| 419 | else | 419 | else |
| 420 | tmp.end = root->end; | 420 | tmp.end = root->end; |
| 421 | 421 | ||
| 422 | if (tmp.end < tmp.start) | ||
| 423 | goto next; | ||
| 424 | |||
| 422 | resource_clip(&tmp, constraint->min, constraint->max); | 425 | resource_clip(&tmp, constraint->min, constraint->max); |
| 423 | arch_remove_reservations(&tmp); | 426 | arch_remove_reservations(&tmp); |
| 424 | 427 | ||
| @@ -436,8 +439,10 @@ static int __find_resource(struct resource *root, struct resource *old, | |||
| 436 | return 0; | 439 | return 0; |
| 437 | } | 440 | } |
| 438 | } | 441 | } |
| 439 | if (!this) | 442 | |
| 443 | next: if (!this || this->end == root->end) | ||
| 440 | break; | 444 | break; |
| 445 | |||
| 441 | if (this != old) | 446 | if (this != old) |
| 442 | tmp.start = this->end + 1; | 447 | tmp.start = this->end + 1; |
| 443 | this = this->sibling; | 448 | this = this->sibling; |
| @@ -553,6 +558,27 @@ int allocate_resource(struct resource *root, struct resource *new, | |||
| 553 | 558 | ||
| 554 | EXPORT_SYMBOL(allocate_resource); | 559 | EXPORT_SYMBOL(allocate_resource); |
| 555 | 560 | ||
| 561 | /** | ||
| 562 | * lookup_resource - find an existing resource by a resource start address | ||
| 563 | * @root: root resource descriptor | ||
| 564 | * @start: resource start address | ||
| 565 | * | ||
| 566 | * Returns a pointer to the resource if found, NULL otherwise | ||
| 567 | */ | ||
| 568 | struct resource *lookup_resource(struct resource *root, resource_size_t start) | ||
| 569 | { | ||
| 570 | struct resource *res; | ||
| 571 | |||
| 572 | read_lock(&resource_lock); | ||
| 573 | for (res = root->child; res; res = res->sibling) { | ||
| 574 | if (res->start == start) | ||
| 575 | break; | ||
| 576 | } | ||
| 577 | read_unlock(&resource_lock); | ||
| 578 | |||
| 579 | return res; | ||
| 580 | } | ||
| 581 | |||
| 556 | /* | 582 | /* |
| 557 | * Insert a resource into the resource tree. If successful, return NULL, | 583 | * Insert a resource into the resource tree. If successful, return NULL, |
| 558 | * otherwise return the conflicting resource (compare to __request_resource()) | 584 | * otherwise return the conflicting resource (compare to __request_resource()) |
diff --git a/kernel/rwsem.c b/kernel/rwsem.c index 176e5e56ffab..9f48f3d82e9b 100644 --- a/kernel/rwsem.c +++ b/kernel/rwsem.c | |||
| @@ -11,7 +11,7 @@ | |||
| 11 | #include <linux/rwsem.h> | 11 | #include <linux/rwsem.h> |
| 12 | 12 | ||
| 13 | #include <asm/system.h> | 13 | #include <asm/system.h> |
| 14 | #include <asm/atomic.h> | 14 | #include <linux/atomic.h> |
| 15 | 15 | ||
| 16 | /* | 16 | /* |
| 17 | * lock for reading | 17 | * lock for reading |
diff --git a/kernel/sched.c b/kernel/sched.c index 9aaf567c5da5..b50b0f0c9aa9 100644 --- a/kernel/sched.c +++ b/kernel/sched.c | |||
| @@ -75,6 +75,9 @@ | |||
| 75 | #include <asm/tlb.h> | 75 | #include <asm/tlb.h> |
| 76 | #include <asm/irq_regs.h> | 76 | #include <asm/irq_regs.h> |
| 77 | #include <asm/mutex.h> | 77 | #include <asm/mutex.h> |
| 78 | #ifdef CONFIG_PARAVIRT | ||
| 79 | #include <asm/paravirt.h> | ||
| 80 | #endif | ||
| 78 | 81 | ||
| 79 | #include "sched_cpupri.h" | 82 | #include "sched_cpupri.h" |
| 80 | #include "workqueue_sched.h" | 83 | #include "workqueue_sched.h" |
| @@ -528,6 +531,12 @@ struct rq { | |||
| 528 | #ifdef CONFIG_IRQ_TIME_ACCOUNTING | 531 | #ifdef CONFIG_IRQ_TIME_ACCOUNTING |
| 529 | u64 prev_irq_time; | 532 | u64 prev_irq_time; |
| 530 | #endif | 533 | #endif |
| 534 | #ifdef CONFIG_PARAVIRT | ||
| 535 | u64 prev_steal_time; | ||
| 536 | #endif | ||
| 537 | #ifdef CONFIG_PARAVIRT_TIME_ACCOUNTING | ||
| 538 | u64 prev_steal_time_rq; | ||
| 539 | #endif | ||
| 531 | 540 | ||
| 532 | /* calc_load related fields */ | 541 | /* calc_load related fields */ |
| 533 | unsigned long calc_load_update; | 542 | unsigned long calc_load_update; |
| @@ -581,7 +590,6 @@ static inline int cpu_of(struct rq *rq) | |||
| 581 | 590 | ||
| 582 | #define rcu_dereference_check_sched_domain(p) \ | 591 | #define rcu_dereference_check_sched_domain(p) \ |
| 583 | rcu_dereference_check((p), \ | 592 | rcu_dereference_check((p), \ |
| 584 | rcu_read_lock_held() || \ | ||
| 585 | lockdep_is_held(&sched_domains_mutex)) | 593 | lockdep_is_held(&sched_domains_mutex)) |
| 586 | 594 | ||
| 587 | /* | 595 | /* |
| @@ -1921,10 +1929,28 @@ void account_system_vtime(struct task_struct *curr) | |||
| 1921 | } | 1929 | } |
| 1922 | EXPORT_SYMBOL_GPL(account_system_vtime); | 1930 | EXPORT_SYMBOL_GPL(account_system_vtime); |
| 1923 | 1931 | ||
| 1924 | static void update_rq_clock_task(struct rq *rq, s64 delta) | 1932 | #endif /* CONFIG_IRQ_TIME_ACCOUNTING */ |
| 1933 | |||
| 1934 | #ifdef CONFIG_PARAVIRT | ||
| 1935 | static inline u64 steal_ticks(u64 steal) | ||
| 1925 | { | 1936 | { |
| 1926 | s64 irq_delta; | 1937 | if (unlikely(steal > NSEC_PER_SEC)) |
| 1938 | return div_u64(steal, TICK_NSEC); | ||
| 1927 | 1939 | ||
| 1940 | return __iter_div_u64_rem(steal, TICK_NSEC, &steal); | ||
| 1941 | } | ||
| 1942 | #endif | ||
| 1943 | |||
| 1944 | static void update_rq_clock_task(struct rq *rq, s64 delta) | ||
| 1945 | { | ||
| 1946 | /* | ||
| 1947 | * In theory, the compile should just see 0 here, and optimize out the call | ||
| 1948 | * to sched_rt_avg_update. But I don't trust it... | ||
| 1949 | */ | ||
| 1950 | #if defined(CONFIG_IRQ_TIME_ACCOUNTING) || defined(CONFIG_PARAVIRT_TIME_ACCOUNTING) | ||
| 1951 | s64 steal = 0, irq_delta = 0; | ||
| 1952 | #endif | ||
| 1953 | #ifdef CONFIG_IRQ_TIME_ACCOUNTING | ||
| 1928 | irq_delta = irq_time_read(cpu_of(rq)) - rq->prev_irq_time; | 1954 | irq_delta = irq_time_read(cpu_of(rq)) - rq->prev_irq_time; |
| 1929 | 1955 | ||
| 1930 | /* | 1956 | /* |
| @@ -1947,12 +1973,35 @@ static void update_rq_clock_task(struct rq *rq, s64 delta) | |||
| 1947 | 1973 | ||
| 1948 | rq->prev_irq_time += irq_delta; | 1974 | rq->prev_irq_time += irq_delta; |
| 1949 | delta -= irq_delta; | 1975 | delta -= irq_delta; |
| 1976 | #endif | ||
| 1977 | #ifdef CONFIG_PARAVIRT_TIME_ACCOUNTING | ||
| 1978 | if (static_branch((¶virt_steal_rq_enabled))) { | ||
| 1979 | u64 st; | ||
| 1980 | |||
| 1981 | steal = paravirt_steal_clock(cpu_of(rq)); | ||
| 1982 | steal -= rq->prev_steal_time_rq; | ||
| 1983 | |||
| 1984 | if (unlikely(steal > delta)) | ||
| 1985 | steal = delta; | ||
| 1986 | |||
| 1987 | st = steal_ticks(steal); | ||
| 1988 | steal = st * TICK_NSEC; | ||
| 1989 | |||
| 1990 | rq->prev_steal_time_rq += steal; | ||
| 1991 | |||
| 1992 | delta -= steal; | ||
| 1993 | } | ||
| 1994 | #endif | ||
| 1995 | |||
| 1950 | rq->clock_task += delta; | 1996 | rq->clock_task += delta; |
| 1951 | 1997 | ||
| 1952 | if (irq_delta && sched_feat(NONIRQ_POWER)) | 1998 | #if defined(CONFIG_IRQ_TIME_ACCOUNTING) || defined(CONFIG_PARAVIRT_TIME_ACCOUNTING) |
| 1953 | sched_rt_avg_update(rq, irq_delta); | 1999 | if ((irq_delta + steal) && sched_feat(NONTASK_POWER)) |
| 2000 | sched_rt_avg_update(rq, irq_delta + steal); | ||
| 2001 | #endif | ||
| 1954 | } | 2002 | } |
| 1955 | 2003 | ||
| 2004 | #ifdef CONFIG_IRQ_TIME_ACCOUNTING | ||
| 1956 | static int irqtime_account_hi_update(void) | 2005 | static int irqtime_account_hi_update(void) |
| 1957 | { | 2006 | { |
| 1958 | struct cpu_usage_stat *cpustat = &kstat_this_cpu.cpustat; | 2007 | struct cpu_usage_stat *cpustat = &kstat_this_cpu.cpustat; |
| @@ -1987,12 +2036,7 @@ static int irqtime_account_si_update(void) | |||
| 1987 | 2036 | ||
| 1988 | #define sched_clock_irqtime (0) | 2037 | #define sched_clock_irqtime (0) |
| 1989 | 2038 | ||
| 1990 | static void update_rq_clock_task(struct rq *rq, s64 delta) | 2039 | #endif |
| 1991 | { | ||
| 1992 | rq->clock_task += delta; | ||
| 1993 | } | ||
| 1994 | |||
| 1995 | #endif /* CONFIG_IRQ_TIME_ACCOUNTING */ | ||
| 1996 | 2040 | ||
| 1997 | #include "sched_idletask.c" | 2041 | #include "sched_idletask.c" |
| 1998 | #include "sched_fair.c" | 2042 | #include "sched_fair.c" |
| @@ -3021,7 +3065,7 @@ static void finish_task_switch(struct rq *rq, struct task_struct *prev) | |||
| 3021 | #ifdef __ARCH_WANT_INTERRUPTS_ON_CTXSW | 3065 | #ifdef __ARCH_WANT_INTERRUPTS_ON_CTXSW |
| 3022 | local_irq_disable(); | 3066 | local_irq_disable(); |
| 3023 | #endif /* __ARCH_WANT_INTERRUPTS_ON_CTXSW */ | 3067 | #endif /* __ARCH_WANT_INTERRUPTS_ON_CTXSW */ |
| 3024 | perf_event_task_sched_in(current); | 3068 | perf_event_task_sched_in(prev, current); |
| 3025 | #ifdef __ARCH_WANT_INTERRUPTS_ON_CTXSW | 3069 | #ifdef __ARCH_WANT_INTERRUPTS_ON_CTXSW |
| 3026 | local_irq_enable(); | 3070 | local_irq_enable(); |
| 3027 | #endif /* __ARCH_WANT_INTERRUPTS_ON_CTXSW */ | 3071 | #endif /* __ARCH_WANT_INTERRUPTS_ON_CTXSW */ |
| @@ -3681,30 +3725,6 @@ unsigned long long task_sched_runtime(struct task_struct *p) | |||
| 3681 | } | 3725 | } |
| 3682 | 3726 | ||
| 3683 | /* | 3727 | /* |
| 3684 | * Return sum_exec_runtime for the thread group. | ||
| 3685 | * In case the task is currently running, return the sum plus current's | ||
| 3686 | * pending runtime that have not been accounted yet. | ||
| 3687 | * | ||
| 3688 | * Note that the thread group might have other running tasks as well, | ||
| 3689 | * so the return value not includes other pending runtime that other | ||
| 3690 | * running tasks might have. | ||
| 3691 | */ | ||
| 3692 | unsigned long long thread_group_sched_runtime(struct task_struct *p) | ||
| 3693 | { | ||
| 3694 | struct task_cputime totals; | ||
| 3695 | unsigned long flags; | ||
| 3696 | struct rq *rq; | ||
| 3697 | u64 ns; | ||
| 3698 | |||
| 3699 | rq = task_rq_lock(p, &flags); | ||
| 3700 | thread_group_cputime(p, &totals); | ||
| 3701 | ns = totals.sum_exec_runtime + do_task_delta_exec(p, rq); | ||
| 3702 | task_rq_unlock(rq, p, &flags); | ||
| 3703 | |||
| 3704 | return ns; | ||
| 3705 | } | ||
| 3706 | |||
| 3707 | /* | ||
| 3708 | * Account user cpu time to a process. | 3728 | * Account user cpu time to a process. |
| 3709 | * @p: the process that the cpu time gets accounted to | 3729 | * @p: the process that the cpu time gets accounted to |
| 3710 | * @cputime: the cpu time spent in user space since the last update | 3730 | * @cputime: the cpu time spent in user space since the last update |
| @@ -3845,6 +3865,25 @@ void account_idle_time(cputime_t cputime) | |||
| 3845 | cpustat->idle = cputime64_add(cpustat->idle, cputime64); | 3865 | cpustat->idle = cputime64_add(cpustat->idle, cputime64); |
| 3846 | } | 3866 | } |
| 3847 | 3867 | ||
| 3868 | static __always_inline bool steal_account_process_tick(void) | ||
| 3869 | { | ||
| 3870 | #ifdef CONFIG_PARAVIRT | ||
| 3871 | if (static_branch(¶virt_steal_enabled)) { | ||
| 3872 | u64 steal, st = 0; | ||
| 3873 | |||
| 3874 | steal = paravirt_steal_clock(smp_processor_id()); | ||
| 3875 | steal -= this_rq()->prev_steal_time; | ||
| 3876 | |||
| 3877 | st = steal_ticks(steal); | ||
| 3878 | this_rq()->prev_steal_time += st * TICK_NSEC; | ||
| 3879 | |||
| 3880 | account_steal_time(st); | ||
| 3881 | return st; | ||
| 3882 | } | ||
| 3883 | #endif | ||
| 3884 | return false; | ||
| 3885 | } | ||
| 3886 | |||
| 3848 | #ifndef CONFIG_VIRT_CPU_ACCOUNTING | 3887 | #ifndef CONFIG_VIRT_CPU_ACCOUNTING |
| 3849 | 3888 | ||
| 3850 | #ifdef CONFIG_IRQ_TIME_ACCOUNTING | 3889 | #ifdef CONFIG_IRQ_TIME_ACCOUNTING |
| @@ -3876,6 +3915,9 @@ static void irqtime_account_process_tick(struct task_struct *p, int user_tick, | |||
| 3876 | cputime64_t tmp = cputime_to_cputime64(cputime_one_jiffy); | 3915 | cputime64_t tmp = cputime_to_cputime64(cputime_one_jiffy); |
| 3877 | struct cpu_usage_stat *cpustat = &kstat_this_cpu.cpustat; | 3916 | struct cpu_usage_stat *cpustat = &kstat_this_cpu.cpustat; |
| 3878 | 3917 | ||
| 3918 | if (steal_account_process_tick()) | ||
| 3919 | return; | ||
| 3920 | |||
| 3879 | if (irqtime_account_hi_update()) { | 3921 | if (irqtime_account_hi_update()) { |
| 3880 | cpustat->irq = cputime64_add(cpustat->irq, tmp); | 3922 | cpustat->irq = cputime64_add(cpustat->irq, tmp); |
| 3881 | } else if (irqtime_account_si_update()) { | 3923 | } else if (irqtime_account_si_update()) { |
| @@ -3929,6 +3971,9 @@ void account_process_tick(struct task_struct *p, int user_tick) | |||
| 3929 | return; | 3971 | return; |
| 3930 | } | 3972 | } |
| 3931 | 3973 | ||
| 3974 | if (steal_account_process_tick()) | ||
| 3975 | return; | ||
| 3976 | |||
| 3932 | if (user_tick) | 3977 | if (user_tick) |
| 3933 | account_user_time(p, cputime_one_jiffy, one_jiffy_scaled); | 3978 | account_user_time(p, cputime_one_jiffy, one_jiffy_scaled); |
| 3934 | else if ((p != rq->idle) || (irq_count() != HARDIRQ_OFFSET)) | 3979 | else if ((p != rq->idle) || (irq_count() != HARDIRQ_OFFSET)) |
| @@ -4210,9 +4255,9 @@ pick_next_task(struct rq *rq) | |||
| 4210 | } | 4255 | } |
| 4211 | 4256 | ||
| 4212 | /* | 4257 | /* |
| 4213 | * schedule() is the main scheduler function. | 4258 | * __schedule() is the main scheduler function. |
| 4214 | */ | 4259 | */ |
| 4215 | asmlinkage void __sched schedule(void) | 4260 | static void __sched __schedule(void) |
| 4216 | { | 4261 | { |
| 4217 | struct task_struct *prev, *next; | 4262 | struct task_struct *prev, *next; |
| 4218 | unsigned long *switch_count; | 4263 | unsigned long *switch_count; |
| @@ -4253,16 +4298,6 @@ need_resched: | |||
| 4253 | if (to_wakeup) | 4298 | if (to_wakeup) |
| 4254 | try_to_wake_up_local(to_wakeup); | 4299 | try_to_wake_up_local(to_wakeup); |
| 4255 | } | 4300 | } |
| 4256 | |||
| 4257 | /* | ||
| 4258 | * If we are going to sleep and we have plugged IO | ||
| 4259 | * queued, make sure to submit it to avoid deadlocks. | ||
| 4260 | */ | ||
| 4261 | if (blk_needs_flush_plug(prev)) { | ||
| 4262 | raw_spin_unlock(&rq->lock); | ||
| 4263 | blk_schedule_flush_plug(prev); | ||
| 4264 | raw_spin_lock(&rq->lock); | ||
| 4265 | } | ||
| 4266 | } | 4301 | } |
| 4267 | switch_count = &prev->nvcsw; | 4302 | switch_count = &prev->nvcsw; |
| 4268 | } | 4303 | } |
| @@ -4300,6 +4335,26 @@ need_resched: | |||
| 4300 | if (need_resched()) | 4335 | if (need_resched()) |
| 4301 | goto need_resched; | 4336 | goto need_resched; |
| 4302 | } | 4337 | } |
| 4338 | |||
| 4339 | static inline void sched_submit_work(struct task_struct *tsk) | ||
| 4340 | { | ||
| 4341 | if (!tsk->state) | ||
| 4342 | return; | ||
| 4343 | /* | ||
| 4344 | * If we are going to sleep and we have plugged IO queued, | ||
| 4345 | * make sure to submit it to avoid deadlocks. | ||
| 4346 | */ | ||
| 4347 | if (blk_needs_flush_plug(tsk)) | ||
| 4348 | blk_schedule_flush_plug(tsk); | ||
| 4349 | } | ||
| 4350 | |||
| 4351 | asmlinkage void __sched schedule(void) | ||
| 4352 | { | ||
| 4353 | struct task_struct *tsk = current; | ||
| 4354 | |||
| 4355 | sched_submit_work(tsk); | ||
| 4356 | __schedule(); | ||
| 4357 | } | ||
| 4303 | EXPORT_SYMBOL(schedule); | 4358 | EXPORT_SYMBOL(schedule); |
| 4304 | 4359 | ||
| 4305 | #ifdef CONFIG_MUTEX_SPIN_ON_OWNER | 4360 | #ifdef CONFIG_MUTEX_SPIN_ON_OWNER |
| @@ -4366,7 +4421,7 @@ asmlinkage void __sched notrace preempt_schedule(void) | |||
| 4366 | 4421 | ||
| 4367 | do { | 4422 | do { |
| 4368 | add_preempt_count_notrace(PREEMPT_ACTIVE); | 4423 | add_preempt_count_notrace(PREEMPT_ACTIVE); |
| 4369 | schedule(); | 4424 | __schedule(); |
| 4370 | sub_preempt_count_notrace(PREEMPT_ACTIVE); | 4425 | sub_preempt_count_notrace(PREEMPT_ACTIVE); |
| 4371 | 4426 | ||
| 4372 | /* | 4427 | /* |
| @@ -4394,7 +4449,7 @@ asmlinkage void __sched preempt_schedule_irq(void) | |||
| 4394 | do { | 4449 | do { |
| 4395 | add_preempt_count(PREEMPT_ACTIVE); | 4450 | add_preempt_count(PREEMPT_ACTIVE); |
| 4396 | local_irq_enable(); | 4451 | local_irq_enable(); |
| 4397 | schedule(); | 4452 | __schedule(); |
| 4398 | local_irq_disable(); | 4453 | local_irq_disable(); |
| 4399 | sub_preempt_count(PREEMPT_ACTIVE); | 4454 | sub_preempt_count(PREEMPT_ACTIVE); |
| 4400 | 4455 | ||
| @@ -5519,7 +5574,7 @@ static inline int should_resched(void) | |||
| 5519 | static void __cond_resched(void) | 5574 | static void __cond_resched(void) |
| 5520 | { | 5575 | { |
| 5521 | add_preempt_count(PREEMPT_ACTIVE); | 5576 | add_preempt_count(PREEMPT_ACTIVE); |
| 5522 | schedule(); | 5577 | __schedule(); |
| 5523 | sub_preempt_count(PREEMPT_ACTIVE); | 5578 | sub_preempt_count(PREEMPT_ACTIVE); |
| 5524 | } | 5579 | } |
| 5525 | 5580 | ||
| @@ -7374,6 +7429,7 @@ static void __sdt_free(const struct cpumask *cpu_map) | |||
| 7374 | struct sched_domain *sd = *per_cpu_ptr(sdd->sd, j); | 7429 | struct sched_domain *sd = *per_cpu_ptr(sdd->sd, j); |
| 7375 | if (sd && (sd->flags & SD_OVERLAP)) | 7430 | if (sd && (sd->flags & SD_OVERLAP)) |
| 7376 | free_sched_groups(sd->groups, 0); | 7431 | free_sched_groups(sd->groups, 0); |
| 7432 | kfree(*per_cpu_ptr(sdd->sd, j)); | ||
| 7377 | kfree(*per_cpu_ptr(sdd->sg, j)); | 7433 | kfree(*per_cpu_ptr(sdd->sg, j)); |
| 7378 | kfree(*per_cpu_ptr(sdd->sgp, j)); | 7434 | kfree(*per_cpu_ptr(sdd->sgp, j)); |
| 7379 | } | 7435 | } |
diff --git a/kernel/sched_features.h b/kernel/sched_features.h index 1e7066d76c26..2e74677cb040 100644 --- a/kernel/sched_features.h +++ b/kernel/sched_features.h | |||
| @@ -61,9 +61,9 @@ SCHED_FEAT(LB_BIAS, 1) | |||
| 61 | SCHED_FEAT(OWNER_SPIN, 1) | 61 | SCHED_FEAT(OWNER_SPIN, 1) |
| 62 | 62 | ||
| 63 | /* | 63 | /* |
| 64 | * Decrement CPU power based on irq activity | 64 | * Decrement CPU power based on time not spent running tasks |
| 65 | */ | 65 | */ |
| 66 | SCHED_FEAT(NONIRQ_POWER, 1) | 66 | SCHED_FEAT(NONTASK_POWER, 1) |
| 67 | 67 | ||
| 68 | /* | 68 | /* |
| 69 | * Queue remote wakeups on the target CPU and process them | 69 | * Queue remote wakeups on the target CPU and process them |
diff --git a/kernel/sched_rt.c b/kernel/sched_rt.c index 97540f0c9e47..af1177858be3 100644 --- a/kernel/sched_rt.c +++ b/kernel/sched_rt.c | |||
| @@ -1050,7 +1050,7 @@ select_task_rq_rt(struct task_struct *p, int sd_flag, int flags) | |||
| 1050 | */ | 1050 | */ |
| 1051 | if (curr && unlikely(rt_task(curr)) && | 1051 | if (curr && unlikely(rt_task(curr)) && |
| 1052 | (curr->rt.nr_cpus_allowed < 2 || | 1052 | (curr->rt.nr_cpus_allowed < 2 || |
| 1053 | curr->prio < p->prio) && | 1053 | curr->prio <= p->prio) && |
| 1054 | (p->rt.nr_cpus_allowed > 1)) { | 1054 | (p->rt.nr_cpus_allowed > 1)) { |
| 1055 | int target = find_lowest_rq(p); | 1055 | int target = find_lowest_rq(p); |
| 1056 | 1056 | ||
| @@ -1581,7 +1581,7 @@ static void task_woken_rt(struct rq *rq, struct task_struct *p) | |||
| 1581 | p->rt.nr_cpus_allowed > 1 && | 1581 | p->rt.nr_cpus_allowed > 1 && |
| 1582 | rt_task(rq->curr) && | 1582 | rt_task(rq->curr) && |
| 1583 | (rq->curr->rt.nr_cpus_allowed < 2 || | 1583 | (rq->curr->rt.nr_cpus_allowed < 2 || |
| 1584 | rq->curr->prio < p->prio)) | 1584 | rq->curr->prio <= p->prio)) |
| 1585 | push_rt_tasks(rq); | 1585 | push_rt_tasks(rq); |
| 1586 | } | 1586 | } |
| 1587 | 1587 | ||
diff --git a/kernel/signal.c b/kernel/signal.c index d7f70aed1cc0..291c9700be75 100644 --- a/kernel/signal.c +++ b/kernel/signal.c | |||
| @@ -3102,15 +3102,11 @@ SYSCALL_DEFINE0(sgetmask) | |||
| 3102 | 3102 | ||
| 3103 | SYSCALL_DEFINE1(ssetmask, int, newmask) | 3103 | SYSCALL_DEFINE1(ssetmask, int, newmask) |
| 3104 | { | 3104 | { |
| 3105 | int old; | 3105 | int old = current->blocked.sig[0]; |
| 3106 | 3106 | sigset_t newset; | |
| 3107 | spin_lock_irq(¤t->sighand->siglock); | ||
| 3108 | old = current->blocked.sig[0]; | ||
| 3109 | 3107 | ||
| 3110 | siginitset(¤t->blocked, newmask & ~(sigmask(SIGKILL)| | 3108 | siginitset(&newset, newmask & ~(sigmask(SIGKILL) | sigmask(SIGSTOP))); |
| 3111 | sigmask(SIGSTOP))); | 3109 | set_current_blocked(&newset); |
| 3112 | recalc_sigpending(); | ||
| 3113 | spin_unlock_irq(¤t->sighand->siglock); | ||
| 3114 | 3110 | ||
| 3115 | return old; | 3111 | return old; |
| 3116 | } | 3112 | } |
| @@ -3167,11 +3163,8 @@ SYSCALL_DEFINE2(rt_sigsuspend, sigset_t __user *, unewset, size_t, sigsetsize) | |||
| 3167 | return -EFAULT; | 3163 | return -EFAULT; |
| 3168 | sigdelsetmask(&newset, sigmask(SIGKILL)|sigmask(SIGSTOP)); | 3164 | sigdelsetmask(&newset, sigmask(SIGKILL)|sigmask(SIGSTOP)); |
| 3169 | 3165 | ||
| 3170 | spin_lock_irq(¤t->sighand->siglock); | ||
| 3171 | current->saved_sigmask = current->blocked; | 3166 | current->saved_sigmask = current->blocked; |
| 3172 | current->blocked = newset; | 3167 | set_current_blocked(&newset); |
| 3173 | recalc_sigpending(); | ||
| 3174 | spin_unlock_irq(¤t->sighand->siglock); | ||
| 3175 | 3168 | ||
| 3176 | current->state = TASK_INTERRUPTIBLE; | 3169 | current->state = TASK_INTERRUPTIBLE; |
| 3177 | schedule(); | 3170 | schedule(); |
diff --git a/kernel/stop_machine.c b/kernel/stop_machine.c index c1124752e1d3..ba5070ce5765 100644 --- a/kernel/stop_machine.c +++ b/kernel/stop_machine.c | |||
| @@ -19,7 +19,7 @@ | |||
| 19 | #include <linux/interrupt.h> | 19 | #include <linux/interrupt.h> |
| 20 | #include <linux/kallsyms.h> | 20 | #include <linux/kallsyms.h> |
| 21 | 21 | ||
| 22 | #include <asm/atomic.h> | 22 | #include <linux/atomic.h> |
| 23 | 23 | ||
| 24 | /* | 24 | /* |
| 25 | * Structure to determine completion condition and record errors. May | 25 | * Structure to determine completion condition and record errors. May |
diff --git a/kernel/sys.c b/kernel/sys.c index e4128b278f23..18ee1d2f6474 100644 --- a/kernel/sys.c +++ b/kernel/sys.c | |||
| @@ -8,7 +8,6 @@ | |||
| 8 | #include <linux/mm.h> | 8 | #include <linux/mm.h> |
| 9 | #include <linux/utsname.h> | 9 | #include <linux/utsname.h> |
| 10 | #include <linux/mman.h> | 10 | #include <linux/mman.h> |
| 11 | #include <linux/notifier.h> | ||
| 12 | #include <linux/reboot.h> | 11 | #include <linux/reboot.h> |
| 13 | #include <linux/prctl.h> | 12 | #include <linux/prctl.h> |
| 14 | #include <linux/highuid.h> | 13 | #include <linux/highuid.h> |
| @@ -38,6 +37,8 @@ | |||
| 38 | #include <linux/fs_struct.h> | 37 | #include <linux/fs_struct.h> |
| 39 | #include <linux/gfp.h> | 38 | #include <linux/gfp.h> |
| 40 | #include <linux/syscore_ops.h> | 39 | #include <linux/syscore_ops.h> |
| 40 | #include <linux/version.h> | ||
| 41 | #include <linux/ctype.h> | ||
| 41 | 42 | ||
| 42 | #include <linux/compat.h> | 43 | #include <linux/compat.h> |
| 43 | #include <linux/syscalls.h> | 44 | #include <linux/syscalls.h> |
| @@ -45,6 +46,8 @@ | |||
| 45 | #include <linux/user_namespace.h> | 46 | #include <linux/user_namespace.h> |
| 46 | 47 | ||
| 47 | #include <linux/kmsg_dump.h> | 48 | #include <linux/kmsg_dump.h> |
| 49 | /* Move somewhere else to avoid recompiling? */ | ||
| 50 | #include <generated/utsrelease.h> | ||
| 48 | 51 | ||
| 49 | #include <asm/uaccess.h> | 52 | #include <asm/uaccess.h> |
| 50 | #include <asm/io.h> | 53 | #include <asm/io.h> |
| @@ -320,6 +323,37 @@ void kernel_restart_prepare(char *cmd) | |||
| 320 | } | 323 | } |
| 321 | 324 | ||
| 322 | /** | 325 | /** |
| 326 | * register_reboot_notifier - Register function to be called at reboot time | ||
| 327 | * @nb: Info about notifier function to be called | ||
| 328 | * | ||
| 329 | * Registers a function with the list of functions | ||
| 330 | * to be called at reboot time. | ||
| 331 | * | ||
| 332 | * Currently always returns zero, as blocking_notifier_chain_register() | ||
| 333 | * always returns zero. | ||
| 334 | */ | ||
| 335 | int register_reboot_notifier(struct notifier_block *nb) | ||
| 336 | { | ||
| 337 | return blocking_notifier_chain_register(&reboot_notifier_list, nb); | ||
| 338 | } | ||
| 339 | EXPORT_SYMBOL(register_reboot_notifier); | ||
| 340 | |||
| 341 | /** | ||
| 342 | * unregister_reboot_notifier - Unregister previously registered reboot notifier | ||
| 343 | * @nb: Hook to be unregistered | ||
| 344 | * | ||
| 345 | * Unregisters a previously registered reboot | ||
| 346 | * notifier function. | ||
| 347 | * | ||
| 348 | * Returns zero on success, or %-ENOENT on failure. | ||
| 349 | */ | ||
| 350 | int unregister_reboot_notifier(struct notifier_block *nb) | ||
| 351 | { | ||
| 352 | return blocking_notifier_chain_unregister(&reboot_notifier_list, nb); | ||
| 353 | } | ||
| 354 | EXPORT_SYMBOL(unregister_reboot_notifier); | ||
| 355 | |||
| 356 | /** | ||
| 323 | * kernel_restart - reboot the system | 357 | * kernel_restart - reboot the system |
| 324 | * @cmd: pointer to buffer containing command to execute for restart | 358 | * @cmd: pointer to buffer containing command to execute for restart |
| 325 | * or %NULL | 359 | * or %NULL |
| @@ -591,11 +625,18 @@ static int set_user(struct cred *new) | |||
| 591 | if (!new_user) | 625 | if (!new_user) |
| 592 | return -EAGAIN; | 626 | return -EAGAIN; |
| 593 | 627 | ||
| 628 | /* | ||
| 629 | * We don't fail in case of NPROC limit excess here because too many | ||
| 630 | * poorly written programs don't check set*uid() return code, assuming | ||
| 631 | * it never fails if called by root. We may still enforce NPROC limit | ||
| 632 | * for programs doing set*uid()+execve() by harmlessly deferring the | ||
| 633 | * failure to the execve() stage. | ||
| 634 | */ | ||
| 594 | if (atomic_read(&new_user->processes) >= rlimit(RLIMIT_NPROC) && | 635 | if (atomic_read(&new_user->processes) >= rlimit(RLIMIT_NPROC) && |
| 595 | new_user != INIT_USER) { | 636 | new_user != INIT_USER) |
| 596 | free_uid(new_user); | 637 | current->flags |= PF_NPROC_EXCEEDED; |
| 597 | return -EAGAIN; | 638 | else |
| 598 | } | 639 | current->flags &= ~PF_NPROC_EXCEEDED; |
| 599 | 640 | ||
| 600 | free_uid(new->user); | 641 | free_uid(new->user); |
| 601 | new->user = new_user; | 642 | new->user = new_user; |
| @@ -1124,6 +1165,34 @@ DECLARE_RWSEM(uts_sem); | |||
| 1124 | #define override_architecture(name) 0 | 1165 | #define override_architecture(name) 0 |
| 1125 | #endif | 1166 | #endif |
| 1126 | 1167 | ||
| 1168 | /* | ||
| 1169 | * Work around broken programs that cannot handle "Linux 3.0". | ||
| 1170 | * Instead we map 3.x to 2.6.40+x, so e.g. 3.0 would be 2.6.40 | ||
| 1171 | */ | ||
| 1172 | static int override_release(char __user *release, int len) | ||
| 1173 | { | ||
| 1174 | int ret = 0; | ||
| 1175 | char buf[len]; | ||
| 1176 | |||
| 1177 | if (current->personality & UNAME26) { | ||
| 1178 | char *rest = UTS_RELEASE; | ||
| 1179 | int ndots = 0; | ||
| 1180 | unsigned v; | ||
| 1181 | |||
| 1182 | while (*rest) { | ||
| 1183 | if (*rest == '.' && ++ndots >= 3) | ||
| 1184 | break; | ||
| 1185 | if (!isdigit(*rest) && *rest != '.') | ||
| 1186 | break; | ||
| 1187 | rest++; | ||
| 1188 | } | ||
| 1189 | v = ((LINUX_VERSION_CODE >> 8) & 0xff) + 40; | ||
| 1190 | snprintf(buf, len, "2.6.%u%s", v, rest); | ||
| 1191 | ret = copy_to_user(release, buf, len); | ||
| 1192 | } | ||
| 1193 | return ret; | ||
| 1194 | } | ||
| 1195 | |||
| 1127 | SYSCALL_DEFINE1(newuname, struct new_utsname __user *, name) | 1196 | SYSCALL_DEFINE1(newuname, struct new_utsname __user *, name) |
| 1128 | { | 1197 | { |
| 1129 | int errno = 0; | 1198 | int errno = 0; |
| @@ -1133,6 +1202,8 @@ SYSCALL_DEFINE1(newuname, struct new_utsname __user *, name) | |||
| 1133 | errno = -EFAULT; | 1202 | errno = -EFAULT; |
| 1134 | up_read(&uts_sem); | 1203 | up_read(&uts_sem); |
| 1135 | 1204 | ||
| 1205 | if (!errno && override_release(name->release, sizeof(name->release))) | ||
| 1206 | errno = -EFAULT; | ||
| 1136 | if (!errno && override_architecture(name)) | 1207 | if (!errno && override_architecture(name)) |
| 1137 | errno = -EFAULT; | 1208 | errno = -EFAULT; |
| 1138 | return errno; | 1209 | return errno; |
| @@ -1154,6 +1225,8 @@ SYSCALL_DEFINE1(uname, struct old_utsname __user *, name) | |||
| 1154 | error = -EFAULT; | 1225 | error = -EFAULT; |
| 1155 | up_read(&uts_sem); | 1226 | up_read(&uts_sem); |
| 1156 | 1227 | ||
| 1228 | if (!error && override_release(name->release, sizeof(name->release))) | ||
| 1229 | error = -EFAULT; | ||
| 1157 | if (!error && override_architecture(name)) | 1230 | if (!error && override_architecture(name)) |
| 1158 | error = -EFAULT; | 1231 | error = -EFAULT; |
| 1159 | return error; | 1232 | return error; |
| @@ -1188,6 +1261,8 @@ SYSCALL_DEFINE1(olduname, struct oldold_utsname __user *, name) | |||
| 1188 | 1261 | ||
| 1189 | if (!error && override_architecture(name)) | 1262 | if (!error && override_architecture(name)) |
| 1190 | error = -EFAULT; | 1263 | error = -EFAULT; |
| 1264 | if (!error && override_release(name->release, sizeof(name->release))) | ||
| 1265 | error = -EFAULT; | ||
| 1191 | return error ? -EFAULT : 0; | 1266 | return error ? -EFAULT : 0; |
| 1192 | } | 1267 | } |
| 1193 | #endif | 1268 | #endif |
diff --git a/kernel/sys_ni.c b/kernel/sys_ni.c index 62cbc8877fef..a9a5de07c4f1 100644 --- a/kernel/sys_ni.c +++ b/kernel/sys_ni.c | |||
| @@ -16,7 +16,6 @@ asmlinkage long sys_ni_syscall(void) | |||
| 16 | return -ENOSYS; | 16 | return -ENOSYS; |
| 17 | } | 17 | } |
| 18 | 18 | ||
| 19 | cond_syscall(sys_nfsservctl); | ||
| 20 | cond_syscall(sys_quotactl); | 19 | cond_syscall(sys_quotactl); |
| 21 | cond_syscall(sys32_quotactl); | 20 | cond_syscall(sys32_quotactl); |
| 22 | cond_syscall(sys_acct); | 21 | cond_syscall(sys_acct); |
diff --git a/kernel/sysctl_binary.c b/kernel/sysctl_binary.c index 3b8e028b9601..e8bffbe2ba4b 100644 --- a/kernel/sysctl_binary.c +++ b/kernel/sysctl_binary.c | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | #include <linux/stat.h> | 1 | #include <linux/stat.h> |
| 2 | #include <linux/sysctl.h> | 2 | #include <linux/sysctl.h> |
| 3 | #include "../fs/xfs/linux-2.6/xfs_sysctl.h" | 3 | #include "../fs/xfs/xfs_sysctl.h" |
| 4 | #include <linux/sunrpc/debug.h> | 4 | #include <linux/sunrpc/debug.h> |
| 5 | #include <linux/string.h> | 5 | #include <linux/string.h> |
| 6 | #include <net/ip_vs.h> | 6 | #include <net/ip_vs.h> |
diff --git a/kernel/sysctl_check.c b/kernel/sysctl_check.c index 4e4932a7b360..362da653813d 100644 --- a/kernel/sysctl_check.c +++ b/kernel/sysctl_check.c | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | #include <linux/stat.h> | 1 | #include <linux/stat.h> |
| 2 | #include <linux/sysctl.h> | 2 | #include <linux/sysctl.h> |
| 3 | #include "../fs/xfs/linux-2.6/xfs_sysctl.h" | 3 | #include "../fs/xfs/xfs_sysctl.h" |
| 4 | #include <linux/sunrpc/debug.h> | 4 | #include <linux/sunrpc/debug.h> |
| 5 | #include <linux/string.h> | 5 | #include <linux/string.h> |
| 6 | #include <net/ip_vs.h> | 6 | #include <net/ip_vs.h> |
diff --git a/kernel/taskstats.c b/kernel/taskstats.c index fc0f22005417..e66046456f4f 100644 --- a/kernel/taskstats.c +++ b/kernel/taskstats.c | |||
| @@ -28,7 +28,7 @@ | |||
| 28 | #include <linux/fs.h> | 28 | #include <linux/fs.h> |
| 29 | #include <linux/file.h> | 29 | #include <linux/file.h> |
| 30 | #include <net/genetlink.h> | 30 | #include <net/genetlink.h> |
| 31 | #include <asm/atomic.h> | 31 | #include <linux/atomic.h> |
| 32 | 32 | ||
| 33 | /* | 33 | /* |
| 34 | * Maximum length of a cpumask that can be specified in | 34 | * Maximum length of a cpumask that can be specified in |
| @@ -291,30 +291,28 @@ static int add_del_listener(pid_t pid, const struct cpumask *mask, int isadd) | |||
| 291 | if (!cpumask_subset(mask, cpu_possible_mask)) | 291 | if (!cpumask_subset(mask, cpu_possible_mask)) |
| 292 | return -EINVAL; | 292 | return -EINVAL; |
| 293 | 293 | ||
| 294 | s = NULL; | ||
| 295 | if (isadd == REGISTER) { | 294 | if (isadd == REGISTER) { |
| 296 | for_each_cpu(cpu, mask) { | 295 | for_each_cpu(cpu, mask) { |
| 297 | if (!s) | 296 | s = kmalloc_node(sizeof(struct listener), |
| 298 | s = kmalloc_node(sizeof(struct listener), | 297 | GFP_KERNEL, cpu_to_node(cpu)); |
| 299 | GFP_KERNEL, cpu_to_node(cpu)); | ||
| 300 | if (!s) | 298 | if (!s) |
| 301 | goto cleanup; | 299 | goto cleanup; |
| 300 | |||
| 302 | s->pid = pid; | 301 | s->pid = pid; |
| 303 | INIT_LIST_HEAD(&s->list); | ||
| 304 | s->valid = 1; | 302 | s->valid = 1; |
| 305 | 303 | ||
| 306 | listeners = &per_cpu(listener_array, cpu); | 304 | listeners = &per_cpu(listener_array, cpu); |
| 307 | down_write(&listeners->sem); | 305 | down_write(&listeners->sem); |
| 308 | list_for_each_entry_safe(s2, tmp, &listeners->list, list) { | 306 | list_for_each_entry(s2, &listeners->list, list) { |
| 309 | if (s2->pid == pid) | 307 | if (s2->pid == pid && s2->valid) |
| 310 | goto next_cpu; | 308 | goto exists; |
| 311 | } | 309 | } |
| 312 | list_add(&s->list, &listeners->list); | 310 | list_add(&s->list, &listeners->list); |
| 313 | s = NULL; | 311 | s = NULL; |
| 314 | next_cpu: | 312 | exists: |
| 315 | up_write(&listeners->sem); | 313 | up_write(&listeners->sem); |
| 314 | kfree(s); /* nop if NULL */ | ||
| 316 | } | 315 | } |
| 317 | kfree(s); | ||
| 318 | return 0; | 316 | return 0; |
| 319 | } | 317 | } |
| 320 | 318 | ||
| @@ -657,6 +655,7 @@ static struct genl_ops taskstats_ops = { | |||
| 657 | .cmd = TASKSTATS_CMD_GET, | 655 | .cmd = TASKSTATS_CMD_GET, |
| 658 | .doit = taskstats_user_cmd, | 656 | .doit = taskstats_user_cmd, |
| 659 | .policy = taskstats_cmd_get_policy, | 657 | .policy = taskstats_cmd_get_policy, |
| 658 | .flags = GENL_ADMIN_PERM, | ||
| 660 | }; | 659 | }; |
| 661 | 660 | ||
| 662 | static struct genl_ops cgroupstats_ops = { | 661 | static struct genl_ops cgroupstats_ops = { |
diff --git a/kernel/time/alarmtimer.c b/kernel/time/alarmtimer.c index 59f369f98a04..ea5e1a928d5b 100644 --- a/kernel/time/alarmtimer.c +++ b/kernel/time/alarmtimer.c | |||
| @@ -441,6 +441,8 @@ static int alarm_timer_create(struct k_itimer *new_timer) | |||
| 441 | static void alarm_timer_get(struct k_itimer *timr, | 441 | static void alarm_timer_get(struct k_itimer *timr, |
| 442 | struct itimerspec *cur_setting) | 442 | struct itimerspec *cur_setting) |
| 443 | { | 443 | { |
| 444 | memset(cur_setting, 0, sizeof(struct itimerspec)); | ||
| 445 | |||
| 444 | cur_setting->it_interval = | 446 | cur_setting->it_interval = |
| 445 | ktime_to_timespec(timr->it.alarmtimer.period); | 447 | ktime_to_timespec(timr->it.alarmtimer.period); |
| 446 | cur_setting->it_value = | 448 | cur_setting->it_value = |
| @@ -479,11 +481,17 @@ static int alarm_timer_set(struct k_itimer *timr, int flags, | |||
| 479 | if (!rtcdev) | 481 | if (!rtcdev) |
| 480 | return -ENOTSUPP; | 482 | return -ENOTSUPP; |
| 481 | 483 | ||
| 482 | /* Save old values */ | 484 | /* |
| 483 | old_setting->it_interval = | 485 | * XXX HACK! Currently we can DOS a system if the interval |
| 484 | ktime_to_timespec(timr->it.alarmtimer.period); | 486 | * period on alarmtimers is too small. Cap the interval here |
| 485 | old_setting->it_value = | 487 | * to 100us and solve this properly in a future patch! -jstultz |
| 486 | ktime_to_timespec(timr->it.alarmtimer.node.expires); | 488 | */ |
| 489 | if ((new_setting->it_interval.tv_sec == 0) && | ||
| 490 | (new_setting->it_interval.tv_nsec < 100000)) | ||
| 491 | new_setting->it_interval.tv_nsec = 100000; | ||
| 492 | |||
| 493 | if (old_setting) | ||
| 494 | alarm_timer_get(timr, old_setting); | ||
| 487 | 495 | ||
| 488 | /* If the timer was already set, cancel it */ | 496 | /* If the timer was already set, cancel it */ |
| 489 | alarm_cancel(&timr->it.alarmtimer); | 497 | alarm_cancel(&timr->it.alarmtimer); |
diff --git a/kernel/trace/Kconfig b/kernel/trace/Kconfig index 2ad39e556cb4..cd3134510f3d 100644 --- a/kernel/trace/Kconfig +++ b/kernel/trace/Kconfig | |||
| @@ -82,7 +82,7 @@ config EVENT_POWER_TRACING_DEPRECATED | |||
| 82 | power:power_frequency | 82 | power:power_frequency |
| 83 | This is for userspace compatibility | 83 | This is for userspace compatibility |
| 84 | and will vanish after 5 kernel iterations, | 84 | and will vanish after 5 kernel iterations, |
| 85 | namely 2.6.41. | 85 | namely 3.1. |
| 86 | 86 | ||
| 87 | config CONTEXT_SWITCH_TRACER | 87 | config CONTEXT_SWITCH_TRACER |
| 88 | bool | 88 | bool |
diff --git a/kernel/trace/blktrace.c b/kernel/trace/blktrace.c index 6957aa298dfa..7c910a5593a6 100644 --- a/kernel/trace/blktrace.c +++ b/kernel/trace/blktrace.c | |||
| @@ -206,6 +206,8 @@ static void __blk_add_trace(struct blk_trace *bt, sector_t sector, int bytes, | |||
| 206 | what |= MASK_TC_BIT(rw, RAHEAD); | 206 | what |= MASK_TC_BIT(rw, RAHEAD); |
| 207 | what |= MASK_TC_BIT(rw, META); | 207 | what |= MASK_TC_BIT(rw, META); |
| 208 | what |= MASK_TC_BIT(rw, DISCARD); | 208 | what |= MASK_TC_BIT(rw, DISCARD); |
| 209 | what |= MASK_TC_BIT(rw, FLUSH); | ||
| 210 | what |= MASK_TC_BIT(rw, FUA); | ||
| 209 | 211 | ||
| 210 | pid = tsk->pid; | 212 | pid = tsk->pid; |
| 211 | if (act_log_check(bt, what, sector, pid)) | 213 | if (act_log_check(bt, what, sector, pid)) |
| @@ -1054,6 +1056,9 @@ static void fill_rwbs(char *rwbs, const struct blk_io_trace *t) | |||
| 1054 | goto out; | 1056 | goto out; |
| 1055 | } | 1057 | } |
| 1056 | 1058 | ||
| 1059 | if (tc & BLK_TC_FLUSH) | ||
| 1060 | rwbs[i++] = 'F'; | ||
| 1061 | |||
| 1057 | if (tc & BLK_TC_DISCARD) | 1062 | if (tc & BLK_TC_DISCARD) |
| 1058 | rwbs[i++] = 'D'; | 1063 | rwbs[i++] = 'D'; |
| 1059 | else if (tc & BLK_TC_WRITE) | 1064 | else if (tc & BLK_TC_WRITE) |
| @@ -1063,10 +1068,10 @@ static void fill_rwbs(char *rwbs, const struct blk_io_trace *t) | |||
| 1063 | else | 1068 | else |
| 1064 | rwbs[i++] = 'N'; | 1069 | rwbs[i++] = 'N'; |
| 1065 | 1070 | ||
| 1071 | if (tc & BLK_TC_FUA) | ||
| 1072 | rwbs[i++] = 'F'; | ||
| 1066 | if (tc & BLK_TC_AHEAD) | 1073 | if (tc & BLK_TC_AHEAD) |
| 1067 | rwbs[i++] = 'A'; | 1074 | rwbs[i++] = 'A'; |
| 1068 | if (tc & BLK_TC_BARRIER) | ||
| 1069 | rwbs[i++] = 'B'; | ||
| 1070 | if (tc & BLK_TC_SYNC) | 1075 | if (tc & BLK_TC_SYNC) |
| 1071 | rwbs[i++] = 'S'; | 1076 | rwbs[i++] = 'S'; |
| 1072 | if (tc & BLK_TC_META) | 1077 | if (tc & BLK_TC_META) |
| @@ -1132,7 +1137,7 @@ typedef int (blk_log_action_t) (struct trace_iterator *iter, const char *act); | |||
| 1132 | 1137 | ||
| 1133 | static int blk_log_action_classic(struct trace_iterator *iter, const char *act) | 1138 | static int blk_log_action_classic(struct trace_iterator *iter, const char *act) |
| 1134 | { | 1139 | { |
| 1135 | char rwbs[6]; | 1140 | char rwbs[RWBS_LEN]; |
| 1136 | unsigned long long ts = iter->ts; | 1141 | unsigned long long ts = iter->ts; |
| 1137 | unsigned long nsec_rem = do_div(ts, NSEC_PER_SEC); | 1142 | unsigned long nsec_rem = do_div(ts, NSEC_PER_SEC); |
| 1138 | unsigned secs = (unsigned long)ts; | 1143 | unsigned secs = (unsigned long)ts; |
| @@ -1148,7 +1153,7 @@ static int blk_log_action_classic(struct trace_iterator *iter, const char *act) | |||
| 1148 | 1153 | ||
| 1149 | static int blk_log_action(struct trace_iterator *iter, const char *act) | 1154 | static int blk_log_action(struct trace_iterator *iter, const char *act) |
| 1150 | { | 1155 | { |
| 1151 | char rwbs[6]; | 1156 | char rwbs[RWBS_LEN]; |
| 1152 | const struct blk_io_trace *t = te_blk_io_trace(iter->ent); | 1157 | const struct blk_io_trace *t = te_blk_io_trace(iter->ent); |
| 1153 | 1158 | ||
| 1154 | fill_rwbs(rwbs, t); | 1159 | fill_rwbs(rwbs, t); |
| @@ -1561,7 +1566,7 @@ static const struct { | |||
| 1561 | } mask_maps[] = { | 1566 | } mask_maps[] = { |
| 1562 | { BLK_TC_READ, "read" }, | 1567 | { BLK_TC_READ, "read" }, |
| 1563 | { BLK_TC_WRITE, "write" }, | 1568 | { BLK_TC_WRITE, "write" }, |
| 1564 | { BLK_TC_BARRIER, "barrier" }, | 1569 | { BLK_TC_FLUSH, "flush" }, |
| 1565 | { BLK_TC_SYNC, "sync" }, | 1570 | { BLK_TC_SYNC, "sync" }, |
| 1566 | { BLK_TC_QUEUE, "queue" }, | 1571 | { BLK_TC_QUEUE, "queue" }, |
| 1567 | { BLK_TC_REQUEUE, "requeue" }, | 1572 | { BLK_TC_REQUEUE, "requeue" }, |
| @@ -1573,6 +1578,7 @@ static const struct { | |||
| 1573 | { BLK_TC_META, "meta" }, | 1578 | { BLK_TC_META, "meta" }, |
| 1574 | { BLK_TC_DISCARD, "discard" }, | 1579 | { BLK_TC_DISCARD, "discard" }, |
| 1575 | { BLK_TC_DRV_DATA, "drv_data" }, | 1580 | { BLK_TC_DRV_DATA, "drv_data" }, |
| 1581 | { BLK_TC_FUA, "fua" }, | ||
| 1576 | }; | 1582 | }; |
| 1577 | 1583 | ||
| 1578 | static int blk_trace_str2mask(const char *str) | 1584 | static int blk_trace_str2mask(const char *str) |
| @@ -1788,6 +1794,9 @@ void blk_fill_rwbs(char *rwbs, u32 rw, int bytes) | |||
| 1788 | { | 1794 | { |
| 1789 | int i = 0; | 1795 | int i = 0; |
| 1790 | 1796 | ||
| 1797 | if (rw & REQ_FLUSH) | ||
| 1798 | rwbs[i++] = 'F'; | ||
| 1799 | |||
| 1791 | if (rw & WRITE) | 1800 | if (rw & WRITE) |
| 1792 | rwbs[i++] = 'W'; | 1801 | rwbs[i++] = 'W'; |
| 1793 | else if (rw & REQ_DISCARD) | 1802 | else if (rw & REQ_DISCARD) |
| @@ -1797,6 +1806,8 @@ void blk_fill_rwbs(char *rwbs, u32 rw, int bytes) | |||
| 1797 | else | 1806 | else |
| 1798 | rwbs[i++] = 'N'; | 1807 | rwbs[i++] = 'N'; |
| 1799 | 1808 | ||
| 1809 | if (rw & REQ_FUA) | ||
| 1810 | rwbs[i++] = 'F'; | ||
| 1800 | if (rw & REQ_RAHEAD) | 1811 | if (rw & REQ_RAHEAD) |
| 1801 | rwbs[i++] = 'A'; | 1812 | rwbs[i++] = 'A'; |
| 1802 | if (rw & REQ_SYNC) | 1813 | if (rw & REQ_SYNC) |
diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h index 3f381d0b20a8..616846bcfee5 100644 --- a/kernel/trace/trace.h +++ b/kernel/trace/trace.h | |||
| @@ -2,7 +2,7 @@ | |||
| 2 | #define _LINUX_KERNEL_TRACE_H | 2 | #define _LINUX_KERNEL_TRACE_H |
| 3 | 3 | ||
| 4 | #include <linux/fs.h> | 4 | #include <linux/fs.h> |
| 5 | #include <asm/atomic.h> | 5 | #include <linux/atomic.h> |
| 6 | #include <linux/sched.h> | 6 | #include <linux/sched.h> |
| 7 | #include <linux/clocksource.h> | 7 | #include <linux/clocksource.h> |
| 8 | #include <linux/ring_buffer.h> | 8 | #include <linux/ring_buffer.h> |
diff --git a/kernel/trace/trace_mmiotrace.c b/kernel/trace/trace_mmiotrace.c index 017fa376505d..fd3c8aae55e5 100644 --- a/kernel/trace/trace_mmiotrace.c +++ b/kernel/trace/trace_mmiotrace.c | |||
| @@ -12,7 +12,7 @@ | |||
| 12 | #include <linux/slab.h> | 12 | #include <linux/slab.h> |
| 13 | #include <linux/time.h> | 13 | #include <linux/time.h> |
| 14 | 14 | ||
| 15 | #include <asm/atomic.h> | 15 | #include <linux/atomic.h> |
| 16 | 16 | ||
| 17 | #include "trace.h" | 17 | #include "trace.h" |
| 18 | #include "trace_output.h" | 18 | #include "trace_output.h" |
diff --git a/kernel/tsacct.c b/kernel/tsacct.c index 24dc60d9fa1f..5bbfac85866e 100644 --- a/kernel/tsacct.c +++ b/kernel/tsacct.c | |||
| @@ -78,6 +78,7 @@ void bacct_add_tsk(struct taskstats *stats, struct task_struct *tsk) | |||
| 78 | 78 | ||
| 79 | #define KB 1024 | 79 | #define KB 1024 |
| 80 | #define MB (1024*KB) | 80 | #define MB (1024*KB) |
| 81 | #define KB_MASK (~(KB-1)) | ||
| 81 | /* | 82 | /* |
| 82 | * fill in extended accounting fields | 83 | * fill in extended accounting fields |
| 83 | */ | 84 | */ |
| @@ -95,14 +96,14 @@ void xacct_add_tsk(struct taskstats *stats, struct task_struct *p) | |||
| 95 | stats->hiwater_vm = get_mm_hiwater_vm(mm) * PAGE_SIZE / KB; | 96 | stats->hiwater_vm = get_mm_hiwater_vm(mm) * PAGE_SIZE / KB; |
| 96 | mmput(mm); | 97 | mmput(mm); |
| 97 | } | 98 | } |
| 98 | stats->read_char = p->ioac.rchar; | 99 | stats->read_char = p->ioac.rchar & KB_MASK; |
| 99 | stats->write_char = p->ioac.wchar; | 100 | stats->write_char = p->ioac.wchar & KB_MASK; |
| 100 | stats->read_syscalls = p->ioac.syscr; | 101 | stats->read_syscalls = p->ioac.syscr & KB_MASK; |
| 101 | stats->write_syscalls = p->ioac.syscw; | 102 | stats->write_syscalls = p->ioac.syscw & KB_MASK; |
| 102 | #ifdef CONFIG_TASK_IO_ACCOUNTING | 103 | #ifdef CONFIG_TASK_IO_ACCOUNTING |
| 103 | stats->read_bytes = p->ioac.read_bytes; | 104 | stats->read_bytes = p->ioac.read_bytes & KB_MASK; |
| 104 | stats->write_bytes = p->ioac.write_bytes; | 105 | stats->write_bytes = p->ioac.write_bytes & KB_MASK; |
| 105 | stats->cancelled_write_bytes = p->ioac.cancelled_write_bytes; | 106 | stats->cancelled_write_bytes = p->ioac.cancelled_write_bytes & KB_MASK; |
| 106 | #else | 107 | #else |
| 107 | stats->read_bytes = 0; | 108 | stats->read_bytes = 0; |
| 108 | stats->write_bytes = 0; | 109 | stats->write_bytes = 0; |
diff --git a/kernel/workqueue.c b/kernel/workqueue.c index 25fb1b0e53fa..1783aabc6128 100644 --- a/kernel/workqueue.c +++ b/kernel/workqueue.c | |||
| @@ -2412,8 +2412,13 @@ reflush: | |||
| 2412 | 2412 | ||
| 2413 | for_each_cwq_cpu(cpu, wq) { | 2413 | for_each_cwq_cpu(cpu, wq) { |
| 2414 | struct cpu_workqueue_struct *cwq = get_cwq(cpu, wq); | 2414 | struct cpu_workqueue_struct *cwq = get_cwq(cpu, wq); |
| 2415 | bool drained; | ||
| 2415 | 2416 | ||
| 2416 | if (!cwq->nr_active && list_empty(&cwq->delayed_works)) | 2417 | spin_lock_irq(&cwq->gcwq->lock); |
| 2418 | drained = !cwq->nr_active && list_empty(&cwq->delayed_works); | ||
| 2419 | spin_unlock_irq(&cwq->gcwq->lock); | ||
| 2420 | |||
| 2421 | if (drained) | ||
| 2417 | continue; | 2422 | continue; |
| 2418 | 2423 | ||
| 2419 | if (++flush_cnt == 10 || | 2424 | if (++flush_cnt == 10 || |
