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=-5.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=no 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 C692EC433E0 for ; Wed, 17 Mar 2021 15:02:23 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 3F0C864F75 for ; Wed, 17 Mar 2021 15:02:23 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3F0C864F75 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 959D16B0073; Wed, 17 Mar 2021 11:02:22 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 909DD6B0074; Wed, 17 Mar 2021 11:02:22 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7D1A36B007B; Wed, 17 Mar 2021 11:02:22 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0232.hostedemail.com [216.40.44.232]) by kanga.kvack.org (Postfix) with ESMTP id 6101B6B0073 for ; Wed, 17 Mar 2021 11:02:22 -0400 (EDT) Received: from smtpin20.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 1FFB76139 for ; Wed, 17 Mar 2021 15:02:22 +0000 (UTC) X-FDA: 77929682124.20.C1CD24B Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by imf22.hostedemail.com (Postfix) with ESMTP id 50FF6C158E06 for ; Wed, 17 Mar 2021 14:49:56 +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=1615992595; 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=Tek4PfCVWiuyin6G0ewc2/R9tv/tX0ZabWGaRWUeMFQ=; b=P78fHpKrigGwrusKUCB6W7i47Y1VCFMQmjrWooHYPEVW7mHQ98t4SaWikOgDTCMColWDrb px+zrer2zjMLMuoHrtNwPRjrcwbn13SRdt35UQLj90yhO1nR3b9MTG0Y6EkusRp1L1C4Pc 4HyFvKLrQ7EKZUOHx9aKd9yOoXBdtto= Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 2D5ABACA8; Wed, 17 Mar 2021 14:49:55 +0000 (UTC) Date: Wed, 17 Mar 2021 15:49:54 +0100 From: Michal Hocko To: David Hildenbrand Cc: Oscar Salvador , Andrew Morton , Vlastimil Babka , Muchun Song , Mike Kravetz , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v5 1/5] mm,page_alloc: Bail out earlier on -ENOMEM in alloc_contig_migrate_range Message-ID: References: <20210317111251.17808-1-osalvador@suse.de> <20210317111251.17808-2-osalvador@suse.de> <89830f41-b3f2-a158-a173-8c14101edcaa@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <89830f41-b3f2-a158-a173-8c14101edcaa@redhat.com> X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 50FF6C158E06 X-Stat-Signature: 71jxcymxwb5h7px8oxaekn49xztbd4rc Received-SPF: none (suse.com>: No applicable sender policy available) receiver=imf22; identity=mailfrom; envelope-from=""; helo=mx2.suse.de; client-ip=195.135.220.15 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1615992596-145709 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 Wed 17-03-21 15:42:43, David Hildenbrand wrote: > On 17.03.21 15:05, Michal Hocko wrote: > > On Wed 17-03-21 12:12:47, Oscar Salvador wrote: > > > 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. > > > > I suspect this is not really a real life problem, right? The allocation > > would be more costly in the end but this is to be expected under a heavy > > memory pressure. > > > > That being said, bailing out early makes sense to me. But now that > > you've made me look into the migrate_pages excellent error state reporting > > I suspect we have a bug here. Note the > > "Returns the number of pages that were not migrated, or an error code." > > > > but I do not see putback_movable_pages for ret > 0 so it seems we might > > leak some pages. > > At least in __alloc_contig_migrate_range() we seem to always leave the loop > with ret <= 0 and do a putback_movable_pages() with ret < 0. > > Which code are you referring to? OK, my bad. I have managed to confuse myself around the retry bailout which indeed overrides the return value. So there is no bug. Sorry about the noise but I still believe making migrate_pages less tricky with error handling would be an improvement. Thanks! -- Michal Hocko SUSE Labs