The following command sequence fails:
        mkdir -p /sys/fs/cgroup/cpuset/test
        echo 1 >  /sys/fs/cgroup/cpuset/test/cpuset.mems
        echo 1 >  /sys/fs/cgroup/cpuset/test/cpuset.cpus
        echo $$ > /sys/fs/cgroup/cpuset/test/tasks
        /usr/libexec/qemu-kvm -enable-kvm
        kvm_init_vcpu failed: Cannot allocate memory

kvm_init_vcpu() calls KVM_CREATE_VCPU ioctl() which fails with
ENOMEM because it calls __alloc_page(GFP_KERNEL|__GFP_DMA32)
and DMA32 zone present only on NUMA node 0 while process is bound
to the 1 NUMA node. However such allocation should fail, because
there is no __GFP_HARDWALL flag, thus it allowed to fallback
to the 0 NUMA node.

Allocation fails because on the fast-path we try to find zone
withing cpuset_current_mems_allowed nodemask and don't fallback
to default nodemask if zone not found.

https://jira.sw.ru/browse/PSBM-92274
Signed-off-by: Andrey Ryabinin <aryabi...@virtuozzo.com>
---
 mm/page_alloc.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 5dc48331242a..45da030d8da2 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -3576,6 +3576,14 @@ __alloc_pages_nodemask(gfp_t gfp_mask, unsigned int 
order,
        first_zones_zonelist(zonelist, high_zoneidx,
                                nodemask ? : &cpuset_current_mems_allowed,
                                &preferred_zone);
+
+       /*
+        * No zone within cpuset_current_mems_allowed nodemask?
+        * Fallback to default nodemask.
+        */
+       if (!preferred_zone && !nodemask)
+               first_zones_zonelist(zonelist, high_zoneidx,
+                               nodemask, &preferred_zone);
        if (!preferred_zone)
                goto out;
 
-- 
2.19.2

_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel

Reply via email to