[Devel] [PATCH RHEL7 COMMIT] mm/page_alloc: fix allocation failure of zone-restricted allocation

Konstantin Khorenko khorenko at virtuozzo.com
Thu Mar 28 12:05:22 MSK 2019


The commit is pushed to "branch-rh7-3.10.0-957.10.1.vz7.85.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-957.10.1.vz7.85.4
------>
commit 01abea8eb0dc1842223171232b57fc244eb74483
Author: Andrey Ryabinin <aryabinin at virtuozzo.com>
Date:   Thu Mar 28 12:05:20 2019 +0300

    mm/page_alloc: fix allocation failure of zone-restricted allocation
    
    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 not 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 <aryabinin at 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;
 



More information about the Devel mailing list