Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp13146791rwl; Wed, 4 Jan 2023 04:18:13 -0800 (PST) X-Google-Smtp-Source: AMrXdXvcjHkrXsExddbOcIcg/rlnuS7FhmGprUSYCnTwCzuW7X5VlXNlW9S2BIJRthRlqBB+a27s X-Received: by 2002:a05:6402:1759:b0:468:260e:ad53 with SMTP id v25-20020a056402175900b00468260ead53mr39264909edx.10.1672834693459; Wed, 04 Jan 2023 04:18:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672834693; cv=none; d=google.com; s=arc-20160816; b=gJNoxS/pHw+NWppYl/u1kqilufsaAe8ZUX/sljIuP0v8OYSyPpLnJz/UgShdlH+xyE honWhNgAiAuLwoFlSHtoJWm/ATlrWPo/tdGjkAAUxCnp4iG8cRryRDKqfBbvOlfwGemr 7Fu5a38/9KptmLf7H6CFlxUe/SDZ48AWznpKUUwyTPRp7/vbCZ29AR0ofMU3Nhe+2kCY 7l9S1jQNmmhsQRfSnYbWqGKKrscaqDonxbqjxkmocarqoAoDYwDkuNtRU+yZ+xmJfb7M sj/zuoIeb1bH2F+vEBC1ofC8PrD9L6VjpVt25OhxG8IpzXi7yCncVQpb+gRUzxHvZaG3 cMDg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=Q3eOdpHBzq9I8EOOChOPzvBVJ4hdZChie5+8pxozOFE=; b=rK/cPBbGLT8tlZTdH/qE7LQGZY8Hg5cP8pe6MYcag87RBPqgNOv0DWeX4vA1eRPJ4N Lx5nLNfYXFaf1EVDnQelC5u00HRAyzxEmd6kmviQVtAIm2/u9Xw25AqcYeWI/FnNKCzU ocu2ocNlorzc0WEIR3VclRCtbdH60IMeKGlff09I0MeoGzvm5OHDSuCBmmb8ee8Gaav5 FCoL3MD2jqAATRLklsA72vTqMnt9hrrgP1Qaw9e5fIpT6V9Of7xUU1JwB4Lh3K/pOSzI S9ITaLpTsDwtfPutVih/N0nn73TY091vB6X7ZUv9O7BCTVbYUl7qHJHDjAETCHAdrMFc pkvA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w20-20020a50fa94000000b0047d80fb1ddfsi32873128edr.221.2023.01.04.04.17.59; Wed, 04 Jan 2023 04:18:13 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239185AbjADLyU (ORCPT + 57 others); Wed, 4 Jan 2023 06:54:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60044 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239184AbjADLyN (ORCPT ); Wed, 4 Jan 2023 06:54:13 -0500 X-Greylist: delayed 540 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Wed, 04 Jan 2023 03:54:06 PST Received: from outbound-smtp47.blacknight.com (outbound-smtp47.blacknight.com [46.22.136.64]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E2E161EEDA for ; Wed, 4 Jan 2023 03:54:06 -0800 (PST) Received: from mail.blacknight.com (pemlinmail02.blacknight.ie [81.17.254.11]) by outbound-smtp47.blacknight.com (Postfix) with ESMTPS id 9C733FACE0 for ; Wed, 4 Jan 2023 11:45:04 +0000 (GMT) Received: (qmail 1950 invoked from network); 4 Jan 2023 11:45:04 -0000 Received: from unknown (HELO techsingularity.net) (mgorman@techsingularity.net@[84.203.198.246]) by 81.17.254.9 with ESMTPSA (AES256-SHA encrypted, authenticated); 4 Jan 2023 11:45:04 -0000 Date: Wed, 4 Jan 2023 11:45:02 +0000 From: Mel Gorman To: Vlastimil Babka Cc: Linux-MM , Andrew Morton , Michal Hocko , NeilBrown , Thierry Reding , Matthew Wilcox , LKML Subject: Re: [PATCH 3/6] mm/page_alloc: Explicitly record high-order atomic allocations in alloc_flags Message-ID: <20230104114502.j4hzzjohxk7bdkcj@techsingularity.net> References: <20221129151701.23261-1-mgorman@techsingularity.net> <20221129151701.23261-4-mgorman@techsingularity.net> <915a5034-53e6-9464-3fc7-4d1b5a0aa26d@suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-15 Content-Disposition: inline In-Reply-To: <915a5034-53e6-9464-3fc7-4d1b5a0aa26d@suse.cz> X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org First off, sorry for the long delay getting back to you. I was sick for a few weeks and still catching up. I'm still not 100%. On Thu, Dec 08, 2022 at 05:51:11PM +0100, Vlastimil Babka wrote: > On 11/29/22 16:16, Mel Gorman wrote: > > diff --git a/mm/page_alloc.c b/mm/page_alloc.c > > index da746e9eb2cf..e2b65767dda0 100644 > > --- a/mm/page_alloc.c > > +++ b/mm/page_alloc.c > > @@ -3710,7 +3710,7 @@ struct page *rmqueue_buddy(struct zone *preferred_zone, struct zone *zone, > > * reserved for high-order atomic allocation, so order-0 > > * request should skip it. > > */ > > - if (order > 0 && alloc_flags & ALLOC_HARDER) > > + if (alloc_flags & ALLOC_HIGHATOMIC) > > page = __rmqueue_smallest(zone, order, MIGRATE_HIGHATOMIC); > > if (!page) { > > page = __rmqueue(zone, order, migratetype, alloc_flags); > > @@ -4028,8 +4028,10 @@ bool __zone_watermark_ok(struct zone *z, unsigned int order, unsigned long mark, > > return true; > > } > > #endif > > - if (alloc_harder && !free_area_empty(area, MIGRATE_HIGHATOMIC)) > > + if ((alloc_flags & ALLOC_HIGHATOMIC) && > > + !free_area_empty(area, MIGRATE_HIGHATOMIC)) { > > return true; > > alloc_harder is defined as > (alloc_flags & (ALLOC_HARDER|ALLOC_OOM)); > AFAICS this means we no longer allow ALLOC_OOM to use the highatomic > reserve. Isn't that a risk? > Yes, it is. I intend to apply the patch below on top. I didn't alter the first check for ALLOC_HIGHATOMIC as I wanted OOM handling to only use the high-order reserves if there was no other option. While this is a change in behaviour, it should be a harmless one. I'll add a note in the changelog. diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 50fc1e7cb154..0ef4f3236a5a 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -3710,6 +3710,16 @@ struct page *rmqueue_buddy(struct zone *preferred_zone, struct zone *zone, page = __rmqueue_smallest(zone, order, MIGRATE_HIGHATOMIC); if (!page) { page = __rmqueue(zone, order, migratetype, alloc_flags); + + /* + * If the allocation fails, allow OOM handling access + * to HIGHATOMIC reserves as failing now is worse than + * failing a high-order atomic allocation in the + * future. + */ + if (!page && (alloc_flags & ALLOC_OOM)) + page = __rmqueue_smallest(zone, order, MIGRATE_HIGHATOMIC); + if (!page) { spin_unlock_irqrestore(&zone->lock, flags); return NULL; @@ -4023,7 +4033,7 @@ bool __zone_watermark_ok(struct zone *z, unsigned int order, unsigned long mark, return true; } #endif - if ((alloc_flags & ALLOC_HIGHATOMIC) && + if ((alloc_flags & (ALLOC_HIGHATOMIC|ALLOC_OOM)) && !free_area_empty(area, MIGRATE_HIGHATOMIC)) { return true; } -- Mel Gorman SUSE Labs