Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp124209pxb; Fri, 16 Apr 2021 01:05:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxpY3/Ggd/SAzARVru1LypZxpSazDHWXEQTKUiN+EsFdUDsDw2h4mKj5XIHDmPp5+GlRrG7 X-Received: by 2002:a63:338b:: with SMTP id z133mr6888817pgz.442.1618560339254; Fri, 16 Apr 2021 01:05:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618560339; cv=none; d=google.com; s=arc-20160816; b=VQL18mRcbm0MlryGKBca6je7w21w4L0dSCoPj+fHnLUsQ5zkz1EFFvQ10cqbm6oHAQ R0MxPaSgBkvAeYMRvTSPnsRJKdyRYlv6E0BfK2sldbkXe5p2x8907JBsp4QomOpMWHUB KtppJnDYfWla6LYEZFR5lIlJjfaJdjB8u+d3xrLFSPeoxKx7MxGtIg4oj9jZ/AuB7A3m TSGSaSZtn1K/8hNB6WOcKgu4zX5gpX1p4uzg/l1WJeSUeG2BrH2dabaL58JjYCkz+jjx OXjRdOo83joauNUHkGbGUcpgFiwLfeDhr2OpI6XcxCaTpnZCyMG95wiyYMZ7q9UkW4zk KrWA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=Q5ZmPn/9C9kJczMa4OLKn5ocZyvXmOBVDXwQazoigok=; b=rrLwwrBjntZxmEWnZsD5QFh77GWPhjzG4DQbJFGXkqhyYcAFrr+njQIgAnSyRbqSJr QSXplsMU/h2KgI6ulMmFUWd/oYanY1bDbSFHySx/8T+m6JT4bElSXYNzMiEiHiRH562X 2vnMHH5xOEE11yfU8d97vO5Y+DrA3W84muZ3HJ/qhJ4Gwp/qELOzi5AQh4RmpTMA5Z5E Pkps7gO0PTLYNixIlMstxHwgTLC0l0VgJwJCLo4RSHoPGKhFeojv0+fJ8lbgeMQ4TTUN PiSbz1hQnSaOG9jKMo/6J64ldQqO2H2yiHyQV/OTt6L6gZcR6KNMuSirwGYsK64ekcwc ti2g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b30si5666254pgb.352.2021.04.16.01.05.27; Fri, 16 Apr 2021 01:05:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239076AbhDPHA6 (ORCPT + 99 others); Fri, 16 Apr 2021 03:00:58 -0400 Received: from mx2.suse.de ([195.135.220.15]:48980 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234914AbhDPHA4 (ORCPT ); Fri, 16 Apr 2021 03:00:56 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id CEC59AF03; Fri, 16 Apr 2021 07:00:31 +0000 (UTC) From: Oscar Salvador To: Andrew Morton Cc: Mike Kravetz , Vlastimil Babka , David Hildenbrand , Michal Hocko , Muchun Song , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Oscar Salvador , Michal Hocko Subject: [PATCH v9 1/7] mm,page_alloc: Bail out earlier on -ENOMEM in alloc_contig_migrate_range Date: Fri, 16 Apr 2021 09:00:17 +0200 Message-Id: <20210416070023.4742-2-osalvador@suse.de> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20210416070023.4742-1-osalvador@suse.de> References: <20210416070023.4742-1-osalvador@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Currently, __alloc_contig_migrate_range can generate -EINTR, -ENOMEM or -EBUSY, and report them down the chain. The problem is that when migrate_pages() reports -ENOMEM, we keep going till we exhaust all the try-attempts (5 at the moment) instead of bailing out. migrate_pages() bails out right away on -ENOMEM because it is considered a fatal error. Do the same here instead of keep going and retrying. Note that this is not fixing a real issue, just a cosmetic change. Although we can save some cycles by backing off ealier Signed-off-by: Oscar Salvador Acked-by: Vlastimil Babka Reviewed-by: David Hildenbrand Acked-by: Michal Hocko Acked-by: Mike Kravetz --- mm/page_alloc.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 1c67c99603a3..689454692de1 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -8697,7 +8697,7 @@ static int __alloc_contig_migrate_range(struct compact_control *cc, } tries = 0; } else if (++tries == 5) { - ret = ret < 0 ? ret : -EBUSY; + ret = -EBUSY; break; } @@ -8707,6 +8707,13 @@ static int __alloc_contig_migrate_range(struct compact_control *cc, ret = migrate_pages(&cc->migratepages, alloc_migration_target, NULL, (unsigned long)&mtc, cc->mode, MR_CONTIG_RANGE); + + /* + * On -ENOMEM, migrate_pages() bails out right away. It is pointless + * to retry again over this error, so do the same here. + */ + if (ret == -ENOMEM) + break; } lru_cache_enable(); -- 2.16.3