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=-3.8 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=no 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 188E3C433DF for ; Tue, 4 Aug 2020 19:43:03 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id D15C62076E for ; Tue, 4 Aug 2020 19:43:02 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="jn+L5gW3" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D15C62076E Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 6897D8D018A; Tue, 4 Aug 2020 15:43:02 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6390A8D0189; Tue, 4 Aug 2020 15:43:02 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 528CD8D018A; Tue, 4 Aug 2020 15:43:02 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0030.hostedemail.com [216.40.44.30]) by kanga.kvack.org (Postfix) with ESMTP id 389108D0189 for ; Tue, 4 Aug 2020 15:43:02 -0400 (EDT) Received: from smtpin11.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id F03278248047 for ; Tue, 4 Aug 2020 19:43:01 +0000 (UTC) X-FDA: 77113909362.11.horse75_5b0f65626fa9 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin11.hostedemail.com (Postfix) with ESMTP id C61CA180F8B80 for ; Tue, 4 Aug 2020 19:43:01 +0000 (UTC) X-HE-Tag: horse75_5b0f65626fa9 X-Filterd-Recvd-Size: 3105 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf14.hostedemail.com (Postfix) with ESMTP for ; Tue, 4 Aug 2020 19:43:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=e4sOMHSNomDNgSHA1tMxghReFjWLOhXwGM/Di/RfBXY=; b=jn+L5gW3cXN4wz1jI0vHGUIDvP m4IvDM0nLHa4pOxpZtr5m4d8zwqYd1H21fVCqC1J9f9jEYbdUqF9l03FQxv5+LNbAg3H5//BPud/f 4gSE4REfMvdAN13rgatfo2FA5XZPV71HGbGLP5E2fovQOCnuLfBvGe8uNODMSq/YdjSlBM4Fyddxm JSO5MB19ZIgK6QbUiaJ/zVlFZYmFZO/AQ1HA8FPD2bxl/S64DnmKlqb3RZ4AugiJhJ6hW/NSwBUGW s2/Ddyq+EUqCDFoFalbz8F8ffW3IVkib59ZVDIhfKwLsdWE+fjtbyXSq53K/Ivt8gZk/E1BhK6GPH Q2se57FA==; Received: from willy by casper.infradead.org with local (Exim 4.92.3 #3 (Red Hat Linux)) id 1k32ps-0004GL-L6; Tue, 04 Aug 2020 19:42:56 +0000 Date: Tue, 4 Aug 2020 20:42:56 +0100 From: Matthew Wilcox To: John Hubbard Cc: akpm@linux-foundation.org, cai@lca.pw, kirill@shutemov.name, linux-mm@kvack.org, rppt@linux.ibm.com, vbabka@suse.cz, william.kucharski@oracle.com, "Kirill A . Shutemov" Subject: Re: [PATCH] mm, dump_page: do not crash with bad compound_page() Message-ID: <20200804194256.GJ23808@casper.infradead.org> References: <20200804161414.GG23808@casper.infradead.org> <20200804183943.1244828-1-jhubbard@nvidia.com> <20200804184856.GI23808@casper.infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Rspamd-Queue-Id: C61CA180F8B80 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam05 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 Tue, Aug 04, 2020 at 12:17:34PM -0700, John Hubbard wrote: > On 8/4/20 11:48 AM, Matthew Wilcox wrote: > > On Tue, Aug 04, 2020 at 11:39:43AM -0700, John Hubbard wrote: > > > +static inline int __compound_mapcount(struct page *page) > > > +{ > > > + page = compound_head(page); > > > + return atomic_read(compound_mapcount_ptr(page)) + 1; > > > +} > > > > I'd suggest instead: > > > > static inline int head_mapcount(struct page *head) > > { > > return atomic_read(compound_mapcount_ptr(head)) + 1; > > } > > > > > +static inline int dump_page_compound_mapcount(struct page *page) > > > +{ > > > + if (WARN_ON_ONCE(!PageCompound(page))) > > > + return 0; > > > + return __compound_mapcount(page); > > > } > > > > And just dropping this ... it shouldn't be used outside mm/debug.c anyway. > > Yes, that's cleaner. I'll send a v2 that is not a reply, so that Andrew can > spot it more easily. OK to add your "Suggested-by:" to that? Of course! Thanks! > > Thinking about it, we'll get the hint later that this is not to be trusted > > when the flags from the page do not include 'head'. > > > > Good point. I think this will work out pretty well, then. > > thanks, > -- > John Hubbard > NVIDIA