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=-8.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=ham 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 48A6BC433B4 for ; Tue, 6 Apr 2021 12:29:20 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id CE8E56135D for ; Tue, 6 Apr 2021 12:29:19 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CE8E56135D 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 515166B007E; Tue, 6 Apr 2021 08:29:19 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 4EB586B0081; Tue, 6 Apr 2021 08:29:19 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3B4B76B0082; Tue, 6 Apr 2021 08:29:19 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0231.hostedemail.com [216.40.44.231]) by kanga.kvack.org (Postfix) with ESMTP id 210896B007E for ; Tue, 6 Apr 2021 08:29:19 -0400 (EDT) Received: from smtpin20.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id DE2734DD0 for ; Tue, 6 Apr 2021 12:29:18 +0000 (UTC) X-FDA: 78001872396.20.8D60BE2 Received: from mail-lf1-f44.google.com (mail-lf1-f44.google.com [209.85.167.44]) by imf10.hostedemail.com (Postfix) with ESMTP id B691440002C8 for ; Tue, 6 Apr 2021 12:29:15 +0000 (UTC) Received: by mail-lf1-f44.google.com with SMTP id r8so4901103lfp.10 for ; Tue, 06 Apr 2021 05:29:18 -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=57Sd0MjVPJwj9C8CqpwruZwhDWQJmwCtp4DcDbeYrF8=; b=NEO1be9H9hw5hBSR23y/A5JCAtyboH9xWrlmgMhhWVhufIwYwiOazGbF2dO0NdwO9a J9S3ZAMimrz0dT4/afoTSNsL7yhFFLAM/5RAfwzar2YtiFBrCX0IJQ4eYdF83RQPXqCJ Y53J2sO3U9UPgBFY0gMoQy+CHfUdcIsf2Jto3OK3LXjGF4Yhjc14nC1ZTjpBA1Tr1wZG DAoX9coVVL/3vi/e50Z3kAcixfdS3Wkh8OcAGfiy9c0ZlsrqxEyfEg/GWfkNjLpWvvVE YqfewjWc0nwhmCKNStGOfPLlDg8uax4MQC9GhdDy5R2VEZf1LsoFYjw0GaK+YJBxl1sP E9Ew== 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=57Sd0MjVPJwj9C8CqpwruZwhDWQJmwCtp4DcDbeYrF8=; b=FFJlw3TmGnRy0JE51E1XgNsq1Ohw3UH35tnv8O3QGI0m7kO1vxKuEX+I5CP+CuA/Wy XMkNrMVpV+ltbfePtviX6wv4n427gTQXnQejDfuWVXyAvo3PmTIgRqxx4fFpy0+Z4DfX rmhskmdBzTIz5iF1FGhLoSAPk6tajQVSI9Vc3u2XmvxMVuw8YdFP5lp1OPf3Fj8DPmH1 K+DBBymxrHjfc6d2IahRXxeHLG0GB9ayM9eS5b0Moa/aX2Q5evrBLbmLvuKK7UBPm84W ByL4M1hXYYuQXzRQkkFe5CzxxLOJXEqIbumgQRL1CV+CgVlmBa6IUkJbNYM16yMK8DI8 Lirw== X-Gm-Message-State: AOAM5334FGjj9oHYQc0j8fwboS0J2u5prqfnOjxgzdLlWpKNeiXFj4rW wHAgJjHd9RqbNvOtil/ngTDexg== X-Google-Smtp-Source: ABdhPJwN+7HNNe6vl5shpanay18CZEn+2wHwc1TZiipOq36OoeeDMJquiT51ffeyPvbSUxAjHkldig== X-Received: by 2002:a19:ee0d:: with SMTP id g13mr21536160lfb.38.1617712156785; Tue, 06 Apr 2021 05:29:16 -0700 (PDT) Received: from box.localdomain ([86.57.175.117]) by smtp.gmail.com with ESMTPSA id q7sm2197962lfc.260.2021.04.06.05.29.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Apr 2021 05:29:16 -0700 (PDT) Received: by box.localdomain (Postfix, from userid 1000) id 9E879101FF7; Tue, 6 Apr 2021 15:29:18 +0300 (+03) Date: Tue, 6 Apr 2021 15:29:18 +0300 From: "Kirill A. Shutemov" To: "Matthew Wilcox (Oracle)" Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-cachefs@redhat.com, linux-afs@lists.infradead.org Subject: Re: [PATCH v6 01/27] mm: Introduce struct folio Message-ID: <20210406122918.h5dsnbjhmwpfasf4@box.shutemov.name> References: <20210331184728.1188084-1-willy@infradead.org> <20210331184728.1188084-2-willy@infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210331184728.1188084-2-willy@infradead.org> X-Stat-Signature: 8xwtqo3d6zju8ts1bde1ze9casabr7bn X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: B691440002C8 Received-SPF: none (shutemov.name>: No applicable sender policy available) receiver=imf10; identity=mailfrom; envelope-from=""; helo=mail-lf1-f44.google.com; client-ip=209.85.167.44 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1617712155-207943 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 Wed, Mar 31, 2021 at 07:47:02PM +0100, Matthew Wilcox (Oracle) wrote: > +/** > + * folio_next - Move to the next physical folio. > + * @folio: The folio we're currently operating on. > + * > + * If you have physically contiguous memory which may span more than > + * one folio (eg a &struct bio_vec), use this function to move from one > + * folio to the next. Do not use it if the memory is only virtually > + * contiguous as the folios are almost certainly not adjacent to each > + * other. This is the folio equivalent to writing ``page++``. > + * > + * Context: We assume that the folios are refcounted and/or locked at a > + * higher level and do not adjust the reference counts. > + * Return: The next struct folio. > + */ > +static inline struct folio *folio_next(struct folio *folio) > +{ > +#if defined(CONFIG_SPARSEMEM) && !defined(CONFIG_SPARSEMEM_VMEMMAP) > + return (struct folio *)nth_page(&folio->page, folio_nr_pages(folio)); > +#else > + return folio + folio_nr_pages(folio); > +#endif Do we really need the #if here? >From quick look at nth_page() and memory_model.h, compiler should be able to simplify calculation for FLATMEM or SPARSEMEM_VMEMMAP to what you do in the #else. No? > @@ -224,6 +224,71 @@ struct page { > #endif > } _struct_page_alignment; > > +/** > + * struct folio - Represents a contiguous set of bytes. > + * @flags: Identical to the page flags. > + * @lru: Least Recently Used list; tracks how recently this folio was used. > + * @mapping: The file this page belongs to, or refers to the anon_vma for > + * anonymous pages. > + * @index: Offset within the file, in units of pages. For anonymous pages, > + * this is the index from the beginning of the mmap. > + * @private: Filesystem per-folio data (see attach_folio_private()). > + * Used for swp_entry_t if FolioSwapCache(). > + * @_mapcount: How many times this folio is mapped to userspace. Use > + * folio_mapcount() to access it. > + * @_refcount: Number of references to this folio. Use folio_ref_count() > + * to read it. > + * @memcg_data: Memory Control Group data. > + * > + * A folio is a physically, virtually and logically contiguous set > + * of bytes. It is a power-of-two in size, and it is aligned to that > + * same power-of-two. It is at least as large as %PAGE_SIZE. If it is > + * in the page cache, it is at a file offset which is a multiple of that > + * power-of-two. > + */ > +struct folio { > + /* private: don't document the anon union */ > + union { > + struct { > + /* public: */ > + unsigned long flags; > + struct list_head lru; > + struct address_space *mapping; > + pgoff_t index; > + unsigned long private; > + atomic_t _mapcount; > + atomic_t _refcount; > +#ifdef CONFIG_MEMCG > + unsigned long memcg_data; > +#endif As Christoph, I'm not a fan of this :/ > + /* private: the union with struct page is transitional */ > + }; > + struct page page; > + }; > +}; -- Kirill A. Shutemov