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=-15.3 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=unavailable 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 603E3C433ED for ; Wed, 12 May 2021 03:23:32 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id D5165613AF for ; Wed, 12 May 2021 03:23:31 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D5165613AF Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=huawei.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 5A50D6B0036; Tue, 11 May 2021 23:23:31 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5550E6B006E; Tue, 11 May 2021 23:23:31 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3F5106B0070; Tue, 11 May 2021 23:23:31 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0052.hostedemail.com [216.40.44.52]) by kanga.kvack.org (Postfix) with ESMTP id 216186B0036 for ; Tue, 11 May 2021 23:23:31 -0400 (EDT) Received: from smtpin29.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id C203852AE for ; Wed, 12 May 2021 03:23:30 +0000 (UTC) X-FDA: 78131133780.29.5F8BCE9 Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by imf15.hostedemail.com (Postfix) with ESMTP id 3E87CA0003B8 for ; Wed, 12 May 2021 03:23:22 +0000 (UTC) Received: from dggeml717-chm.china.huawei.com (unknown [172.30.72.53]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4Fg0Qq4N9Fz60XX; Wed, 12 May 2021 11:20:03 +0800 (CST) Received: from dggpemm500001.china.huawei.com (7.185.36.107) by dggeml717-chm.china.huawei.com (10.3.17.128) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2176.2; Wed, 12 May 2021 11:23:25 +0800 Received: from [10.174.177.243] (10.174.177.243) by dggpemm500001.china.huawei.com (7.185.36.107) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Wed, 12 May 2021 11:23:25 +0800 Subject: Re: [PATCH 3/3] mm/debug: Check page poisoned firstly in dump_page() To: Matthew Wilcox CC: Andrew Morton , , References: <20210512031057.13580-1-wangkefeng.wang@huawei.com> <20210512031057.13580-3-wangkefeng.wang@huawei.com> From: Kefeng Wang Message-ID: Date: Wed, 12 May 2021 11:23:24 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.7.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="utf-8"; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.174.177.243] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To dggpemm500001.china.huawei.com (7.185.36.107) X-CFilter-Loop: Reflected X-Rspamd-Queue-Id: 3E87CA0003B8 Authentication-Results: imf15.hostedemail.com; dkim=none; spf=pass (imf15.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.189 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com; dmarc=pass (policy=none) header.from=huawei.com X-Rspamd-Server: rspam03 X-Stat-Signature: ktbuqseux9jfdkdehuz8cgqgf6744s1j Received-SPF: none (huawei.com>: No applicable sender policy available) receiver=imf15; identity=mailfrom; envelope-from=""; helo=szxga03-in.huawei.com; client-ip=45.249.212.189 X-HE-DKIM-Result: none/none X-HE-Tag: 1620789802-773143 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 2021/5/12 11:15, Matthew Wilcox wrote: > On Wed, May 12, 2021 at 11:10:57AM +0800, Kefeng Wang wrote: >> If page is poisoned, it will crash when we call some page related >> functions, so must check whether the page is poisoned or not firstly. > > https://lore.kernel.org/linux-mm/20210430145549.2662354-4-willy@infradead.org/ OK, please ignore them, I found this when debug arm issue in lts5.10, thanks. > >> Fixes: 6197ab984b41 ("mm: improve dump_page() for compound pages") >> Signed-off-by: Kefeng Wang >> --- >> mm/debug.c | 15 +++++++++------ >> 1 file changed, 9 insertions(+), 6 deletions(-) >> >> diff --git a/mm/debug.c b/mm/debug.c >> index 84cdcd0f7bd3..cf84cd9df527 100644 >> --- a/mm/debug.c >> +++ b/mm/debug.c >> @@ -44,20 +44,19 @@ const struct trace_print_flags vmaflag_names[] = { >> >> static void __dump_page(struct page *page, const char *reason) >> { >> - struct page *head = compound_head(page); >> + struct page *head = NULL; >> struct address_space *mapping; >> - bool page_poisoned = PagePoisoned(page); >> - bool compound = PageCompound(page); >> + bool compound; >> /* >> * Accessing the pageblock without the zone lock. It could change to >> * "isolate" again in the meantime, but since we are just dumping the >> * state for debugging, it should be fine to accept a bit of >> * inaccuracy here due to racing. >> */ >> - bool page_cma = is_migrate_cma_page(page); >> + bool page_cma; >> int mapcount; >> char *type = ""; >> - >> + bool page_poisoned = PagePoisoned(page); >> /* >> * If struct page is poisoned don't access Page*() functions as that >> * leads to recursive loop. Page*() check for poisoned pages, and calls >> @@ -68,6 +67,10 @@ static void __dump_page(struct page *page, const char *reason) >> goto hex_only; >> } >> >> + head = compound_head(page); >> + page_poisoned = PagePoisoned(page); >> + page_cma = is_migrate_cma_page(page); >> + >> if (page < head || (page >= head + MAX_ORDER_NR_PAGES)) { >> /* >> * Corrupt page, so we cannot call page_mapping. Instead, do a >> @@ -178,7 +181,7 @@ static void __dump_page(struct page *page, const char *reason) >> print_hex_dump(KERN_WARNING, "raw: ", DUMP_PREFIX_NONE, 32, >> sizeof(unsigned long), page, >> sizeof(struct page), false); >> - if (head != page) >> + if (head && head != page) >> print_hex_dump(KERN_WARNING, "head: ", DUMP_PREFIX_NONE, 32, >> sizeof(unsigned long), head, >> sizeof(struct page), false); >> -- >> 2.26.2 >> >> > . >