diff options
Diffstat (limited to 'kernel/cpuset.c')
-rw-r--r-- | kernel/cpuset.c | 45 |
1 files changed, 32 insertions, 13 deletions
diff --git a/kernel/cpuset.c b/kernel/cpuset.c index ab81fdd4572b..c232dc077438 100644 --- a/kernel/cpuset.c +++ b/kernel/cpuset.c | |||
@@ -18,7 +18,6 @@ | |||
18 | * distribution for more details. | 18 | * distribution for more details. |
19 | */ | 19 | */ |
20 | 20 | ||
21 | #include <linux/config.h> | ||
22 | #include <linux/cpu.h> | 21 | #include <linux/cpu.h> |
23 | #include <linux/cpumask.h> | 22 | #include <linux/cpumask.h> |
24 | #include <linux/cpuset.h> | 23 | #include <linux/cpuset.h> |
@@ -41,6 +40,7 @@ | |||
41 | #include <linux/rcupdate.h> | 40 | #include <linux/rcupdate.h> |
42 | #include <linux/sched.h> | 41 | #include <linux/sched.h> |
43 | #include <linux/seq_file.h> | 42 | #include <linux/seq_file.h> |
43 | #include <linux/security.h> | ||
44 | #include <linux/slab.h> | 44 | #include <linux/slab.h> |
45 | #include <linux/smp_lock.h> | 45 | #include <linux/smp_lock.h> |
46 | #include <linux/spinlock.h> | 46 | #include <linux/spinlock.h> |
@@ -392,11 +392,11 @@ static int cpuset_fill_super(struct super_block *sb, void *unused_data, | |||
392 | return 0; | 392 | return 0; |
393 | } | 393 | } |
394 | 394 | ||
395 | static struct super_block *cpuset_get_sb(struct file_system_type *fs_type, | 395 | static int cpuset_get_sb(struct file_system_type *fs_type, |
396 | int flags, const char *unused_dev_name, | 396 | int flags, const char *unused_dev_name, |
397 | void *data) | 397 | void *data, struct vfsmount *mnt) |
398 | { | 398 | { |
399 | return get_sb_single(fs_type, flags, data, cpuset_fill_super); | 399 | return get_sb_single(fs_type, flags, data, cpuset_fill_super, mnt); |
400 | } | 400 | } |
401 | 401 | ||
402 | static struct file_system_type cpuset_fs_type = { | 402 | static struct file_system_type cpuset_fs_type = { |
@@ -1063,7 +1063,7 @@ static int update_flag(cpuset_flagbits_t bit, struct cpuset *cs, char *buf) | |||
1063 | } | 1063 | } |
1064 | 1064 | ||
1065 | /* | 1065 | /* |
1066 | * Frequency meter - How fast is some event occuring? | 1066 | * Frequency meter - How fast is some event occurring? |
1067 | * | 1067 | * |
1068 | * These routines manage a digitally filtered, constant time based, | 1068 | * These routines manage a digitally filtered, constant time based, |
1069 | * event frequency meter. There are four routines: | 1069 | * event frequency meter. There are four routines: |
@@ -1177,6 +1177,7 @@ static int attach_task(struct cpuset *cs, char *pidbuf, char **ppathbuf) | |||
1177 | cpumask_t cpus; | 1177 | cpumask_t cpus; |
1178 | nodemask_t from, to; | 1178 | nodemask_t from, to; |
1179 | struct mm_struct *mm; | 1179 | struct mm_struct *mm; |
1180 | int retval; | ||
1180 | 1181 | ||
1181 | if (sscanf(pidbuf, "%d", &pid) != 1) | 1182 | if (sscanf(pidbuf, "%d", &pid) != 1) |
1182 | return -EIO; | 1183 | return -EIO; |
@@ -1205,6 +1206,12 @@ static int attach_task(struct cpuset *cs, char *pidbuf, char **ppathbuf) | |||
1205 | get_task_struct(tsk); | 1206 | get_task_struct(tsk); |
1206 | } | 1207 | } |
1207 | 1208 | ||
1209 | retval = security_task_setscheduler(tsk, 0, NULL); | ||
1210 | if (retval) { | ||
1211 | put_task_struct(tsk); | ||
1212 | return retval; | ||
1213 | } | ||
1214 | |||
1208 | mutex_lock(&callback_mutex); | 1215 | mutex_lock(&callback_mutex); |
1209 | 1216 | ||
1210 | task_lock(tsk); | 1217 | task_lock(tsk); |
@@ -2434,31 +2441,43 @@ void __cpuset_memory_pressure_bump(void) | |||
2434 | */ | 2441 | */ |
2435 | static int proc_cpuset_show(struct seq_file *m, void *v) | 2442 | static int proc_cpuset_show(struct seq_file *m, void *v) |
2436 | { | 2443 | { |
2444 | struct pid *pid; | ||
2437 | struct task_struct *tsk; | 2445 | struct task_struct *tsk; |
2438 | char *buf; | 2446 | char *buf; |
2439 | int retval = 0; | 2447 | int retval; |
2440 | 2448 | ||
2449 | retval = -ENOMEM; | ||
2441 | buf = kmalloc(PAGE_SIZE, GFP_KERNEL); | 2450 | buf = kmalloc(PAGE_SIZE, GFP_KERNEL); |
2442 | if (!buf) | 2451 | if (!buf) |
2443 | return -ENOMEM; | 2452 | goto out; |
2444 | 2453 | ||
2445 | tsk = m->private; | 2454 | retval = -ESRCH; |
2455 | pid = m->private; | ||
2456 | tsk = get_pid_task(pid, PIDTYPE_PID); | ||
2457 | if (!tsk) | ||
2458 | goto out_free; | ||
2459 | |||
2460 | retval = -EINVAL; | ||
2446 | mutex_lock(&manage_mutex); | 2461 | mutex_lock(&manage_mutex); |
2462 | |||
2447 | retval = cpuset_path(tsk->cpuset, buf, PAGE_SIZE); | 2463 | retval = cpuset_path(tsk->cpuset, buf, PAGE_SIZE); |
2448 | if (retval < 0) | 2464 | if (retval < 0) |
2449 | goto out; | 2465 | goto out_unlock; |
2450 | seq_puts(m, buf); | 2466 | seq_puts(m, buf); |
2451 | seq_putc(m, '\n'); | 2467 | seq_putc(m, '\n'); |
2452 | out: | 2468 | out_unlock: |
2453 | mutex_unlock(&manage_mutex); | 2469 | mutex_unlock(&manage_mutex); |
2470 | put_task_struct(tsk); | ||
2471 | out_free: | ||
2454 | kfree(buf); | 2472 | kfree(buf); |
2473 | out: | ||
2455 | return retval; | 2474 | return retval; |
2456 | } | 2475 | } |
2457 | 2476 | ||
2458 | static int cpuset_open(struct inode *inode, struct file *file) | 2477 | static int cpuset_open(struct inode *inode, struct file *file) |
2459 | { | 2478 | { |
2460 | struct task_struct *tsk = PROC_I(inode)->task; | 2479 | struct pid *pid = PROC_I(inode)->pid; |
2461 | return single_open(file, proc_cpuset_show, tsk); | 2480 | return single_open(file, proc_cpuset_show, pid); |
2462 | } | 2481 | } |
2463 | 2482 | ||
2464 | struct file_operations proc_cpuset_operations = { | 2483 | struct file_operations proc_cpuset_operations = { |