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_SIGNED, DKIM_VALID,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 DE87AC433ED for ; Mon, 19 Apr 2021 09:06:27 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 6B06B60FDA for ; Mon, 19 Apr 2021 09:06:27 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6B06B60FDA 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 D46966B0036; Mon, 19 Apr 2021 05:06:26 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id CF6D66B006E; Mon, 19 Apr 2021 05:06:26 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B982F6B0070; Mon, 19 Apr 2021 05:06:26 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0054.hostedemail.com [216.40.44.54]) by kanga.kvack.org (Postfix) with ESMTP id 99D7E6B0036 for ; Mon, 19 Apr 2021 05:06:26 -0400 (EDT) Received: from smtpin32.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 47C38181AEF32 for ; Mon, 19 Apr 2021 09:06:26 +0000 (UTC) X-FDA: 78048535572.32.F68B241 Received: from mail-lf1-f50.google.com (mail-lf1-f50.google.com [209.85.167.50]) by imf21.hostedemail.com (Postfix) with ESMTP id 731CBE000122 for ; Mon, 19 Apr 2021 09:06:23 +0000 (UTC) Received: by mail-lf1-f50.google.com with SMTP id z13so37743350lfd.9 for ; Mon, 19 Apr 2021 02:06:25 -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=rWuG5NeIc1o/ad5klAkavJ7HFtGU9PaK/EU9Glk/tKw=; b=CgI4H4+aTxyFoTO1NukOChfSc6R8+1c/waFJB6dwuDtbNvu65VayAVjZ7J1ISLnbZj Z2QDgrAaXKqBfnagE7Ja7IscorV16wwRAAruVDNlHt2xZhhA1IbFdppke3Uoo3bejxMI b/l8SfuSCQ0FY/vwzxOL6abk/qjSp3oYT4sZ1ysUg+n+JMnEqYkjwtmJe0CYVq+h2TdF htKBzNcJLdVbfoFjjkVKoI14O9XD7CAEPNBQh/cF9ow97L24m3EvNrstW1VHqtqi/EAi mnZkm3KlhfS+TqXHDsUbiX49ln1Ij7hNUgZzFI/zLFOr4U5AcwWtz1X3qsRYgC4ZHH2f iEGQ== 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=rWuG5NeIc1o/ad5klAkavJ7HFtGU9PaK/EU9Glk/tKw=; b=PjrO9am44hmhPVQWjIa1UFdj4chn4kdgkDQhAWiFFSm1mpWJ5NzBWgKiioru44CHDI iHSlUOwC4tB2vc3P7v503wEKMJ2T1b/UVq0sKDkY9rWPjXxCk3h/tUqkW8GV2pjdXPNs X57iac5kofg6YUPIFEh/7rsTW8BhFy8kywdhtenLaGxEjsrsZrbUmy5iMJ4NPR8FYGm3 yPkro1Z8ynvzMk+FY9YJPUr2A5eRKgIvksIwMhOy48NO0Nwm7mZsH15jsLozTFg0IA23 wD4ekXIAZOC3K/JItsXK7m5yfaPHHEvsahmAfD+R5ulwKBwbhFVhFDxKt5MPMbbhlpPQ vjqw== X-Gm-Message-State: AOAM532w5A03oyLb46PiLU5WTlfLtI05tInsLvKtVlsZjeNSg+WqOrPY PwFMDEZBOAbhVzFb/a2wAPbotQ== X-Google-Smtp-Source: ABdhPJyQ+cekKtiDshFu5qbboMb9ko0+ZqNUwPVYvJjUx458DCCdyMl9xVyFjwKyT1+D6M/uxZ6B0w== X-Received: by 2002:a05:6512:b26:: with SMTP id w38mr11467105lfu.152.1618823184183; Mon, 19 Apr 2021 02:06:24 -0700 (PDT) Received: from box.localdomain ([86.57.175.117]) by smtp.gmail.com with ESMTPSA id k5sm38284ljg.33.2021.04.19.02.06.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Apr 2021 02:06:23 -0700 (PDT) Received: by box.localdomain (Postfix, from userid 1000) id A07E3102567; Mon, 19 Apr 2021 12:06:22 +0300 (+03) Date: Mon, 19 Apr 2021 12:06:22 +0300 From: "Kirill A. Shutemov" To: Matthew Wilcox Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-cachefs@redhat.com, linux-afs@lists.infradead.org, Jeff Layton Subject: Re: [PATCH v7 02/28] mm: Introduce struct folio Message-ID: <20210419090622.bjz7flufdjiaou7k@box.shutemov.name> References: <20210409185105.188284-1-willy@infradead.org> <20210409185105.188284-3-willy@infradead.org> <20210416155516.GM2531743@casper.infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210416155516.GM2531743@casper.infradead.org> X-Rspamd-Queue-Id: 731CBE000122 X-Stat-Signature: 4nrdkooc5n9ez4p8g1wsruf9a7qc4inx X-Rspamd-Server: rspam02 Received-SPF: none (shutemov.name>: No applicable sender policy available) receiver=imf21; identity=mailfrom; envelope-from=""; helo=mail-lf1-f50.google.com; client-ip=209.85.167.50 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1618823183-543718 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 Fri, Apr 16, 2021 at 04:55:16PM +0100, Matthew Wilcox wrote: > On Fri, Apr 09, 2021 at 07:50:39PM +0100, Matthew Wilcox (Oracle) wrote: > > A struct folio is a new abstraction to replace the venerable struct page. > > A function which takes a struct folio argument declares that it will > > operate on the entire (possibly compound) page, not just PAGE_SIZE bytes. > > In return, the caller guarantees that the pointer it is passing does > > not point to a tail page. > > +++ b/include/linux/mm_types.h > [...] > > +static inline struct folio *page_folio(struct page *page) > > +{ > > + unsigned long head = READ_ONCE(page->compound_head); > > + > > + if (unlikely(head & 1)) > > + return (struct folio *)(head - 1); > > + return (struct folio *)page; > > +} > > I'm looking at changing this for the next revision, and basing it on > my recent patch to make compound_head() const-preserving: > > +#define page_folio(page) _Generic((page), \ > + const struct page *: (const struct folio *)_compound_head(page), \ > + struct page *: (struct folio *)_compound_head(page)) > > I've also noticed an awkward pattern occurring that I think this makes > less awkward: > > +/** > + * folio_page - Return a page from a folio. > + * @folio: The folio. > + * @n: The page number to return. > + * > + * @n is relative to the start of the folio. It should be between > + * 0 and folio_nr_pages(@folio) - 1, but this is not checked for. > + */ > +#define folio_page(folio, n) nth_page(&(folio)->page, n) > > That lets me simplify folio_next(): > > +static inline struct folio *folio_next(struct folio *folio) > +{ > + return (struct folio *)folio_page(folio, folio_nr_pages(folio)); > +} > > (it occurs to me this should also be const-preserving, but it's not clear > that's needed yet) Are we risking that we would need to replace inline functions with macros all the way down? Not sure const-preserving worth it. -- Kirill A. Shutemov