Re: [PATCH] mm/memcg: swappiness should between 0 and 100

Gavin Shan
2012-07-06T05:16:58Z

On Fri, Jul 06, 2012 at 12:51:52PM +0800, Wanpeng Li wrote:
>From: Wanpeng Li <liwp@linux.vnet.ibm.com>
>
>Signed-off-by: Wanpeng Li <liwp.linux@gmail.com>
>---
> mm/memcontrol.c | 2 +-
> 1 files changed, 1 insertions(+), 1 deletions(-)
>
>diff --git a/mm/memcontrol.c b/mm/memcontrol.c
>index 5e4d1ab..69a7d45 100644
>--- a/mm/memcontrol.c
>+++ b/mm/memcontrol.c
>@@ -4176,7 +4176,7 @@ static int mem_cgroup_swappiness_write(struct cgroup *cgrp, struct cftype *cft,
> struct mem_cgroup *memcg = mem_cgroup_from_cont(cgrp);
> struct mem_cgroup *parent;
>
>- if (val > 100)
>+ if (val > 100 || val < 0)

Wanpeng, the "val" was defined as "u64". So how it could be less than 0?

static int mem_cgroup_swappiness_write(struct cgroup *cgrp, struct cftype *cft,
u64 val)

Thanks,
Gavin

> return -EINVAL;
>
> if (cgrp->parent == NULL)
>--
>1.7.5.4