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.5 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,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 7D5A9C2BA2B for ; Thu, 9 Apr 2020 14:15:54 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 38DC820771 for ; Thu, 9 Apr 2020 14:15:54 +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="isOFsBIh" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 38DC820771 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 DAC958E000D; Thu, 9 Apr 2020 10:15:53 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D5D408E0006; Thu, 9 Apr 2020 10:15:53 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C73748E000D; Thu, 9 Apr 2020 10:15:53 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0139.hostedemail.com [216.40.44.139]) by kanga.kvack.org (Postfix) with ESMTP id BC5908E0006 for ; Thu, 9 Apr 2020 10:15:53 -0400 (EDT) Received: from smtpin16.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 90BB0181AC553 for ; Thu, 9 Apr 2020 14:15:53 +0000 (UTC) X-FDA: 76688515386.16.ink85_6d9d3c0b2290f X-HE-Tag: ink85_6d9d3c0b2290f X-Filterd-Recvd-Size: 3456 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf13.hostedemail.com (Postfix) with ESMTP for ; Thu, 9 Apr 2020 14:15:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.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=ho7K/CndNRCfGDSsx3dXYUSC88hMgv8e4HFs+4cvnEQ=; b=isOFsBIh6ihf75gDM2ShohxnAz kevpwP3EX3kJHwRDnBkFyQ5r+HGG7ZiVT1Am7rFdFYOtU1iuigFmbWWl2CBd2TSMsBgWtYJ54ROVH Oc9BgNnT0QwcrvwG2MxhMQubg+n7CC6oyVqA85nqoaOLTGiBFaWprR5CevK32wOfaxuCFb9R1zYY7 z4jGkpwxapMF4E9nlVGEsq8blg1NPm+8z6c2KTFT2nxaQOMq+ploA24tCatjsp4Q3xf8DTFhT/2mO xO25trnA8ij1psF/NN3rjQYYKt0gR07ad4Q9w8w57GCMxvePNFm8qCa8XW6JoA0lRtRgVqbVj5nKz +jua6OCw==; Received: from willy by bombadil.infradead.org with local (Exim 4.92.3 #3 (Red Hat Linux)) id 1jMXyA-0005wh-7g; Thu, 09 Apr 2020 14:15:50 +0000 Date: Thu, 9 Apr 2020 07:15:50 -0700 From: Matthew Wilcox To: "Kirill A. Shutemov" Cc: linux-mm@kvack.org, kirill.shutemov@linux.intel.com, pasha.tatashin@soleen.com Subject: Re: [PATCH 1/5] mm: Constify a lot of struct page arguments Message-ID: <20200409141550.GU21484@bombadil.infradead.org> References: <20200408150148.25290-1-willy@infradead.org> <20200408150148.25290-2-willy@infradead.org> <20200409140914.u3mff4xrk5u4tvht@box> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200409140914.u3mff4xrk5u4tvht@box> 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 Thu, Apr 09, 2020 at 05:09:14PM +0300, Kirill A. Shutemov wrote: > On Wed, Apr 08, 2020 at 08:01:44AM -0700, Matthew Wilcox wrote: > > diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h > > index 4aba6c0c2ba8..a8c3fa076f43 100644 > > --- a/include/linux/mm_types.h > > +++ b/include/linux/mm_types.h > > @@ -221,15 +221,8 @@ struct page { > > #endif > > } _struct_page_alignment; > > > > -static inline atomic_t *compound_mapcount_ptr(struct page *page) > > -{ > > - return &page[1].compound_mapcount; > > -} > > - > > -static inline atomic_t *compound_pincount_ptr(struct page *page) > > -{ > > - return &page[2].hpage_pinned_refcount; > > -} > > +#define compound_mapcount_ptr(page) (&(page)[1].compound_mapcount) > > +#define compound_pincount_ptr(page) (&(page)[2].hpage_pinned_refcount) > > Looks like this conversion is not covered by the reason given in the > commit message. Hm? They were supposed to be covered by "That means some inline functions have to become macros so they can return a struct page which is the same const-ness as their argument." They're not quite covered since they need to return an atomic_t that is the same constness as their argument. > > +#define compound_head(page) ({ \ > > + __typeof__(page) _page = page; \ > > + unsigned long head = READ_ONCE(_page->compound_head); \ > > + if (unlikely(head & 1)) \ > > + _page = (void *)(head - 1); \ > > + _page; \ > > +}) > > Ugh.. > > Other option would be to make compound_head() take 'const struct page *' > and return 'void *'. It arguably would provide better type safety, no? We have a few places that do things like mm/filemap.c: if (unlikely(compound_head(page)->mapping != mapping)) {