From: "Kirill A. Shutemov" <kirill@shutemov.name>
To: "Matthew Wilcox (Oracle)" <willy@infradead.org>
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
Date: Tue, 6 Apr 2021 15:29:18 +0300 [thread overview]
Message-ID: <20210406122918.h5dsnbjhmwpfasf4@box.shutemov.name> (raw)
In-Reply-To: <20210331184728.1188084-2-willy@infradead.org>
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
next prev parent reply other threads:[~2021-04-06 12:29 UTC|newest]
Thread overview: 76+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-31 18:47 [PATCH v6 00/27] Memory Folios Matthew Wilcox (Oracle)
2021-03-31 18:47 ` [PATCH v6 01/27] mm: Introduce struct folio Matthew Wilcox (Oracle)
2021-04-06 12:29 ` Kirill A. Shutemov [this message]
2021-04-06 12:48 ` Matthew Wilcox
2021-04-06 14:21 ` Kirill A. Shutemov
2021-04-06 14:31 ` Christoph Hellwig
2021-04-06 14:40 ` Matthew Wilcox
2021-04-06 14:47 ` Christoph Hellwig
2021-04-06 14:55 ` Matthew Wilcox
2021-04-06 15:05 ` Christoph Hellwig
2021-04-06 16:25 ` Matthew Wilcox
2021-04-07 6:09 ` Christoph Hellwig
2021-04-08 9:01 ` Rasmus Villemoes
2021-03-31 18:47 ` [PATCH v6 02/27] mm: Add folio_pgdat and folio_zone Matthew Wilcox (Oracle)
2021-04-06 13:23 ` Christoph Hellwig
2021-03-31 18:47 ` [PATCH v6 03/27] mm/vmstat: Add functions to account folio statistics Matthew Wilcox (Oracle)
2021-04-06 13:25 ` Christoph Hellwig
2021-03-31 18:47 ` [PATCH v6 04/27] mm/debug: Add VM_BUG_ON_FOLIO and VM_WARN_ON_ONCE_FOLIO Matthew Wilcox (Oracle)
2021-04-06 13:26 ` Christoph Hellwig
2021-03-31 18:47 ` [PATCH v6 05/27] mm: Add folio reference count functions Matthew Wilcox (Oracle)
2021-04-06 13:30 ` Christoph Hellwig
2021-03-31 18:47 ` [PATCH v6 06/27] mm: Add put_folio Matthew Wilcox (Oracle)
2021-04-06 13:31 ` Christoph Hellwig
2021-03-31 18:47 ` [PATCH v6 07/27] mm: Add get_folio Matthew Wilcox (Oracle)
2021-04-06 13:32 ` Christoph Hellwig
2021-03-31 18:47 ` [PATCH v6 08/27] mm: Create FolioFlags Matthew Wilcox (Oracle)
2021-04-06 13:34 ` Christoph Hellwig
2021-03-31 18:47 ` [PATCH v6 09/27] mm: Handle per-folio private data Matthew Wilcox (Oracle)
2021-04-06 13:37 ` Christoph Hellwig
2021-03-31 18:47 ` [PATCH v6 10/27] mm/filemap: Add folio_index, folio_file_page and folio_contains Matthew Wilcox (Oracle)
2021-04-06 13:39 ` Christoph Hellwig
2021-03-31 18:47 ` [PATCH v6 11/27] mm/filemap: Add folio_next_index Matthew Wilcox (Oracle)
2021-04-06 13:40 ` Christoph Hellwig
2021-03-31 18:47 ` [PATCH v6 12/27] mm/filemap: Add folio_offset and folio_file_offset Matthew Wilcox (Oracle)
2021-04-06 13:42 ` Christoph Hellwig
2021-03-31 18:47 ` [PATCH v6 13/27] mm/util: Add folio_mapping and folio_file_mapping Matthew Wilcox (Oracle)
2021-04-06 13:45 ` Christoph Hellwig
2021-03-31 18:47 ` [PATCH v6 14/27] mm: Add folio_mapcount Matthew Wilcox (Oracle)
2021-04-06 13:46 ` Christoph Hellwig
2021-03-31 18:47 ` [PATCH v6 15/27] mm/memcg: Add folio wrappers for various functions Matthew Wilcox (Oracle)
2021-04-06 13:48 ` Christoph Hellwig
2021-03-31 18:47 ` [PATCH v6 16/27] mm/filemap: Add unlock_folio Matthew Wilcox (Oracle)
2021-04-06 13:51 ` Christoph Hellwig
2021-03-31 18:47 ` [PATCH v6 17/27] mm/filemap: Add lock_folio Matthew Wilcox (Oracle)
2021-04-06 13:52 ` Christoph Hellwig
2021-03-31 18:47 ` [PATCH v6 18/27] mm/filemap: Add lock_folio_killable Matthew Wilcox (Oracle)
2021-04-06 13:53 ` Christoph Hellwig
2021-03-31 18:47 ` [PATCH v6 19/27] mm/filemap: Add __lock_folio_async Matthew Wilcox (Oracle)
2021-04-06 13:55 ` Christoph Hellwig
2021-03-31 18:47 ` [PATCH v6 20/27] mm/filemap: Add __lock_folio_or_retry Matthew Wilcox (Oracle)
2021-04-06 13:57 ` Christoph Hellwig
2021-03-31 18:47 ` [PATCH v6 21/27] mm/filemap: Add wait_on_folio_locked Matthew Wilcox (Oracle)
2021-04-06 14:11 ` Christoph Hellwig
2021-03-31 18:47 ` [PATCH v6 22/27] mm/filemap: Add end_folio_writeback Matthew Wilcox (Oracle)
2021-04-06 14:13 ` Christoph Hellwig
2021-03-31 18:47 ` [PATCH v6 23/27] mm/writeback: Add wait_on_folio_writeback Matthew Wilcox (Oracle)
2021-04-06 14:15 ` Christoph Hellwig
2021-03-31 18:47 ` [PATCH v6 24/27] mm/writeback: Add wait_for_stable_folio Matthew Wilcox (Oracle)
2021-04-06 14:18 ` Christoph Hellwig
2021-03-31 18:47 ` [PATCH v6 25/27] mm/filemap: Convert wait_on_page_bit to wait_on_folio_bit Matthew Wilcox (Oracle)
2021-04-06 14:19 ` Christoph Hellwig
2021-03-31 18:47 ` [PATCH v6 26/27] mm/filemap: Convert wake_up_page_bit to wake_up_folio_bit Matthew Wilcox (Oracle)
2021-04-06 14:23 ` Christoph Hellwig
2021-03-31 18:47 ` [PATCH v6 27/27] mm/filemap: Convert page wait queues to be folios Matthew Wilcox (Oracle)
2021-04-06 14:25 ` Christoph Hellwig
2021-04-01 7:05 ` [PATCH v6 00/27] Memory Folios Christoph Hellwig
2021-04-01 11:26 ` Matthew Wilcox
2021-04-01 12:28 ` Jason Gunthorpe
2021-04-01 12:52 ` Matthew Wilcox
2021-04-01 13:30 ` Jason Gunthorpe
2021-04-02 14:37 ` Christoph Hellwig
2021-04-02 14:49 ` Matthew Wilcox
2021-04-03 0:31 ` Kent Overstreet
2021-04-05 19:14 ` Jeff Layton
2021-04-05 19:31 ` Matthew Wilcox
2021-04-06 15:14 ` Jeff Layton
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210406122918.h5dsnbjhmwpfasf4@box.shutemov.name \
--to=kirill@shutemov.name \
--cc=linux-afs@lists.infradead.org \
--cc=linux-cachefs@redhat.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=willy@infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).