Commit 9303e0c4814d2a6afca878cc35433291e862169c
Committed by
Linus Torvalds
1 parent
f9434ad155
Exists in
master
and in
4 other branches
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>
Showing 1 changed file with 8 additions and 16 deletions Side-by-side Diff
kernel/cpuset.c
... | ... | @@ -1610,34 +1610,26 @@ |
1610 | 1610 | * across a page fault. |
1611 | 1611 | */ |
1612 | 1612 | |
1613 | -static int cpuset_sprintf_cpulist(char *page, struct cpuset *cs) | |
1613 | +static size_t cpuset_sprintf_cpulist(char *page, struct cpuset *cs) | |
1614 | 1614 | { |
1615 | - int ret; | |
1615 | + size_t count; | |
1616 | 1616 | |
1617 | 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 | 1619 | mutex_unlock(&callback_mutex); |
1620 | 1620 | |
1621 | - return ret; | |
1621 | + return count; | |
1622 | 1622 | } |
1623 | 1623 | |
1624 | -static int cpuset_sprintf_memlist(char *page, struct cpuset *cs) | |
1624 | +static size_t cpuset_sprintf_memlist(char *page, struct cpuset *cs) | |
1625 | 1625 | { |
1626 | - NODEMASK_ALLOC(nodemask_t, mask, GFP_KERNEL); | |
1627 | - int retval; | |
1626 | + size_t count; | |
1628 | 1627 | |
1629 | - if (mask == NULL) | |
1630 | - return -ENOMEM; | |
1631 | - | |
1632 | 1628 | mutex_lock(&callback_mutex); |
1633 | - *mask = cs->mems_allowed; | |
1629 | + count = nodelist_scnprintf(page, PAGE_SIZE, cs->mems_allowed); | |
1634 | 1630 | mutex_unlock(&callback_mutex); |
1635 | 1631 | |
1636 | - retval = nodelist_scnprintf(page, PAGE_SIZE, *mask); | |
1637 | - | |
1638 | - NODEMASK_FREE(mask); | |
1639 | - | |
1640 | - return retval; | |
1632 | + return count; | |
1641 | 1633 | } |
1642 | 1634 | |
1643 | 1635 | static ssize_t cpuset_common_file_read(struct cgroup *cont, |