diff options
Diffstat (limited to 'kernel')
33 files changed, 357 insertions, 315 deletions
diff --git a/kernel/audit.c b/kernel/audit.c index 4414e93d8750..ce6d8ea3131e 100644 --- a/kernel/audit.c +++ b/kernel/audit.c | |||
@@ -61,8 +61,11 @@ | |||
61 | 61 | ||
62 | #include "audit.h" | 62 | #include "audit.h" |
63 | 63 | ||
64 | /* No auditing will take place until audit_initialized != 0. | 64 | /* No auditing will take place until audit_initialized == AUDIT_INITIALIZED. |
65 | * (Initialization happens after skb_init is called.) */ | 65 | * (Initialization happens after skb_init is called.) */ |
66 | #define AUDIT_DISABLED -1 | ||
67 | #define AUDIT_UNINITIALIZED 0 | ||
68 | #define AUDIT_INITIALIZED 1 | ||
66 | static int audit_initialized; | 69 | static int audit_initialized; |
67 | 70 | ||
68 | #define AUDIT_OFF 0 | 71 | #define AUDIT_OFF 0 |
@@ -965,6 +968,9 @@ static int __init audit_init(void) | |||
965 | { | 968 | { |
966 | int i; | 969 | int i; |
967 | 970 | ||
971 | if (audit_initialized == AUDIT_DISABLED) | ||
972 | return 0; | ||
973 | |||
968 | printk(KERN_INFO "audit: initializing netlink socket (%s)\n", | 974 | printk(KERN_INFO "audit: initializing netlink socket (%s)\n", |
969 | audit_default ? "enabled" : "disabled"); | 975 | audit_default ? "enabled" : "disabled"); |
970 | audit_sock = netlink_kernel_create(&init_net, NETLINK_AUDIT, 0, | 976 | audit_sock = netlink_kernel_create(&init_net, NETLINK_AUDIT, 0, |
@@ -976,7 +982,7 @@ static int __init audit_init(void) | |||
976 | 982 | ||
977 | skb_queue_head_init(&audit_skb_queue); | 983 | skb_queue_head_init(&audit_skb_queue); |
978 | skb_queue_head_init(&audit_skb_hold_queue); | 984 | skb_queue_head_init(&audit_skb_hold_queue); |
979 | audit_initialized = 1; | 985 | audit_initialized = AUDIT_INITIALIZED; |
980 | audit_enabled = audit_default; | 986 | audit_enabled = audit_default; |
981 | audit_ever_enabled |= !!audit_default; | 987 | audit_ever_enabled |= !!audit_default; |
982 | 988 | ||
@@ -999,13 +1005,21 @@ __initcall(audit_init); | |||
999 | static int __init audit_enable(char *str) | 1005 | static int __init audit_enable(char *str) |
1000 | { | 1006 | { |
1001 | audit_default = !!simple_strtol(str, NULL, 0); | 1007 | audit_default = !!simple_strtol(str, NULL, 0); |
1002 | printk(KERN_INFO "audit: %s%s\n", | 1008 | if (!audit_default) |
1003 | audit_default ? "enabled" : "disabled", | 1009 | audit_initialized = AUDIT_DISABLED; |
1004 | audit_initialized ? "" : " (after initialization)"); | 1010 | |
1005 | if (audit_initialized) { | 1011 | printk(KERN_INFO "audit: %s", audit_default ? "enabled" : "disabled"); |
1012 | |||
1013 | if (audit_initialized == AUDIT_INITIALIZED) { | ||
1006 | audit_enabled = audit_default; | 1014 | audit_enabled = audit_default; |
1007 | audit_ever_enabled |= !!audit_default; | 1015 | audit_ever_enabled |= !!audit_default; |
1016 | } else if (audit_initialized == AUDIT_UNINITIALIZED) { | ||
1017 | printk(" (after initialization)"); | ||
1018 | } else { | ||
1019 | printk(" (until reboot)"); | ||
1008 | } | 1020 | } |
1021 | printk("\n"); | ||
1022 | |||
1009 | return 1; | 1023 | return 1; |
1010 | } | 1024 | } |
1011 | 1025 | ||
@@ -1107,9 +1121,7 @@ unsigned int audit_serial(void) | |||
1107 | static inline void audit_get_stamp(struct audit_context *ctx, | 1121 | static inline void audit_get_stamp(struct audit_context *ctx, |
1108 | struct timespec *t, unsigned int *serial) | 1122 | struct timespec *t, unsigned int *serial) |
1109 | { | 1123 | { |
1110 | if (ctx) | 1124 | if (!ctx || !auditsc_get_stamp(ctx, t, serial)) { |
1111 | auditsc_get_stamp(ctx, t, serial); | ||
1112 | else { | ||
1113 | *t = CURRENT_TIME; | 1125 | *t = CURRENT_TIME; |
1114 | *serial = audit_serial(); | 1126 | *serial = audit_serial(); |
1115 | } | 1127 | } |
@@ -1146,7 +1158,7 @@ struct audit_buffer *audit_log_start(struct audit_context *ctx, gfp_t gfp_mask, | |||
1146 | int reserve; | 1158 | int reserve; |
1147 | unsigned long timeout_start = jiffies; | 1159 | unsigned long timeout_start = jiffies; |
1148 | 1160 | ||
1149 | if (!audit_initialized) | 1161 | if (audit_initialized != AUDIT_INITIALIZED) |
1150 | return NULL; | 1162 | return NULL; |
1151 | 1163 | ||
1152 | if (unlikely(audit_filter_type(type))) | 1164 | if (unlikely(audit_filter_type(type))) |
diff --git a/kernel/auditsc.c b/kernel/auditsc.c index cf5bc2f5f9c3..2a3f0afc4d2a 100644 --- a/kernel/auditsc.c +++ b/kernel/auditsc.c | |||
@@ -1459,7 +1459,6 @@ void audit_free(struct task_struct *tsk) | |||
1459 | 1459 | ||
1460 | /** | 1460 | /** |
1461 | * audit_syscall_entry - fill in an audit record at syscall entry | 1461 | * audit_syscall_entry - fill in an audit record at syscall entry |
1462 | * @tsk: task being audited | ||
1463 | * @arch: architecture type | 1462 | * @arch: architecture type |
1464 | * @major: major syscall type (function) | 1463 | * @major: major syscall type (function) |
1465 | * @a1: additional syscall register 1 | 1464 | * @a1: additional syscall register 1 |
@@ -1548,9 +1547,25 @@ void audit_syscall_entry(int arch, int major, | |||
1548 | context->ppid = 0; | 1547 | context->ppid = 0; |
1549 | } | 1548 | } |
1550 | 1549 | ||
1550 | void audit_finish_fork(struct task_struct *child) | ||
1551 | { | ||
1552 | struct audit_context *ctx = current->audit_context; | ||
1553 | struct audit_context *p = child->audit_context; | ||
1554 | if (!p || !ctx || !ctx->auditable) | ||
1555 | return; | ||
1556 | p->arch = ctx->arch; | ||
1557 | p->major = ctx->major; | ||
1558 | memcpy(p->argv, ctx->argv, sizeof(ctx->argv)); | ||
1559 | p->ctime = ctx->ctime; | ||
1560 | p->dummy = ctx->dummy; | ||
1561 | p->auditable = ctx->auditable; | ||
1562 | p->in_syscall = ctx->in_syscall; | ||
1563 | p->filterkey = kstrdup(ctx->filterkey, GFP_KERNEL); | ||
1564 | p->ppid = current->pid; | ||
1565 | } | ||
1566 | |||
1551 | /** | 1567 | /** |
1552 | * audit_syscall_exit - deallocate audit context after a system call | 1568 | * audit_syscall_exit - deallocate audit context after a system call |
1553 | * @tsk: task being audited | ||
1554 | * @valid: success/failure flag | 1569 | * @valid: success/failure flag |
1555 | * @return_code: syscall return value | 1570 | * @return_code: syscall return value |
1556 | * | 1571 | * |
@@ -1942,15 +1957,18 @@ EXPORT_SYMBOL_GPL(__audit_inode_child); | |||
1942 | * | 1957 | * |
1943 | * Also sets the context as auditable. | 1958 | * Also sets the context as auditable. |
1944 | */ | 1959 | */ |
1945 | void auditsc_get_stamp(struct audit_context *ctx, | 1960 | int auditsc_get_stamp(struct audit_context *ctx, |
1946 | struct timespec *t, unsigned int *serial) | 1961 | struct timespec *t, unsigned int *serial) |
1947 | { | 1962 | { |
1963 | if (!ctx->in_syscall) | ||
1964 | return 0; | ||
1948 | if (!ctx->serial) | 1965 | if (!ctx->serial) |
1949 | ctx->serial = audit_serial(); | 1966 | ctx->serial = audit_serial(); |
1950 | t->tv_sec = ctx->ctime.tv_sec; | 1967 | t->tv_sec = ctx->ctime.tv_sec; |
1951 | t->tv_nsec = ctx->ctime.tv_nsec; | 1968 | t->tv_nsec = ctx->ctime.tv_nsec; |
1952 | *serial = ctx->serial; | 1969 | *serial = ctx->serial; |
1953 | ctx->auditable = 1; | 1970 | ctx->auditable = 1; |
1971 | return 1; | ||
1954 | } | 1972 | } |
1955 | 1973 | ||
1956 | /* global counter which is incremented every time something logs in */ | 1974 | /* global counter which is incremented every time something logs in */ |
diff --git a/kernel/cgroup.c b/kernel/cgroup.c index fe00b3b983a8..2606d0fb4e54 100644 --- a/kernel/cgroup.c +++ b/kernel/cgroup.c | |||
@@ -702,7 +702,7 @@ static int rebind_subsystems(struct cgroupfs_root *root, | |||
702 | * any child cgroups exist. This is theoretically supportable | 702 | * any child cgroups exist. This is theoretically supportable |
703 | * but involves complex error handling, so it's being left until | 703 | * but involves complex error handling, so it's being left until |
704 | * later */ | 704 | * later */ |
705 | if (!list_empty(&cgrp->children)) | 705 | if (root->number_of_cgroups > 1) |
706 | return -EBUSY; | 706 | return -EBUSY; |
707 | 707 | ||
708 | /* Process each subsystem */ | 708 | /* Process each subsystem */ |
@@ -1024,7 +1024,7 @@ static int cgroup_get_sb(struct file_system_type *fs_type, | |||
1024 | if (ret == -EBUSY) { | 1024 | if (ret == -EBUSY) { |
1025 | mutex_unlock(&cgroup_mutex); | 1025 | mutex_unlock(&cgroup_mutex); |
1026 | mutex_unlock(&inode->i_mutex); | 1026 | mutex_unlock(&inode->i_mutex); |
1027 | goto drop_new_super; | 1027 | goto free_cg_links; |
1028 | } | 1028 | } |
1029 | 1029 | ||
1030 | /* EBUSY should be the only error here */ | 1030 | /* EBUSY should be the only error here */ |
@@ -1073,10 +1073,11 @@ static int cgroup_get_sb(struct file_system_type *fs_type, | |||
1073 | 1073 | ||
1074 | return simple_set_mnt(mnt, sb); | 1074 | return simple_set_mnt(mnt, sb); |
1075 | 1075 | ||
1076 | free_cg_links: | ||
1077 | free_cg_links(&tmp_cg_links); | ||
1076 | drop_new_super: | 1078 | drop_new_super: |
1077 | up_write(&sb->s_umount); | 1079 | up_write(&sb->s_umount); |
1078 | deactivate_super(sb); | 1080 | deactivate_super(sb); |
1079 | free_cg_links(&tmp_cg_links); | ||
1080 | return ret; | 1081 | return ret; |
1081 | } | 1082 | } |
1082 | 1083 | ||
@@ -2934,9 +2935,6 @@ int cgroup_clone(struct task_struct *tsk, struct cgroup_subsys *subsys, | |||
2934 | again: | 2935 | again: |
2935 | root = subsys->root; | 2936 | root = subsys->root; |
2936 | if (root == &rootnode) { | 2937 | if (root == &rootnode) { |
2937 | printk(KERN_INFO | ||
2938 | "Not cloning cgroup for unused subsystem %s\n", | ||
2939 | subsys->name); | ||
2940 | mutex_unlock(&cgroup_mutex); | 2938 | mutex_unlock(&cgroup_mutex); |
2941 | return 0; | 2939 | return 0; |
2942 | } | 2940 | } |
diff --git a/kernel/cpu.c b/kernel/cpu.c index 5a732c5ef08b..8ea32e8d68b0 100644 --- a/kernel/cpu.c +++ b/kernel/cpu.c | |||
@@ -462,7 +462,7 @@ out: | |||
462 | * It must be called by the arch code on the new cpu, before the new cpu | 462 | * It must be called by the arch code on the new cpu, before the new cpu |
463 | * enables interrupts and before the "boot" cpu returns from __cpu_up(). | 463 | * enables interrupts and before the "boot" cpu returns from __cpu_up(). |
464 | */ | 464 | */ |
465 | void notify_cpu_starting(unsigned int cpu) | 465 | void __cpuinit notify_cpu_starting(unsigned int cpu) |
466 | { | 466 | { |
467 | unsigned long val = CPU_STARTING; | 467 | unsigned long val = CPU_STARTING; |
468 | 468 | ||
diff --git a/kernel/cpuset.c b/kernel/cpuset.c index da7ff6137f37..96c0ba13b8cd 100644 --- a/kernel/cpuset.c +++ b/kernel/cpuset.c | |||
@@ -585,7 +585,7 @@ static int generate_sched_domains(cpumask_t **domains, | |||
585 | int i, j, k; /* indices for partition finding loops */ | 585 | int i, j, k; /* indices for partition finding loops */ |
586 | cpumask_t *doms; /* resulting partition; i.e. sched domains */ | 586 | cpumask_t *doms; /* resulting partition; i.e. sched domains */ |
587 | struct sched_domain_attr *dattr; /* attributes for custom domains */ | 587 | struct sched_domain_attr *dattr; /* attributes for custom domains */ |
588 | int ndoms; /* number of sched domains in result */ | 588 | int ndoms = 0; /* number of sched domains in result */ |
589 | int nslot; /* next empty doms[] cpumask_t slot */ | 589 | int nslot; /* next empty doms[] cpumask_t slot */ |
590 | 590 | ||
591 | doms = NULL; | 591 | doms = NULL; |
diff --git a/kernel/exit.c b/kernel/exit.c index 2d8be7ebb0f7..30fcdf16737a 100644 --- a/kernel/exit.c +++ b/kernel/exit.c | |||
@@ -1321,10 +1321,10 @@ static int wait_task_zombie(struct task_struct *p, int options, | |||
1321 | * group, which consolidates times for all threads in the | 1321 | * group, which consolidates times for all threads in the |
1322 | * group including the group leader. | 1322 | * group including the group leader. |
1323 | */ | 1323 | */ |
1324 | thread_group_cputime(p, &cputime); | ||
1324 | spin_lock_irq(&p->parent->sighand->siglock); | 1325 | spin_lock_irq(&p->parent->sighand->siglock); |
1325 | psig = p->parent->signal; | 1326 | psig = p->parent->signal; |
1326 | sig = p->signal; | 1327 | sig = p->signal; |
1327 | thread_group_cputime(p, &cputime); | ||
1328 | psig->cutime = | 1328 | psig->cutime = |
1329 | cputime_add(psig->cutime, | 1329 | cputime_add(psig->cutime, |
1330 | cputime_add(cputime.utime, | 1330 | cputime_add(cputime.utime, |
diff --git a/kernel/fork.c b/kernel/fork.c index 2a372a0e206f..495da2e9a8b4 100644 --- a/kernel/fork.c +++ b/kernel/fork.c | |||
@@ -315,17 +315,20 @@ static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm) | |||
315 | file = tmp->vm_file; | 315 | file = tmp->vm_file; |
316 | if (file) { | 316 | if (file) { |
317 | struct inode *inode = file->f_path.dentry->d_inode; | 317 | struct inode *inode = file->f_path.dentry->d_inode; |
318 | struct address_space *mapping = file->f_mapping; | ||
319 | |||
318 | get_file(file); | 320 | get_file(file); |
319 | if (tmp->vm_flags & VM_DENYWRITE) | 321 | if (tmp->vm_flags & VM_DENYWRITE) |
320 | atomic_dec(&inode->i_writecount); | 322 | atomic_dec(&inode->i_writecount); |
321 | 323 | spin_lock(&mapping->i_mmap_lock); | |
322 | /* insert tmp into the share list, just after mpnt */ | 324 | if (tmp->vm_flags & VM_SHARED) |
323 | spin_lock(&file->f_mapping->i_mmap_lock); | 325 | mapping->i_mmap_writable++; |
324 | tmp->vm_truncate_count = mpnt->vm_truncate_count; | 326 | tmp->vm_truncate_count = mpnt->vm_truncate_count; |
325 | flush_dcache_mmap_lock(file->f_mapping); | 327 | flush_dcache_mmap_lock(mapping); |
328 | /* insert tmp into the share list, just after mpnt */ | ||
326 | vma_prio_tree_add(tmp, mpnt); | 329 | vma_prio_tree_add(tmp, mpnt); |
327 | flush_dcache_mmap_unlock(file->f_mapping); | 330 | flush_dcache_mmap_unlock(mapping); |
328 | spin_unlock(&file->f_mapping->i_mmap_lock); | 331 | spin_unlock(&mapping->i_mmap_lock); |
329 | } | 332 | } |
330 | 333 | ||
331 | /* | 334 | /* |
@@ -1398,6 +1401,7 @@ long do_fork(unsigned long clone_flags, | |||
1398 | init_completion(&vfork); | 1401 | init_completion(&vfork); |
1399 | } | 1402 | } |
1400 | 1403 | ||
1404 | audit_finish_fork(p); | ||
1401 | tracehook_report_clone(trace, regs, clone_flags, nr, p); | 1405 | tracehook_report_clone(trace, regs, clone_flags, nr, p); |
1402 | 1406 | ||
1403 | /* | 1407 | /* |
diff --git a/kernel/futex.c b/kernel/futex.c index 8af10027514b..e10c5c8786a6 100644 --- a/kernel/futex.c +++ b/kernel/futex.c | |||
@@ -123,24 +123,6 @@ struct futex_hash_bucket { | |||
123 | static struct futex_hash_bucket futex_queues[1<<FUTEX_HASHBITS]; | 123 | static struct futex_hash_bucket futex_queues[1<<FUTEX_HASHBITS]; |
124 | 124 | ||
125 | /* | 125 | /* |
126 | * Take mm->mmap_sem, when futex is shared | ||
127 | */ | ||
128 | static inline void futex_lock_mm(struct rw_semaphore *fshared) | ||
129 | { | ||
130 | if (fshared) | ||
131 | down_read(fshared); | ||
132 | } | ||
133 | |||
134 | /* | ||
135 | * Release mm->mmap_sem, when the futex is shared | ||
136 | */ | ||
137 | static inline void futex_unlock_mm(struct rw_semaphore *fshared) | ||
138 | { | ||
139 | if (fshared) | ||
140 | up_read(fshared); | ||
141 | } | ||
142 | |||
143 | /* | ||
144 | * We hash on the keys returned from get_futex_key (see below). | 126 | * We hash on the keys returned from get_futex_key (see below). |
145 | */ | 127 | */ |
146 | static struct futex_hash_bucket *hash_futex(union futex_key *key) | 128 | static struct futex_hash_bucket *hash_futex(union futex_key *key) |
@@ -161,6 +143,45 @@ static inline int match_futex(union futex_key *key1, union futex_key *key2) | |||
161 | && key1->both.offset == key2->both.offset); | 143 | && key1->both.offset == key2->both.offset); |
162 | } | 144 | } |
163 | 145 | ||
146 | /* | ||
147 | * Take a reference to the resource addressed by a key. | ||
148 | * Can be called while holding spinlocks. | ||
149 | * | ||
150 | */ | ||
151 | static void get_futex_key_refs(union futex_key *key) | ||
152 | { | ||
153 | if (!key->both.ptr) | ||
154 | return; | ||
155 | |||
156 | switch (key->both.offset & (FUT_OFF_INODE|FUT_OFF_MMSHARED)) { | ||
157 | case FUT_OFF_INODE: | ||
158 | atomic_inc(&key->shared.inode->i_count); | ||
159 | break; | ||
160 | case FUT_OFF_MMSHARED: | ||
161 | atomic_inc(&key->private.mm->mm_count); | ||
162 | break; | ||
163 | } | ||
164 | } | ||
165 | |||
166 | /* | ||
167 | * Drop a reference to the resource addressed by a key. | ||
168 | * The hash bucket spinlock must not be held. | ||
169 | */ | ||
170 | static void drop_futex_key_refs(union futex_key *key) | ||
171 | { | ||
172 | if (!key->both.ptr) | ||
173 | return; | ||
174 | |||
175 | switch (key->both.offset & (FUT_OFF_INODE|FUT_OFF_MMSHARED)) { | ||
176 | case FUT_OFF_INODE: | ||
177 | iput(key->shared.inode); | ||
178 | break; | ||
179 | case FUT_OFF_MMSHARED: | ||
180 | mmdrop(key->private.mm); | ||
181 | break; | ||
182 | } | ||
183 | } | ||
184 | |||
164 | /** | 185 | /** |
165 | * get_futex_key - Get parameters which are the keys for a futex. | 186 | * get_futex_key - Get parameters which are the keys for a futex. |
166 | * @uaddr: virtual address of the futex | 187 | * @uaddr: virtual address of the futex |
@@ -179,12 +200,10 @@ static inline int match_futex(union futex_key *key1, union futex_key *key2) | |||
179 | * For other futexes, it points to ¤t->mm->mmap_sem and | 200 | * For other futexes, it points to ¤t->mm->mmap_sem and |
180 | * caller must have taken the reader lock. but NOT any spinlocks. | 201 | * caller must have taken the reader lock. but NOT any spinlocks. |
181 | */ | 202 | */ |
182 | static int get_futex_key(u32 __user *uaddr, struct rw_semaphore *fshared, | 203 | static int get_futex_key(u32 __user *uaddr, int fshared, union futex_key *key) |
183 | union futex_key *key) | ||
184 | { | 204 | { |
185 | unsigned long address = (unsigned long)uaddr; | 205 | unsigned long address = (unsigned long)uaddr; |
186 | struct mm_struct *mm = current->mm; | 206 | struct mm_struct *mm = current->mm; |
187 | struct vm_area_struct *vma; | ||
188 | struct page *page; | 207 | struct page *page; |
189 | int err; | 208 | int err; |
190 | 209 | ||
@@ -208,100 +227,50 @@ static int get_futex_key(u32 __user *uaddr, struct rw_semaphore *fshared, | |||
208 | return -EFAULT; | 227 | return -EFAULT; |
209 | key->private.mm = mm; | 228 | key->private.mm = mm; |
210 | key->private.address = address; | 229 | key->private.address = address; |
230 | get_futex_key_refs(key); | ||
211 | return 0; | 231 | return 0; |
212 | } | 232 | } |
213 | /* | ||
214 | * The futex is hashed differently depending on whether | ||
215 | * it's in a shared or private mapping. So check vma first. | ||
216 | */ | ||
217 | vma = find_extend_vma(mm, address); | ||
218 | if (unlikely(!vma)) | ||
219 | return -EFAULT; | ||
220 | 233 | ||
221 | /* | 234 | again: |
222 | * Permissions. | 235 | err = get_user_pages_fast(address, 1, 0, &page); |
223 | */ | 236 | if (err < 0) |
224 | if (unlikely((vma->vm_flags & (VM_IO|VM_READ)) != VM_READ)) | 237 | return err; |
225 | return (vma->vm_flags & VM_IO) ? -EPERM : -EACCES; | 238 | |
239 | lock_page(page); | ||
240 | if (!page->mapping) { | ||
241 | unlock_page(page); | ||
242 | put_page(page); | ||
243 | goto again; | ||
244 | } | ||
226 | 245 | ||
227 | /* | 246 | /* |
228 | * Private mappings are handled in a simple way. | 247 | * Private mappings are handled in a simple way. |
229 | * | 248 | * |
230 | * NOTE: When userspace waits on a MAP_SHARED mapping, even if | 249 | * NOTE: When userspace waits on a MAP_SHARED mapping, even if |
231 | * it's a read-only handle, it's expected that futexes attach to | 250 | * it's a read-only handle, it's expected that futexes attach to |
232 | * the object not the particular process. Therefore we use | 251 | * the object not the particular process. |
233 | * VM_MAYSHARE here, not VM_SHARED which is restricted to shared | ||
234 | * mappings of _writable_ handles. | ||
235 | */ | 252 | */ |
236 | if (likely(!(vma->vm_flags & VM_MAYSHARE))) { | 253 | if (PageAnon(page)) { |
237 | key->both.offset |= FUT_OFF_MMSHARED; /* reference taken on mm */ | 254 | key->both.offset |= FUT_OFF_MMSHARED; /* ref taken on mm */ |
238 | key->private.mm = mm; | 255 | key->private.mm = mm; |
239 | key->private.address = address; | 256 | key->private.address = address; |
240 | return 0; | 257 | } else { |
258 | key->both.offset |= FUT_OFF_INODE; /* inode-based key */ | ||
259 | key->shared.inode = page->mapping->host; | ||
260 | key->shared.pgoff = page->index; | ||
241 | } | 261 | } |
242 | 262 | ||
243 | /* | 263 | get_futex_key_refs(key); |
244 | * Linear file mappings are also simple. | ||
245 | */ | ||
246 | key->shared.inode = vma->vm_file->f_path.dentry->d_inode; | ||
247 | key->both.offset |= FUT_OFF_INODE; /* inode-based key. */ | ||
248 | if (likely(!(vma->vm_flags & VM_NONLINEAR))) { | ||
249 | key->shared.pgoff = (((address - vma->vm_start) >> PAGE_SHIFT) | ||
250 | + vma->vm_pgoff); | ||
251 | return 0; | ||
252 | } | ||
253 | 264 | ||
254 | /* | 265 | unlock_page(page); |
255 | * We could walk the page table to read the non-linear | 266 | put_page(page); |
256 | * pte, and get the page index without fetching the page | 267 | return 0; |
257 | * from swap. But that's a lot of code to duplicate here | ||
258 | * for a rare case, so we simply fetch the page. | ||
259 | */ | ||
260 | err = get_user_pages(current, mm, address, 1, 0, 0, &page, NULL); | ||
261 | if (err >= 0) { | ||
262 | key->shared.pgoff = | ||
263 | page->index << (PAGE_CACHE_SHIFT - PAGE_SHIFT); | ||
264 | put_page(page); | ||
265 | return 0; | ||
266 | } | ||
267 | return err; | ||
268 | } | ||
269 | |||
270 | /* | ||
271 | * Take a reference to the resource addressed by a key. | ||
272 | * Can be called while holding spinlocks. | ||
273 | * | ||
274 | */ | ||
275 | static void get_futex_key_refs(union futex_key *key) | ||
276 | { | ||
277 | if (key->both.ptr == NULL) | ||
278 | return; | ||
279 | switch (key->both.offset & (FUT_OFF_INODE|FUT_OFF_MMSHARED)) { | ||
280 | case FUT_OFF_INODE: | ||
281 | atomic_inc(&key->shared.inode->i_count); | ||
282 | break; | ||
283 | case FUT_OFF_MMSHARED: | ||
284 | atomic_inc(&key->private.mm->mm_count); | ||
285 | break; | ||
286 | } | ||
287 | } | 268 | } |
288 | 269 | ||
289 | /* | 270 | static inline |
290 | * Drop a reference to the resource addressed by a key. | 271 | void put_futex_key(int fshared, union futex_key *key) |
291 | * The hash bucket spinlock must not be held. | ||
292 | */ | ||
293 | static void drop_futex_key_refs(union futex_key *key) | ||
294 | { | 272 | { |
295 | if (!key->both.ptr) | 273 | drop_futex_key_refs(key); |
296 | return; | ||
297 | switch (key->both.offset & (FUT_OFF_INODE|FUT_OFF_MMSHARED)) { | ||
298 | case FUT_OFF_INODE: | ||
299 | iput(key->shared.inode); | ||
300 | break; | ||
301 | case FUT_OFF_MMSHARED: | ||
302 | mmdrop(key->private.mm); | ||
303 | break; | ||
304 | } | ||
305 | } | 274 | } |
306 | 275 | ||
307 | static u32 cmpxchg_futex_value_locked(u32 __user *uaddr, u32 uval, u32 newval) | 276 | static u32 cmpxchg_futex_value_locked(u32 __user *uaddr, u32 uval, u32 newval) |
@@ -328,10 +297,8 @@ static int get_futex_value_locked(u32 *dest, u32 __user *from) | |||
328 | 297 | ||
329 | /* | 298 | /* |
330 | * Fault handling. | 299 | * Fault handling. |
331 | * if fshared is non NULL, current->mm->mmap_sem is already held | ||
332 | */ | 300 | */ |
333 | static int futex_handle_fault(unsigned long address, | 301 | static int futex_handle_fault(unsigned long address, int attempt) |
334 | struct rw_semaphore *fshared, int attempt) | ||
335 | { | 302 | { |
336 | struct vm_area_struct * vma; | 303 | struct vm_area_struct * vma; |
337 | struct mm_struct *mm = current->mm; | 304 | struct mm_struct *mm = current->mm; |
@@ -340,8 +307,7 @@ static int futex_handle_fault(unsigned long address, | |||
340 | if (attempt > 2) | 307 | if (attempt > 2) |
341 | return ret; | 308 | return ret; |
342 | 309 | ||
343 | if (!fshared) | 310 | down_read(&mm->mmap_sem); |
344 | down_read(&mm->mmap_sem); | ||
345 | vma = find_vma(mm, address); | 311 | vma = find_vma(mm, address); |
346 | if (vma && address >= vma->vm_start && | 312 | if (vma && address >= vma->vm_start && |
347 | (vma->vm_flags & VM_WRITE)) { | 313 | (vma->vm_flags & VM_WRITE)) { |
@@ -361,8 +327,7 @@ static int futex_handle_fault(unsigned long address, | |||
361 | current->min_flt++; | 327 | current->min_flt++; |
362 | } | 328 | } |
363 | } | 329 | } |
364 | if (!fshared) | 330 | up_read(&mm->mmap_sem); |
365 | up_read(&mm->mmap_sem); | ||
366 | return ret; | 331 | return ret; |
367 | } | 332 | } |
368 | 333 | ||
@@ -385,6 +350,7 @@ static int refill_pi_state_cache(void) | |||
385 | /* pi_mutex gets initialized later */ | 350 | /* pi_mutex gets initialized later */ |
386 | pi_state->owner = NULL; | 351 | pi_state->owner = NULL; |
387 | atomic_set(&pi_state->refcount, 1); | 352 | atomic_set(&pi_state->refcount, 1); |
353 | pi_state->key = FUTEX_KEY_INIT; | ||
388 | 354 | ||
389 | current->pi_state_cache = pi_state; | 355 | current->pi_state_cache = pi_state; |
390 | 356 | ||
@@ -462,7 +428,7 @@ void exit_pi_state_list(struct task_struct *curr) | |||
462 | struct list_head *next, *head = &curr->pi_state_list; | 428 | struct list_head *next, *head = &curr->pi_state_list; |
463 | struct futex_pi_state *pi_state; | 429 | struct futex_pi_state *pi_state; |
464 | struct futex_hash_bucket *hb; | 430 | struct futex_hash_bucket *hb; |
465 | union futex_key key; | 431 | union futex_key key = FUTEX_KEY_INIT; |
466 | 432 | ||
467 | if (!futex_cmpxchg_enabled) | 433 | if (!futex_cmpxchg_enabled) |
468 | return; | 434 | return; |
@@ -719,20 +685,17 @@ double_lock_hb(struct futex_hash_bucket *hb1, struct futex_hash_bucket *hb2) | |||
719 | * Wake up all waiters hashed on the physical page that is mapped | 685 | * Wake up all waiters hashed on the physical page that is mapped |
720 | * to this virtual address: | 686 | * to this virtual address: |
721 | */ | 687 | */ |
722 | static int futex_wake(u32 __user *uaddr, struct rw_semaphore *fshared, | 688 | static int futex_wake(u32 __user *uaddr, int fshared, int nr_wake, u32 bitset) |
723 | int nr_wake, u32 bitset) | ||
724 | { | 689 | { |
725 | struct futex_hash_bucket *hb; | 690 | struct futex_hash_bucket *hb; |
726 | struct futex_q *this, *next; | 691 | struct futex_q *this, *next; |
727 | struct plist_head *head; | 692 | struct plist_head *head; |
728 | union futex_key key; | 693 | union futex_key key = FUTEX_KEY_INIT; |
729 | int ret; | 694 | int ret; |
730 | 695 | ||
731 | if (!bitset) | 696 | if (!bitset) |
732 | return -EINVAL; | 697 | return -EINVAL; |
733 | 698 | ||
734 | futex_lock_mm(fshared); | ||
735 | |||
736 | ret = get_futex_key(uaddr, fshared, &key); | 699 | ret = get_futex_key(uaddr, fshared, &key); |
737 | if (unlikely(ret != 0)) | 700 | if (unlikely(ret != 0)) |
738 | goto out; | 701 | goto out; |
@@ -760,7 +723,7 @@ static int futex_wake(u32 __user *uaddr, struct rw_semaphore *fshared, | |||
760 | 723 | ||
761 | spin_unlock(&hb->lock); | 724 | spin_unlock(&hb->lock); |
762 | out: | 725 | out: |
763 | futex_unlock_mm(fshared); | 726 | put_futex_key(fshared, &key); |
764 | return ret; | 727 | return ret; |
765 | } | 728 | } |
766 | 729 | ||
@@ -769,19 +732,16 @@ out: | |||
769 | * to this virtual address: | 732 | * to this virtual address: |
770 | */ | 733 | */ |
771 | static int | 734 | static int |
772 | futex_wake_op(u32 __user *uaddr1, struct rw_semaphore *fshared, | 735 | futex_wake_op(u32 __user *uaddr1, int fshared, u32 __user *uaddr2, |
773 | u32 __user *uaddr2, | ||
774 | int nr_wake, int nr_wake2, int op) | 736 | int nr_wake, int nr_wake2, int op) |
775 | { | 737 | { |
776 | union futex_key key1, key2; | 738 | union futex_key key1 = FUTEX_KEY_INIT, key2 = FUTEX_KEY_INIT; |
777 | struct futex_hash_bucket *hb1, *hb2; | 739 | struct futex_hash_bucket *hb1, *hb2; |
778 | struct plist_head *head; | 740 | struct plist_head *head; |
779 | struct futex_q *this, *next; | 741 | struct futex_q *this, *next; |
780 | int ret, op_ret, attempt = 0; | 742 | int ret, op_ret, attempt = 0; |
781 | 743 | ||
782 | retryfull: | 744 | retryfull: |
783 | futex_lock_mm(fshared); | ||
784 | |||
785 | ret = get_futex_key(uaddr1, fshared, &key1); | 745 | ret = get_futex_key(uaddr1, fshared, &key1); |
786 | if (unlikely(ret != 0)) | 746 | if (unlikely(ret != 0)) |
787 | goto out; | 747 | goto out; |
@@ -826,18 +786,12 @@ retry: | |||
826 | */ | 786 | */ |
827 | if (attempt++) { | 787 | if (attempt++) { |
828 | ret = futex_handle_fault((unsigned long)uaddr2, | 788 | ret = futex_handle_fault((unsigned long)uaddr2, |
829 | fshared, attempt); | 789 | attempt); |
830 | if (ret) | 790 | if (ret) |
831 | goto out; | 791 | goto out; |
832 | goto retry; | 792 | goto retry; |
833 | } | 793 | } |
834 | 794 | ||
835 | /* | ||
836 | * If we would have faulted, release mmap_sem, | ||
837 | * fault it in and start all over again. | ||
838 | */ | ||
839 | futex_unlock_mm(fshared); | ||
840 | |||
841 | ret = get_user(dummy, uaddr2); | 795 | ret = get_user(dummy, uaddr2); |
842 | if (ret) | 796 | if (ret) |
843 | return ret; | 797 | return ret; |
@@ -873,7 +827,8 @@ retry: | |||
873 | if (hb1 != hb2) | 827 | if (hb1 != hb2) |
874 | spin_unlock(&hb2->lock); | 828 | spin_unlock(&hb2->lock); |
875 | out: | 829 | out: |
876 | futex_unlock_mm(fshared); | 830 | put_futex_key(fshared, &key2); |
831 | put_futex_key(fshared, &key1); | ||
877 | 832 | ||
878 | return ret; | 833 | return ret; |
879 | } | 834 | } |
@@ -882,19 +837,16 @@ out: | |||
882 | * Requeue all waiters hashed on one physical page to another | 837 | * Requeue all waiters hashed on one physical page to another |
883 | * physical page. | 838 | * physical page. |
884 | */ | 839 | */ |
885 | static int futex_requeue(u32 __user *uaddr1, struct rw_semaphore *fshared, | 840 | static int futex_requeue(u32 __user *uaddr1, int fshared, u32 __user *uaddr2, |
886 | u32 __user *uaddr2, | ||
887 | int nr_wake, int nr_requeue, u32 *cmpval) | 841 | int nr_wake, int nr_requeue, u32 *cmpval) |
888 | { | 842 | { |
889 | union futex_key key1, key2; | 843 | union futex_key key1 = FUTEX_KEY_INIT, key2 = FUTEX_KEY_INIT; |
890 | struct futex_hash_bucket *hb1, *hb2; | 844 | struct futex_hash_bucket *hb1, *hb2; |
891 | struct plist_head *head1; | 845 | struct plist_head *head1; |
892 | struct futex_q *this, *next; | 846 | struct futex_q *this, *next; |
893 | int ret, drop_count = 0; | 847 | int ret, drop_count = 0; |
894 | 848 | ||
895 | retry: | 849 | retry: |
896 | futex_lock_mm(fshared); | ||
897 | |||
898 | ret = get_futex_key(uaddr1, fshared, &key1); | 850 | ret = get_futex_key(uaddr1, fshared, &key1); |
899 | if (unlikely(ret != 0)) | 851 | if (unlikely(ret != 0)) |
900 | goto out; | 852 | goto out; |
@@ -917,12 +869,6 @@ static int futex_requeue(u32 __user *uaddr1, struct rw_semaphore *fshared, | |||
917 | if (hb1 != hb2) | 869 | if (hb1 != hb2) |
918 | spin_unlock(&hb2->lock); | 870 | spin_unlock(&hb2->lock); |
919 | 871 | ||
920 | /* | ||
921 | * If we would have faulted, release mmap_sem, fault | ||
922 | * it in and start all over again. | ||
923 | */ | ||
924 | futex_unlock_mm(fshared); | ||
925 | |||
926 | ret = get_user(curval, uaddr1); | 872 | ret = get_user(curval, uaddr1); |
927 | 873 | ||
928 | if (!ret) | 874 | if (!ret) |
@@ -974,7 +920,8 @@ out_unlock: | |||
974 | drop_futex_key_refs(&key1); | 920 | drop_futex_key_refs(&key1); |
975 | 921 | ||
976 | out: | 922 | out: |
977 | futex_unlock_mm(fshared); | 923 | put_futex_key(fshared, &key2); |
924 | put_futex_key(fshared, &key1); | ||
978 | return ret; | 925 | return ret; |
979 | } | 926 | } |
980 | 927 | ||
@@ -1096,8 +1043,7 @@ static void unqueue_me_pi(struct futex_q *q) | |||
1096 | * private futexes. | 1043 | * private futexes. |
1097 | */ | 1044 | */ |
1098 | static int fixup_pi_state_owner(u32 __user *uaddr, struct futex_q *q, | 1045 | static int fixup_pi_state_owner(u32 __user *uaddr, struct futex_q *q, |
1099 | struct task_struct *newowner, | 1046 | struct task_struct *newowner, int fshared) |
1100 | struct rw_semaphore *fshared) | ||
1101 | { | 1047 | { |
1102 | u32 newtid = task_pid_vnr(newowner) | FUTEX_WAITERS; | 1048 | u32 newtid = task_pid_vnr(newowner) | FUTEX_WAITERS; |
1103 | struct futex_pi_state *pi_state = q->pi_state; | 1049 | struct futex_pi_state *pi_state = q->pi_state; |
@@ -1176,7 +1122,7 @@ retry: | |||
1176 | handle_fault: | 1122 | handle_fault: |
1177 | spin_unlock(q->lock_ptr); | 1123 | spin_unlock(q->lock_ptr); |
1178 | 1124 | ||
1179 | ret = futex_handle_fault((unsigned long)uaddr, fshared, attempt++); | 1125 | ret = futex_handle_fault((unsigned long)uaddr, attempt++); |
1180 | 1126 | ||
1181 | spin_lock(q->lock_ptr); | 1127 | spin_lock(q->lock_ptr); |
1182 | 1128 | ||
@@ -1200,7 +1146,7 @@ handle_fault: | |||
1200 | 1146 | ||
1201 | static long futex_wait_restart(struct restart_block *restart); | 1147 | static long futex_wait_restart(struct restart_block *restart); |
1202 | 1148 | ||
1203 | static int futex_wait(u32 __user *uaddr, struct rw_semaphore *fshared, | 1149 | static int futex_wait(u32 __user *uaddr, int fshared, |
1204 | u32 val, ktime_t *abs_time, u32 bitset) | 1150 | u32 val, ktime_t *abs_time, u32 bitset) |
1205 | { | 1151 | { |
1206 | struct task_struct *curr = current; | 1152 | struct task_struct *curr = current; |
@@ -1218,8 +1164,7 @@ static int futex_wait(u32 __user *uaddr, struct rw_semaphore *fshared, | |||
1218 | q.pi_state = NULL; | 1164 | q.pi_state = NULL; |
1219 | q.bitset = bitset; | 1165 | q.bitset = bitset; |
1220 | retry: | 1166 | retry: |
1221 | futex_lock_mm(fshared); | 1167 | q.key = FUTEX_KEY_INIT; |
1222 | |||
1223 | ret = get_futex_key(uaddr, fshared, &q.key); | 1168 | ret = get_futex_key(uaddr, fshared, &q.key); |
1224 | if (unlikely(ret != 0)) | 1169 | if (unlikely(ret != 0)) |
1225 | goto out_release_sem; | 1170 | goto out_release_sem; |
@@ -1251,12 +1196,6 @@ static int futex_wait(u32 __user *uaddr, struct rw_semaphore *fshared, | |||
1251 | if (unlikely(ret)) { | 1196 | if (unlikely(ret)) { |
1252 | queue_unlock(&q, hb); | 1197 | queue_unlock(&q, hb); |
1253 | 1198 | ||
1254 | /* | ||
1255 | * If we would have faulted, release mmap_sem, fault it in and | ||
1256 | * start all over again. | ||
1257 | */ | ||
1258 | futex_unlock_mm(fshared); | ||
1259 | |||
1260 | ret = get_user(uval, uaddr); | 1199 | ret = get_user(uval, uaddr); |
1261 | 1200 | ||
1262 | if (!ret) | 1201 | if (!ret) |
@@ -1271,12 +1210,6 @@ static int futex_wait(u32 __user *uaddr, struct rw_semaphore *fshared, | |||
1271 | queue_me(&q, hb); | 1210 | queue_me(&q, hb); |
1272 | 1211 | ||
1273 | /* | 1212 | /* |
1274 | * Now the futex is queued and we have checked the data, we | ||
1275 | * don't want to hold mmap_sem while we sleep. | ||
1276 | */ | ||
1277 | futex_unlock_mm(fshared); | ||
1278 | |||
1279 | /* | ||
1280 | * There might have been scheduling since the queue_me(), as we | 1213 | * There might have been scheduling since the queue_me(), as we |
1281 | * cannot hold a spinlock across the get_user() in case it | 1214 | * cannot hold a spinlock across the get_user() in case it |
1282 | * faults, and we cannot just set TASK_INTERRUPTIBLE state when | 1215 | * faults, and we cannot just set TASK_INTERRUPTIBLE state when |
@@ -1363,7 +1296,7 @@ static int futex_wait(u32 __user *uaddr, struct rw_semaphore *fshared, | |||
1363 | queue_unlock(&q, hb); | 1296 | queue_unlock(&q, hb); |
1364 | 1297 | ||
1365 | out_release_sem: | 1298 | out_release_sem: |
1366 | futex_unlock_mm(fshared); | 1299 | put_futex_key(fshared, &q.key); |
1367 | return ret; | 1300 | return ret; |
1368 | } | 1301 | } |
1369 | 1302 | ||
@@ -1371,13 +1304,13 @@ static int futex_wait(u32 __user *uaddr, struct rw_semaphore *fshared, | |||
1371 | static long futex_wait_restart(struct restart_block *restart) | 1304 | static long futex_wait_restart(struct restart_block *restart) |
1372 | { | 1305 | { |
1373 | u32 __user *uaddr = (u32 __user *)restart->futex.uaddr; | 1306 | u32 __user *uaddr = (u32 __user *)restart->futex.uaddr; |
1374 | struct rw_semaphore *fshared = NULL; | 1307 | int fshared = 0; |
1375 | ktime_t t; | 1308 | ktime_t t; |
1376 | 1309 | ||
1377 | t.tv64 = restart->futex.time; | 1310 | t.tv64 = restart->futex.time; |
1378 | restart->fn = do_no_restart_syscall; | 1311 | restart->fn = do_no_restart_syscall; |
1379 | if (restart->futex.flags & FLAGS_SHARED) | 1312 | if (restart->futex.flags & FLAGS_SHARED) |
1380 | fshared = ¤t->mm->mmap_sem; | 1313 | fshared = 1; |
1381 | return (long)futex_wait(uaddr, fshared, restart->futex.val, &t, | 1314 | return (long)futex_wait(uaddr, fshared, restart->futex.val, &t, |
1382 | restart->futex.bitset); | 1315 | restart->futex.bitset); |
1383 | } | 1316 | } |
@@ -1389,7 +1322,7 @@ static long futex_wait_restart(struct restart_block *restart) | |||
1389 | * if there are waiters then it will block, it does PI, etc. (Due to | 1322 | * if there are waiters then it will block, it does PI, etc. (Due to |
1390 | * races the kernel might see a 0 value of the futex too.) | 1323 | * races the kernel might see a 0 value of the futex too.) |
1391 | */ | 1324 | */ |
1392 | static int futex_lock_pi(u32 __user *uaddr, struct rw_semaphore *fshared, | 1325 | static int futex_lock_pi(u32 __user *uaddr, int fshared, |
1393 | int detect, ktime_t *time, int trylock) | 1326 | int detect, ktime_t *time, int trylock) |
1394 | { | 1327 | { |
1395 | struct hrtimer_sleeper timeout, *to = NULL; | 1328 | struct hrtimer_sleeper timeout, *to = NULL; |
@@ -1412,8 +1345,7 @@ static int futex_lock_pi(u32 __user *uaddr, struct rw_semaphore *fshared, | |||
1412 | 1345 | ||
1413 | q.pi_state = NULL; | 1346 | q.pi_state = NULL; |
1414 | retry: | 1347 | retry: |
1415 | futex_lock_mm(fshared); | 1348 | q.key = FUTEX_KEY_INIT; |
1416 | |||
1417 | ret = get_futex_key(uaddr, fshared, &q.key); | 1349 | ret = get_futex_key(uaddr, fshared, &q.key); |
1418 | if (unlikely(ret != 0)) | 1350 | if (unlikely(ret != 0)) |
1419 | goto out_release_sem; | 1351 | goto out_release_sem; |
@@ -1502,7 +1434,6 @@ static int futex_lock_pi(u32 __user *uaddr, struct rw_semaphore *fshared, | |||
1502 | * exit to complete. | 1434 | * exit to complete. |
1503 | */ | 1435 | */ |
1504 | queue_unlock(&q, hb); | 1436 | queue_unlock(&q, hb); |
1505 | futex_unlock_mm(fshared); | ||
1506 | cond_resched(); | 1437 | cond_resched(); |
1507 | goto retry; | 1438 | goto retry; |
1508 | 1439 | ||
@@ -1534,12 +1465,6 @@ static int futex_lock_pi(u32 __user *uaddr, struct rw_semaphore *fshared, | |||
1534 | */ | 1465 | */ |
1535 | queue_me(&q, hb); | 1466 | queue_me(&q, hb); |
1536 | 1467 | ||
1537 | /* | ||
1538 | * Now the futex is queued and we have checked the data, we | ||
1539 | * don't want to hold mmap_sem while we sleep. | ||
1540 | */ | ||
1541 | futex_unlock_mm(fshared); | ||
1542 | |||
1543 | WARN_ON(!q.pi_state); | 1468 | WARN_ON(!q.pi_state); |
1544 | /* | 1469 | /* |
1545 | * Block on the PI mutex: | 1470 | * Block on the PI mutex: |
@@ -1552,7 +1477,6 @@ static int futex_lock_pi(u32 __user *uaddr, struct rw_semaphore *fshared, | |||
1552 | ret = ret ? 0 : -EWOULDBLOCK; | 1477 | ret = ret ? 0 : -EWOULDBLOCK; |
1553 | } | 1478 | } |
1554 | 1479 | ||
1555 | futex_lock_mm(fshared); | ||
1556 | spin_lock(q.lock_ptr); | 1480 | spin_lock(q.lock_ptr); |
1557 | 1481 | ||
1558 | if (!ret) { | 1482 | if (!ret) { |
@@ -1618,7 +1542,6 @@ static int futex_lock_pi(u32 __user *uaddr, struct rw_semaphore *fshared, | |||
1618 | 1542 | ||
1619 | /* Unqueue and drop the lock */ | 1543 | /* Unqueue and drop the lock */ |
1620 | unqueue_me_pi(&q); | 1544 | unqueue_me_pi(&q); |
1621 | futex_unlock_mm(fshared); | ||
1622 | 1545 | ||
1623 | if (to) | 1546 | if (to) |
1624 | destroy_hrtimer_on_stack(&to->timer); | 1547 | destroy_hrtimer_on_stack(&to->timer); |
@@ -1628,7 +1551,7 @@ static int futex_lock_pi(u32 __user *uaddr, struct rw_semaphore *fshared, | |||
1628 | queue_unlock(&q, hb); | 1551 | queue_unlock(&q, hb); |
1629 | 1552 | ||
1630 | out_release_sem: | 1553 | out_release_sem: |
1631 | futex_unlock_mm(fshared); | 1554 | put_futex_key(fshared, &q.key); |
1632 | if (to) | 1555 | if (to) |
1633 | destroy_hrtimer_on_stack(&to->timer); | 1556 | destroy_hrtimer_on_stack(&to->timer); |
1634 | return ret; | 1557 | return ret; |
@@ -1645,15 +1568,12 @@ static int futex_lock_pi(u32 __user *uaddr, struct rw_semaphore *fshared, | |||
1645 | queue_unlock(&q, hb); | 1568 | queue_unlock(&q, hb); |
1646 | 1569 | ||
1647 | if (attempt++) { | 1570 | if (attempt++) { |
1648 | ret = futex_handle_fault((unsigned long)uaddr, fshared, | 1571 | ret = futex_handle_fault((unsigned long)uaddr, attempt); |
1649 | attempt); | ||
1650 | if (ret) | 1572 | if (ret) |
1651 | goto out_release_sem; | 1573 | goto out_release_sem; |
1652 | goto retry_unlocked; | 1574 | goto retry_unlocked; |
1653 | } | 1575 | } |
1654 | 1576 | ||
1655 | futex_unlock_mm(fshared); | ||
1656 | |||
1657 | ret = get_user(uval, uaddr); | 1577 | ret = get_user(uval, uaddr); |
1658 | if (!ret && (uval != -EFAULT)) | 1578 | if (!ret && (uval != -EFAULT)) |
1659 | goto retry; | 1579 | goto retry; |
@@ -1668,13 +1588,13 @@ static int futex_lock_pi(u32 __user *uaddr, struct rw_semaphore *fshared, | |||
1668 | * This is the in-kernel slowpath: we look up the PI state (if any), | 1588 | * This is the in-kernel slowpath: we look up the PI state (if any), |
1669 | * and do the rt-mutex unlock. | 1589 | * and do the rt-mutex unlock. |
1670 | */ | 1590 | */ |
1671 | static int futex_unlock_pi(u32 __user *uaddr, struct rw_semaphore *fshared) | 1591 | static int futex_unlock_pi(u32 __user *uaddr, int fshared) |
1672 | { | 1592 | { |
1673 | struct futex_hash_bucket *hb; | 1593 | struct futex_hash_bucket *hb; |
1674 | struct futex_q *this, *next; | 1594 | struct futex_q *this, *next; |
1675 | u32 uval; | 1595 | u32 uval; |
1676 | struct plist_head *head; | 1596 | struct plist_head *head; |
1677 | union futex_key key; | 1597 | union futex_key key = FUTEX_KEY_INIT; |
1678 | int ret, attempt = 0; | 1598 | int ret, attempt = 0; |
1679 | 1599 | ||
1680 | retry: | 1600 | retry: |
@@ -1685,10 +1605,6 @@ retry: | |||
1685 | */ | 1605 | */ |
1686 | if ((uval & FUTEX_TID_MASK) != task_pid_vnr(current)) | 1606 | if ((uval & FUTEX_TID_MASK) != task_pid_vnr(current)) |
1687 | return -EPERM; | 1607 | return -EPERM; |
1688 | /* | ||
1689 | * First take all the futex related locks: | ||
1690 | */ | ||
1691 | futex_lock_mm(fshared); | ||
1692 | 1608 | ||
1693 | ret = get_futex_key(uaddr, fshared, &key); | 1609 | ret = get_futex_key(uaddr, fshared, &key); |
1694 | if (unlikely(ret != 0)) | 1610 | if (unlikely(ret != 0)) |
@@ -1747,7 +1663,7 @@ retry_unlocked: | |||
1747 | out_unlock: | 1663 | out_unlock: |
1748 | spin_unlock(&hb->lock); | 1664 | spin_unlock(&hb->lock); |
1749 | out: | 1665 | out: |
1750 | futex_unlock_mm(fshared); | 1666 | put_futex_key(fshared, &key); |
1751 | 1667 | ||
1752 | return ret; | 1668 | return ret; |
1753 | 1669 | ||
@@ -1763,16 +1679,13 @@ pi_faulted: | |||
1763 | spin_unlock(&hb->lock); | 1679 | spin_unlock(&hb->lock); |
1764 | 1680 | ||
1765 | if (attempt++) { | 1681 | if (attempt++) { |
1766 | ret = futex_handle_fault((unsigned long)uaddr, fshared, | 1682 | ret = futex_handle_fault((unsigned long)uaddr, attempt); |
1767 | attempt); | ||
1768 | if (ret) | 1683 | if (ret) |
1769 | goto out; | 1684 | goto out; |
1770 | uval = 0; | 1685 | uval = 0; |
1771 | goto retry_unlocked; | 1686 | goto retry_unlocked; |
1772 | } | 1687 | } |
1773 | 1688 | ||
1774 | futex_unlock_mm(fshared); | ||
1775 | |||
1776 | ret = get_user(uval, uaddr); | 1689 | ret = get_user(uval, uaddr); |
1777 | if (!ret && (uval != -EFAULT)) | 1690 | if (!ret && (uval != -EFAULT)) |
1778 | goto retry; | 1691 | goto retry; |
@@ -1898,8 +1811,7 @@ retry: | |||
1898 | * PI futexes happens in exit_pi_state(): | 1811 | * PI futexes happens in exit_pi_state(): |
1899 | */ | 1812 | */ |
1900 | if (!pi && (uval & FUTEX_WAITERS)) | 1813 | if (!pi && (uval & FUTEX_WAITERS)) |
1901 | futex_wake(uaddr, &curr->mm->mmap_sem, 1, | 1814 | futex_wake(uaddr, 1, 1, FUTEX_BITSET_MATCH_ANY); |
1902 | FUTEX_BITSET_MATCH_ANY); | ||
1903 | } | 1815 | } |
1904 | return 0; | 1816 | return 0; |
1905 | } | 1817 | } |
@@ -1995,10 +1907,10 @@ long do_futex(u32 __user *uaddr, int op, u32 val, ktime_t *timeout, | |||
1995 | { | 1907 | { |
1996 | int ret = -ENOSYS; | 1908 | int ret = -ENOSYS; |
1997 | int cmd = op & FUTEX_CMD_MASK; | 1909 | int cmd = op & FUTEX_CMD_MASK; |
1998 | struct rw_semaphore *fshared = NULL; | 1910 | int fshared = 0; |
1999 | 1911 | ||
2000 | if (!(op & FUTEX_PRIVATE_FLAG)) | 1912 | if (!(op & FUTEX_PRIVATE_FLAG)) |
2001 | fshared = ¤t->mm->mmap_sem; | 1913 | fshared = 1; |
2002 | 1914 | ||
2003 | switch (cmd) { | 1915 | switch (cmd) { |
2004 | case FUTEX_WAIT: | 1916 | case FUTEX_WAIT: |
diff --git a/kernel/irq/internals.h b/kernel/irq/internals.h index c9767e641980..64c1c7253dae 100644 --- a/kernel/irq/internals.h +++ b/kernel/irq/internals.h | |||
@@ -25,6 +25,8 @@ static inline void unregister_handler_proc(unsigned int irq, | |||
25 | struct irqaction *action) { } | 25 | struct irqaction *action) { } |
26 | #endif | 26 | #endif |
27 | 27 | ||
28 | extern int irq_select_affinity_usr(unsigned int irq); | ||
29 | |||
28 | /* | 30 | /* |
29 | * Debugging printout: | 31 | * Debugging printout: |
30 | */ | 32 | */ |
diff --git a/kernel/irq/manage.c b/kernel/irq/manage.c index c498a1b8c621..801addda3c43 100644 --- a/kernel/irq/manage.c +++ b/kernel/irq/manage.c | |||
@@ -82,24 +82,27 @@ int irq_can_set_affinity(unsigned int irq) | |||
82 | int irq_set_affinity(unsigned int irq, cpumask_t cpumask) | 82 | int irq_set_affinity(unsigned int irq, cpumask_t cpumask) |
83 | { | 83 | { |
84 | struct irq_desc *desc = irq_to_desc(irq); | 84 | struct irq_desc *desc = irq_to_desc(irq); |
85 | unsigned long flags; | ||
85 | 86 | ||
86 | if (!desc->chip->set_affinity) | 87 | if (!desc->chip->set_affinity) |
87 | return -EINVAL; | 88 | return -EINVAL; |
88 | 89 | ||
90 | spin_lock_irqsave(&desc->lock, flags); | ||
91 | |||
89 | #ifdef CONFIG_GENERIC_PENDING_IRQ | 92 | #ifdef CONFIG_GENERIC_PENDING_IRQ |
90 | if (desc->status & IRQ_MOVE_PCNTXT || desc->status & IRQ_DISABLED) { | 93 | if (desc->status & IRQ_MOVE_PCNTXT || desc->status & IRQ_DISABLED) { |
91 | unsigned long flags; | ||
92 | |||
93 | spin_lock_irqsave(&desc->lock, flags); | ||
94 | desc->affinity = cpumask; | 94 | desc->affinity = cpumask; |
95 | desc->chip->set_affinity(irq, cpumask); | 95 | desc->chip->set_affinity(irq, cpumask); |
96 | spin_unlock_irqrestore(&desc->lock, flags); | 96 | } else { |
97 | } else | 97 | desc->status |= IRQ_MOVE_PENDING; |
98 | set_pending_irq(irq, cpumask); | 98 | desc->pending_mask = cpumask; |
99 | } | ||
99 | #else | 100 | #else |
100 | desc->affinity = cpumask; | 101 | desc->affinity = cpumask; |
101 | desc->chip->set_affinity(irq, cpumask); | 102 | desc->chip->set_affinity(irq, cpumask); |
102 | #endif | 103 | #endif |
104 | desc->status |= IRQ_AFFINITY_SET; | ||
105 | spin_unlock_irqrestore(&desc->lock, flags); | ||
103 | return 0; | 106 | return 0; |
104 | } | 107 | } |
105 | 108 | ||
@@ -107,24 +110,59 @@ int irq_set_affinity(unsigned int irq, cpumask_t cpumask) | |||
107 | /* | 110 | /* |
108 | * Generic version of the affinity autoselector. | 111 | * Generic version of the affinity autoselector. |
109 | */ | 112 | */ |
110 | int irq_select_affinity(unsigned int irq) | 113 | int do_irq_select_affinity(unsigned int irq, struct irq_desc *desc) |
111 | { | 114 | { |
112 | cpumask_t mask; | 115 | cpumask_t mask; |
113 | struct irq_desc *desc; | ||
114 | 116 | ||
115 | if (!irq_can_set_affinity(irq)) | 117 | if (!irq_can_set_affinity(irq)) |
116 | return 0; | 118 | return 0; |
117 | 119 | ||
118 | cpus_and(mask, cpu_online_map, irq_default_affinity); | 120 | cpus_and(mask, cpu_online_map, irq_default_affinity); |
119 | 121 | ||
120 | desc = irq_to_desc(irq); | 122 | /* |
123 | * Preserve an userspace affinity setup, but make sure that | ||
124 | * one of the targets is online. | ||
125 | */ | ||
126 | if (desc->status & (IRQ_AFFINITY_SET | IRQ_NO_BALANCING)) { | ||
127 | if (cpus_intersects(desc->affinity, cpu_online_map)) | ||
128 | mask = desc->affinity; | ||
129 | else | ||
130 | desc->status &= ~IRQ_AFFINITY_SET; | ||
131 | } | ||
132 | |||
121 | desc->affinity = mask; | 133 | desc->affinity = mask; |
122 | desc->chip->set_affinity(irq, mask); | 134 | desc->chip->set_affinity(irq, mask); |
123 | 135 | ||
124 | return 0; | 136 | return 0; |
125 | } | 137 | } |
138 | #else | ||
139 | static inline int do_irq_select_affinity(unsigned int irq, struct irq_desc *d) | ||
140 | { | ||
141 | return irq_select_affinity(irq); | ||
142 | } | ||
126 | #endif | 143 | #endif |
127 | 144 | ||
145 | /* | ||
146 | * Called when affinity is set via /proc/irq | ||
147 | */ | ||
148 | int irq_select_affinity_usr(unsigned int irq) | ||
149 | { | ||
150 | struct irq_desc *desc = irq_to_desc(irq); | ||
151 | unsigned long flags; | ||
152 | int ret; | ||
153 | |||
154 | spin_lock_irqsave(&desc->lock, flags); | ||
155 | ret = do_irq_select_affinity(irq, desc); | ||
156 | spin_unlock_irqrestore(&desc->lock, flags); | ||
157 | |||
158 | return ret; | ||
159 | } | ||
160 | |||
161 | #else | ||
162 | static inline int do_irq_select_affinity(int irq, struct irq_desc *desc) | ||
163 | { | ||
164 | return 0; | ||
165 | } | ||
128 | #endif | 166 | #endif |
129 | 167 | ||
130 | /** | 168 | /** |
@@ -327,7 +365,7 @@ int __irq_set_trigger(struct irq_desc *desc, unsigned int irq, | |||
327 | * IRQF_TRIGGER_* but the PIC does not support multiple | 365 | * IRQF_TRIGGER_* but the PIC does not support multiple |
328 | * flow-types? | 366 | * flow-types? |
329 | */ | 367 | */ |
330 | pr_warning("No set_type function for IRQ %d (%s)\n", irq, | 368 | pr_debug("No set_type function for IRQ %d (%s)\n", irq, |
331 | chip ? (chip->name ? : "unknown") : "unknown"); | 369 | chip ? (chip->name ? : "unknown") : "unknown"); |
332 | return 0; | 370 | return 0; |
333 | } | 371 | } |
@@ -445,8 +483,12 @@ __setup_irq(unsigned int irq, struct irq_desc * desc, struct irqaction *new) | |||
445 | /* Undo nested disables: */ | 483 | /* Undo nested disables: */ |
446 | desc->depth = 1; | 484 | desc->depth = 1; |
447 | 485 | ||
486 | /* Exclude IRQ from balancing if requested */ | ||
487 | if (new->flags & IRQF_NOBALANCING) | ||
488 | desc->status |= IRQ_NO_BALANCING; | ||
489 | |||
448 | /* Set default affinity mask once everything is setup */ | 490 | /* Set default affinity mask once everything is setup */ |
449 | irq_select_affinity(irq); | 491 | do_irq_select_affinity(irq, desc); |
450 | 492 | ||
451 | } else if ((new->flags & IRQF_TRIGGER_MASK) | 493 | } else if ((new->flags & IRQF_TRIGGER_MASK) |
452 | && (new->flags & IRQF_TRIGGER_MASK) | 494 | && (new->flags & IRQF_TRIGGER_MASK) |
@@ -459,10 +501,6 @@ __setup_irq(unsigned int irq, struct irq_desc * desc, struct irqaction *new) | |||
459 | 501 | ||
460 | *p = new; | 502 | *p = new; |
461 | 503 | ||
462 | /* Exclude IRQ from balancing */ | ||
463 | if (new->flags & IRQF_NOBALANCING) | ||
464 | desc->status |= IRQ_NO_BALANCING; | ||
465 | |||
466 | /* Reset broken irq detection when installing new handler */ | 504 | /* Reset broken irq detection when installing new handler */ |
467 | desc->irq_count = 0; | 505 | desc->irq_count = 0; |
468 | desc->irqs_unhandled = 0; | 506 | desc->irqs_unhandled = 0; |
diff --git a/kernel/irq/migration.c b/kernel/irq/migration.c index 90b920d3f52b..9db681d95814 100644 --- a/kernel/irq/migration.c +++ b/kernel/irq/migration.c | |||
@@ -1,17 +1,6 @@ | |||
1 | 1 | ||
2 | #include <linux/irq.h> | 2 | #include <linux/irq.h> |
3 | 3 | ||
4 | void set_pending_irq(unsigned int irq, cpumask_t mask) | ||
5 | { | ||
6 | struct irq_desc *desc = irq_to_desc(irq); | ||
7 | unsigned long flags; | ||
8 | |||
9 | spin_lock_irqsave(&desc->lock, flags); | ||
10 | desc->status |= IRQ_MOVE_PENDING; | ||
11 | desc->pending_mask = mask; | ||
12 | spin_unlock_irqrestore(&desc->lock, flags); | ||
13 | } | ||
14 | |||
15 | void move_masked_irq(int irq) | 4 | void move_masked_irq(int irq) |
16 | { | 5 | { |
17 | struct irq_desc *desc = irq_to_desc(irq); | 6 | struct irq_desc *desc = irq_to_desc(irq); |
diff --git a/kernel/irq/proc.c b/kernel/irq/proc.c index 4d161c70ba55..d257e7d6a8a4 100644 --- a/kernel/irq/proc.c +++ b/kernel/irq/proc.c | |||
@@ -62,7 +62,7 @@ static ssize_t irq_affinity_proc_write(struct file *file, | |||
62 | if (!cpus_intersects(new_value, cpu_online_map)) | 62 | if (!cpus_intersects(new_value, cpu_online_map)) |
63 | /* Special case for empty set - allow the architecture | 63 | /* Special case for empty set - allow the architecture |
64 | code to set default SMP affinity. */ | 64 | code to set default SMP affinity. */ |
65 | return irq_select_affinity(irq) ? -EINVAL : count; | 65 | return irq_select_affinity_usr(irq) ? -EINVAL : count; |
66 | 66 | ||
67 | irq_set_affinity(irq, new_value); | 67 | irq_set_affinity(irq, new_value); |
68 | 68 | ||
diff --git a/kernel/latencytop.c b/kernel/latencytop.c index 5e7b45c56923..449db466bdbc 100644 --- a/kernel/latencytop.c +++ b/kernel/latencytop.c | |||
@@ -191,7 +191,7 @@ static int lstats_show(struct seq_file *m, void *v) | |||
191 | latency_record[i].time, | 191 | latency_record[i].time, |
192 | latency_record[i].max); | 192 | latency_record[i].max); |
193 | for (q = 0; q < LT_BACKTRACEDEPTH; q++) { | 193 | for (q = 0; q < LT_BACKTRACEDEPTH; q++) { |
194 | char sym[KSYM_NAME_LEN]; | 194 | char sym[KSYM_SYMBOL_LEN]; |
195 | char *c; | 195 | char *c; |
196 | if (!latency_record[i].backtrace[q]) | 196 | if (!latency_record[i].backtrace[q]) |
197 | break; | 197 | break; |
diff --git a/kernel/lockdep.c b/kernel/lockdep.c index 06e157119d2b..e4bdda8dcf04 100644 --- a/kernel/lockdep.c +++ b/kernel/lockdep.c | |||
@@ -136,16 +136,16 @@ static inline struct lock_class *hlock_class(struct held_lock *hlock) | |||
136 | #ifdef CONFIG_LOCK_STAT | 136 | #ifdef CONFIG_LOCK_STAT |
137 | static DEFINE_PER_CPU(struct lock_class_stats[MAX_LOCKDEP_KEYS], lock_stats); | 137 | static DEFINE_PER_CPU(struct lock_class_stats[MAX_LOCKDEP_KEYS], lock_stats); |
138 | 138 | ||
139 | static int lock_contention_point(struct lock_class *class, unsigned long ip) | 139 | static int lock_point(unsigned long points[], unsigned long ip) |
140 | { | 140 | { |
141 | int i; | 141 | int i; |
142 | 142 | ||
143 | for (i = 0; i < ARRAY_SIZE(class->contention_point); i++) { | 143 | for (i = 0; i < LOCKSTAT_POINTS; i++) { |
144 | if (class->contention_point[i] == 0) { | 144 | if (points[i] == 0) { |
145 | class->contention_point[i] = ip; | 145 | points[i] = ip; |
146 | break; | 146 | break; |
147 | } | 147 | } |
148 | if (class->contention_point[i] == ip) | 148 | if (points[i] == ip) |
149 | break; | 149 | break; |
150 | } | 150 | } |
151 | 151 | ||
@@ -185,6 +185,9 @@ struct lock_class_stats lock_stats(struct lock_class *class) | |||
185 | for (i = 0; i < ARRAY_SIZE(stats.contention_point); i++) | 185 | for (i = 0; i < ARRAY_SIZE(stats.contention_point); i++) |
186 | stats.contention_point[i] += pcs->contention_point[i]; | 186 | stats.contention_point[i] += pcs->contention_point[i]; |
187 | 187 | ||
188 | for (i = 0; i < ARRAY_SIZE(stats.contending_point); i++) | ||
189 | stats.contending_point[i] += pcs->contending_point[i]; | ||
190 | |||
188 | lock_time_add(&pcs->read_waittime, &stats.read_waittime); | 191 | lock_time_add(&pcs->read_waittime, &stats.read_waittime); |
189 | lock_time_add(&pcs->write_waittime, &stats.write_waittime); | 192 | lock_time_add(&pcs->write_waittime, &stats.write_waittime); |
190 | 193 | ||
@@ -209,6 +212,7 @@ void clear_lock_stats(struct lock_class *class) | |||
209 | memset(cpu_stats, 0, sizeof(struct lock_class_stats)); | 212 | memset(cpu_stats, 0, sizeof(struct lock_class_stats)); |
210 | } | 213 | } |
211 | memset(class->contention_point, 0, sizeof(class->contention_point)); | 214 | memset(class->contention_point, 0, sizeof(class->contention_point)); |
215 | memset(class->contending_point, 0, sizeof(class->contending_point)); | ||
212 | } | 216 | } |
213 | 217 | ||
214 | static struct lock_class_stats *get_lock_stats(struct lock_class *class) | 218 | static struct lock_class_stats *get_lock_stats(struct lock_class *class) |
@@ -2999,7 +3003,7 @@ __lock_contended(struct lockdep_map *lock, unsigned long ip) | |||
2999 | struct held_lock *hlock, *prev_hlock; | 3003 | struct held_lock *hlock, *prev_hlock; |
3000 | struct lock_class_stats *stats; | 3004 | struct lock_class_stats *stats; |
3001 | unsigned int depth; | 3005 | unsigned int depth; |
3002 | int i, point; | 3006 | int i, contention_point, contending_point; |
3003 | 3007 | ||
3004 | depth = curr->lockdep_depth; | 3008 | depth = curr->lockdep_depth; |
3005 | if (DEBUG_LOCKS_WARN_ON(!depth)) | 3009 | if (DEBUG_LOCKS_WARN_ON(!depth)) |
@@ -3023,18 +3027,22 @@ __lock_contended(struct lockdep_map *lock, unsigned long ip) | |||
3023 | found_it: | 3027 | found_it: |
3024 | hlock->waittime_stamp = sched_clock(); | 3028 | hlock->waittime_stamp = sched_clock(); |
3025 | 3029 | ||
3026 | point = lock_contention_point(hlock_class(hlock), ip); | 3030 | contention_point = lock_point(hlock_class(hlock)->contention_point, ip); |
3031 | contending_point = lock_point(hlock_class(hlock)->contending_point, | ||
3032 | lock->ip); | ||
3027 | 3033 | ||
3028 | stats = get_lock_stats(hlock_class(hlock)); | 3034 | stats = get_lock_stats(hlock_class(hlock)); |
3029 | if (point < ARRAY_SIZE(stats->contention_point)) | 3035 | if (contention_point < LOCKSTAT_POINTS) |
3030 | stats->contention_point[point]++; | 3036 | stats->contention_point[contention_point]++; |
3037 | if (contending_point < LOCKSTAT_POINTS) | ||
3038 | stats->contending_point[contending_point]++; | ||
3031 | if (lock->cpu != smp_processor_id()) | 3039 | if (lock->cpu != smp_processor_id()) |
3032 | stats->bounces[bounce_contended + !!hlock->read]++; | 3040 | stats->bounces[bounce_contended + !!hlock->read]++; |
3033 | put_lock_stats(stats); | 3041 | put_lock_stats(stats); |
3034 | } | 3042 | } |
3035 | 3043 | ||
3036 | static void | 3044 | static void |
3037 | __lock_acquired(struct lockdep_map *lock) | 3045 | __lock_acquired(struct lockdep_map *lock, unsigned long ip) |
3038 | { | 3046 | { |
3039 | struct task_struct *curr = current; | 3047 | struct task_struct *curr = current; |
3040 | struct held_lock *hlock, *prev_hlock; | 3048 | struct held_lock *hlock, *prev_hlock; |
@@ -3083,6 +3091,7 @@ found_it: | |||
3083 | put_lock_stats(stats); | 3091 | put_lock_stats(stats); |
3084 | 3092 | ||
3085 | lock->cpu = cpu; | 3093 | lock->cpu = cpu; |
3094 | lock->ip = ip; | ||
3086 | } | 3095 | } |
3087 | 3096 | ||
3088 | void lock_contended(struct lockdep_map *lock, unsigned long ip) | 3097 | void lock_contended(struct lockdep_map *lock, unsigned long ip) |
@@ -3104,7 +3113,7 @@ void lock_contended(struct lockdep_map *lock, unsigned long ip) | |||
3104 | } | 3113 | } |
3105 | EXPORT_SYMBOL_GPL(lock_contended); | 3114 | EXPORT_SYMBOL_GPL(lock_contended); |
3106 | 3115 | ||
3107 | void lock_acquired(struct lockdep_map *lock) | 3116 | void lock_acquired(struct lockdep_map *lock, unsigned long ip) |
3108 | { | 3117 | { |
3109 | unsigned long flags; | 3118 | unsigned long flags; |
3110 | 3119 | ||
@@ -3117,7 +3126,7 @@ void lock_acquired(struct lockdep_map *lock) | |||
3117 | raw_local_irq_save(flags); | 3126 | raw_local_irq_save(flags); |
3118 | check_flags(flags); | 3127 | check_flags(flags); |
3119 | current->lockdep_recursion = 1; | 3128 | current->lockdep_recursion = 1; |
3120 | __lock_acquired(lock); | 3129 | __lock_acquired(lock, ip); |
3121 | current->lockdep_recursion = 0; | 3130 | current->lockdep_recursion = 0; |
3122 | raw_local_irq_restore(flags); | 3131 | raw_local_irq_restore(flags); |
3123 | } | 3132 | } |
@@ -3276,10 +3285,10 @@ void __init lockdep_info(void) | |||
3276 | { | 3285 | { |
3277 | printk("Lock dependency validator: Copyright (c) 2006 Red Hat, Inc., Ingo Molnar\n"); | 3286 | printk("Lock dependency validator: Copyright (c) 2006 Red Hat, Inc., Ingo Molnar\n"); |
3278 | 3287 | ||
3279 | printk("... MAX_LOCKDEP_SUBCLASSES: %lu\n", MAX_LOCKDEP_SUBCLASSES); | 3288 | printk("... MAX_LOCKDEP_SUBCLASSES: %lu\n", MAX_LOCKDEP_SUBCLASSES); |
3280 | printk("... MAX_LOCK_DEPTH: %lu\n", MAX_LOCK_DEPTH); | 3289 | printk("... MAX_LOCK_DEPTH: %lu\n", MAX_LOCK_DEPTH); |
3281 | printk("... MAX_LOCKDEP_KEYS: %lu\n", MAX_LOCKDEP_KEYS); | 3290 | printk("... MAX_LOCKDEP_KEYS: %lu\n", MAX_LOCKDEP_KEYS); |
3282 | printk("... CLASSHASH_SIZE: %lu\n", CLASSHASH_SIZE); | 3291 | printk("... CLASSHASH_SIZE: %lu\n", CLASSHASH_SIZE); |
3283 | printk("... MAX_LOCKDEP_ENTRIES: %lu\n", MAX_LOCKDEP_ENTRIES); | 3292 | printk("... MAX_LOCKDEP_ENTRIES: %lu\n", MAX_LOCKDEP_ENTRIES); |
3284 | printk("... MAX_LOCKDEP_CHAINS: %lu\n", MAX_LOCKDEP_CHAINS); | 3293 | printk("... MAX_LOCKDEP_CHAINS: %lu\n", MAX_LOCKDEP_CHAINS); |
3285 | printk("... CHAINHASH_SIZE: %lu\n", CHAINHASH_SIZE); | 3294 | printk("... CHAINHASH_SIZE: %lu\n", CHAINHASH_SIZE); |
diff --git a/kernel/lockdep_proc.c b/kernel/lockdep_proc.c index 20dbcbf9c7dd..13716b813896 100644 --- a/kernel/lockdep_proc.c +++ b/kernel/lockdep_proc.c | |||
@@ -470,11 +470,12 @@ static void seq_line(struct seq_file *m, char c, int offset, int length) | |||
470 | 470 | ||
471 | static void snprint_time(char *buf, size_t bufsiz, s64 nr) | 471 | static void snprint_time(char *buf, size_t bufsiz, s64 nr) |
472 | { | 472 | { |
473 | unsigned long rem; | 473 | s64 div; |
474 | s32 rem; | ||
474 | 475 | ||
475 | nr += 5; /* for display rounding */ | 476 | nr += 5; /* for display rounding */ |
476 | rem = do_div(nr, 1000); /* XXX: do_div_signed */ | 477 | div = div_s64_rem(nr, 1000, &rem); |
477 | snprintf(buf, bufsiz, "%lld.%02d", (long long)nr, (int)rem/10); | 478 | snprintf(buf, bufsiz, "%lld.%02d", (long long)div, (int)rem/10); |
478 | } | 479 | } |
479 | 480 | ||
480 | static void seq_time(struct seq_file *m, s64 time) | 481 | static void seq_time(struct seq_file *m, s64 time) |
@@ -556,7 +557,7 @@ static void seq_stats(struct seq_file *m, struct lock_stat_data *data) | |||
556 | if (stats->read_holdtime.nr) | 557 | if (stats->read_holdtime.nr) |
557 | namelen += 2; | 558 | namelen += 2; |
558 | 559 | ||
559 | for (i = 0; i < ARRAY_SIZE(class->contention_point); i++) { | 560 | for (i = 0; i < LOCKSTAT_POINTS; i++) { |
560 | char sym[KSYM_SYMBOL_LEN]; | 561 | char sym[KSYM_SYMBOL_LEN]; |
561 | char ip[32]; | 562 | char ip[32]; |
562 | 563 | ||
@@ -573,6 +574,23 @@ static void seq_stats(struct seq_file *m, struct lock_stat_data *data) | |||
573 | stats->contention_point[i], | 574 | stats->contention_point[i], |
574 | ip, sym); | 575 | ip, sym); |
575 | } | 576 | } |
577 | for (i = 0; i < LOCKSTAT_POINTS; i++) { | ||
578 | char sym[KSYM_SYMBOL_LEN]; | ||
579 | char ip[32]; | ||
580 | |||
581 | if (class->contending_point[i] == 0) | ||
582 | break; | ||
583 | |||
584 | if (!i) | ||
585 | seq_line(m, '-', 40-namelen, namelen); | ||
586 | |||
587 | sprint_symbol(sym, class->contending_point[i]); | ||
588 | snprintf(ip, sizeof(ip), "[<%p>]", | ||
589 | (void *)class->contending_point[i]); | ||
590 | seq_printf(m, "%40s %14lu %29s %s\n", name, | ||
591 | stats->contending_point[i], | ||
592 | ip, sym); | ||
593 | } | ||
576 | if (i) { | 594 | if (i) { |
577 | seq_puts(m, "\n"); | 595 | seq_puts(m, "\n"); |
578 | seq_line(m, '.', 0, 40 + 1 + 10 * (14 + 1)); | 596 | seq_line(m, '.', 0, 40 + 1 + 10 * (14 + 1)); |
@@ -582,7 +600,7 @@ static void seq_stats(struct seq_file *m, struct lock_stat_data *data) | |||
582 | 600 | ||
583 | static void seq_header(struct seq_file *m) | 601 | static void seq_header(struct seq_file *m) |
584 | { | 602 | { |
585 | seq_printf(m, "lock_stat version 0.2\n"); | 603 | seq_printf(m, "lock_stat version 0.3\n"); |
586 | seq_line(m, '-', 0, 40 + 1 + 10 * (14 + 1)); | 604 | seq_line(m, '-', 0, 40 + 1 + 10 * (14 + 1)); |
587 | seq_printf(m, "%40s %14s %14s %14s %14s %14s %14s %14s %14s " | 605 | seq_printf(m, "%40s %14s %14s %14s %14s %14s %14s %14s %14s " |
588 | "%14s %14s\n", | 606 | "%14s %14s\n", |
diff --git a/kernel/mutex.c b/kernel/mutex.c index 12c779dc65d4..4f45d4b658ef 100644 --- a/kernel/mutex.c +++ b/kernel/mutex.c | |||
@@ -59,7 +59,7 @@ EXPORT_SYMBOL(__mutex_init); | |||
59 | * We also put the fastpath first in the kernel image, to make sure the | 59 | * We also put the fastpath first in the kernel image, to make sure the |
60 | * branch is predicted by the CPU as default-untaken. | 60 | * branch is predicted by the CPU as default-untaken. |
61 | */ | 61 | */ |
62 | static void noinline __sched | 62 | static __used noinline void __sched |
63 | __mutex_lock_slowpath(atomic_t *lock_count); | 63 | __mutex_lock_slowpath(atomic_t *lock_count); |
64 | 64 | ||
65 | /*** | 65 | /*** |
@@ -96,7 +96,7 @@ void inline __sched mutex_lock(struct mutex *lock) | |||
96 | EXPORT_SYMBOL(mutex_lock); | 96 | EXPORT_SYMBOL(mutex_lock); |
97 | #endif | 97 | #endif |
98 | 98 | ||
99 | static noinline void __sched __mutex_unlock_slowpath(atomic_t *lock_count); | 99 | static __used noinline void __sched __mutex_unlock_slowpath(atomic_t *lock_count); |
100 | 100 | ||
101 | /*** | 101 | /*** |
102 | * mutex_unlock - release the mutex | 102 | * mutex_unlock - release the mutex |
@@ -184,7 +184,7 @@ __mutex_lock_common(struct mutex *lock, long state, unsigned int subclass, | |||
184 | } | 184 | } |
185 | 185 | ||
186 | done: | 186 | done: |
187 | lock_acquired(&lock->dep_map); | 187 | lock_acquired(&lock->dep_map, ip); |
188 | /* got the lock - rejoice! */ | 188 | /* got the lock - rejoice! */ |
189 | mutex_remove_waiter(lock, &waiter, task_thread_info(task)); | 189 | mutex_remove_waiter(lock, &waiter, task_thread_info(task)); |
190 | debug_mutex_set_owner(lock, task_thread_info(task)); | 190 | debug_mutex_set_owner(lock, task_thread_info(task)); |
@@ -268,7 +268,7 @@ __mutex_unlock_common_slowpath(atomic_t *lock_count, int nested) | |||
268 | /* | 268 | /* |
269 | * Release the lock, slowpath: | 269 | * Release the lock, slowpath: |
270 | */ | 270 | */ |
271 | static noinline void | 271 | static __used noinline void |
272 | __mutex_unlock_slowpath(atomic_t *lock_count) | 272 | __mutex_unlock_slowpath(atomic_t *lock_count) |
273 | { | 273 | { |
274 | __mutex_unlock_common_slowpath(lock_count, 1); | 274 | __mutex_unlock_common_slowpath(lock_count, 1); |
@@ -313,7 +313,7 @@ int __sched mutex_lock_killable(struct mutex *lock) | |||
313 | } | 313 | } |
314 | EXPORT_SYMBOL(mutex_lock_killable); | 314 | EXPORT_SYMBOL(mutex_lock_killable); |
315 | 315 | ||
316 | static noinline void __sched | 316 | static __used noinline void __sched |
317 | __mutex_lock_slowpath(atomic_t *lock_count) | 317 | __mutex_lock_slowpath(atomic_t *lock_count) |
318 | { | 318 | { |
319 | struct mutex *lock = container_of(lock_count, struct mutex, count); | 319 | struct mutex *lock = container_of(lock_count, struct mutex, count); |
diff --git a/kernel/panic.c b/kernel/panic.c index 50349a41fba7..13f06349a786 100644 --- a/kernel/panic.c +++ b/kernel/panic.c | |||
@@ -168,6 +168,7 @@ static const struct tnt tnts[] = { | |||
168 | * 'M' - System experienced a machine check exception. | 168 | * 'M' - System experienced a machine check exception. |
169 | * 'B' - System has hit bad_page. | 169 | * 'B' - System has hit bad_page. |
170 | * 'U' - Userspace-defined naughtiness. | 170 | * 'U' - Userspace-defined naughtiness. |
171 | * 'D' - Kernel has oopsed before | ||
171 | * 'A' - ACPI table overridden. | 172 | * 'A' - ACPI table overridden. |
172 | * 'W' - Taint on warning. | 173 | * 'W' - Taint on warning. |
173 | * 'C' - modules from drivers/staging are loaded. | 174 | * 'C' - modules from drivers/staging are loaded. |
diff --git a/kernel/posix-cpu-timers.c b/kernel/posix-cpu-timers.c index 895337b16a24..157de3a47832 100644 --- a/kernel/posix-cpu-timers.c +++ b/kernel/posix-cpu-timers.c | |||
@@ -58,21 +58,21 @@ void thread_group_cputime( | |||
58 | struct task_struct *tsk, | 58 | struct task_struct *tsk, |
59 | struct task_cputime *times) | 59 | struct task_cputime *times) |
60 | { | 60 | { |
61 | struct signal_struct *sig; | 61 | struct task_cputime *totals, *tot; |
62 | int i; | 62 | int i; |
63 | struct task_cputime *tot; | ||
64 | 63 | ||
65 | sig = tsk->signal; | 64 | totals = tsk->signal->cputime.totals; |
66 | if (unlikely(!sig) || !sig->cputime.totals) { | 65 | if (!totals) { |
67 | times->utime = tsk->utime; | 66 | times->utime = tsk->utime; |
68 | times->stime = tsk->stime; | 67 | times->stime = tsk->stime; |
69 | times->sum_exec_runtime = tsk->se.sum_exec_runtime; | 68 | times->sum_exec_runtime = tsk->se.sum_exec_runtime; |
70 | return; | 69 | return; |
71 | } | 70 | } |
71 | |||
72 | times->stime = times->utime = cputime_zero; | 72 | times->stime = times->utime = cputime_zero; |
73 | times->sum_exec_runtime = 0; | 73 | times->sum_exec_runtime = 0; |
74 | for_each_possible_cpu(i) { | 74 | for_each_possible_cpu(i) { |
75 | tot = per_cpu_ptr(tsk->signal->cputime.totals, i); | 75 | tot = per_cpu_ptr(totals, i); |
76 | times->utime = cputime_add(times->utime, tot->utime); | 76 | times->utime = cputime_add(times->utime, tot->utime); |
77 | times->stime = cputime_add(times->stime, tot->stime); | 77 | times->stime = cputime_add(times->stime, tot->stime); |
78 | times->sum_exec_runtime += tot->sum_exec_runtime; | 78 | times->sum_exec_runtime += tot->sum_exec_runtime; |
@@ -311,7 +311,7 @@ static int cpu_clock_sample_group(const clockid_t which_clock, | |||
311 | struct task_cputime cputime; | 311 | struct task_cputime cputime; |
312 | 312 | ||
313 | thread_group_cputime(p, &cputime); | 313 | thread_group_cputime(p, &cputime); |
314 | switch (which_clock) { | 314 | switch (CPUCLOCK_WHICH(which_clock)) { |
315 | default: | 315 | default: |
316 | return -EINVAL; | 316 | return -EINVAL; |
317 | case CPUCLOCK_PROF: | 317 | case CPUCLOCK_PROF: |
diff --git a/kernel/posix-timers.c b/kernel/posix-timers.c index 5e79c662294b..a140e44eebba 100644 --- a/kernel/posix-timers.c +++ b/kernel/posix-timers.c | |||
@@ -197,6 +197,11 @@ static int common_timer_create(struct k_itimer *new_timer) | |||
197 | return 0; | 197 | return 0; |
198 | } | 198 | } |
199 | 199 | ||
200 | static int no_timer_create(struct k_itimer *new_timer) | ||
201 | { | ||
202 | return -EOPNOTSUPP; | ||
203 | } | ||
204 | |||
200 | /* | 205 | /* |
201 | * Return nonzero if we know a priori this clockid_t value is bogus. | 206 | * Return nonzero if we know a priori this clockid_t value is bogus. |
202 | */ | 207 | */ |
@@ -248,6 +253,7 @@ static __init int init_posix_timers(void) | |||
248 | .clock_getres = hrtimer_get_res, | 253 | .clock_getres = hrtimer_get_res, |
249 | .clock_get = posix_get_monotonic_raw, | 254 | .clock_get = posix_get_monotonic_raw, |
250 | .clock_set = do_posix_clock_nosettime, | 255 | .clock_set = do_posix_clock_nosettime, |
256 | .timer_create = no_timer_create, | ||
251 | }; | 257 | }; |
252 | 258 | ||
253 | register_posix_clock(CLOCK_REALTIME, &clock_realtime); | 259 | register_posix_clock(CLOCK_REALTIME, &clock_realtime); |
diff --git a/kernel/power/swap.c b/kernel/power/swap.c index b7713b53d07a..6da14358537c 100644 --- a/kernel/power/swap.c +++ b/kernel/power/swap.c | |||
@@ -633,7 +633,7 @@ void swsusp_close(fmode_t mode) | |||
633 | return; | 633 | return; |
634 | } | 634 | } |
635 | 635 | ||
636 | blkdev_put(resume_bdev, mode); /* move up */ | 636 | blkdev_put(resume_bdev, mode); |
637 | } | 637 | } |
638 | 638 | ||
639 | static int swsusp_header_init(void) | 639 | static int swsusp_header_init(void) |
diff --git a/kernel/profile.c b/kernel/profile.c index 5b7d1ac7124c..dc41827fbfee 100644 --- a/kernel/profile.c +++ b/kernel/profile.c | |||
@@ -351,7 +351,7 @@ out: | |||
351 | put_cpu(); | 351 | put_cpu(); |
352 | } | 352 | } |
353 | 353 | ||
354 | static int __devinit profile_cpu_callback(struct notifier_block *info, | 354 | static int __cpuinit profile_cpu_callback(struct notifier_block *info, |
355 | unsigned long action, void *__cpu) | 355 | unsigned long action, void *__cpu) |
356 | { | 356 | { |
357 | int node, cpu = (unsigned long)__cpu; | 357 | int node, cpu = (unsigned long)__cpu; |
@@ -596,7 +596,7 @@ out_cleanup: | |||
596 | #define create_hash_tables() ({ 0; }) | 596 | #define create_hash_tables() ({ 0; }) |
597 | #endif | 597 | #endif |
598 | 598 | ||
599 | int create_proc_profile(void) | 599 | int __ref create_proc_profile(void) /* false positive from hotcpu_notifier */ |
600 | { | 600 | { |
601 | struct proc_dir_entry *entry; | 601 | struct proc_dir_entry *entry; |
602 | 602 | ||
diff --git a/kernel/ptrace.c b/kernel/ptrace.c index 1e68e4c39e2c..4c8bcd7dd8e0 100644 --- a/kernel/ptrace.c +++ b/kernel/ptrace.c | |||
@@ -612,7 +612,7 @@ int generic_ptrace_pokedata(struct task_struct *tsk, long addr, long data) | |||
612 | return (copied == sizeof(data)) ? 0 : -EIO; | 612 | return (copied == sizeof(data)) ? 0 : -EIO; |
613 | } | 613 | } |
614 | 614 | ||
615 | #if defined CONFIG_COMPAT && defined __ARCH_WANT_COMPAT_SYS_PTRACE | 615 | #if defined CONFIG_COMPAT |
616 | #include <linux/compat.h> | 616 | #include <linux/compat.h> |
617 | 617 | ||
618 | int compat_ptrace_request(struct task_struct *child, compat_long_t request, | 618 | int compat_ptrace_request(struct task_struct *child, compat_long_t request, |
@@ -709,4 +709,4 @@ asmlinkage long compat_sys_ptrace(compat_long_t request, compat_long_t pid, | |||
709 | unlock_kernel(); | 709 | unlock_kernel(); |
710 | return ret; | 710 | return ret; |
711 | } | 711 | } |
712 | #endif /* CONFIG_COMPAT && __ARCH_WANT_COMPAT_SYS_PTRACE */ | 712 | #endif /* CONFIG_COMPAT */ |
diff --git a/kernel/rcuclassic.c b/kernel/rcuclassic.c index 37f72e551542..e503a002f330 100644 --- a/kernel/rcuclassic.c +++ b/kernel/rcuclassic.c | |||
@@ -191,7 +191,7 @@ static void print_other_cpu_stall(struct rcu_ctrlblk *rcp) | |||
191 | 191 | ||
192 | /* OK, time to rat on our buddy... */ | 192 | /* OK, time to rat on our buddy... */ |
193 | 193 | ||
194 | printk(KERN_ERR "RCU detected CPU stalls:"); | 194 | printk(KERN_ERR "INFO: RCU detected CPU stalls:"); |
195 | for_each_possible_cpu(cpu) { | 195 | for_each_possible_cpu(cpu) { |
196 | if (cpu_isset(cpu, rcp->cpumask)) | 196 | if (cpu_isset(cpu, rcp->cpumask)) |
197 | printk(" %d", cpu); | 197 | printk(" %d", cpu); |
@@ -204,7 +204,7 @@ static void print_cpu_stall(struct rcu_ctrlblk *rcp) | |||
204 | { | 204 | { |
205 | unsigned long flags; | 205 | unsigned long flags; |
206 | 206 | ||
207 | printk(KERN_ERR "RCU detected CPU %d stall (t=%lu/%lu jiffies)\n", | 207 | printk(KERN_ERR "INFO: RCU detected CPU %d stall (t=%lu/%lu jiffies)\n", |
208 | smp_processor_id(), jiffies, | 208 | smp_processor_id(), jiffies, |
209 | jiffies - rcp->gp_start); | 209 | jiffies - rcp->gp_start); |
210 | dump_stack(); | 210 | dump_stack(); |
diff --git a/kernel/relay.c b/kernel/relay.c index 32b0befdcb6a..09ac2008f77b 100644 --- a/kernel/relay.c +++ b/kernel/relay.c | |||
@@ -1317,12 +1317,9 @@ static ssize_t relay_file_splice_read(struct file *in, | |||
1317 | if (ret < 0) | 1317 | if (ret < 0) |
1318 | break; | 1318 | break; |
1319 | else if (!ret) { | 1319 | else if (!ret) { |
1320 | if (spliced) | 1320 | if (flags & SPLICE_F_NONBLOCK) |
1321 | break; | ||
1322 | if (flags & SPLICE_F_NONBLOCK) { | ||
1323 | ret = -EAGAIN; | 1321 | ret = -EAGAIN; |
1324 | break; | 1322 | break; |
1325 | } | ||
1326 | } | 1323 | } |
1327 | 1324 | ||
1328 | *ppos += ret; | 1325 | *ppos += ret; |
diff --git a/kernel/sched.c b/kernel/sched.c index 9b1e79371c20..3e70963120a0 100644 --- a/kernel/sched.c +++ b/kernel/sched.c | |||
@@ -1453,9 +1453,10 @@ static int task_hot(struct task_struct *p, u64 now, struct sched_domain *sd); | |||
1453 | static unsigned long cpu_avg_load_per_task(int cpu) | 1453 | static unsigned long cpu_avg_load_per_task(int cpu) |
1454 | { | 1454 | { |
1455 | struct rq *rq = cpu_rq(cpu); | 1455 | struct rq *rq = cpu_rq(cpu); |
1456 | unsigned long nr_running = ACCESS_ONCE(rq->nr_running); | ||
1456 | 1457 | ||
1457 | if (rq->nr_running) | 1458 | if (nr_running) |
1458 | rq->avg_load_per_task = rq->load.weight / rq->nr_running; | 1459 | rq->avg_load_per_task = rq->load.weight / nr_running; |
1459 | else | 1460 | else |
1460 | rq->avg_load_per_task = 0; | 1461 | rq->avg_load_per_task = 0; |
1461 | 1462 | ||
@@ -4202,7 +4203,6 @@ void account_steal_time(struct task_struct *p, cputime_t steal) | |||
4202 | 4203 | ||
4203 | if (p == rq->idle) { | 4204 | if (p == rq->idle) { |
4204 | p->stime = cputime_add(p->stime, steal); | 4205 | p->stime = cputime_add(p->stime, steal); |
4205 | account_group_system_time(p, steal); | ||
4206 | if (atomic_read(&rq->nr_iowait) > 0) | 4206 | if (atomic_read(&rq->nr_iowait) > 0) |
4207 | cpustat->iowait = cputime64_add(cpustat->iowait, tmp); | 4207 | cpustat->iowait = cputime64_add(cpustat->iowait, tmp); |
4208 | else | 4208 | else |
@@ -4338,7 +4338,7 @@ void __kprobes sub_preempt_count(int val) | |||
4338 | /* | 4338 | /* |
4339 | * Underflow? | 4339 | * Underflow? |
4340 | */ | 4340 | */ |
4341 | if (DEBUG_LOCKS_WARN_ON(val > preempt_count())) | 4341 | if (DEBUG_LOCKS_WARN_ON(val > preempt_count() - (!!kernel_locked()))) |
4342 | return; | 4342 | return; |
4343 | /* | 4343 | /* |
4344 | * Is the spinlock portion underflowing? | 4344 | * Is the spinlock portion underflowing? |
@@ -6586,7 +6586,9 @@ migration_call(struct notifier_block *nfb, unsigned long action, void *hcpu) | |||
6586 | req = list_entry(rq->migration_queue.next, | 6586 | req = list_entry(rq->migration_queue.next, |
6587 | struct migration_req, list); | 6587 | struct migration_req, list); |
6588 | list_del_init(&req->list); | 6588 | list_del_init(&req->list); |
6589 | spin_unlock_irq(&rq->lock); | ||
6589 | complete(&req->done); | 6590 | complete(&req->done); |
6591 | spin_lock_irq(&rq->lock); | ||
6590 | } | 6592 | } |
6591 | spin_unlock_irq(&rq->lock); | 6593 | spin_unlock_irq(&rq->lock); |
6592 | break; | 6594 | break; |
diff --git a/kernel/sched_clock.c b/kernel/sched_clock.c index 81787248b60f..e8ab096ddfe3 100644 --- a/kernel/sched_clock.c +++ b/kernel/sched_clock.c | |||
@@ -118,13 +118,13 @@ static u64 __update_sched_clock(struct sched_clock_data *scd, u64 now) | |||
118 | 118 | ||
119 | /* | 119 | /* |
120 | * scd->clock = clamp(scd->tick_gtod + delta, | 120 | * scd->clock = clamp(scd->tick_gtod + delta, |
121 | * max(scd->tick_gtod, scd->clock), | 121 | * max(scd->tick_gtod, scd->clock), |
122 | * max(scd->clock, scd->tick_gtod + TICK_NSEC)); | 122 | * scd->tick_gtod + TICK_NSEC); |
123 | */ | 123 | */ |
124 | 124 | ||
125 | clock = scd->tick_gtod + delta; | 125 | clock = scd->tick_gtod + delta; |
126 | min_clock = wrap_max(scd->tick_gtod, scd->clock); | 126 | min_clock = wrap_max(scd->tick_gtod, scd->clock); |
127 | max_clock = wrap_max(scd->clock, scd->tick_gtod + TICK_NSEC); | 127 | max_clock = scd->tick_gtod + TICK_NSEC; |
128 | 128 | ||
129 | clock = wrap_max(clock, min_clock); | 129 | clock = wrap_max(clock, min_clock); |
130 | clock = wrap_min(clock, max_clock); | 130 | clock = wrap_min(clock, max_clock); |
diff --git a/kernel/softlockup.c b/kernel/softlockup.c index 884e6cd2769c..1ab790c67b17 100644 --- a/kernel/softlockup.c +++ b/kernel/softlockup.c | |||
@@ -188,7 +188,7 @@ static void check_hung_task(struct task_struct *t, unsigned long now) | |||
188 | if ((long)(now - t->last_switch_timestamp) < | 188 | if ((long)(now - t->last_switch_timestamp) < |
189 | sysctl_hung_task_timeout_secs) | 189 | sysctl_hung_task_timeout_secs) |
190 | return; | 190 | return; |
191 | if (sysctl_hung_task_warnings < 0) | 191 | if (!sysctl_hung_task_warnings) |
192 | return; | 192 | return; |
193 | sysctl_hung_task_warnings--; | 193 | sysctl_hung_task_warnings--; |
194 | 194 | ||
diff --git a/kernel/sys.c b/kernel/sys.c index 31deba8f7d16..5fc3a0cfb994 100644 --- a/kernel/sys.c +++ b/kernel/sys.c | |||
@@ -858,8 +858,8 @@ void do_sys_times(struct tms *tms) | |||
858 | struct task_cputime cputime; | 858 | struct task_cputime cputime; |
859 | cputime_t cutime, cstime; | 859 | cputime_t cutime, cstime; |
860 | 860 | ||
861 | spin_lock_irq(¤t->sighand->siglock); | ||
862 | thread_group_cputime(current, &cputime); | 861 | thread_group_cputime(current, &cputime); |
862 | spin_lock_irq(¤t->sighand->siglock); | ||
863 | cutime = current->signal->cutime; | 863 | cutime = current->signal->cutime; |
864 | cstime = current->signal->cstime; | 864 | cstime = current->signal->cstime; |
865 | spin_unlock_irq(¤t->sighand->siglock); | 865 | spin_unlock_irq(¤t->sighand->siglock); |
diff --git a/kernel/sysctl.c b/kernel/sysctl.c index 9d048fa2d902..3d56fe7570da 100644 --- a/kernel/sysctl.c +++ b/kernel/sysctl.c | |||
@@ -176,6 +176,9 @@ extern struct ctl_table random_table[]; | |||
176 | #ifdef CONFIG_INOTIFY_USER | 176 | #ifdef CONFIG_INOTIFY_USER |
177 | extern struct ctl_table inotify_table[]; | 177 | extern struct ctl_table inotify_table[]; |
178 | #endif | 178 | #endif |
179 | #ifdef CONFIG_EPOLL | ||
180 | extern struct ctl_table epoll_table[]; | ||
181 | #endif | ||
179 | 182 | ||
180 | #ifdef HAVE_ARCH_PICK_MMAP_LAYOUT | 183 | #ifdef HAVE_ARCH_PICK_MMAP_LAYOUT |
181 | int sysctl_legacy_va_layout; | 184 | int sysctl_legacy_va_layout; |
@@ -1325,6 +1328,13 @@ static struct ctl_table fs_table[] = { | |||
1325 | .child = inotify_table, | 1328 | .child = inotify_table, |
1326 | }, | 1329 | }, |
1327 | #endif | 1330 | #endif |
1331 | #ifdef CONFIG_EPOLL | ||
1332 | { | ||
1333 | .procname = "epoll", | ||
1334 | .mode = 0555, | ||
1335 | .child = epoll_table, | ||
1336 | }, | ||
1337 | #endif | ||
1328 | #endif | 1338 | #endif |
1329 | { | 1339 | { |
1330 | .ctl_name = KERN_SETUID_DUMPABLE, | 1340 | .ctl_name = KERN_SETUID_DUMPABLE, |
diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c index e7acfb482a68..fa05e88aa76f 100644 --- a/kernel/time/timekeeping.c +++ b/kernel/time/timekeeping.c | |||
@@ -518,6 +518,28 @@ void update_wall_time(void) | |||
518 | /* correct the clock when NTP error is too big */ | 518 | /* correct the clock when NTP error is too big */ |
519 | clocksource_adjust(offset); | 519 | clocksource_adjust(offset); |
520 | 520 | ||
521 | /* | ||
522 | * Since in the loop above, we accumulate any amount of time | ||
523 | * in xtime_nsec over a second into xtime.tv_sec, its possible for | ||
524 | * xtime_nsec to be fairly small after the loop. Further, if we're | ||
525 | * slightly speeding the clocksource up in clocksource_adjust(), | ||
526 | * its possible the required corrective factor to xtime_nsec could | ||
527 | * cause it to underflow. | ||
528 | * | ||
529 | * Now, we cannot simply roll the accumulated second back, since | ||
530 | * the NTP subsystem has been notified via second_overflow. So | ||
531 | * instead we push xtime_nsec forward by the amount we underflowed, | ||
532 | * and add that amount into the error. | ||
533 | * | ||
534 | * We'll correct this error next time through this function, when | ||
535 | * xtime_nsec is not as small. | ||
536 | */ | ||
537 | if (unlikely((s64)clock->xtime_nsec < 0)) { | ||
538 | s64 neg = -(s64)clock->xtime_nsec; | ||
539 | clock->xtime_nsec = 0; | ||
540 | clock->error += neg << (NTP_SCALE_SHIFT - clock->shift); | ||
541 | } | ||
542 | |||
521 | /* store full nanoseconds into xtime after rounding it up and | 543 | /* store full nanoseconds into xtime after rounding it up and |
522 | * add the remainder to the error difference. | 544 | * add the remainder to the error difference. |
523 | */ | 545 | */ |
diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c index f780e9552f91..668bbb5ef2bd 100644 --- a/kernel/trace/ring_buffer.c +++ b/kernel/trace/ring_buffer.c | |||
@@ -1215,7 +1215,7 @@ ring_buffer_lock_reserve(struct ring_buffer *buffer, | |||
1215 | 1215 | ||
1216 | out: | 1216 | out: |
1217 | if (resched) | 1217 | if (resched) |
1218 | preempt_enable_notrace(); | 1218 | preempt_enable_no_resched_notrace(); |
1219 | else | 1219 | else |
1220 | preempt_enable_notrace(); | 1220 | preempt_enable_notrace(); |
1221 | return NULL; | 1221 | return NULL; |
diff --git a/kernel/trace/trace_mmiotrace.c b/kernel/trace/trace_mmiotrace.c index f28484618ff0..e62cbf78eab6 100644 --- a/kernel/trace/trace_mmiotrace.c +++ b/kernel/trace/trace_mmiotrace.c | |||
@@ -18,12 +18,14 @@ struct header_iter { | |||
18 | 18 | ||
19 | static struct trace_array *mmio_trace_array; | 19 | static struct trace_array *mmio_trace_array; |
20 | static bool overrun_detected; | 20 | static bool overrun_detected; |
21 | static unsigned long prev_overruns; | ||
21 | 22 | ||
22 | static void mmio_reset_data(struct trace_array *tr) | 23 | static void mmio_reset_data(struct trace_array *tr) |
23 | { | 24 | { |
24 | int cpu; | 25 | int cpu; |
25 | 26 | ||
26 | overrun_detected = false; | 27 | overrun_detected = false; |
28 | prev_overruns = 0; | ||
27 | tr->time_start = ftrace_now(tr->cpu); | 29 | tr->time_start = ftrace_now(tr->cpu); |
28 | 30 | ||
29 | for_each_online_cpu(cpu) | 31 | for_each_online_cpu(cpu) |
@@ -128,16 +130,12 @@ static void mmio_close(struct trace_iterator *iter) | |||
128 | 130 | ||
129 | static unsigned long count_overruns(struct trace_iterator *iter) | 131 | static unsigned long count_overruns(struct trace_iterator *iter) |
130 | { | 132 | { |
131 | int cpu; | ||
132 | unsigned long cnt = 0; | 133 | unsigned long cnt = 0; |
133 | /* FIXME: */ | 134 | unsigned long over = ring_buffer_overruns(iter->tr->buffer); |
134 | #if 0 | 135 | |
135 | for_each_online_cpu(cpu) { | 136 | if (over > prev_overruns) |
136 | cnt += iter->overrun[cpu]; | 137 | cnt = over - prev_overruns; |
137 | iter->overrun[cpu] = 0; | 138 | prev_overruns = over; |
138 | } | ||
139 | #endif | ||
140 | (void)cpu; | ||
141 | return cnt; | 139 | return cnt; |
142 | } | 140 | } |
143 | 141 | ||
diff --git a/kernel/trace/trace_stack.c b/kernel/trace/trace_stack.c index be682b62fe58..3bdb44bde4b7 100644 --- a/kernel/trace/trace_stack.c +++ b/kernel/trace/trace_stack.c | |||
@@ -184,11 +184,16 @@ static struct file_operations stack_max_size_fops = { | |||
184 | static void * | 184 | static void * |
185 | t_next(struct seq_file *m, void *v, loff_t *pos) | 185 | t_next(struct seq_file *m, void *v, loff_t *pos) |
186 | { | 186 | { |
187 | long i = (long)m->private; | 187 | long i; |
188 | 188 | ||
189 | (*pos)++; | 189 | (*pos)++; |
190 | 190 | ||
191 | i++; | 191 | if (v == SEQ_START_TOKEN) |
192 | i = 0; | ||
193 | else { | ||
194 | i = *(long *)v; | ||
195 | i++; | ||
196 | } | ||
192 | 197 | ||
193 | if (i >= max_stack_trace.nr_entries || | 198 | if (i >= max_stack_trace.nr_entries || |
194 | stack_dump_trace[i] == ULONG_MAX) | 199 | stack_dump_trace[i] == ULONG_MAX) |
@@ -201,12 +206,15 @@ t_next(struct seq_file *m, void *v, loff_t *pos) | |||
201 | 206 | ||
202 | static void *t_start(struct seq_file *m, loff_t *pos) | 207 | static void *t_start(struct seq_file *m, loff_t *pos) |
203 | { | 208 | { |
204 | void *t = &m->private; | 209 | void *t = SEQ_START_TOKEN; |
205 | loff_t l = 0; | 210 | loff_t l = 0; |
206 | 211 | ||
207 | local_irq_disable(); | 212 | local_irq_disable(); |
208 | __raw_spin_lock(&max_stack_lock); | 213 | __raw_spin_lock(&max_stack_lock); |
209 | 214 | ||
215 | if (*pos == 0) | ||
216 | return SEQ_START_TOKEN; | ||
217 | |||
210 | for (; t && l < *pos; t = t_next(m, t, &l)) | 218 | for (; t && l < *pos; t = t_next(m, t, &l)) |
211 | ; | 219 | ; |
212 | 220 | ||
@@ -235,10 +243,10 @@ static int trace_lookup_stack(struct seq_file *m, long i) | |||
235 | 243 | ||
236 | static int t_show(struct seq_file *m, void *v) | 244 | static int t_show(struct seq_file *m, void *v) |
237 | { | 245 | { |
238 | long i = *(long *)v; | 246 | long i; |
239 | int size; | 247 | int size; |
240 | 248 | ||
241 | if (i < 0) { | 249 | if (v == SEQ_START_TOKEN) { |
242 | seq_printf(m, " Depth Size Location" | 250 | seq_printf(m, " Depth Size Location" |
243 | " (%d entries)\n" | 251 | " (%d entries)\n" |
244 | " ----- ---- --------\n", | 252 | " ----- ---- --------\n", |
@@ -246,6 +254,8 @@ static int t_show(struct seq_file *m, void *v) | |||
246 | return 0; | 254 | return 0; |
247 | } | 255 | } |
248 | 256 | ||
257 | i = *(long *)v; | ||
258 | |||
249 | if (i >= max_stack_trace.nr_entries || | 259 | if (i >= max_stack_trace.nr_entries || |
250 | stack_dump_trace[i] == ULONG_MAX) | 260 | stack_dump_trace[i] == ULONG_MAX) |
251 | return 0; | 261 | return 0; |
@@ -275,10 +285,6 @@ static int stack_trace_open(struct inode *inode, struct file *file) | |||
275 | int ret; | 285 | int ret; |
276 | 286 | ||
277 | ret = seq_open(file, &stack_trace_seq_ops); | 287 | ret = seq_open(file, &stack_trace_seq_ops); |
278 | if (!ret) { | ||
279 | struct seq_file *m = file->private_data; | ||
280 | m->private = (void *)-1; | ||
281 | } | ||
282 | 288 | ||
283 | return ret; | 289 | return ret; |
284 | } | 290 | } |