Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp254933imm; Mon, 2 Jul 2018 10:57:16 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJ5mMxViUtbR5vBQ4/UpqaD5XBDV8wwYaXvg3dH3QMpm7XhbAFaJyOnk3vQdbgMaNTBnhSq X-Received: by 2002:a63:3348:: with SMTP id z69-v6mr22118633pgz.171.1530554236590; Mon, 02 Jul 2018 10:57:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530554236; cv=none; d=google.com; s=arc-20160816; b=Cpr6tzt5EFoP60znMB/fGIo3KtWT+1/24ZSQt1NM3Iop91GRK6RQSM2dKqbqSgAxRL oLPX3WOXmCc0EQ5HufFuK9zXEhz1bMshuaiKPkXVtXpKeLzWiyGYferkTCz+FR7kjrcP tTB1yOy1MaAjbEqS+uGc/WruIflaWv7QelWtth+iYtWzTfrdLJsyqzgMuv6MBgOFLL1X i6uilQDGIs3/uXNNzdWKoqv3ZZ4eTRSGueJeLa+XYKo5U3FEdvc9K9hP1z1PNQwLrZs4 ttNjFoyRGSp1rQPAultwq7LkAupoXY4vEuCOu+EdmfSAumtTpI6xCq9vCmPAtR3ee/+y 02mw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature :arc-authentication-results; bh=zMpBZqIob5wP3bvZyyHOiqfojBEoxGq3SbF724kndgs=; b=Tqczmtyy84fgZzIxnyFl0yJnYWtg0+2FYTKwgPSFXERtgTQjupw8axbX3WYU8XMhfi judIfajTsOCeRKo4Plat6UvKOuihoo4VoteWXTYNrZcWcd+uAhiBhCKaPtE+Mv7jB1ZH yh1LR7MnRDOpU9G3HnGWot6u+ubGRaTMSvN8Jouw6Xva7ORaZU1YGY4V+JsZWrz3XWRi j00aPdyJopFOC83nJxdr8ixZX5n2bGsIjo/I5JexiP7raTciROfkz1oDNVcZ9owxIUgF DupdOIcQy9k+nWljaqOYal/z21dOZERY0FAjeGnNJZqAuZxNgaGvUSlUlwT6xvaByQq2 nqYw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2017-10-26 header.b=F3scf1Wt; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g9-v6si16130189plt.232.2018.07.02.10.57.02; Mon, 02 Jul 2018 10:57:16 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2017-10-26 header.b=F3scf1Wt; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753156AbeGBRzJ (ORCPT + 99 others); Mon, 2 Jul 2018 13:55:09 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:53364 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752808AbeGBRzI (ORCPT ); Mon, 2 Jul 2018 13:55:08 -0400 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w62Hrelx009106 for ; Mon, 2 Jul 2018 17:55:07 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=mime-version : references : in-reply-to : from : date : message-id : subject : to : cc : content-type; s=corp-2017-10-26; bh=zMpBZqIob5wP3bvZyyHOiqfojBEoxGq3SbF724kndgs=; b=F3scf1WtUylzCqAQ+it+PEVFtAfvqaH8rmn+SI9rgEKLdQIIVzxTAHAOFN1loaRLKQOQ hiYXTutpQIuA14cLnwFyFYp3LTgz5VVMprk3CRgA0v1E3ypYA6e7dGqB9nboB7JopOjN LALNSRGyRl0W15Q/mMeNiAIrI8tW259SImhB3Xqf/j56iEs1/PJrDd2ywuhrRBa7a9Z+ AfEo7E+LEy+DLknCdQPWxduvOSzuhgddcwUPsOVJL0Q6eoxKJVfhWAec8mcgiltJ6J7Q OOWMSaAwXMqdYp+P8eBXA5/DcbM33xs74+hJk32yq3+X+H3D4EMbFLi8zDOUjhHOsWMz eQ== Received: from aserv0021.oracle.com (aserv0021.oracle.com [141.146.126.233]) by aserp2120.oracle.com with ESMTP id 2jx1tnwg9j-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Mon, 02 Jul 2018 17:55:07 +0000 Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserv0021.oracle.com (8.14.4/8.14.4) with ESMTP id w62Ht6RA025723 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Mon, 2 Jul 2018 17:55:06 GMT Received: from abhmp0011.oracle.com (abhmp0011.oracle.com [141.146.116.17]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id w62Ht6dg027448 for ; Mon, 2 Jul 2018 17:55:06 GMT Received: from mail-oi0-f45.google.com (/209.85.218.45) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 02 Jul 2018 10:55:06 -0700 Received: by mail-oi0-f45.google.com with SMTP id w126-v6so10698025oie.7 for ; Mon, 02 Jul 2018 10:55:06 -0700 (PDT) X-Gm-Message-State: APt69E3tx9bdJl4GAm8Z3jUcI5xTxBq+NMCmpNvJlBMvHufPwpKWtZYM r234wfW9VUrEEBpc0EU3dIJR44U/HNZGtJwizk4= X-Received: by 2002:a54:4f88:: with SMTP id g8-v6mr2921742oiy.191.1530554105791; Mon, 02 Jul 2018 10:55:05 -0700 (PDT) MIME-Version: 1.0 References: <20180702152745.27596-1-pasha.tatashin@oracle.com> <20180702155858.GE19043@dhcp22.suse.cz> In-Reply-To: <20180702155858.GE19043@dhcp22.suse.cz> From: Pavel Tatashin Date: Mon, 2 Jul 2018 13:54:29 -0400 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] mm: teach dump_page() to correctly output poisoned struct pages To: mhocko@kernel.org Cc: Steven Sistare , Daniel Jordan , LKML , Andrew Morton , kirill.shutemov@linux.intel.com, Linux Memory Management List , mgorman@techsingularity.net, gregkh@linuxfoundation.org Content-Type: text/plain; charset="UTF-8" X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=8942 signatures=668704 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=3 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1806210000 definitions=main-1807020200 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jul 2, 2018 at 11:59 AM Michal Hocko wrote: > > On Mon 02-07-18 11:27:45, Pavel Tatashin wrote: > > If struct page is poisoned, and uninitialized access is detected via > > PF_POISONED_CHECK(page) dump_page() is called to output the page. But, > > the dump_page() itself accesses struct page to determine how to print > > it, and therefore gets into a recursive loop. > > > > For example: > > dump_page() > > __dump_page() > > PageSlab(page) > > PF_POISONED_CHECK(page) > > VM_BUG_ON_PGFLAGS(PagePoisoned(page), page) > > dump_page() recursion loop. > > This deserves a big fat comment in __dump_page. Basically no Page$FOO > can be used on an HWPoison page. > > > Fixes: f165b378bbdf ("mm: uninitialized struct page poisoning sanity checking") > > Signed-off-by: Pavel Tatashin > > Acked-by: Michal Hocko Thank you, I will send out an updated version with a comment. Pavel > > > --- > > mm/debug.c | 13 +++++++++++-- > > 1 file changed, 11 insertions(+), 2 deletions(-) > > > > diff --git a/mm/debug.c b/mm/debug.c > > index 56e2d9125ea5..469b526e6abc 100644 > > --- a/mm/debug.c > > +++ b/mm/debug.c > > @@ -43,12 +43,20 @@ const struct trace_print_flags vmaflag_names[] = { > > > > void __dump_page(struct page *page, const char *reason) > > { > > + bool page_poisoned = PagePoisoned(page); > > + int mapcount; > > + > > + if (page_poisoned) { > > + pr_emerg("page:%px is uninitialized and poisoned", page); > > + goto hex_only; > > + } > > + > > /* > > * Avoid VM_BUG_ON() in page_mapcount(). > > * page->_mapcount space in struct page is used by sl[aou]b pages to > > * encode own info. > > */ > > - int mapcount = PageSlab(page) ? 0 : page_mapcount(page); > > + mapcount = PageSlab(page) ? 0 : page_mapcount(page); > > > > pr_emerg("page:%px count:%d mapcount:%d mapping:%px index:%#lx", > > page, page_ref_count(page), mapcount, > > @@ -60,6 +68,7 @@ void __dump_page(struct page *page, const char *reason) > > > > pr_emerg("flags: %#lx(%pGp)\n", page->flags, &page->flags); > > > > +hex_only: > > print_hex_dump(KERN_ALERT, "raw: ", DUMP_PREFIX_NONE, 32, > > sizeof(unsigned long), page, > > sizeof(struct page), false); > > @@ -68,7 +77,7 @@ void __dump_page(struct page *page, const char *reason) > > pr_alert("page dumped because: %s\n", reason); > > > > #ifdef CONFIG_MEMCG > > - if (page->mem_cgroup) > > + if (!page_poisoned && page->mem_cgroup) > > pr_alert("page->mem_cgroup:%px\n", page->mem_cgroup); > > #endif > > } > > -- > > 2.18.0 > > > > -- > Michal Hocko > SUSE Labs >