From patchwork Mon Mar 8 20:20:47 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Minchan Kim X-Patchwork-Id: 12123363 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 42F55C433DB for ; Mon, 8 Mar 2021 20:20:58 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id D058465272 for ; Mon, 8 Mar 2021 20:20:57 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D058465272 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 3FB8C8D0072; Mon, 8 Mar 2021 15:20:57 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 3ABF68D001D; Mon, 8 Mar 2021 15:20:57 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 225798D0072; Mon, 8 Mar 2021 15:20:57 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0244.hostedemail.com [216.40.44.244]) by kanga.kvack.org (Postfix) with ESMTP id 074998D001D for ; Mon, 8 Mar 2021 15:20:57 -0500 (EST) Received: from smtpin27.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id C24344DDD for ; Mon, 8 Mar 2021 20:20:56 +0000 (UTC) X-FDA: 77897825712.27.64C1E24 Received: from mail-pj1-f44.google.com (mail-pj1-f44.google.com [209.85.216.44]) by imf07.hostedemail.com (Postfix) with ESMTP id 2BB03A0009E6 for ; Mon, 8 Mar 2021 20:20:56 +0000 (UTC) Received: by mail-pj1-f44.google.com with SMTP id kx1so296972pjb.3 for ; Mon, 08 Mar 2021 12:20:56 -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=csGvzyVxMjdQkcW+Isd77wk7YphcfPE9DgicYzGkyLE=; b=ehsPqZWxk85w4HGbpw9PXVVdgMdfSGJvH685P2AwQapZ1TQGdgn75UQNV1tj9YkoVy 0mgUL+Z3/F2OhIBZIqJnXoTaGpOEZs+G7KD6j/zOACgYPx24CMQIX4qNazvOx6dzSKCa rTqfbG/W7xqdmSVOriErC/aux/8wVOTu0t51lO1g7nc3AQEmE3/NJK5lu777SEUe/UWI T7P/XFkojV2OUF4OwAuL9gWgbRs+sGDZmmLYo9VCopU49+gDKuKkoqGGRGjpTbnL1ycA zWe7QTjRGB/Uy9w4STy5dozxmgDPsjvwPxEWaicFZIvyVw0W1Yu82Qg65jcpYSYEgGwD euVg== 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=csGvzyVxMjdQkcW+Isd77wk7YphcfPE9DgicYzGkyLE=; b=XvAZb3oMXcsOKS9EtfuL8+34i/BBJRHBcqUK035LBGAY38FWDaqDGfhV/z/SVIRSDJ uK6xGr7IrZM5zVzMAibVHkXEpHPJouHNhiDtTHE/3ypcWntKIkWpEG6ddKihKV9/hK+M aZAQ/jZ1N5ABmJ0POudfKftdxU1lgYS+9bmcr81O9jc+apFyN8lMtsd/DIAmAlEaETFR oGY0JG4LoFVogHA8Uy3rel+REd3bT2VYdIq07NZ9RvmezQAU5VDR9CH9mEwWwyVDhzid FO9kAi7Wy+DDlCfjh4ecE1vnjkHXVSCEr8UPAin1usPFZy4lUQqY6PIOe2XGnxlfAmzu o4SA== X-Gm-Message-State: AOAM532hPPdE79V3Dw5yQA+oARZ2g1V2JrIJK15DozsPAhFWtjAXEJue 6LDP5it4vWbBVWyKg7s+u4k= X-Google-Smtp-Source: ABdhPJw2BopEs7NcQbmzx23rnm0ntcqcZ9j4B5IC2fBwB+PNRppULRwJ1K2odDzBIiiE/4q13Huh3A== X-Received: by 2002:a17:903:2283:b029:e4:8a:d7cb with SMTP id b3-20020a1709032283b02900e4008ad7cbmr23015562plh.5.1615234855395; Mon, 08 Mar 2021 12:20:55 -0800 (PST) Received: from bbox-1.mtv.corp.google.com ([2620:15c:211:201:4ccc:acdd:25da:14d1]) by smtp.gmail.com with ESMTPSA id b15sm10987910pgj.84.2021.03.08.12.20.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Mar 2021 12:20:54 -0800 (PST) From: Minchan Kim To: Andrew Morton Cc: linux-mm , LKML , John Dias , Michal Hocko , David Hildenbrand , Jason Baron , Minchan Kim Subject: [PATCH v2] mm: page_alloc: dump migrate-failed pages Date: Mon, 8 Mar 2021 12:20:47 -0800 Message-Id: <20210308202047.1903802-1-minchan@kernel.org> X-Mailer: git-send-email 2.30.1.766.gb4fecdf3b7-goog MIME-Version: 1.0 X-Stat-Signature: foa54po3maadr4c8pgi1ppyy8dud71f7 X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 2BB03A0009E6 Received-SPF: none (gmail.com>: No applicable sender policy available) receiver=imf07; identity=mailfrom; envelope-from=""; helo=mail-pj1-f44.google.com; client-ip=209.85.216.44 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1615234856-359186 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: alloc_contig_range is usually used on cma area or movable zone. It's critical if the page migration fails on those areas so dump more debugging message. page refcount, mapcount with page flags on dump_page are helpful information to deduce the culprit. Furthermore, dump_page_owner was super helpful to find long term pinner who initiated the page allocation. Admin could enable the dump like this(by default, disabled) echo "func dump_migrate_failure_pages +p" > control Admin could disable it. echo "func dump_migrate_failure_pages =_" > control Signed-off-by: Minchan Kim Reported-by: kernel test robot Reported-by: kernel test robot --- * 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 | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 3e4b29ee2b1e..bb0aeca2069c 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -8453,6 +8453,34 @@ 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)) +static DEFINE_RATELIMIT_STATE(alloc_contig_ratelimit_state, + DEFAULT_RATELIMIT_INTERVAL, DEFAULT_RATELIMIT_BURST); +int alloc_contig_ratelimit(void) +{ + return __ratelimit(&alloc_contig_ratelimit_state); +} + +void dump_migrate_failure_pages(struct list_head *page_list) +{ + DEFINE_DYNAMIC_DEBUG_METADATA(descriptor, + "migrate failure"); + if (DYNAMIC_DEBUG_BRANCH(descriptor) && + alloc_contig_ratelimit()) { + struct page *page; + + WARN(1, "failed callstack"); + list_for_each_entry(page, page_list, lru) + dump_page(page, "migration failure"); + } +} +#else +static inline void dump_migrate_failure_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 +8524,7 @@ 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); putback_movable_pages(&cc->migratepages); return ret; }