diff options
Diffstat (limited to 'kernel')
| -rw-r--r-- | kernel/cpuset.c | 27 |
1 files changed, 20 insertions, 7 deletions
diff --git a/kernel/cpuset.c b/kernel/cpuset.c index b602f73fb38d..3e991c0c02e2 100644 --- a/kernel/cpuset.c +++ b/kernel/cpuset.c | |||
| @@ -50,6 +50,7 @@ | |||
| 50 | #include <linux/time.h> | 50 | #include <linux/time.h> |
| 51 | #include <linux/backing-dev.h> | 51 | #include <linux/backing-dev.h> |
| 52 | #include <linux/sort.h> | 52 | #include <linux/sort.h> |
| 53 | #include <linux/task_ref.h> | ||
| 53 | 54 | ||
| 54 | #include <asm/uaccess.h> | 55 | #include <asm/uaccess.h> |
| 55 | #include <asm/atomic.h> | 56 | #include <asm/atomic.h> |
| @@ -2442,31 +2443,43 @@ void __cpuset_memory_pressure_bump(void) | |||
| 2442 | */ | 2443 | */ |
| 2443 | static int proc_cpuset_show(struct seq_file *m, void *v) | 2444 | static int proc_cpuset_show(struct seq_file *m, void *v) |
| 2444 | { | 2445 | { |
| 2446 | struct task_ref *tref; | ||
| 2445 | struct task_struct *tsk; | 2447 | struct task_struct *tsk; |
| 2446 | char *buf; | 2448 | char *buf; |
| 2447 | int retval = 0; | 2449 | int retval; |
| 2448 | 2450 | ||
| 2451 | retval = -ENOMEM; | ||
| 2449 | buf = kmalloc(PAGE_SIZE, GFP_KERNEL); | 2452 | buf = kmalloc(PAGE_SIZE, GFP_KERNEL); |
| 2450 | if (!buf) | 2453 | if (!buf) |
| 2451 | return -ENOMEM; | 2454 | goto out; |
| 2455 | |||
| 2456 | retval = -ESRCH; | ||
| 2457 | tref = m->private; | ||
| 2458 | tsk = get_tref_task(tref); | ||
| 2459 | if (!tsk) | ||
| 2460 | goto out_free; | ||
| 2452 | 2461 | ||
| 2453 | tsk = m->private; | 2462 | retval = -EINVAL; |
| 2454 | mutex_lock(&manage_mutex); | 2463 | mutex_lock(&manage_mutex); |
| 2464 | |||
| 2455 | retval = cpuset_path(tsk->cpuset, buf, PAGE_SIZE); | 2465 | retval = cpuset_path(tsk->cpuset, buf, PAGE_SIZE); |
| 2456 | if (retval < 0) | 2466 | if (retval < 0) |
| 2457 | goto out; | 2467 | goto out_unlock; |
| 2458 | seq_puts(m, buf); | 2468 | seq_puts(m, buf); |
| 2459 | seq_putc(m, '\n'); | 2469 | seq_putc(m, '\n'); |
| 2460 | out: | 2470 | out_unlock: |
| 2461 | mutex_unlock(&manage_mutex); | 2471 | mutex_unlock(&manage_mutex); |
| 2472 | put_task_struct(tsk); | ||
| 2473 | out_free: | ||
| 2462 | kfree(buf); | 2474 | kfree(buf); |
| 2475 | out: | ||
| 2463 | return retval; | 2476 | return retval; |
| 2464 | } | 2477 | } |
| 2465 | 2478 | ||
| 2466 | static int cpuset_open(struct inode *inode, struct file *file) | 2479 | static int cpuset_open(struct inode *inode, struct file *file) |
| 2467 | { | 2480 | { |
| 2468 | struct task_struct *tsk = PROC_I(inode)->task; | 2481 | struct task_ref *tref = PROC_I(inode)->tref; |
| 2469 | return single_open(file, proc_cpuset_show, tsk); | 2482 | return single_open(file, proc_cpuset_show, tref); |
| 2470 | } | 2483 | } |
| 2471 | 2484 | ||
| 2472 | struct file_operations proc_cpuset_operations = { | 2485 | struct file_operations proc_cpuset_operations = { |
