From: Chris Li <chrisl@kernel.org>
To: David Hildenbrand <david@redhat.com>
Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org,
linux-arm-kernel@lists.infradead.org,
Andrew Morton <akpm@linux-foundation.org>,
Matthew Wilcox <willy@infradead.org>,
Peter Xu <peterx@redhat.com>,
Catalin Marinas <catalin.marinas@arm.com>,
Will Deacon <will@kernel.org>, Hugh Dickins <hughd@google.com>,
Seth Jennings <sjenning@redhat.com>,
Dan Streetman <ddstreet@ieee.org>,
Vitaly Wool <vitaly.wool@konsulko.com>
Subject: Re: [PATCH mm-unstable v1 2/4] mm/swap: use dedicated entry for swap in folio
Date: Wed, 23 Aug 2023 06:15:08 -0700 [thread overview]
Message-ID: <CAF8kJuP9E0AmWQ3_-ay_rt0NxhCihTDA+hvx+YLnWeuY=kp+uw@mail.gmail.com> (raw)
In-Reply-To: <20230821160849.531668-3-david@redhat.com>
Reviewed-by: Chris Li <chrisl@kernel.org>
Chris
On Mon, Aug 21, 2023 at 9:09 AM David Hildenbrand <david@redhat.com> wrote:
>
> From: Matthew Wilcox <willy@infradead.org>
>
> Let's stop working on the private field and use an explicit swap field.
> We have to move the swp_entry_t typedef.
>
> Signed-off-by: Matthew Wilcox <willy@infradead.org>
> Signed-off-by: David Hildenbrand <david@redhat.com>
> ---
> include/linux/mm_types.h | 23 +++++++++++++----------
> include/linux/swap.h | 5 ++---
> 2 files changed, 15 insertions(+), 13 deletions(-)
>
> diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h
> index 61361f1750c3..438a07854f8c 100644
> --- a/include/linux/mm_types.h
> +++ b/include/linux/mm_types.h
> @@ -259,6 +259,14 @@ static inline struct page *encoded_page_ptr(struct encoded_page *page)
> */
> #define TAIL_MAPPING_REUSED_MAX (2)
>
> +/*
> + * A swap entry has to fit into a "unsigned long", as the entry is hidden
> + * in the "index" field of the swapper address space.
> + */
> +typedef struct {
> + unsigned long val;
> +} swp_entry_t;
> +
> /**
> * struct folio - Represents a contiguous set of bytes.
> * @flags: Identical to the page flags.
> @@ -269,7 +277,7 @@ static inline struct page *encoded_page_ptr(struct encoded_page *page)
> * @index: Offset within the file, in units of pages. For anonymous memory,
> * this is the index from the beginning of the mmap.
> * @private: Filesystem per-folio data (see folio_attach_private()).
> - * Used for swp_entry_t if folio_test_swapcache().
> + * @swap: Used for swp_entry_t if folio_test_swapcache().
> * @_mapcount: Do not access this member directly. Use folio_mapcount() to
> * find out how many times this folio is mapped by userspace.
> * @_refcount: Do not access this member directly. Use folio_ref_count()
> @@ -312,7 +320,10 @@ struct folio {
> };
> struct address_space *mapping;
> pgoff_t index;
> - void *private;
> + union {
> + void *private;
> + swp_entry_t swap;
> + };
> atomic_t _mapcount;
> atomic_t _refcount;
> #ifdef CONFIG_MEMCG
> @@ -1220,14 +1231,6 @@ enum tlb_flush_reason {
> NR_TLB_FLUSH_REASONS,
> };
>
> - /*
> - * A swap entry has to fit into a "unsigned long", as the entry is hidden
> - * in the "index" field of the swapper address space.
> - */
> -typedef struct {
> - unsigned long val;
> -} swp_entry_t;
> -
> /**
> * enum fault_flag - Fault flag definitions.
> * @FAULT_FLAG_WRITE: Fault was a write fault.
> diff --git a/include/linux/swap.h b/include/linux/swap.h
> index 84fe0e94f5cd..82859a1944f5 100644
> --- a/include/linux/swap.h
> +++ b/include/linux/swap.h
> @@ -335,8 +335,7 @@ struct swap_info_struct {
>
> static inline swp_entry_t folio_swap_entry(struct folio *folio)
> {
> - swp_entry_t entry = { .val = page_private(&folio->page) };
> - return entry;
> + return folio->swap;
> }
>
> static inline swp_entry_t page_swap_entry(struct page *page)
> @@ -350,7 +349,7 @@ static inline swp_entry_t page_swap_entry(struct page *page)
>
> static inline void folio_set_swap_entry(struct folio *folio, swp_entry_t entry)
> {
> - folio->private = (void *)entry.val;
> + folio->swap = entry;
> }
>
> /* linux/mm/workingset.c */
> --
> 2.41.0
>
>
next prev parent reply other threads:[~2023-08-23 13:15 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-21 16:08 [PATCH mm-unstable v1 0/4] mm/swap: stop using page->private on tail pages for THP_SWAP + cleanups David Hildenbrand
2023-08-21 16:08 ` [PATCH mm-unstable v1 1/4] mm/swap: stop using page->private on tail pages for THP_SWAP David Hildenbrand
2023-08-22 16:24 ` Catalin Marinas
2023-08-22 17:00 ` Yosry Ahmed
2023-08-22 17:14 ` David Hildenbrand
2023-08-23 12:15 ` David Hildenbrand
2023-08-23 15:12 ` Yosry Ahmed
2023-08-23 15:17 ` David Hildenbrand
2023-08-23 15:21 ` Yosry Ahmed
2023-08-23 15:26 ` David Hildenbrand
2023-08-23 15:31 ` Yosry Ahmed
2023-08-21 16:08 ` [PATCH mm-unstable v1 2/4] mm/swap: use dedicated entry for swap in folio David Hildenbrand
2023-08-23 13:15 ` Chris Li [this message]
2023-08-21 16:08 ` [PATCH mm-unstable v1 3/4] mm/swap: inline folio_set_swap_entry() and folio_swap_entry() David Hildenbrand
2023-08-23 13:15 ` Chris Li
2023-08-21 16:08 ` [PATCH mm-unstable v1 4/4] mm/huge_memory: work on folio->swap instead of page->private when splitting folio David Hildenbrand
2023-08-23 13:16 ` Chris Li
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='CAF8kJuP9E0AmWQ3_-ay_rt0NxhCihTDA+hvx+YLnWeuY=kp+uw@mail.gmail.com' \
--to=chrisl@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=catalin.marinas@arm.com \
--cc=david@redhat.com \
--cc=ddstreet@ieee.org \
--cc=hughd@google.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=peterx@redhat.com \
--cc=sjenning@redhat.com \
--cc=vitaly.wool@konsulko.com \
--cc=will@kernel.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