Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp659413pxb; Thu, 15 Apr 2021 03:38:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxwUVXeTqqD682FZAoDvxq1IJXp1DiHZ9Bxw6LTQxIbj+IrCQFWXRzJoTkky4CMaal0rFdU X-Received: by 2002:a63:7c59:: with SMTP id l25mr2924950pgn.224.1618483092105; Thu, 15 Apr 2021 03:38:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618483092; cv=none; d=google.com; s=arc-20160816; b=BIkE1fG+mNCz6RxZp3yfPMTrb27l6E4+orCEcEWfwXPul/eKZ0f8JrS0WmHXMztEK8 i3NxCOR7OmSpgfUDqXMeWke2WnjqCGiUXHeg0xkdpE90SUksex97SZ8Xp0THRETjGfMb poicTC5nNd4EKELqScIiIWyCxJyvRRLEI0FyHxrKT7DjMxCKyXEjLRVAK+TVynwpRJKx P1L+TpJMbh1xnJOhz34+/DbxMOB6/o8/OIq/uJRgxRDdOx4SPs58nZ+PZ1rZoZkRp80o u4K0srGPcssKnMARxmZ125xfndIIKsubMKBS/2hBoDEAhsHZAHb8j45O/3ctmI0fo1ij 3rcw== 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=fgP30d1S3qoaqK3Br0hZ7Ev1zRfmdp0KCoRizmwCYOQXoYnK1HNSap3kwnbki8M9FV qZHxZ90R65tIGLNdTLXafDC7lQWRYGkSxFhqKQCXWamHkTqjZMLVQGetq3ceTqSPZm9o u5UaFJyHCPT4AyNN1HwMUxkbaifoqXyMh1owPsTKqqUpkUqlk4B4HIVyU5pqdxIs4ziW /3zlIuhVwb4MJL2Sa8RqJq5+keAooxXPb2MSj4AqJ0H/0aUfX0dwNS9bL3Gtoht8GtTj 3GoOgdx0RwJS70NiSr0JzEXw+gMrupJDWyfu/KFqVTBwLGHG+rgaPoMzdKjDP2bRVXfw S7yg== 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 h66si2737263pfb.66.2021.04.15.03.37.45; Thu, 15 Apr 2021 03:38:12 -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 S232070AbhDOKgO (ORCPT + 99 others); Thu, 15 Apr 2021 06:36:14 -0400 Received: from mx2.suse.de ([195.135.220.15]:49430 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230190AbhDOKgN (ORCPT ); Thu, 15 Apr 2021 06:36:13 -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 B94B8AF0D; Thu, 15 Apr 2021 10:35:49 +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 v8 1/7] mm,page_alloc: Bail out earlier on -ENOMEM in alloc_contig_migrate_range Date: Thu, 15 Apr 2021 12:35:38 +0200 Message-Id: <20210415103544.6791-2-osalvador@suse.de> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20210415103544.6791-1-osalvador@suse.de> References: <20210415103544.6791-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