Received: by 2002:ab2:7a55:0:b0:1f4:4a7d:290d with SMTP id u21csp652382lqp; Fri, 5 Apr 2024 05:12:03 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCX49Thitwj31KNx6l1JQsILu2lpY2qtXjDfRCjF9HToipP/ly/eQeX6DF2aMOMmA+2aVO8M4GSkd6yE4Csd3qusvWOlfl2IZ3zOZ/m8rQ== X-Google-Smtp-Source: AGHT+IGpEKaSYW05piuA0r1Nv9H3b1c37agX7QNJqY7hQ3MZyRm3/iuhOBy6r6uKly98fGA7qhbv X-Received: by 2002:a05:6214:e88:b0:699:2f65:e18f with SMTP id hf8-20020a0562140e8800b006992f65e18fmr1470635qvb.6.1712319123290; Fri, 05 Apr 2024 05:12:03 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712319123; cv=pass; d=google.com; s=arc-20160816; b=rVyLPnYDwV843z9c/G2HlLYYfyyRSoOoiGeh5d531fYwm7JSefU726Yp/LU+AIPYdz eZnZFM5dGo2B/ANX59jfQTpCaqu3FEeNlmL24vuQP4fJioHB9DC46r8oOTci1ZEZw8+w 648228yAezuZ/YxcWG22Lc8s38O9k5E46ib4LfJrwRfwKLvNvjykvIsPXSgD3bTxK77I 9zYvb3KX/nFunBmjnjUkCvbuoJXXO/aJ8VzHHECfQzQ3IGAWTCJP/XDpN15o4zXncitP T/clJh8aOeyB6071RW7gEsTDgUKOjjZD1RmiYWO/f1aSYE14GqNP3wFLCfwJh+curD8W i8wg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to:subject :user-agent:mime-version:list-unsubscribe:list-subscribe:list-id :precedence:date:message-id:dkim-signature; bh=9fz61hlqVv5Z1o8Ub3fZ44zLTWtwbwciinGGCyQu1nk=; fh=DWllDvkmT/mSWGY3c9E7JAQY6a8OJe91dbvnjd/T4Fs=; b=A7Xqz4soGbgQSG2swWmLtn6dWnYdjmE7L2RcjF5qZyZD805+A/uPQyYhfR+DKa2Ugb IdxhkJ8WQId/RJbPegcsA2R2sC6/hThpaR8r71J6oKnXAuvqARZz9Lw//zdzTESVrGF4 36uHQhPn0EPA1Puxs97w52FyMyhyGGlLcLj19B58aL3m177RyAdJgJ6fqPAt4nrz8Nd7 LDQwbrVkokNMPCYK8U7D3PhHPafEAB3YjkWQRQYEn5xyyvEdbZCvBZtmyCUodBj3RHBm VSN2MrsKUEp6GSjExcn+yyGDQ0w4t1FX/KvwYpGviT1Kyo8vylS4slK1emVSvUoPk1GZ tEEQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux.alibaba.com header.s=default header.b=S9ry6wyo; arc=pass (i=1 spf=pass spfdomain=linux.alibaba.com dkim=pass dkdomain=linux.alibaba.com dmarc=pass fromdomain=linux.alibaba.com); spf=pass (google.com: domain of linux-kernel+bounces-132958-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-132958-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.alibaba.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id x18-20020a0ce0d2000000b00699307c54c2si1584113qvk.523.2024.04.05.05.12.03 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Apr 2024 05:12:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-132958-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.alibaba.com header.s=default header.b=S9ry6wyo; arc=pass (i=1 spf=pass spfdomain=linux.alibaba.com dkim=pass dkdomain=linux.alibaba.com dmarc=pass fromdomain=linux.alibaba.com); spf=pass (google.com: domain of linux-kernel+bounces-132958-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-132958-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.alibaba.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id E4EC21C21080 for ; Fri, 5 Apr 2024 12:12:02 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5C70516C852; Fri, 5 Apr 2024 12:11:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.alibaba.com header.i=@linux.alibaba.com header.b="S9ry6wyo" Received: from out30-99.freemail.mail.aliyun.com (out30-99.freemail.mail.aliyun.com [115.124.30.99]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7C1EA16C847 for ; Fri, 5 Apr 2024 12:11:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=115.124.30.99 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712319116; cv=none; b=N8zM5eELPzmIXWLzaE1Bo6q0xSePsDw0p1d2xGkZD5ljikxfjKDxIFwJinyuchLvQcNUWdhc/qTzE+7vrjMPh22lr23SJ0+wa4cmW52QPUC7i8B0iKL1Jk0zUX7ML3fXfuUXathbazFjGFCPuiBQRgR9zwNY4hv3TBqKARkZml0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712319116; c=relaxed/simple; bh=WFlxGTBuwpYiVwdfcrt7KqNmAZYMQlS8lcryaJCATz8=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=j4qZAvWX+wdCidKjsrocyQgZxF038QVOQ5MSO4/T8gCAYMCnk1GijUA3CxZNA1YYwzonnf3TCNFviKT3UgmSUtgRZFr4GG0pvRk4nRDuFWAFa2Eeq0FLOuPe5CRpVaI0274vMimjmep6SF++z27s+HD0padflXaD9rMa4Jc2FLc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com; spf=pass smtp.mailfrom=linux.alibaba.com; dkim=pass (1024-bit key) header.d=linux.alibaba.com header.i=@linux.alibaba.com header.b=S9ry6wyo; arc=none smtp.client-ip=115.124.30.99 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.alibaba.com DKIM-Signature:v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1712319109; h=Message-ID:Date:MIME-Version:Subject:To:From:Content-Type; bh=9fz61hlqVv5Z1o8Ub3fZ44zLTWtwbwciinGGCyQu1nk=; b=S9ry6wyo7kviGQviRlZpcRId8/nEhypYq9s6mKP4545X70ckW+Ss9q7r1Klxu7NRgGdwcmEC3R7fAC9COruCnE4jZvUZGU6XKaWTMvkpNuwHAboNmStvcrjNpQc/NOBgXHf90Xm+kN+nma6zOIejpUkfINinYEeDsBDggih2EAs= X-Alimail-AntiSpam:AC=PASS;BC=-1|-1;BR=01201311R191e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018045168;MF=baolin.wang@linux.alibaba.com;NM=1;PH=DS;RN=9;SR=0;TI=SMTPD_---0W3wvon9_1712319107; Received: from 30.15.228.201(mailfrom:baolin.wang@linux.alibaba.com fp:SMTPD_---0W3wvon9_1712319107) by smtp.aliyun-inc.com; Fri, 05 Apr 2024 20:11:48 +0800 Message-ID: Date: Fri, 5 Apr 2024 20:11:47 +0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 06/10] mm: page_alloc: fix freelist movement during block conversion To: Johannes Weiner , Andrew Morton Cc: Vlastimil Babka , Mel Gorman , Zi Yan , "Huang, Ying" , David Hildenbrand , linux-mm@kvack.org, linux-kernel@vger.kernel.org References: <20240320180429.678181-1-hannes@cmpxchg.org> <20240320180429.678181-7-hannes@cmpxchg.org> From: Baolin Wang In-Reply-To: <20240320180429.678181-7-hannes@cmpxchg.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Hi Johannes, On 2024/3/21 02:02, Johannes Weiner wrote: > Currently, page block type conversion during fallbacks, atomic > reservations and isolation can strand various amounts of free pages on > incorrect freelists. > > For example, fallback stealing moves free pages in the block to the > new type's freelists, but then may not actually claim the block for > that type if there aren't enough compatible pages already allocated. > > In all cases, free page moving might fail if the block straddles more > than one zone, in which case no free pages are moved at all, but the > block type is changed anyway. > > This is detrimental to type hygiene on the freelists. It encourages > incompatible page mixing down the line (ask for one type, get another) > and thus contributes to long-term fragmentation. > > Split the process into a proper transaction: check first if conversion > will happen, then try to move the free pages, and only if that was > successful convert the block to the new type. > > Tested-by: "Huang, Ying" > Signed-off-by: Johannes Weiner > --- > include/linux/page-isolation.h | 3 +- > mm/page_alloc.c | 175 ++++++++++++++++++++------------- > mm/page_isolation.c | 22 +++-- > 3 files changed, 121 insertions(+), 79 deletions(-) > > diff --git a/include/linux/page-isolation.h b/include/linux/page-isolation.h > index 4ac34392823a..8550b3c91480 100644 > --- a/include/linux/page-isolation.h > +++ b/include/linux/page-isolation.h > @@ -34,8 +34,7 @@ static inline bool is_migrate_isolate(int migratetype) > #define REPORT_FAILURE 0x2 > > void set_pageblock_migratetype(struct page *page, int migratetype); > -int move_freepages_block(struct zone *zone, struct page *page, > - int migratetype, int *num_movable); > +int move_freepages_block(struct zone *zone, struct page *page, int migratetype); > > int start_isolate_page_range(unsigned long start_pfn, unsigned long end_pfn, > int migratetype, int flags, gfp_t gfp_flags); > diff --git a/mm/page_alloc.c b/mm/page_alloc.c > index 7373329763e6..e7d0d4711bdd 100644 > --- a/mm/page_alloc.c > +++ b/mm/page_alloc.c > @@ -1596,9 +1596,8 @@ static inline struct page *__rmqueue_cma_fallback(struct zone *zone, > * Note that start_page and end_pages are not aligned on a pageblock > * boundary. If alignment is required, use move_freepages_block() > */ > -static int move_freepages(struct zone *zone, > - unsigned long start_pfn, unsigned long end_pfn, > - int migratetype, int *num_movable) > +static int move_freepages(struct zone *zone, unsigned long start_pfn, > + unsigned long end_pfn, int migratetype) > { > struct page *page; > unsigned long pfn; > @@ -1608,14 +1607,6 @@ static int move_freepages(struct zone *zone, > for (pfn = start_pfn; pfn <= end_pfn;) { > page = pfn_to_page(pfn); > if (!PageBuddy(page)) { > - /* > - * We assume that pages that could be isolated for > - * migration are movable. But we don't actually try > - * isolating, as that would be expensive. > - */ > - if (num_movable && > - (PageLRU(page) || __PageMovable(page))) > - (*num_movable)++; > pfn++; > continue; > } > @@ -1633,17 +1624,16 @@ static int move_freepages(struct zone *zone, > return pages_moved; > } > > -int move_freepages_block(struct zone *zone, struct page *page, > - int migratetype, int *num_movable) > +static bool prep_move_freepages_block(struct zone *zone, struct page *page, > + unsigned long *start_pfn, > + unsigned long *end_pfn, > + int *num_free, int *num_movable) > { > - unsigned long start_pfn, end_pfn, pfn; > - > - if (num_movable) > - *num_movable = 0; > + unsigned long pfn, start, end; > > pfn = page_to_pfn(page); > - start_pfn = pageblock_start_pfn(pfn); > - end_pfn = pageblock_end_pfn(pfn) - 1; > + start = pageblock_start_pfn(pfn); > + end = pageblock_end_pfn(pfn) - 1; > > /* > * The caller only has the lock for @zone, don't touch ranges > @@ -1652,13 +1642,50 @@ int move_freepages_block(struct zone *zone, struct page *page, > * accompanied by other operations such as migratetype updates > * which also should be locked. > */ > - if (!zone_spans_pfn(zone, start_pfn)) > - return 0; > - if (!zone_spans_pfn(zone, end_pfn)) > - return 0; > + if (!zone_spans_pfn(zone, start)) > + return false; > + if (!zone_spans_pfn(zone, end)) > + return false; > + > + *start_pfn = start; > + *end_pfn = end; > + > + if (num_free) { > + *num_free = 0; > + *num_movable = 0; > + for (pfn = start; pfn <= end;) { > + page = pfn_to_page(pfn); > + if (PageBuddy(page)) { > + int nr = 1 << buddy_order(page); > + > + *num_free += nr; > + pfn += nr; > + continue; > + } > + /* > + * We assume that pages that could be isolated for > + * migration are movable. But we don't actually try > + * isolating, as that would be expensive. > + */ > + if (PageLRU(page) || __PageMovable(page)) > + (*num_movable)++; > + pfn++; > + } > + } > + > + return true; > +} > + > +int move_freepages_block(struct zone *zone, struct page *page, > + int migratetype) > +{ > + unsigned long start_pfn, end_pfn; > + > + if (!prep_move_freepages_block(zone, page, &start_pfn, &end_pfn, > + NULL, NULL)) > + return -1; > > - return move_freepages(zone, start_pfn, end_pfn, migratetype, > - num_movable); > + return move_freepages(zone, start_pfn, end_pfn, migratetype); > } > > static void change_pageblock_range(struct page *pageblock_page, > @@ -1743,33 +1770,37 @@ static inline bool boost_watermark(struct zone *zone) > } > > /* > - * This function implements actual steal behaviour. If order is large enough, > - * we can steal whole pageblock. If not, we first move freepages in this > - * pageblock to our migratetype and determine how many already-allocated pages > - * are there in the pageblock with a compatible migratetype. If at least half > - * of pages are free or compatible, we can change migratetype of the pageblock > - * itself, so pages freed in the future will be put on the correct free list. > + * This function implements actual steal behaviour. If order is large enough, we > + * can claim the whole pageblock for the requested migratetype. If not, we check > + * the pageblock for constituent pages; if at least half of the pages are free > + * or compatible, we can still claim the whole block, so pages freed in the > + * future will be put on the correct free list. Otherwise, we isolate exactly > + * the order we need from the fallback block and leave its migratetype alone. > */ > -static void steal_suitable_fallback(struct zone *zone, struct page *page, > - unsigned int alloc_flags, int start_type, bool whole_block) > +static struct page * > +steal_suitable_fallback(struct zone *zone, struct page *page, > + int current_order, int order, int start_type, > + unsigned int alloc_flags, bool whole_block) > { > - unsigned int current_order = buddy_order(page); > int free_pages, movable_pages, alike_pages; > - int old_block_type; > + unsigned long start_pfn, end_pfn; > + int block_type; > > - old_block_type = get_pageblock_migratetype(page); > + block_type = get_pageblock_migratetype(page); > > /* > * This can happen due to races and we want to prevent broken > * highatomic accounting. > */ > - if (is_migrate_highatomic(old_block_type)) > + if (is_migrate_highatomic(block_type)) > goto single_page; > > /* Take ownership for orders >= pageblock_order */ > if (current_order >= pageblock_order) { > + del_page_from_free_list(page, zone, current_order); > change_pageblock_range(page, current_order, start_type); > - goto single_page; > + expand(zone, page, order, current_order, start_type); > + return page; > } > > /* > @@ -1784,10 +1815,9 @@ static void steal_suitable_fallback(struct zone *zone, struct page *page, > if (!whole_block) > goto single_page; > > - free_pages = move_freepages_block(zone, page, start_type, > - &movable_pages); > /* moving whole block can fail due to zone boundary conditions */ > - if (!free_pages) > + if (!prep_move_freepages_block(zone, page, &start_pfn, &end_pfn, > + &free_pages, &movable_pages)) > goto single_page; > > /* > @@ -1805,7 +1835,7 @@ static void steal_suitable_fallback(struct zone *zone, struct page *page, > * vice versa, be conservative since we can't distinguish the > * exact migratetype of non-movable pages. > */ > - if (old_block_type == MIGRATE_MOVABLE) > + if (block_type == MIGRATE_MOVABLE) > alike_pages = pageblock_nr_pages > - (free_pages + movable_pages); > else > @@ -1816,13 +1846,16 @@ static void steal_suitable_fallback(struct zone *zone, struct page *page, > * compatible migratability as our allocation, claim the whole block. > */ > if (free_pages + alike_pages >= (1 << (pageblock_order-1)) || > - page_group_by_mobility_disabled) > + page_group_by_mobility_disabled) { > + move_freepages(zone, start_pfn, end_pfn, start_type); > set_pageblock_migratetype(page, start_type); > - > - return; > + return __rmqueue_smallest(zone, order, start_type); > + } > > single_page: > - move_to_free_list(page, zone, current_order, start_type); > + del_page_from_free_list(page, zone, current_order); > + expand(zone, page, order, current_order, block_type); > + return page; > } > > /* > @@ -1890,9 +1923,10 @@ static void reserve_highatomic_pageblock(struct page *page, struct zone *zone) > mt = get_pageblock_migratetype(page); > /* Only reserve normal pageblocks (i.e., they can merge with others) */ > if (migratetype_is_mergeable(mt)) { > - zone->nr_reserved_highatomic += pageblock_nr_pages; > - set_pageblock_migratetype(page, MIGRATE_HIGHATOMIC); > - move_freepages_block(zone, page, MIGRATE_HIGHATOMIC, NULL); > + if (move_freepages_block(zone, page, MIGRATE_HIGHATOMIC) != -1) { > + set_pageblock_migratetype(page, MIGRATE_HIGHATOMIC); > + zone->nr_reserved_highatomic += pageblock_nr_pages; > + } > } > > out_unlock: > @@ -1917,7 +1951,7 @@ static bool unreserve_highatomic_pageblock(const struct alloc_context *ac, > struct zone *zone; > struct page *page; > int order; > - bool ret; > + int ret; > > for_each_zone_zonelist_nodemask(zone, z, zonelist, ac->highest_zoneidx, > ac->nodemask) { > @@ -1966,10 +2000,14 @@ static bool unreserve_highatomic_pageblock(const struct alloc_context *ac, > * of pageblocks that cannot be completely freed > * may increase. > */ > + ret = move_freepages_block(zone, page, ac->migratetype); > + /* > + * Reserving this block already succeeded, so this should > + * not fail on zone boundaries. > + */ > + WARN_ON_ONCE(ret == -1); > set_pageblock_migratetype(page, ac->migratetype); > - ret = move_freepages_block(zone, page, ac->migratetype, > - NULL); > - if (ret) { > + if (ret > 0) { > spin_unlock_irqrestore(&zone->lock, flags); > return ret; > } > @@ -1990,7 +2028,7 @@ static bool unreserve_highatomic_pageblock(const struct alloc_context *ac, > * deviation from the rest of this file, to make the for loop > * condition simpler. > */ > -static __always_inline bool > +static __always_inline struct page * > __rmqueue_fallback(struct zone *zone, int order, int start_migratetype, > unsigned int alloc_flags) > { > @@ -2037,7 +2075,7 @@ __rmqueue_fallback(struct zone *zone, int order, int start_migratetype, > goto do_steal; > } > > - return false; > + return NULL; > > find_smallest: > for (current_order = order; current_order < NR_PAGE_ORDERS; current_order++) { > @@ -2057,14 +2095,14 @@ __rmqueue_fallback(struct zone *zone, int order, int start_migratetype, > do_steal: > page = get_page_from_free_area(area, fallback_mt); > > - steal_suitable_fallback(zone, page, alloc_flags, start_migratetype, > - can_steal); > + /* take off list, maybe claim block, expand remainder */ > + page = steal_suitable_fallback(zone, page, current_order, order, > + start_migratetype, alloc_flags, can_steal); > > trace_mm_page_alloc_extfrag(page, order, current_order, > start_migratetype, fallback_mt); > > - return true; > - > + return page; > } > > #ifdef CONFIG_CMA > @@ -2127,15 +2165,14 @@ __rmqueue(struct zone *zone, unsigned int order, int migratetype, > return page; > } > } > -retry: > + > page = __rmqueue_smallest(zone, order, migratetype); > if (unlikely(!page)) { > if (alloc_flags & ALLOC_CMA) > page = __rmqueue_cma_fallback(zone, order); > - > - if (!page && __rmqueue_fallback(zone, order, migratetype, > - alloc_flags)) > - goto retry; > + else > + page = __rmqueue_fallback(zone, order, migratetype, > + alloc_flags); (Sorry for chim in late.) I have some doubts about the changes here. The original code logic was that if the 'migratetype' type allocation is failed, it would first try CMA page allocation and then attempt to fallback to other migratetype allocations. Now it has been changed so that if CMA allocation fails, it will directly return. This change has caused a regression when I running the thpcompact benchmark, resulting in a significant reduction in the percentage of THPs like below: thpcompact Percentage Faults Huge K6.9-rc2 K6.9-rc2 + this patch Percentage huge-1 78.18 ( 0.00%) 42.49 ( -45.65%) Percentage huge-3 86.70 ( 0.00%) 35.13 ( -59.49%) Percentage huge-5 90.26 ( 0.00%) 52.35 ( -42.00%) Percentage huge-7 92.34 ( 0.00%) 31.84 ( -65.52%) Percentage huge-12 91.18 ( 0.00%) 45.85 ( -49.72%) Percentage huge-18 89.00 ( 0.00%) 29.18 ( -67.22%) Percentage huge-24 90.52 ( 0.00%) 46.68 ( -48.43%) Percentage huge-30 94.44 ( 0.00%) 38.35 ( -59.39%) Percentage huge-32 93.09 ( 0.00%) 39.37 ( -57.70%) After making the following modifications, the regression is gone. diff --git a/mm/page_alloc.c b/mm/page_alloc.c index ce67dc6777fa..a7cfe65e45c1 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -2139,7 +2139,8 @@ __rmqueue(struct zone *zone, unsigned int order, int migratetype, if (unlikely(!page)) { if (alloc_flags & ALLOC_CMA) page = __rmqueue_cma_fallback(zone, order); - else + + if (!page) page = __rmqueue_fallback(zone, order, migratetype, alloc_flags); } But I am not sure your original change is intentional? IIUC, we still need try fallbacking even though CMA allocation is failed, please correct me if I misunderstand your code. Thanks.