From patchwork Thu Mar 11 19:40:42 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Minchan Kim X-Patchwork-Id: 12132791 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=-16.8 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT 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 04F9BC433E0 for ; Thu, 11 Mar 2021 19:40:51 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 6816B64F73 for ; Thu, 11 Mar 2021 19:40:50 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6816B64F73 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 8FEB68D02F4; Thu, 11 Mar 2021 14:40:49 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 886EE8D02B2; Thu, 11 Mar 2021 14:40:49 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 701FF8D02F4; Thu, 11 Mar 2021 14:40:49 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0211.hostedemail.com [216.40.44.211]) by kanga.kvack.org (Postfix) with ESMTP id 4ECD18D02B2 for ; Thu, 11 Mar 2021 14:40:49 -0500 (EST) Received: from smtpin03.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 05ECF2DFA for ; Thu, 11 Mar 2021 19:40:49 +0000 (UTC) X-FDA: 77908611018.03.3819B3B Received: from mail-pf1-f180.google.com (mail-pf1-f180.google.com [209.85.210.180]) by imf17.hostedemail.com (Postfix) with ESMTP id AF06E407F8EB for ; Thu, 11 Mar 2021 19:40:47 +0000 (UTC) Received: by mail-pf1-f180.google.com with SMTP id b23so239596pfo.8 for ; Thu, 11 Mar 2021 11:40:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=LalnUbYf3ptXykE/fAOITuo1+VnkRoBvM429zzABfbw=; b=QH29SGQv+qsfrY41BlWBCcR/c2jDruOpA9TAaYWeoasgmytXsqzci0c823NzjDj0Ro XyWzpCzjwptQ+6PKMTLnBYDgNspqbEM4QppGppJtu7qFnpRscNSYdhIQoR/wAmKKv7s/ 2DGWXNNnmubpk8YUYEiZ9S+nDpMFd8FLRqs77caG4Lfq6Y6ToTuE18cTk7IsPK/28+In yg3Pj6Fq1iVKThomdPxQ//TOtXD7Fm7kNDIRRyY6v2efLWqilv3jjNGrO0X9ceMjHkNy ZLj4pOnV82V/hcLM3Iu3NKtxP3RMqPKLkrAa5YyZmKt7W72fGdVYTjkJ4oq9TgUCKR9Y 1LVA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :mime-version:content-transfer-encoding; bh=LalnUbYf3ptXykE/fAOITuo1+VnkRoBvM429zzABfbw=; b=P2xJnxMDKK/UHMsS+J8GzSyHzTT7sYzhAdTngo9qcWSMpGNiIxZbS6oNcr3ZedliML wL8nlUOs3/8S6saaCWD96+/fB7j7cxgjj+O5ZnWkYVmOVeOHLpCVqKeNJzsMSNGECo/M zRvA2dZOLtznpmS5sH+kgW76O5aiKYKVUQOkoVJhJZLc61CkTNhOxWQz5qNCAWGovtVk P9JpDWw4ETpbZd/N5dU8iKr9zOUcYmUj5DzA1CUP6onMu5vzxspHqEFpz7l5gY2Ejx7K BLE9fRC1BfI8E7v3ya7Puo1lTT5zpXC+i7yVcnzTPFRuU1FFuKAD+n6IPfTqz3aEn+KD PsIg== X-Gm-Message-State: AOAM532x828yZH51m8uTA37tY0QBAjiM8iLc1cxiKQknqHYBHrhRUD8d 7Px+nxa4SF+ohiV/fd0XUPY= X-Google-Smtp-Source: ABdhPJwKSdw3/TfsN8wIXuBnCAgQYOOM2hbHIv3zxJLQl4ktRA4SMuF+hzU8rSVY9On7VZeQW7AQfw== X-Received: by 2002:a62:5bc4:0:b029:1fe:86f7:3a66 with SMTP id p187-20020a625bc40000b02901fe86f73a66mr5871557pfb.42.1615491647278; Thu, 11 Mar 2021 11:40:47 -0800 (PST) Received: from bbox-1.mtv.corp.google.com ([2620:15c:211:201:64cb:74c7:f2c:e5e0]) by smtp.gmail.com with ESMTPSA id s194sm3251595pfs.57.2021.03.11.11.40.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Mar 2021 11:40:46 -0800 (PST) From: Minchan Kim To: Andrew Morton Cc: linux-mm , LKML , John Dias , Michal Hocko , David Hildenbrand , Jason Baron , Minchan Kim Subject: [PATCH v5] mm: page_alloc: dump migrate-failed pages Date: Thu, 11 Mar 2021 11:40:42 -0800 Message-Id: <20210311194042.825152-1-minchan@kernel.org> X-Mailer: git-send-email 2.31.0.rc2.261.g7f71774620-goog MIME-Version: 1.0 X-Stat-Signature: je58b49eye9wf3wmmdk6cgrgehsothbr X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: AF06E407F8EB Received-SPF: none (gmail.com>: No applicable sender policy available) receiver=imf17; identity=mailfrom; envelope-from=""; helo=mail-pf1-f180.google.com; client-ip=209.85.210.180 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1615491647-417105 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: Currently, debugging CMA allocation failures is quite limited. The most common source of these failures seems to be page migration which doesn't provide any useful information on the reason of the failure by itself. alloc_contig_range can report those failures as it holds a list of migrate-failed pages. The information logged by dump_page() has already proven helpful for debugging allocation issues, like identifying long-term pinnings on ZONE_MOVABLE or MIGRATE_CMA. Let's use the dynamic debugging infrastructure, such that we avoid flooding the logs and creating a lot of noise on frequent alloc_contig_range() calls. This information is helpful for debugging only. There are two ifdefery conditions to support common dyndbg options: - CONFIG_DYNAMIC_DEBUG_CORE && DYNAMIC_DEBUG_MODULE It aims for supporting the feature with only specific file with adding ccflags. - CONFIG_DYNAMIC_DEBUG It aims for supporting the feature with system wide globally. A simple example to enable the feature: Admin could enable the dump like this(by default, disabled) echo "func alloc_contig_dump_pages +p" > control Admin could disable it. echo "func alloc_contig_dump_pages =_" > control Detail goes Documentation/admin-guide/dynamic-debug-howto.rst A concern is utility functions in dump_page use inconsistent loglevels. In the future, we might want to make the loglevels used inside dump_page() consistent and eventually rework the way we log the information here. See [1]. [1] https://lore.kernel.org/linux-mm/YEh4doXvyuRl5BDB@google.com/ Reviewed-by: David Hildenbrand Signed-off-by: Minchan Kim --- * from v4 - https://lore.kernel.org/linux-mm/20210311183047.805891-1-minchan@kernel.org/ * better description - david * add reviewed-by - david * from v3 - https://lore.kernel.org/linux-mm/20210310180104.517886-1-minchan@kernel.org * add dyndgb usage comment - akpm * use dumpstack instead of warn_on - david * from v2 - https://lore.kernel.org/linux-mm/20210308202047.1903802-1-minchan@kernel.org/ * remove ratelimit - mhocko * from v1 - https://lore.kernel.org/linux-mm/20210217163603.429062-1-minchan@kernel.org/ * use dynamic debugging with system wide instead of per-call site - mhocko mm/page_alloc.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 3e4b29ee2b1e..d4b72b6682b6 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -8453,6 +8453,27 @@ static unsigned long pfn_max_align_up(unsigned long pfn) pageblock_nr_pages)); } +#if defined(CONFIG_DYNAMIC_DEBUG) || \ + (defined(CONFIG_DYNAMIC_DEBUG_CORE) && defined(DYNAMIC_DEBUG_MODULE)) +/* Usage: See admin-guide/dynamic-debug-howto.rst */ +static void alloc_contig_dump_pages(struct list_head *page_list) +{ + DEFINE_DYNAMIC_DEBUG_METADATA(descriptor, "migrate failure"); + + if (DYNAMIC_DEBUG_BRANCH(descriptor)) { + struct page *page; + + dump_stack(); + list_for_each_entry(page, page_list, lru) + dump_page(page, "migration failure"); + } +} +#else +static inline void alloc_contig_dump_pages(struct list_head *page_list) +{ +} +#endif + /* [start, end) must belong to a single zone. */ static int __alloc_contig_migrate_range(struct compact_control *cc, unsigned long start, unsigned long end) @@ -8496,6 +8517,7 @@ static int __alloc_contig_migrate_range(struct compact_control *cc, NULL, (unsigned long)&mtc, cc->mode, MR_CONTIG_RANGE); } if (ret < 0) { + alloc_contig_dump_pages(&cc->migratepages); putback_movable_pages(&cc->migratepages); return ret; }