From nobody Fri Apr 10 04:51:08 2026 Received: from mail-qv1-f43.google.com (mail-qv1-f43.google.com [209.85.219.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3EF3917F7 for ; Tue, 25 Feb 2025 00:10:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740442237; cv=none; b=OwV3tJ9xr6sNMcex8aXDj578lcPylonwYhF/O+fYbZmVtKCsdIpV72Jo3QcJxZhW4FoS1VDN2LVMAjAKN616mnLC1eUzjbRBaGj05J5bNfbpl6w2vg+OLLCuIxHG6/575cLx0AV8r+W51hSz6p6jlX1U6/5MElH9h9nZcDTL/xQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740442237; c=relaxed/simple; bh=vW6/f9HmG6tIbyx0iIEK4VXIjaqoMfGskZQtTPAvwdk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=FTuJMf6DZwEB4g+t4kIkQKw2OX123t70oEG6pSeufDbVQhUf6jFYY1/JkupxzHEcIh3r3mWs9A2aHYENGad+DawhnwIdPmiji5U+Y6BDlqQrABJ5OsTpBoY/YspW/x7YIellwyS+HY+I7LSbwBxF3mfk1oSvHVnUjIhUL8bCuWU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=cmpxchg.org; spf=pass smtp.mailfrom=cmpxchg.org; dkim=pass (2048-bit key) header.d=cmpxchg-org.20230601.gappssmtp.com header.i=@cmpxchg-org.20230601.gappssmtp.com header.b=bBMqLMA6; arc=none smtp.client-ip=209.85.219.43 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=cmpxchg.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=cmpxchg.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=cmpxchg-org.20230601.gappssmtp.com header.i=@cmpxchg-org.20230601.gappssmtp.com header.b="bBMqLMA6" Received: by mail-qv1-f43.google.com with SMTP id 6a1803df08f44-6ddcff5a823so40602256d6.0 for ; Mon, 24 Feb 2025 16:10:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cmpxchg-org.20230601.gappssmtp.com; s=20230601; t=1740442233; x=1741047033; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Jfbz8GKSHpu/xyC6cCph+07KnkaKzui+briDAaa0nnU=; b=bBMqLMA6k26Yh7fvf+n5C0NkpxW8G1qvzE2lnvVw4+PgN8lRKIckzKI615W/7Bc2ZP bJYRblCiB/217+R0oOCoYtI2TugSJzFC+nLsPWoUUIplGrSe6erUrqQJg6N/AjpVDY/7 lsKMcappEloKmfPhl8oySbbhDnNB+NlqVF4zLwNm1ozLYSQk8ziwKcAa3N2X2mA2ZXs3 Dye1YR0/N1F5gCLcV56r4Jg1mqO8bEZNPHVJkdUKy7PscTP210UqzPP81WUAgUSf8ZAA VKRcAd7aHAqskqLqvPRsP9/MzgAwrVGWxQl5GYY4i70RCqKADSmjIqU677G1E5IRcFhe UyGA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1740442233; x=1741047033; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Jfbz8GKSHpu/xyC6cCph+07KnkaKzui+briDAaa0nnU=; b=BZVrYR8DtjFUg6UQ4fDG2XhuZ2FGpfUy1YEPA7eMcVbsBinzKFZk69FSc3xZJ7fome QZS7hDW0MSqENSP97hAOuAOUUhEQXQi7s46FITrvn2UIwF2sgdFRaTekk9IsBcLa9D2w WpPmtcYtSLsVl7eoIbrGARXqR3sYUb3FtIkDG+QPdrvtUk0a4NHVHHBEtEYVxCCEbgfJ Dz8Z6e1HBmSvl+zW4/JMsEagJeXhPcCvvjhH3IXK7iFq4BGAoYKcW7762K5OituKiBlX aTH6vDgoL1oJ8eEilV3mCT7rWB9Uco06/5G7QX5S/9GnPt7LR0kY3Zvm/i+oiai+HOxv YpPg== X-Forwarded-Encrypted: i=1; AJvYcCWm8apDT3HedCnlHKkaVLyM5s7fSJqb6T3kRESU/P82dnPZmIV0BGl77syfdiT/AboquEEu+rPejQyOXgs=@vger.kernel.org X-Gm-Message-State: AOJu0YwxfuREnI6vRbDL/2z6rp/ZIrwTVH+IeUvDXk7quPzvVITCTN5H hmzEvZWBJSgIwNxvpcFsSmS9nEmo70yG8FMheQitLUPVNJhSz9dQL8f9LSJ7PDc= X-Gm-Gg: ASbGncu9gq9lQUJifa8YtVeIdFcNcQlr3UBZv0zlw9M/Pl9yod0zHstpBlsuVDrw8bR 25fVtfiZwPlKUY8wzjXJ5WhRYRBBuCnJjqlOGlQNM9RLT+zvrYe5EzYMo3iq5Klco0uyd6IEohc vcyO/QjXl0zZZD9b43eWQ0k4cNOJvVgI2FmkK5RPpoJyUJ6pTUHP7ssA7i8O05ZVvbiwWDFJ0zp 1+rPaOzFcRuefjWhNWhnmyRKg97W/NXz7izNoYxRqely12B5f24IDEHAnJRlWE0XYbAa0zL9Ggs gb4qShhWiziJTg1i5snlKBQP X-Google-Smtp-Source: AGHT+IGM3VVUjbDeCXvrKFFPK7jbq7t2UH3GiR9glB2p9o0jhpvV1lYU60G0oFU/Ke/PG5Pti/cUBg== X-Received: by 2002:a05:6214:1bcb:b0:6e6:5a8a:aba with SMTP id 6a1803df08f44-6e6ae829f34mr221625886d6.21.1740442232965; Mon, 24 Feb 2025 16:10:32 -0800 (PST) Received: from localhost ([2603:7000:c01:2716:da5e:d3ff:fee7:26e7]) by smtp.gmail.com with UTF8SMTPSA id 6a1803df08f44-6e87b1564easm3076106d6.72.2025.02.24.16.10.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Feb 2025 16:10:32 -0800 (PST) From: Johannes Weiner To: Andrew Morton Cc: Vlastimil Babka , Brendan Jackman , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/3] mm: page_alloc: don't steal single pages from biggest buddy Date: Mon, 24 Feb 2025 19:08:24 -0500 Message-ID: <20250225001023.1494422-2-hannes@cmpxchg.org> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250225001023.1494422-1-hannes@cmpxchg.org> References: <20250225001023.1494422-1-hannes@cmpxchg.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The fallback code searches for the biggest buddy first in an attempt to steal the whole block and encourage type grouping down the line. The approach used to be this: - Non-movable requests will split the largest buddy and steal the remainder. This splits up contiguity, but it allows subsequent requests of this type to fall back into adjacent space. - Movable requests go and look for the smallest buddy instead. The thinking is that movable requests can be compacted, so grouping is less important than retaining contiguity. c0cd6f557b90 ("mm: page_alloc: fix freelist movement during block conversion") enforces freelist type hygiene, which restricts stealing to either claiming the whole block or just taking the requested chunk; no additional pages or buddy remainders can be stolen any more. The patch mishandled when to switch to finding the smallest buddy in that new reality. As a result, it may steal the exact request size, but from the biggest buddy. This causes fracturing for no good reason. Fix this by committing to the new behavior: either steal the whole block, or fall back to the smallest buddy. Remove single-page stealing from steal_suitable_fallback(). Rename it to try_to_steal_block() to make the intentions clear. If this fails, always fall back to the smallest buddy. The following is from 4 runs of mmtest's thpchallenge. "Pollute" is single page fallback, "steal" is conversion of a partially used block. The numbers for free block conversions (omitted) are comparable. vanilla patched @pollute[unmovable from reclaimable]: 27 106 @pollute[unmovable from movable]: 82 46 @pollute[reclaimable from unmovable]: 256 83 @pollute[reclaimable from movable]: 46 8 @pollute[movable from unmovable]: 4841 868 @pollute[movable from reclaimable]: 5278 12568 @steal[unmovable from reclaimable]: 11 12 @steal[unmovable from movable]: 113 49 @steal[reclaimable from unmovable]: 19 34 @steal[reclaimable from movable]: 47 21 @steal[movable from unmovable]: 250 183 @steal[movable from reclaimable]: 81 93 The allocator appears to do a better job at keeping stealing and polluting to the first fallback preference. As a result, the numbers for "from movable" - the least preferred fallback option, and most detrimental to compactability - are down across the board. Fixes: c0cd6f557b90 ("mm: page_alloc: fix freelist movement during block co= nversion") Suggested-by: Vlastimil Babka Signed-off-by: Johannes Weiner Reviewed-by: Brendan Jackman Reviewed-by: Vlastimil Babka --- mm/page_alloc.c | 80 +++++++++++++++++++++---------------------------- 1 file changed, 34 insertions(+), 46 deletions(-) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 16dfcf7ade74..9ea14ec52449 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -1986,13 +1986,12 @@ static inline bool boost_watermark(struct zone *zon= e) * 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 exac= tly - * the order we need from the fallback block and leave its migratetype alo= ne. + * future will be put on the correct free list. */ 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) +try_to_steal_block(struct zone *zone, struct page *page, + int current_order, int order, int start_type, + unsigned int alloc_flags) { int free_pages, movable_pages, alike_pages; unsigned long start_pfn; @@ -2005,7 +2004,7 @@ steal_suitable_fallback(struct zone *zone, struct pag= e *page, * highatomic accounting. */ if (is_migrate_highatomic(block_type)) - goto single_page; + return NULL; =20 /* Take ownership for orders >=3D pageblock_order */ if (current_order >=3D pageblock_order) { @@ -2026,14 +2025,10 @@ steal_suitable_fallback(struct zone *zone, struct p= age *page, if (boost_watermark(zone) && (alloc_flags & ALLOC_KSWAPD)) set_bit(ZONE_BOOSTED_WATERMARK, &zone->flags); =20 - /* We are not allowed to try stealing from the whole block */ - if (!whole_block) - goto single_page; - /* moving whole block can fail due to zone boundary conditions */ if (!prep_move_freepages_block(zone, page, &start_pfn, &free_pages, &movable_pages)) - goto single_page; + return NULL; =20 /* * Determine how many pages are compatible with our allocation. @@ -2066,9 +2061,7 @@ steal_suitable_fallback(struct zone *zone, struct pag= e *page, return __rmqueue_smallest(zone, order, start_type); } =20 -single_page: - page_del_and_expand(zone, page, order, current_order, block_type); - return page; + return NULL; } =20 /* @@ -2250,14 +2243,19 @@ static bool unreserve_highatomic_pageblock(const st= ruct alloc_context *ac, } =20 /* - * Try finding a free buddy page on the fallback list and put it on the fr= ee - * list of requested migratetype, possibly along with other pages from the= same - * block, depending on fragmentation avoidance heuristics. Returns true if - * fallback was found so that __rmqueue_smallest() can grab it. + * Try finding a free buddy page on the fallback list. + * + * This will attempt to steal a whole pageblock for the requested type + * to ensure grouping of such requests in the future. + * + * If a whole block cannot be stolen, regress to __rmqueue_smallest() + * logic to at least break up as little contiguity as possible. * * The use of signed ints for order and current_order is a deliberate * deviation from the rest of this file, to make the for loop * condition simpler. + * + * Return the stolen page, or NULL if none can be found. */ static __always_inline struct page * __rmqueue_fallback(struct zone *zone, int order, int start_migratetype, @@ -2291,45 +2289,35 @@ __rmqueue_fallback(struct zone *zone, int order, in= t start_migratetype, if (fallback_mt =3D=3D -1) continue; =20 - /* - * We cannot steal all free pages from the pageblock and the - * requested migratetype is movable. In that case it's better to - * steal and split the smallest available page instead of the - * largest available page, because even if the next movable - * allocation falls back into a different pageblock than this - * one, it won't cause permanent fragmentation. - */ - if (!can_steal && start_migratetype =3D=3D MIGRATE_MOVABLE - && current_order > order) - goto find_smallest; + if (!can_steal) + break; =20 - goto do_steal; + page =3D get_page_from_free_area(area, fallback_mt); + page =3D try_to_steal_block(zone, page, current_order, order, + start_migratetype, alloc_flags); + if (page) + goto got_one; } =20 - return NULL; + if (alloc_flags & ALLOC_NOFRAGMENT) + return NULL; =20 -find_smallest: + /* No luck stealing blocks. Find the smallest fallback page */ for (current_order =3D order; current_order < NR_PAGE_ORDERS; current_ord= er++) { area =3D &(zone->free_area[current_order]); fallback_mt =3D find_suitable_fallback(area, current_order, start_migratetype, false, &can_steal); - if (fallback_mt !=3D -1) - break; - } - - /* - * This should not happen - we already found a suitable fallback - * when looking for the largest page. - */ - VM_BUG_ON(current_order > MAX_PAGE_ORDER); + if (fallback_mt =3D=3D -1) + continue; =20 -do_steal: - page =3D get_page_from_free_area(area, fallback_mt); + page =3D get_page_from_free_area(area, fallback_mt); + page_del_and_expand(zone, page, order, current_order, fallback_mt); + goto got_one; + } =20 - /* take off list, maybe claim block, expand remainder */ - page =3D steal_suitable_fallback(zone, page, current_order, order, - start_migratetype, alloc_flags, can_steal); + return NULL; =20 +got_one: trace_mm_page_alloc_extfrag(page, order, current_order, start_migratetype, fallback_mt); =20 --=20 2.48.1 From nobody Fri Apr 10 04:51:08 2026 Received: from mail-qk1-f176.google.com (mail-qk1-f176.google.com [209.85.222.176]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3F50036D for ; Tue, 25 Feb 2025 00:10:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.176 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740442238; cv=none; b=fI9ljAItsIk6PuPhaVJn4zGw/k4gUQ6x0Oztx2AP/xdp6Q2Cbbtvue4vIlnGNzY+dfW/QEZ7h4qtVezk6LRr4wksYHa3roDuxHOQqO7FTWkdhwlPys7NvltbO8BHjcW2sRfPrYkAtpfIa3y5x+KtsgvisugILXbgrCXNt+HwE4M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740442238; c=relaxed/simple; bh=dzh9En4UkKwYrVaxUww9kNyMQJhaqTBw63J9KDBkO1o=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=fhD4mI0b32oHQZ5uD1uvjSH7th6t55rlrau/OeF6M2ZFueYrybKY0kY4sBIB/swWV1HlKuRI0NmesDquPCs0PvR2K0Yd69Ap1AXwRIrlSmQncsMy2cYLh+fh0Q6xGV3KUOFWFrolhfmvJ8gqCc2tUF1pzy3UigAjYOmzdahUl7w= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=cmpxchg.org; spf=pass smtp.mailfrom=cmpxchg.org; dkim=pass (2048-bit key) header.d=cmpxchg-org.20230601.gappssmtp.com header.i=@cmpxchg-org.20230601.gappssmtp.com header.b=mYGo+OtQ; arc=none smtp.client-ip=209.85.222.176 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=cmpxchg.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=cmpxchg.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=cmpxchg-org.20230601.gappssmtp.com header.i=@cmpxchg-org.20230601.gappssmtp.com header.b="mYGo+OtQ" Received: by mail-qk1-f176.google.com with SMTP id af79cd13be357-7c089b2e239so531704385a.0 for ; Mon, 24 Feb 2025 16:10:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cmpxchg-org.20230601.gappssmtp.com; s=20230601; t=1740442235; x=1741047035; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=m4nVpOQMfdjSDVLItpR5dEn5Uy7LgPPGmplcVb1mIdw=; b=mYGo+OtQisgNhLJt+5xvOmo+BDS+u2SYjt0xIaHnNPbtrk3UPgrbrqvzzFbNCMLLFR Zc0uOjJBM8JqZzMZb+EI5vw1ND1Dani2oq1G/NKyANywGn9NQIAXC9jllxOU3ieUSFBd yKoc3A49zVRLOfvUlEvrX6KvGtRQ/kWZQx49u+Ddlm2obJ+suYKya7nPZ20M2IZ4iCRB MNogsfrvvAHb9XZlDxbDTWngBx2quUT2KAKKAix5KE7bL6R97DL55oKSa/TVOLOyL1CT su4U9m9/PiRDLFGh8cVOuqx//J1739IrODNiFabIi5MFLWCqCV9q9q5dhCnotTEJiiwn Daxw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1740442235; x=1741047035; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=m4nVpOQMfdjSDVLItpR5dEn5Uy7LgPPGmplcVb1mIdw=; b=KpGjFfWUXUltXOaC+8zMwWNtsIrO58ci8a+ScVGTzB0r4jG3Z1dKi2hxtHHQc2vdLp GOYnLSi/J1re0jMYy+TOITYIO7yppp3nNcwI/nAaepcMBmuJCBqHO9+0oTWZNagGYCcU VpCT9tnoskwNpyNtP2yNEdscWEV6xaQKNoby3n34WyY5I0+lmqzgWZXVmhcFWiPFgJyO Vpuv4NM7YRyzmETCABGmqdVaCnz3rfHxiuaiYdd1B/fKpopplJQRP7rDZAGsjKr40UoD 4ySPzTXvQP1DGUDUgb8GlPjnQ1TJPDvzi9vc95yrSveRGCnggXgB33ElpcuiEd4Z210U cEaw== X-Forwarded-Encrypted: i=1; AJvYcCUYx8n1ahzhoKhry2rnEErmq23Taq0hNi0aj/xbqOWl9VqXVJQUbAUMzout8uc66zuZqGVOkuY8Xc953hI=@vger.kernel.org X-Gm-Message-State: AOJu0YxoCsJlqW2UAi26FzshEwBO+RX3Hw3nSYnFYKGn92epOAzkWyz+ pxbUHQeW61OSaWIVU7qaJPklimsyAfHivYxRhheVTE2qLGX4RU7m2x0/ujstkNM= X-Gm-Gg: ASbGncvWPQs/VtAqBCnbjlBR/bCwkY3ChHOcb8l+9C6qJqp2xPtDJrv2bKuybEXnejC 7NFbe7ILsNr4VgF+PVSlGWlYm1H8EAhrTgY5K5HnRXT+V6WqOU6OpSaylTau3oR+RP21cp1UoHN E9HjK0wzvhUBY1zFkTwxki0+rKmlFLBIv1dkha4WUISkv2vmaUqFx+k987mT5AYE/QlrTp4jkl3 K3DUJi8DYHZNGixmZ9GWyg88aWAqQbEOYz0qM3jaMb+P67n8eULsujj8VVopEht4cDZjDTSzzBj XfoyJimqA8IVJeiaOy9pErfJ X-Google-Smtp-Source: AGHT+IGoJS6Omh/ikKjODCsa7sYHe0e2NcEJ5qqBqC2I0BPARGB9vb4PzMba6XBAw4fGsuwISK59Ag== X-Received: by 2002:a05:620a:4621:b0:7be:73f6:9e86 with SMTP id af79cd13be357-7c0c227c72dmr2463429485a.20.1740442235091; Mon, 24 Feb 2025 16:10:35 -0800 (PST) Received: from localhost ([2603:7000:c01:2716:da5e:d3ff:fee7:26e7]) by smtp.gmail.com with UTF8SMTPSA id 6a1803df08f44-6e87b06dd05sm3185086d6.8.2025.02.24.16.10.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Feb 2025 16:10:34 -0800 (PST) From: Johannes Weiner To: Andrew Morton Cc: Vlastimil Babka , Brendan Jackman , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/3] mm: page_alloc: remove remnants of unlocked migratetype updates Date: Mon, 24 Feb 2025 19:08:25 -0500 Message-ID: <20250225001023.1494422-3-hannes@cmpxchg.org> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250225001023.1494422-1-hannes@cmpxchg.org> References: <20250225001023.1494422-1-hannes@cmpxchg.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The freelist hygiene patches made migratetype accesses fully protected under the zone->lock. Remove remnants of handling the race conditions that existed before from the MIGRATE_HIGHATOMIC code. Signed-off-by: Johannes Weiner Reviewed-by: Brendan Jackman Reviewed-by: Vlastimil Babka --- mm/page_alloc.c | 50 ++++++++++++++++--------------------------------- 1 file changed, 16 insertions(+), 34 deletions(-) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 9ea14ec52449..53d315aa69c4 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -1991,20 +1991,10 @@ static inline bool boost_watermark(struct zone *zon= e) static struct page * try_to_steal_block(struct zone *zone, struct page *page, int current_order, int order, int start_type, - unsigned int alloc_flags) + int block_type, unsigned int alloc_flags) { int free_pages, movable_pages, alike_pages; unsigned long start_pfn; - int block_type; - - block_type =3D get_pageblock_migratetype(page); - - /* - * This can happen due to races and we want to prevent broken - * highatomic accounting. - */ - if (is_migrate_highatomic(block_type)) - return NULL; =20 /* Take ownership for orders >=3D pageblock_order */ if (current_order >=3D pageblock_order) { @@ -2179,33 +2169,22 @@ static bool unreserve_highatomic_pageblock(const st= ruct alloc_context *ac, spin_lock_irqsave(&zone->lock, flags); for (order =3D 0; order < NR_PAGE_ORDERS; order++) { struct free_area *area =3D &(zone->free_area[order]); - int mt; + unsigned long size; =20 page =3D get_page_from_free_area(area, MIGRATE_HIGHATOMIC); if (!page) continue; =20 - mt =3D get_pageblock_migratetype(page); /* - * In page freeing path, migratetype change is racy so - * we can counter several free pages in a pageblock - * in this loop although we changed the pageblock type - * from highatomic to ac->migratetype. So we should - * adjust the count once. + * It should never happen but changes to + * locking could inadvertently allow a per-cpu + * drain to add pages to MIGRATE_HIGHATOMIC + * while unreserving so be safe and watch for + * underflows. */ - if (is_migrate_highatomic(mt)) { - unsigned long size; - /* - * It should never happen but changes to - * locking could inadvertently allow a per-cpu - * drain to add pages to MIGRATE_HIGHATOMIC - * while unreserving so be safe and watch for - * underflows. - */ - size =3D max(pageblock_nr_pages, 1UL << order); - size =3D min(size, zone->nr_reserved_highatomic); - zone->nr_reserved_highatomic -=3D size; - } + size =3D max(pageblock_nr_pages, 1UL << order); + size =3D min(size, zone->nr_reserved_highatomic); + zone->nr_reserved_highatomic -=3D size; =20 /* * Convert to ac->migratetype and avoid the normal @@ -2217,10 +2196,12 @@ static bool unreserve_highatomic_pageblock(const st= ruct alloc_context *ac, * may increase. */ if (order < pageblock_order) - ret =3D move_freepages_block(zone, page, mt, + ret =3D move_freepages_block(zone, page, + MIGRATE_HIGHATOMIC, ac->migratetype); else { - move_to_free_list(page, zone, order, mt, + move_to_free_list(page, zone, order, + MIGRATE_HIGHATOMIC, ac->migratetype); change_pageblock_range(page, order, ac->migratetype); @@ -2294,7 +2275,8 @@ __rmqueue_fallback(struct zone *zone, int order, int = start_migratetype, =20 page =3D get_page_from_free_area(area, fallback_mt); page =3D try_to_steal_block(zone, page, current_order, order, - start_migratetype, alloc_flags); + start_migratetype, fallback_mt, + alloc_flags); if (page) goto got_one; } --=20 2.48.1 From nobody Fri Apr 10 04:51:08 2026 Received: from mail-qv1-f44.google.com (mail-qv1-f44.google.com [209.85.219.44]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 31AC410A1F for ; Tue, 25 Feb 2025 00:10:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740442246; cv=none; b=nVop8/Z3KVxXlVcAoAwxlqQ1xKcrOCqm5eScPpv2CEJglhRvYzjHaxE/4UlKsmkl+lHgBU6ufPwJnsazKQv0P4Y/+kmmK/Aizyu5MSyvFwrvCWAh23FdinrTEVgGYkUxvtSCgWA2sA9tvr22ziWmlzOXQy2FXDyvdMo/72dlCsE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740442246; c=relaxed/simple; bh=uJIYBBKABsWx06IUAxuzKVX6yW0jaug2nCyJnRc1UsA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=BHiaHY2B8vfoseo4vCm2MaXNZnKR+xyRGzXWoPEgYv5IixDAuWWWwfl1UBITuoDNbtJrN7H5xu+7f+K4pX0l5Jc95CRlfLhu5ViGT+/pIrBBqU0ZTLawNefAhA0e0/rdaW+ntVjKmR8QVkqTmbtxlegVOWgX2wOLoSFzRHqfJyk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=cmpxchg.org; spf=pass smtp.mailfrom=cmpxchg.org; dkim=pass (2048-bit key) header.d=cmpxchg-org.20230601.gappssmtp.com header.i=@cmpxchg-org.20230601.gappssmtp.com header.b=zeJL418W; arc=none smtp.client-ip=209.85.219.44 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=cmpxchg.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=cmpxchg.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=cmpxchg-org.20230601.gappssmtp.com header.i=@cmpxchg-org.20230601.gappssmtp.com header.b="zeJL418W" Received: by mail-qv1-f44.google.com with SMTP id 6a1803df08f44-6e41e17645dso52768516d6.2 for ; Mon, 24 Feb 2025 16:10:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cmpxchg-org.20230601.gappssmtp.com; s=20230601; t=1740442242; x=1741047042; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=2e25n5vpfxDFEGmdOG76BnXvJ2FJi0Uv+lwO0Tt+wqc=; b=zeJL418Wpl6jakxYO61WfUMKtRolKcWTQSrAAkWC4u0kQjYr2YVHgevXkR1YW9K5Ja 5nSfzvsoyXr6qH2WsrxCgvSDR+WDzIrMDPkbJzpPBeVoimPa0MqHfz3ATs/tes2q6ETl JB5lss1UN9jhtA6h5wqc0uaeNaUhFIDJ39hAFQViFWXujvrkNeFYRs1Smfztqc/b9tDY khbIhP88TtkO7LnRgosIBlU89MesoI0TVTYcCc+AX07+E4TcI3YCRu4/kBYMMBBnDPPn TRV+uwFT7ECsk1FNBSrrV3iY2IvQhEvPfj178Cg+K/kW94ADIRu1mxraf0ubmLArqan/ xJjg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1740442242; x=1741047042; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=2e25n5vpfxDFEGmdOG76BnXvJ2FJi0Uv+lwO0Tt+wqc=; b=lHBbZHHEql+xj/7eOiKyiU5zn/S9cQk+7Po4eeB5W6RvNDMdLkOvv9JxLYCtoaCxMZ ke0J7oKyy1fn2p8raSbmVS/+XMXzShD4KiG6bclJiVNaUKBqIICpyxcdlbtU/V7UYjl9 MP7gUHOsP5j/e+ebmN94tdAper+b7ZyXv3G6DWxzusIVs2di+ZgZYNkmJSkZ3Hy5q9kk jWWeJzZRkQsrIBWm7WSAl3OfIZ8rzssfmrpGzVO1Knj56lFwYw8dK5hydQCBhL+u58lw Xs00RoMRuRqr6amFt0sy+5Zuc4Aqi61Kiq4BL5aN4ZEkKwGYOMlMV5ry/u95DLS/jx3Q Td8g== X-Forwarded-Encrypted: i=1; AJvYcCWBnNnIME/ddAKdZWVH8sijYVRL29iy+w4dcUQy1/FngO1NuafgvcEzldc0rxPaIqOtV8kTB9FsUkzab1k=@vger.kernel.org X-Gm-Message-State: AOJu0YxqGoufXbCfIfD8FoCSa/ExwwkRXMNpKUXqFn+pP3vfZ2d44EKi uXYMVEZ3rpTiOwULp1rkFluoO7ginmZwed+GfxjNos2NwkG6s4TY2VBfAE3BdU0= X-Gm-Gg: ASbGncuKDeXHbqhwJHoJOGnQo8nyMlgZDvBZyzhFLkUxI42SvWsx4C0dzAdkrgRZ/JW oBJ0OSPE1nMr+zQk5t92uVVyqU4qaMVXxZqdy3hTwOljTtvhtRPyZNZfk/ScoICR9DqxdwAnTKI dIEfNDE8qzTkgo+maWzREuQcGxlJB+p3H31TF5p3O43ahkm+Qw1RhFbQEpCvlSb07cNurs/XkCa UhnMnlXGT4o74rMHmS8+eHOl0VYZUPdfZ1+q2kB3nQqnSwUKzSXWyEGCOJqWqHkeDfMGaT85bQb R6uoxtb6UYicZId2pmGJIAHX X-Google-Smtp-Source: AGHT+IGgkiR9iptSEyFu7U9mGo/QIIVICqxDDnkseqj6QpgDVUGUnhk9KHuZIRF7lIakpsCc0f0yiA== X-Received: by 2002:a05:6214:2463:b0:6e4:1e1d:10a7 with SMTP id 6a1803df08f44-6e6ae7c6211mr196896276d6.1.1740442241870; Mon, 24 Feb 2025 16:10:41 -0800 (PST) Received: from localhost ([2603:7000:c01:2716:da5e:d3ff:fee7:26e7]) by smtp.gmail.com with UTF8SMTPSA id 6a1803df08f44-6e87b0871e2sm3224846d6.27.2025.02.24.16.10.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Feb 2025 16:10:36 -0800 (PST) From: Johannes Weiner To: Andrew Morton Cc: Vlastimil Babka , Brendan Jackman , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 3/3] mm: page_alloc: group fallback functions together Date: Mon, 24 Feb 2025 19:08:26 -0500 Message-ID: <20250225001023.1494422-4-hannes@cmpxchg.org> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250225001023.1494422-1-hannes@cmpxchg.org> References: <20250225001023.1494422-1-hannes@cmpxchg.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The way the fallback rules are spread out makes them hard to follow. Move the functions next to each other at least. Signed-off-by: Johannes Weiner Reviewed-by: Brendan Jackman Reviewed-by: Vlastimil Babka --- mm/page_alloc.c | 394 ++++++++++++++++++++++++------------------------ 1 file changed, 197 insertions(+), 197 deletions(-) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 53d315aa69c4..d02edb7d5e21 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -1903,6 +1903,43 @@ static void change_pageblock_range(struct page *page= block_page, } } =20 +static inline bool boost_watermark(struct zone *zone) +{ + unsigned long max_boost; + + if (!watermark_boost_factor) + return false; + /* + * Don't bother in zones that are unlikely to produce results. + * On small machines, including kdump capture kernels running + * in a small area, boosting the watermark can cause an out of + * memory situation immediately. + */ + if ((pageblock_nr_pages * 4) > zone_managed_pages(zone)) + return false; + + max_boost =3D mult_frac(zone->_watermark[WMARK_HIGH], + watermark_boost_factor, 10000); + + /* + * high watermark may be uninitialised if fragmentation occurs + * very early in boot so do not boost. We do not fall + * through and boost by pageblock_nr_pages as failing + * allocations that early means that reclaim is not going + * to help and it may even be impossible to reclaim the + * boosted watermark resulting in a hang. + */ + if (!max_boost) + return false; + + max_boost =3D max(pageblock_nr_pages, max_boost); + + zone->watermark_boost =3D min(zone->watermark_boost + pageblock_nr_pages, + max_boost); + + return true; +} + /* * When we are falling back to another migratetype during allocation, try = to * steal extra free pages from the same pageblocks to satisfy further @@ -1944,41 +1981,38 @@ static bool can_steal_fallback(unsigned int order, = int start_mt) return false; } =20 -static inline bool boost_watermark(struct zone *zone) +/* + * Check whether there is a suitable fallback freepage with requested orde= r. + * If only_stealable is true, this function returns fallback_mt only if + * we can steal other freepages all together. This would help to reduce + * fragmentation due to mixed migratetype pages in one pageblock. + */ +int find_suitable_fallback(struct free_area *area, unsigned int order, + int migratetype, bool only_stealable, bool *can_steal) { - unsigned long max_boost; + int i; + int fallback_mt; =20 - if (!watermark_boost_factor) - return false; - /* - * Don't bother in zones that are unlikely to produce results. - * On small machines, including kdump capture kernels running - * in a small area, boosting the watermark can cause an out of - * memory situation immediately. - */ - if ((pageblock_nr_pages * 4) > zone_managed_pages(zone)) - return false; + if (area->nr_free =3D=3D 0) + return -1; =20 - max_boost =3D mult_frac(zone->_watermark[WMARK_HIGH], - watermark_boost_factor, 10000); + *can_steal =3D false; + for (i =3D 0; i < MIGRATE_PCPTYPES - 1 ; i++) { + fallback_mt =3D fallbacks[migratetype][i]; + if (free_area_empty(area, fallback_mt)) + continue; =20 - /* - * high watermark may be uninitialised if fragmentation occurs - * very early in boot so do not boost. We do not fall - * through and boost by pageblock_nr_pages as failing - * allocations that early means that reclaim is not going - * to help and it may even be impossible to reclaim the - * boosted watermark resulting in a hang. - */ - if (!max_boost) - return false; + if (can_steal_fallback(order, migratetype)) + *can_steal =3D true; =20 - max_boost =3D max(pageblock_nr_pages, max_boost); + if (!only_stealable) + return fallback_mt; =20 - zone->watermark_boost =3D min(zone->watermark_boost + pageblock_nr_pages, - max_boost); + if (*can_steal) + return fallback_mt; + } =20 - return true; + return -1; } =20 /* @@ -2054,175 +2088,6 @@ try_to_steal_block(struct zone *zone, struct page *= page, return NULL; } =20 -/* - * Check whether there is a suitable fallback freepage with requested orde= r. - * If only_stealable is true, this function returns fallback_mt only if - * we can steal other freepages all together. This would help to reduce - * fragmentation due to mixed migratetype pages in one pageblock. - */ -int find_suitable_fallback(struct free_area *area, unsigned int order, - int migratetype, bool only_stealable, bool *can_steal) -{ - int i; - int fallback_mt; - - if (area->nr_free =3D=3D 0) - return -1; - - *can_steal =3D false; - for (i =3D 0; i < MIGRATE_PCPTYPES - 1 ; i++) { - fallback_mt =3D fallbacks[migratetype][i]; - if (free_area_empty(area, fallback_mt)) - continue; - - if (can_steal_fallback(order, migratetype)) - *can_steal =3D true; - - if (!only_stealable) - return fallback_mt; - - if (*can_steal) - return fallback_mt; - } - - return -1; -} - -/* - * Reserve the pageblock(s) surrounding an allocation request for - * exclusive use of high-order atomic allocations if there are no - * empty page blocks that contain a page with a suitable order - */ -static void reserve_highatomic_pageblock(struct page *page, int order, - struct zone *zone) -{ - int mt; - unsigned long max_managed, flags; - - /* - * The number reserved as: minimum is 1 pageblock, maximum is - * roughly 1% of a zone. But if 1% of a zone falls below a - * pageblock size, then don't reserve any pageblocks. - * Check is race-prone but harmless. - */ - if ((zone_managed_pages(zone) / 100) < pageblock_nr_pages) - return; - max_managed =3D ALIGN((zone_managed_pages(zone) / 100), pageblock_nr_page= s); - if (zone->nr_reserved_highatomic >=3D max_managed) - return; - - spin_lock_irqsave(&zone->lock, flags); - - /* Recheck the nr_reserved_highatomic limit under the lock */ - if (zone->nr_reserved_highatomic >=3D max_managed) - goto out_unlock; - - /* Yoink! */ - mt =3D get_pageblock_migratetype(page); - /* Only reserve normal pageblocks (i.e., they can merge with others) */ - if (!migratetype_is_mergeable(mt)) - goto out_unlock; - - if (order < pageblock_order) { - if (move_freepages_block(zone, page, mt, MIGRATE_HIGHATOMIC) =3D=3D -1) - goto out_unlock; - zone->nr_reserved_highatomic +=3D pageblock_nr_pages; - } else { - change_pageblock_range(page, order, MIGRATE_HIGHATOMIC); - zone->nr_reserved_highatomic +=3D 1 << order; - } - -out_unlock: - spin_unlock_irqrestore(&zone->lock, flags); -} - -/* - * Used when an allocation is about to fail under memory pressure. This - * potentially hurts the reliability of high-order allocations when under - * intense memory pressure but failed atomic allocations should be easier - * to recover from than an OOM. - * - * If @force is true, try to unreserve pageblocks even though highatomic - * pageblock is exhausted. - */ -static bool unreserve_highatomic_pageblock(const struct alloc_context *ac, - bool force) -{ - struct zonelist *zonelist =3D ac->zonelist; - unsigned long flags; - struct zoneref *z; - struct zone *zone; - struct page *page; - int order; - int ret; - - for_each_zone_zonelist_nodemask(zone, z, zonelist, ac->highest_zoneidx, - ac->nodemask) { - /* - * Preserve at least one pageblock unless memory pressure - * is really high. - */ - if (!force && zone->nr_reserved_highatomic <=3D - pageblock_nr_pages) - continue; - - spin_lock_irqsave(&zone->lock, flags); - for (order =3D 0; order < NR_PAGE_ORDERS; order++) { - struct free_area *area =3D &(zone->free_area[order]); - unsigned long size; - - page =3D get_page_from_free_area(area, MIGRATE_HIGHATOMIC); - if (!page) - continue; - - /* - * It should never happen but changes to - * locking could inadvertently allow a per-cpu - * drain to add pages to MIGRATE_HIGHATOMIC - * while unreserving so be safe and watch for - * underflows. - */ - size =3D max(pageblock_nr_pages, 1UL << order); - size =3D min(size, zone->nr_reserved_highatomic); - zone->nr_reserved_highatomic -=3D size; - - /* - * Convert to ac->migratetype and avoid the normal - * pageblock stealing heuristics. Minimally, the caller - * is doing the work and needs the pages. More - * importantly, if the block was always converted to - * MIGRATE_UNMOVABLE or another type then the number - * of pageblocks that cannot be completely freed - * may increase. - */ - if (order < pageblock_order) - ret =3D move_freepages_block(zone, page, - MIGRATE_HIGHATOMIC, - ac->migratetype); - else { - move_to_free_list(page, zone, order, - MIGRATE_HIGHATOMIC, - ac->migratetype); - change_pageblock_range(page, order, - ac->migratetype); - ret =3D 1; - } - /* - * Reserving the block(s) already succeeded, - * so this should not fail on zone boundaries. - */ - WARN_ON_ONCE(ret =3D=3D -1); - if (ret > 0) { - spin_unlock_irqrestore(&zone->lock, flags); - return ret; - } - } - spin_unlock_irqrestore(&zone->lock, flags); - } - - return false; -} - /* * Try finding a free buddy page on the fallback list. * @@ -3143,6 +3008,141 @@ struct page *rmqueue(struct zone *preferred_zone, return page; } =20 +/* + * Reserve the pageblock(s) surrounding an allocation request for + * exclusive use of high-order atomic allocations if there are no + * empty page blocks that contain a page with a suitable order + */ +static void reserve_highatomic_pageblock(struct page *page, int order, + struct zone *zone) +{ + int mt; + unsigned long max_managed, flags; + + /* + * The number reserved as: minimum is 1 pageblock, maximum is + * roughly 1% of a zone. But if 1% of a zone falls below a + * pageblock size, then don't reserve any pageblocks. + * Check is race-prone but harmless. + */ + if ((zone_managed_pages(zone) / 100) < pageblock_nr_pages) + return; + max_managed =3D ALIGN((zone_managed_pages(zone) / 100), pageblock_nr_page= s); + if (zone->nr_reserved_highatomic >=3D max_managed) + return; + + spin_lock_irqsave(&zone->lock, flags); + + /* Recheck the nr_reserved_highatomic limit under the lock */ + if (zone->nr_reserved_highatomic >=3D max_managed) + goto out_unlock; + + /* Yoink! */ + mt =3D get_pageblock_migratetype(page); + /* Only reserve normal pageblocks (i.e., they can merge with others) */ + if (!migratetype_is_mergeable(mt)) + goto out_unlock; + + if (order < pageblock_order) { + if (move_freepages_block(zone, page, mt, MIGRATE_HIGHATOMIC) =3D=3D -1) + goto out_unlock; + zone->nr_reserved_highatomic +=3D pageblock_nr_pages; + } else { + change_pageblock_range(page, order, MIGRATE_HIGHATOMIC); + zone->nr_reserved_highatomic +=3D 1 << order; + } + +out_unlock: + spin_unlock_irqrestore(&zone->lock, flags); +} + +/* + * Used when an allocation is about to fail under memory pressure. This + * potentially hurts the reliability of high-order allocations when under + * intense memory pressure but failed atomic allocations should be easier + * to recover from than an OOM. + * + * If @force is true, try to unreserve pageblocks even though highatomic + * pageblock is exhausted. + */ +static bool unreserve_highatomic_pageblock(const struct alloc_context *ac, + bool force) +{ + struct zonelist *zonelist =3D ac->zonelist; + unsigned long flags; + struct zoneref *z; + struct zone *zone; + struct page *page; + int order; + int ret; + + for_each_zone_zonelist_nodemask(zone, z, zonelist, ac->highest_zoneidx, + ac->nodemask) { + /* + * Preserve at least one pageblock unless memory pressure + * is really high. + */ + if (!force && zone->nr_reserved_highatomic <=3D + pageblock_nr_pages) + continue; + + spin_lock_irqsave(&zone->lock, flags); + for (order =3D 0; order < NR_PAGE_ORDERS; order++) { + struct free_area *area =3D &(zone->free_area[order]); + unsigned long size; + + page =3D get_page_from_free_area(area, MIGRATE_HIGHATOMIC); + if (!page) + continue; + + /* + * It should never happen but changes to + * locking could inadvertently allow a per-cpu + * drain to add pages to MIGRATE_HIGHATOMIC + * while unreserving so be safe and watch for + * underflows. + */ + size =3D max(pageblock_nr_pages, 1UL << order); + size =3D min(size, zone->nr_reserved_highatomic); + zone->nr_reserved_highatomic -=3D size; + + /* + * Convert to ac->migratetype and avoid the normal + * pageblock stealing heuristics. Minimally, the caller + * is doing the work and needs the pages. More + * importantly, if the block was always converted to + * MIGRATE_UNMOVABLE or another type then the number + * of pageblocks that cannot be completely freed + * may increase. + */ + if (order < pageblock_order) + ret =3D move_freepages_block(zone, page, + MIGRATE_HIGHATOMIC, + ac->migratetype); + else { + move_to_free_list(page, zone, order, + MIGRATE_HIGHATOMIC, + ac->migratetype); + change_pageblock_range(page, order, + ac->migratetype); + ret =3D 1; + } + /* + * Reserving the block(s) already succeeded, + * so this should not fail on zone boundaries. + */ + WARN_ON_ONCE(ret =3D=3D -1); + if (ret > 0) { + spin_unlock_irqrestore(&zone->lock, flags); + return ret; + } + } + spin_unlock_irqrestore(&zone->lock, flags); + } + + return false; +} + static inline long __zone_watermark_unusable_free(struct zone *z, unsigned int order, unsigned int alloc_flags) { --=20 2.48.1