mem/oom: fixed a cpuset error

For the below special NUMA system, oom0[4|5] failed:
 # numactl -H
 available: 2 nodes (0-1)
 node 0 cpus: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
 node 0 size: 0 MB
 node 0 free: 0 MB
 node 1 cpus:
 node 1 size: 16384 MB
 node 1 free: 14173 MB
 node distances:
 node   0   1
   0:  10  40
   1:  40  10

failed log:
 oom04       1  TBROK  :  write /dev/cpuset/1/cpuset.mems: errno=EINVAL(22): Invalid argument

The reason is that node0 only contains all CPUs, no any memory,
and node1 contains all memory, but no CPUs. In the previous codes,
we only do cpuset testing on an independent node, which caused the
sub-cpuset cgroup to only contain CPUs or memory in one node, but
that's not permitted in the scenario described above.

Signed-off-by: Zhouping Liu <zliu@redhat.com>
Reviewed-by: Caspar Zhang <caspar@casparzhang.com>
Acked-by: Wanlong Gao <gaowanlong@cn.fujitsu.com>
Signed-off-by: Wanlong Gao <gaowanlong@cn.fujitsu.com>
3 files changed