lib/mem: modified _gather_cpus() as _gather_node_cpus()

The previous _gather_cpus() tried to collect all the specified
node's cpus, but it didn't pay attention to the offline cpus,
if one cpu in the specified node were offline, it can't write
the cpu number to cgroups/*.cpus, and return -EINVAL.

The patch fixed it, and modified the function name, as the new
name make more sense.

Signed-off-by: Zhouping Liu <zliu@redhat.com>
Acked-by: Wanlong Gao <gaowanlong@cn.fujitsu.com>
Reviewed-by: Caspar Zhang <caspar@casparzhang.com>
Signed-off-by: Wanlong Gao <gaowanlong@cn.fujitsu.com>
mm/oom02: modified 'OOM for NUMA' as 'OOM for mempolicy'

NUMA mechanism can be interpreted as 'memory policy', there are
several mempolicys, such as MPOL_BIND, MPOL_INTERLEAVE,
MPOL_PREFERRED etc, not only MPOL_BIND, so the patch extended OOM
on NUMA system, added MPOL_INTERLEAVE and MPOL_PREFERRED mempolicy.

And the patch also moved 'set_mempolicy()' from child process, and
made it executed inside testoom() func, which is easy to control.

Signed-off-by: Zhouping Liu <zliu@redhat.com>
Acked-by: Wanlong Gao <gaowanlong@cn.fujitsu.com>
Reviewed-by: Caspar Zhang <caspar@casparzhang.com>
Signed-off-by: Wanlong Gao <gaowanlong@cn.fujitsu.com>
numa_helper: added a new function is_numa()

Added a new function is_numa(), which is desinged to judge
whether a system contains more than 1 available numa nodes
or not, and lots of cases need it.

Signed-off-by: Zhouping Liu <zliu@redhat.com>
Acked-by: Wanlong Gao <gaowanlong@cn.fujitsu.com>
Reviewed-by: Caspar Zhang <caspar@casparzhang.com>
Signed-off-by: Wanlong Gao <gaowanlong@cn.fujitsu.com>
mm/oom0[3|4]: added 'OOM for CPUSET' and moved 'OOM with MEMCG & numa' to oom03

OOM with the combination of memcg & numa was moved to oom03,
and oom04 is re-design to be used to test 'OOM with CPUSET'.

also used is_numa() instead of the old method.

Signed-off-by: Zhouping Liu <zliu@redhat.com>
Acked-by: Wanlong Gao <gaowanlong@cn.fujitsu.com>
Reviewed-by: Caspar Zhang <caspar@casparzhang.com>
Signed-off-by: Wanlong Gao <gaowanlong@cn.fujitsu.com>
lib/mem: updated testoom() and oom() funcs

the 'numa' parameter inside testoom() and 'mempolicy' inside oom()
were useless, so removed them.

Signed-off-by: Zhouping Liu <zliu@redhat.com>
Acked-by: Wanlong Gao <gaowanlong@cn.fujitsu.com>
Reviewed-by: Caspar Zhang <caspar@casparzhang.com>
Signed-off-by: Wanlong Gao <gaowanlong@cn.fujitsu.com>
mm/oom05: new testcase

added a new case to test OOM under the combination
of MEMCG and CPUSET.

Signed-off-by: Zhouping Liu <zliu@redhat.com>
Acked-by: Wanlong Gao <gaowanlong@cn.fujitsu.com>
Reviewed-by: Caspar Zhang <caspar@casparzhang.com>
Signed-off-by: Wanlong Gao <gaowanlong@cn.fujitsu.com>
lib/mem: removed the prefix underscore '_' of the internal function name

as chrubis' suggestion, the prefix that start with
_ or __ are reserved for compiler/libc implementation,
inside this patch, I removed all the prefix '_' of
the internal function name.

Signed-off-by: Zhouping Liu <zliu@redhat.com>
Acked-by: Wanlong Gao <gaowanlong@cn.fujitsu.com>
Reviewed-by: Caspar Zhang <caspar@casparzhang.com>
Signed-off-by: Wanlong Gao <gaowanlong@cn.fujitsu.com>
inode02: fix "slash" array overrun

Remove "slash" array and convert strcat to snprintf.

Signed-off-by: Jan Stancek <jstancek@redhat.com>
Reviewed-by: Wanlong Gao <gaowanlong@cn.fujitsu.com>
Reviewed-by: Caspar Zhang <caspar@casparzhang.com>
Signed-off-by: Wanlong Gao <gaowanlong@cn.fujitsu.com>
inode01: remove "slash" array

and replace strcats with snprintf.

Signed-off-by: Jan Stancek <jstancek@redhat.com>
Reviewed-by: Wanlong Gao <gaowanlong@cn.fujitsu.com>
Reviewed-by: Caspar Zhang <caspar@casparzhang.com>
Signed-off-by: Wanlong Gao <gaowanlong@cn.fujitsu.com>