aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/cpuset.c
diff options
context:
space:
mode:
authorLi Zefan <lizf@cn.fujitsu.com>2011-03-23 19:42:45 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2011-03-23 22:46:34 -0400
commit9303e0c4814d2a6afca878cc35433291e862169c (patch)
tree786866f6f0639edcc2996d4157ea7128b2400898 /kernel/cpuset.c
parentf9434ad1552427fab49336e1a6e3ef121895b9d1 (diff)
cpuset: remove unneeded NODEMASK_ALLOC() in cpuset_sprintf_memlist()
It's not necessary to copy cpuset->mems_allowed to a buffer allocated by NODEMASK_ALLOC(). Just pass it to nodelist_scnprintf(). As spotted by Paul, a side effect is we fix a bug that the function can return -ENOMEM but the caller doesn't expect negative return value. Therefore change the return value of cpuset_sprintf_cpulist() and cpuset_sprintf_memlist() from int to size_t. Signed-off-by: Li Zefan <lizf@cn.fujitsu.com> Acked-by: Paul Menage <menage@google.com> Acked-by: David Rientjes <rientjes@google.com> Cc: Miao Xie <miaox@cn.fujitsu.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'kernel/cpuset.c')
-rw-r--r--kernel/cpuset.c24
1 files changed, 8 insertions, 16 deletions
diff --git a/kernel/cpuset.c b/kernel/cpuset.c
index e92e98189032..4683fe728c9b 100644
--- a/kernel/cpuset.c
+++ b/kernel/cpuset.c
@@ -1610,34 +1610,26 @@ out:
1610 * across a page fault. 1610 * across a page fault.
1611 */ 1611 */
1612 1612
1613static int cpuset_sprintf_cpulist(char *page, struct cpuset *cs) 1613static size_t cpuset_sprintf_cpulist(char *page, struct cpuset *cs)
1614{ 1614{
1615 int ret; 1615 size_t count;
1616 1616
1617 mutex_lock(&callback_mutex); 1617 mutex_lock(&callback_mutex);
1618 ret = cpulist_scnprintf(page, PAGE_SIZE, cs->cpus_allowed); 1618 count = cpulist_scnprintf(page, PAGE_SIZE, cs->cpus_allowed);
1619 mutex_unlock(&callback_mutex); 1619 mutex_unlock(&callback_mutex);
1620 1620
1621 return ret; 1621 return count;
1622} 1622}
1623 1623
1624static int cpuset_sprintf_memlist(char *page, struct cpuset *cs) 1624static size_t cpuset_sprintf_memlist(char *page, struct cpuset *cs)
1625{ 1625{
1626 NODEMASK_ALLOC(nodemask_t, mask, GFP_KERNEL); 1626 size_t count;
1627 int retval;
1628
1629 if (mask == NULL)
1630 return -ENOMEM;
1631 1627
1632 mutex_lock(&callback_mutex); 1628 mutex_lock(&callback_mutex);
1633 *mask = cs->mems_allowed; 1629 count = nodelist_scnprintf(page, PAGE_SIZE, cs->mems_allowed);
1634 mutex_unlock(&callback_mutex); 1630 mutex_unlock(&callback_mutex);
1635 1631
1636 retval = nodelist_scnprintf(page, PAGE_SIZE, *mask); 1632 return count;
1637
1638 NODEMASK_FREE(mask);
1639
1640 return retval;
1641} 1633}
1642 1634
1643static ssize_t cpuset_common_file_read(struct cgroup *cont, 1635static ssize_t cpuset_common_file_read(struct cgroup *cont,