Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp2672546pxb; Tue, 13 Apr 2021 07:32:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz8cAWRgnhzS+rkYGVURwrCf+V4rjFzTwL8aE9kmqmGO8qD4JYGPpu4VaBkBN0B/v+PQkL3 X-Received: by 2002:a17:902:f2d1:b029:eb:2e32:8804 with SMTP id h17-20020a170902f2d1b02900eb2e328804mr3193679plc.40.1618324365172; Tue, 13 Apr 2021 07:32:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618324365; cv=none; d=google.com; s=arc-20160816; b=OtNx2ShJNUSeTSQ9pSITyoXkCYsG5xtNCGyUY9YmSx1KUKjI0VmnttTMksgDlE3BO7 5gqKLV9sXKo6kn2OjpmuA/tfVeY1UAtGn71yfzv5aDyXBC/eVkSfAjT+dTbBz977CJHV rGXGz+NNWaPnBcxY6vw+MeNu+nMPHN7UVETpO+RyGpceJc0BgD1SbJCTEwCpEwSzB5NB +sqMfoXXEk0Kz0WoKte1U1BP6VVX25q7x33noqAorLljXlvDae5DTCfv+Z2MSDuVKfw7 5y3Fakm8mtGlDw5FIqA2zVkVqCJKHkIj+XR3sZ2vovnSMjd3K8eZy85ItSV5YOm3Sfxh SoRQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from; bh=96Mle80oWoE2fPW7bUvOLLZPrNAlNEpI5tyBhONVrJM=; b=l3NZHPFRa4c0BO+9n85HpC5sTco/Sc1XoVdD3rl9VXF7dYvZT1Z/Fb2c7/4OrRY+6J Ck4LAzMXJrE+/C0t9hKoDv13ByFk8Lyl06DzI0lLLvv6Czkw5xQODZ+4w6ZzehLUakau ELbBNWzP+rXt/962N9akxiuTVEzoR89B8urWmY8L4qaK6ILk4UzBsc2CVXViQsJi69HL gkk1Z/hURs/Di5Be013LqJWZFvVSBfCMOVrxMIurk7vwiGdhiEvmcxCUqqlgyjM6N+KY aEWtWAoIOcZPRA56Js6SL598ciPIjlXdcldy79KvyUaOT6y8M+P4b5ufmzGykvFhfOyb tuEg== 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 l6si10074860plk.312.2021.04.13.07.32.32; Tue, 13 Apr 2021 07:32:45 -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 S1343882AbhDMKsf (ORCPT + 99 others); Tue, 13 Apr 2021 06:48:35 -0400 Received: from mx2.suse.de ([195.135.220.15]:52768 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236813AbhDMKsV (ORCPT ); Tue, 13 Apr 2021 06:48:21 -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 99402B12D; Tue, 13 Apr 2021 10:48:01 +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 Subject: [PATCH v7 1/7] mm,page_alloc: Bail out earlier on -ENOMEM in alloc_contig_migrate_range Date: Tue, 13 Apr 2021 12:47:41 +0200 Message-Id: <20210413104747.12177-2-osalvador@suse.de> X-Mailer: git-send-email 2.13.7 In-Reply-To: <20210413104747.12177-1-osalvador@suse.de> References: <20210413104747.12177-1-osalvador@suse.de> 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 --- 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