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=-5.4 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,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 1E8F1C35246 for ; Thu, 30 Jan 2020 06:34:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E962B2083E for ; Thu, 30 Jan 2020 06:34:01 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=nvidia.com header.i=@nvidia.com header.b="f4pKrMQl" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726353AbgA3Gd6 (ORCPT ); Thu, 30 Jan 2020 01:33:58 -0500 Received: from hqnvemgate26.nvidia.com ([216.228.121.65]:19859 "EHLO hqnvemgate26.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725865AbgA3Gd6 (ORCPT ); Thu, 30 Jan 2020 01:33:58 -0500 Received: from hqpgpgate102.nvidia.com (Not Verified[216.228.121.13]) by hqnvemgate26.nvidia.com (using TLS: TLSv1.2, DES-CBC3-SHA) id ; Wed, 29 Jan 2020 22:33:43 -0800 Received: from hqmail.nvidia.com ([172.20.161.6]) by hqpgpgate102.nvidia.com (PGP Universal service); Wed, 29 Jan 2020 22:33:57 -0800 X-PGP-Universal: processed; by hqpgpgate102.nvidia.com on Wed, 29 Jan 2020 22:33:57 -0800 Received: from [10.2.165.69] (172.20.13.39) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Thu, 30 Jan 2020 06:33:57 +0000 Subject: Re: [PATCH v2 1/8] mm: dump_page: print head page's refcount, for compound pages From: John Hubbard To: Matthew Wilcox CC: "Kirill A. Shutemov" , Andrew Morton , Al Viro , Christoph Hellwig , Dan Williams , Dave Chinner , Ira Weiny , Jan Kara , Jason Gunthorpe , Jonathan Corbet , =?UTF-8?B?SsOpcsO0bWUgR2xpc3Nl?= , Michal Hocko , Mike Kravetz , Shuah Khan , Vlastimil Babka , , , , , , LKML References: <20200129032417.3085670-1-jhubbard@nvidia.com> <20200129032417.3085670-2-jhubbard@nvidia.com> <20200129112510.ulims6u36ofk2qwa@box> <20200129225957.GH6615@bombadil.infradead.org> X-Nvconfidentiality: public Message-ID: Date: Wed, 29 Jan 2020 22:30:56 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.4.2 MIME-Version: 1.0 In-Reply-To: X-Originating-IP: [172.20.13.39] X-ClientProxiedBy: HQMAIL107.nvidia.com (172.20.187.13) To HQMAIL107.nvidia.com (172.20.187.13) Content-Type: text/plain; charset="utf-8"; format=flowed Content-Language: en-US Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nvidia.com; s=n1; t=1580366023; bh=iZY1/g2/MCQ3KPYqu+CkoD4OYyNxEEjqeo4JNbOECuM=; h=X-PGP-Universal:Subject:From:To:CC:References:X-Nvconfidentiality: Message-ID:Date:User-Agent:MIME-Version:In-Reply-To: X-Originating-IP:X-ClientProxiedBy:Content-Type:Content-Language: Content-Transfer-Encoding; b=f4pKrMQlnQ5lVGDlW7PYL/KTudIQAYyxHJ7kADvSvQcMo7xwDlpmNiw7jRHH02XRu LUbhtnmhoFfoViXeCzyURJZ5ZT2tFv9w7Gk9BnbjxiHqqR68cmGGsL8OQpAUrTKwh+ R+Oe2oriRiuX2tYa5Q/Y6J9XiamJIsg3qsDjvCKVjyu1CTO3AmyUYsyMOqgYJGoiKo sesGH5ZgSCJZQl6twIoECnFRiCw9hq7fox55hgonciXWj/8hqlGsB2QlJUJEzVCVGm qVSi0u7Haqg8rNwptdG7Ds19fKzYYVrSXNV3FYLO8hwx3z1RyYmwXoib0tTh2UpcP+ 0MLpWfq4Ga0vw== Sender: linux-kselftest-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org On 1/29/20 10:23 PM, John Hubbard wrote: > On 1/29/20 2:59 PM, Matthew Wilcox wrote: > ... >> I have a hunk in my current tree which looks like this: >> >> @@ -77,6 +77,11 @@ void __dump_page(struct page *page, const char *reaso= n) >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0 pr_warn("page:%px refcount:%d mapcount:%d mapping:= %px index:%#lx >> \n", >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 pa= ge, page_ref_count(page), mapcount, >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 pa= ge->mapping, page_to_pgoff(page)); >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if (PageTail(page)) { >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0 struct page *head =3D compound_head(page); >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0 pr_warn("head:%px mapping:%px index:%#lx\n", >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 head, head-= >mapping, page_to_pgoff(head)); >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 } >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if (PageKsm(page)) >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0 pr_warn("ksm flags: %#lx(%pGp)\n", page->flags, &p= age->flags); >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 else if (PageAnon(page)= ) >> >> I wonder if we can combine these two patches in some more useful way? >> >> I also think we probably want a sanity check that 'head' and 'page' >> are within a sane range of each other (ie head < page and head + >> MAX_ORDER_NR_PAGES > page) to protect against a struct page that contain= s >> complete garbage. >> >=20 > OK, here's a go at combining those. I like the observation, implicit in y= our > diffs, that PageTail rather than PageCompound is the key differentiator i= n > deciding what to print. How's this look: >=20 > diff --git a/mm/debug.c b/mm/debug.c > index a90da5337c14..944652843e7b 100644 > --- a/mm/debug.c > +++ b/mm/debug.c > @@ -75,12 +75,31 @@ void __dump_page(struct page *page, const char *reaso= n) > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 */ > =C2=A0=C2=A0=C2=A0=C2=A0 mapcount =3D PageSlab(page) ? 0 : page_mapcount= (page); >=20 > -=C2=A0=C2=A0=C2=A0 if (PageCompound(page)) > -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 pr_warn("page:%px refcount:%d= mapcount:%d mapping:%px " > -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 "inde= x:%#lx compound_mapcount: %d\n", > -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 page,= page_ref_count(page), mapcount, > -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 page-= >mapping, page_to_pgoff(page), > -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 compo= und_mapcount(page)); > +=C2=A0=C2=A0=C2=A0 if (PageTail(page)) { > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 struct page *head =3D compoun= d_head(page); > + > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if ((page < head) || (page >= =3D head + MAX_ORDER_NR_PAGES)) { > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 /* > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= * Page is hopelessly corrupted, so limit any reporting > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= * to information about the page itself. Do not attempt > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= * to look at the head page. > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= */ > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 pr_wa= rn("page:%px refcount:%d mapcount:%d mapping:%px " > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0 "index:%#lx (corrupted tail page case)\n", > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0 page, page_ref_count(page), mapcount, > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0 page->mapping, page_to_pgoff(page)); > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 } else { > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 pr_wa= rn("page:%px compound refcount:%d mapcount:%d " > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0 "mapping:%px index:%#lx compound_mapcount:%d\n", > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0 page, page_ref_count(head), > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0 mapcount, head->mapping, page_to_pgoff(head), > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0 compound_mapcount(page)); > + > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if (p= age_ref_count(page) !=3D 0) > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0 pr_warn("page:%px PROBLEM: non-zero refcount (=3D=3D%d) = on " > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 "this tail page\n", page, page_r= ef_count(page)); ...ahem, I sorta botched the above statement, because that should be outside (just below) the "else" statement--it can be done whether or not the page fails the safety/bounds check. :) thanks, --=20 John Hubbard NVIDIA