From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1C6A9C433E0 for ; Thu, 18 Mar 2021 16:16:12 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 7A12B64F01 for ; Thu, 18 Mar 2021 16:16:11 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7A12B64F01 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=suse.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id F0F256B0072; Thu, 18 Mar 2021 12:16:10 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id EE6616B0073; Thu, 18 Mar 2021 12:16:10 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DAD3D6B0074; Thu, 18 Mar 2021 12:16:10 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0124.hostedemail.com [216.40.44.124]) by kanga.kvack.org (Postfix) with ESMTP id C3AB96B0072 for ; Thu, 18 Mar 2021 12:16:10 -0400 (EDT) Received: from smtpin10.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 6DDE987E1 for ; Thu, 18 Mar 2021 16:16:10 +0000 (UTC) X-FDA: 77933496900.10.E4B1ABD Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by imf29.hostedemail.com (Postfix) with ESMTP id 6AF72D5 for ; Thu, 18 Mar 2021 16:16:07 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1616084162; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=wFutwNBa2WeIFmYM5lIk90CePKHrTcZXcZh3QqcNmZQ=; b=LoqwPlOjhiwLkAAbgKJz7q4XhteJEV3BOHqeEdy55YWjvtY1XHcQ8rB8RiSTODP9Fy5UeF e7qUGEjCD70BOhGT0MwlIgDGAlv+YMIV/Lah548nRIrPlSnK8biW7S9wkuUO5KyJCzcrvH OFVxn1pB0OYonh/vPG6FcTpORqFahF4= Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 54B5FAB8C; Thu, 18 Mar 2021 16:16:02 +0000 (UTC) Date: Thu, 18 Mar 2021 17:16:01 +0100 From: Michal Hocko To: Aaron Tomlin Cc: linux-mm@kvack.org, akpm@linux-foundation.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] mm/page_alloc: try oom if reclaim is unable to make forward progress Message-ID: References: <20210315165837.789593-1-atomlin@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210315165837.789593-1-atomlin@redhat.com> X-Stat-Signature: 8x3qitc4j5csf8jciqmiyxehyz4r71rx X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: 6AF72D5 Received-SPF: none (suse.com>: No applicable sender policy available) receiver=imf29; identity=mailfrom; envelope-from=""; helo=mx2.suse.de; client-ip=195.135.220.15 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1616084167-319739 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Mon 15-03-21 16:58:37, Aaron Tomlin wrote: > In the situation where direct reclaim is required to make progress for > compaction but no_progress_loops is already over the limit of > MAX_RECLAIM_RETRIES consider invoking the oom killer. What is the problem you are trying to fix? > > Signed-off-by: Aaron Tomlin > --- > mm/page_alloc.c | 22 ++++++++++++++++++---- > 1 file changed, 18 insertions(+), 4 deletions(-) > > diff --git a/mm/page_alloc.c b/mm/page_alloc.c > index 7a2c89b21115..8d748b1b8d1e 100644 > --- a/mm/page_alloc.c > +++ b/mm/page_alloc.c > @@ -4181,6 +4181,16 @@ __alloc_pages_direct_compact(gfp_t gfp_mask, unsigned int order, > return NULL; > } > > +static inline bool > +should_try_oom(int no_progress_loops, > + enum compact_result last_compact_result) > +{ > + if (no_progress_loops > MAX_RECLAIM_RETRIES && last_compact_result > + == COMPACT_SKIPPED) > + return true; > + return false; > +} > + > static inline bool > should_compact_retry(struct alloc_context *ac, int order, int alloc_flags, > enum compact_result compact_result, > @@ -4547,10 +4557,11 @@ should_reclaim_retry(gfp_t gfp_mask, unsigned order, > * Make sure we converge to OOM if we cannot make any progress > * several times in the row. > */ > - if (*no_progress_loops > MAX_RECLAIM_RETRIES) { > - /* Before OOM, exhaust highatomic_reserve */ > - return unreserve_highatomic_pageblock(ac, true); > - } > + if (*no_progress_loops > MAX_RECLAIM_RETRIES) > + result false; > + /* Last chance before OOM, try draining highatomic_reserve once */ > + else if (*no_progress_loops == MAX_RECLAIM_RETRIES) > + return unreserve_highatomic_pageblock(ac, true) > > /* > * Keep reclaiming pages while there is a chance this will lead > @@ -4822,6 +4833,8 @@ __alloc_pages_slowpath(gfp_t gfp_mask, unsigned int order, > did_some_progress > 0, &no_progress_loops)) > goto retry; > > + if (should_try_oom(no_progress_loops, compact_result)) > + goto oom: > /* > * It doesn't make any sense to retry for the compaction if the order-0 > * reclaim is not able to make any progress because the current > @@ -4839,6 +4852,7 @@ __alloc_pages_slowpath(gfp_t gfp_mask, unsigned int order, > if (check_retry_cpuset(cpuset_mems_cookie, ac)) > goto retry_cpuset; > > +oom: > /* Reclaim has failed us, start killing things */ > page = __alloc_pages_may_oom(gfp_mask, order, ac, &did_some_progress); > if (page) > -- > 2.26.2 > -- Michal Hocko SUSE Labs