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=-8.8 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,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 A3864C433DB for ; Thu, 4 Mar 2021 18:23:09 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 3385E64F60 for ; Thu, 4 Mar 2021 18:23:09 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3385E64F60 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 990C46B0005; Thu, 4 Mar 2021 13:23:08 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 965A46B0006; Thu, 4 Mar 2021 13:23:08 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 807086B0007; Thu, 4 Mar 2021 13:23:08 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0231.hostedemail.com [216.40.44.231]) by kanga.kvack.org (Postfix) with ESMTP id 619356B0005 for ; Thu, 4 Mar 2021 13:23:08 -0500 (EST) Received: from smtpin10.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 24B6B180385D3 for ; Thu, 4 Mar 2021 18:23:08 +0000 (UTC) X-FDA: 77883013656.10.AEA9138 Received: from mail-pg1-f172.google.com (mail-pg1-f172.google.com [209.85.215.172]) by imf16.hostedemail.com (Postfix) with ESMTP id 138FA801A82E for ; Thu, 4 Mar 2021 18:23:05 +0000 (UTC) Received: by mail-pg1-f172.google.com with SMTP id e6so19426988pgk.5 for ; Thu, 04 Mar 2021 10:23:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=r4hMSKBkNtrRITzzBe+cMqUl3cO3UFDjYwJAXk9K9SE=; b=iqJV8iPDKudZQtDxcUCimb3iPY6xqF9k/f6jUMMW5GwvCT1YYo6xmfN6X9f7NvMxHH u+VXMjUXW4fLrAD6xu+3BRaUj6Xjc5Xi1ZZBOUIpL3jdiZ+Ttlo5LgHYbaDW9keTV/h8 2EPX+Bq4BVb9R3/iPMS/I5rct4S9ToTdA46XgIW34wpMvZCFhitQq2rRBGFTKM5QLNQR zhBv55y5Gd13HtQ1nR/WxigglGM2zy6Su6IOXQFZN6FWdHqS3mfGFsxxfLYayLQCrxrg mzB+LtEwDEkEi4Mg7KYjSXI9PJj45auYKBBDg1r8n5mJpvmyd3z7PQejuOHKTB5goBKG G1Hw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :references:mime-version:content-disposition:in-reply-to; bh=r4hMSKBkNtrRITzzBe+cMqUl3cO3UFDjYwJAXk9K9SE=; b=QnNyKJDTq0R2nwj38Bn7eD1DBtFPtQPx8kSXFcU1rPyF1GhBnQAmDT23IUhJgvSbtW Y8aFNh9nUdQb8ngVxJH7qfwc5fhwEP67ekPSUzuieJBmL6wNLlDalaMi/CfAJVULzmpQ cO5ApuTZfODCGHdhiZ3lwqRRXz0g6bFkCLkgdIlZ+/hH1JJp8/rokGooKrMdf6Qq62JR TNxjPYu1SD4frHcm3H5+LSstpzYJbpvgcWCm2DRl1opyIEwTjl49rloPqy16vosvO12I pxgR4AScQ98zlVcRD2IjspZbasze6nXKxF6tU/QrRUPq9VqEnpLOjmbh28BnLV0PfS9G BE+g== X-Gm-Message-State: AOAM533AKkZREwrxq6NPxuIzPZSX2TII/z1zB0QFsPKCfLuG/bVKGeon 5XM/zzOtQ+X5ATmtGwAscSU= X-Google-Smtp-Source: ABdhPJxeqoZxYxdmo5120knr6cW1UDMzeLOpdCT5XxG7B8H6LSIWljM+JxlXDSgixlLhOsESPgVyNA== X-Received: by 2002:aa7:9281:0:b029:1ec:48b2:811c with SMTP id j1-20020aa792810000b02901ec48b2811cmr5005240pfa.18.1614882175190; Thu, 04 Mar 2021 10:22:55 -0800 (PST) Received: from google.com ([2620:15c:211:201:edb1:8010:5c27:a8cc]) by smtp.gmail.com with ESMTPSA id w128sm106609pfw.86.2021.03.04.10.22.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Mar 2021 10:22:53 -0800 (PST) Date: Thu, 4 Mar 2021 10:22:51 -0800 From: Minchan Kim To: David Hildenbrand Cc: Michal Hocko , Andrew Morton , linux-mm , LKML , joaodias@google.com Subject: Re: [PATCH] mm: be more verbose for alloc_contig_range faliures Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: 138FA801A82E X-Stat-Signature: 3z3pinaayudthc74zno9yag1ypgriybc Received-SPF: none (gmail.com>: No applicable sender policy available) receiver=imf16; identity=mailfrom; envelope-from=""; helo=mail-pg1-f172.google.com; client-ip=209.85.215.172 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1614882185-237739 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 Thu, Mar 04, 2021 at 10:11:35AM -0800, Minchan Kim wrote: > On Thu, Mar 04, 2021 at 06:23:09PM +0100, David Hildenbrand wrote: > > > > You want to debug something, so you try triggering it and capturing debug > > > > data. There are not that many alloc_contig_range() users such that this > > > > would really be an issue to isolate ... > > > > > > cma_alloc uses alloc_contig_range and cma_alloc has lots of users. > > > Even, it is expoerted by dmabuf so any userspace would trigger the > > > allocation by their own. Some of them could be tolerant for the failure, > > > rest of them could be critical. We should't expect it by limited kernel > > > usecase. > > > > Assume you are debugging allocation failures. You either collect the data > > yourself or ask someone to send you that output. You care about any > > alloc_contig_range() allocation failures that shouldn't happen, don't you? > > > > > > > > > > > > > Strictly speaking: any allocation failure on ZONE_MOVABLE or CMA is > > > > problematic (putting aside NORETRY logic and similar aside). So any such > > > > page you hit is worth investigating and, therefore, worth getting logged for > > > > debugging purposes. > > > > > > If you believe the every alloc_contig_range failure is problematic > > > > Every one where we should have guarantees I guess: ZONE_MOVABLE or > > MIGRAT_CMA. On ZONE_NORMAL, there are no guarantees. > > Indeed. How about this? diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 238d0fc232aa..489e557b9390 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -8481,7 +8481,8 @@ static inline void dump_migrate_failure_pages(struct list_head *page_list) /* [start, end) must belong to a single zone. */ static int __alloc_contig_migrate_range(struct compact_control *cc, - unsigned long start, unsigned long end) + unsigned long start, unsigned long end, + bool nofail) { /* This function is based on compact_zone() from compaction.c. */ unsigned int nr_reclaimed; @@ -8522,7 +8523,8 @@ static int __alloc_contig_migrate_range(struct compact_control *cc, NULL, (unsigned long)&mtc, cc->mode, MR_CONTIG_RANGE); } if (ret < 0) { - dump_migrate_failure_pages(&cc->migratepages); + if (ret == -EBUSY && nofail) + dump_migrate_failure_pages(&cc->migratepages); putback_movable_pages(&cc->migratepages); return ret; } @@ -8610,7 +8612,9 @@ int alloc_contig_range(unsigned long start, unsigned long end, * allocated. So, if we fall through be sure to clear ret so that * -EBUSY is not accidentally used or returned to caller. */ - ret = __alloc_contig_migrate_range(&cc, start, end); + ret = __alloc_contig_migrate_range(&cc, start, end, + migratetype == CMA || + zone_idx(cc.zone) == ZONE_MOVABLE); if (ret && ret != -EBUSY) goto done; ret =0;