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.7 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED 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 E4EBFC2BA2B for ; Thu, 9 Apr 2020 14:28:55 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 9B752214D8 for ; Thu, 9 Apr 2020 14:28:55 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=shutemov-name.20150623.gappssmtp.com header.i=@shutemov-name.20150623.gappssmtp.com header.b="H9g9Aau2" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9B752214D8 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=shutemov.name Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 47A968E000D; Thu, 9 Apr 2020 10:28:55 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 42B018E0006; Thu, 9 Apr 2020 10:28:55 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2CB488E000D; Thu, 9 Apr 2020 10:28:55 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0224.hostedemail.com [216.40.44.224]) by kanga.kvack.org (Postfix) with ESMTP id 1D0D98E0006 for ; Thu, 9 Apr 2020 10:28:55 -0400 (EDT) Received: from smtpin21.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id E3E852472 for ; Thu, 9 Apr 2020 14:28:54 +0000 (UTC) X-FDA: 76688548188.21.rub53_4dccb085d3c0d X-HE-Tag: rub53_4dccb085d3c0d X-Filterd-Recvd-Size: 5239 Received: from mail-lf1-f68.google.com (mail-lf1-f68.google.com [209.85.167.68]) by imf18.hostedemail.com (Postfix) with ESMTP for ; Thu, 9 Apr 2020 14:28:54 +0000 (UTC) Received: by mail-lf1-f68.google.com with SMTP id z23so8060065lfh.8 for ; Thu, 09 Apr 2020 07:28:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=shutemov-name.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=nMzhxikHb9DG9j+GI/D6htiRBa0uqQcQssc83MVDHc8=; b=H9g9Aau233QULZxfRPxbl+fX2ukzeuMgkfT/ts+GMSckDAStx0R9FwihUGtBfUe6Xc FNjqxmlZBrwX98/v9Qlym4gIUuUYWdN3R2YydEGBxyB5tU7s/ediF6NSr5AzxbHcOCys cfJQ9wqZE6SsboN/kx4ld6+7MivUcyHXqYAz2wTA6JL20OYYfRtbw58RfzjxP63wI0nf iSX8rd3NU79xcAhqGnFU9CpB+uXi57+zkG7W6xGzAtZHL09nLnQDKptGoKiNo+wJf+tM GmcxaDGt0zYz82p0eZw7MEfPSuNYiAibOFPj1TDw/qAW0zn2I+Ond7KvfbvnvLvMsd1v KIzw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=nMzhxikHb9DG9j+GI/D6htiRBa0uqQcQssc83MVDHc8=; b=WU6LL8lQQBy/0rQwl1A8/D+rvdDtHkvA7Q+8KibukEsRDAWpBK2eNSUqLY0uN3JV6Y x1qEytirAZdd3CiddC0Zff7y85HjFv+X+AqSDvALqOmnquSJi5ddRQIqgojdLPcmexfi r0YqW28QYb49sZJG5aHN1bEDMm9kKnVAdK1VJMmfErwVvFsoT8MCrGGQDmKGbEk77+ZR fQkgNyP+8eZ3kqlv3Ko0K84W2GhX8VabbDiiPLCmvzt0YJQ3BnhKVHpk+YzRbBBQIo+y Yd0bRcO5bAOtWc58pUDYXAUigKzsETdoC7LfK+5XEjqhFqufKPp30sxJcObmUb5g5DdR iYjg== X-Gm-Message-State: AGi0Puavp6kzBcmgRIANiWTVJnKK8V2UWlEWC+/4pqqKBLfehG45+vdX ZDNyPEdwh139eV8gXdd27JQD8Q== X-Google-Smtp-Source: APiQypKPkVNpYYNdwvukj1qh6iMLDszvuMCjTVKg+zUxdiFp6cxebldhZvfXREa7uBhjhWxV9DoEAg== X-Received: by 2002:a05:6512:3189:: with SMTP id i9mr7884540lfe.178.1586442533147; Thu, 09 Apr 2020 07:28:53 -0700 (PDT) Received: from box.localdomain ([86.57.175.117]) by smtp.gmail.com with ESMTPSA id y16sm15006979ljc.78.2020.04.09.07.28.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Apr 2020 07:28:52 -0700 (PDT) Received: by box.localdomain (Postfix, from userid 1000) id BAF6F102132; Thu, 9 Apr 2020 17:28:51 +0300 (+03) Date: Thu, 9 Apr 2020 17:28:51 +0300 From: "Kirill A. Shutemov" To: Matthew Wilcox 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: <20200409142851.obndv6u7wpo2zovj@box> References: <20200408150148.25290-1-willy@infradead.org> <20200408150148.25290-2-willy@infradead.org> <20200409140914.u3mff4xrk5u4tvht@box> <20200409141550.GU21484@bombadil.infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200409141550.GU21484@bombadil.infradead.org> 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 07:15:50AM -0700, Matthew Wilcox wrote: > 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. Ah, right. > > > +#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)) { Good point. Acked-by: Kirill A. Shutemov -- Kirill A. Shutemov