lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Wed, 23 Aug 2023 06:15:08 -0700
From:   Chris Li <chrisl@...nel.org>
To:     David Hildenbrand <david@...hat.com>
Cc:     linux-kernel@...r.kernel.org, linux-mm@...ck.org,
        linux-arm-kernel@...ts.infradead.org,
        Andrew Morton <akpm@...ux-foundation.org>,
        Matthew Wilcox <willy@...radead.org>,
        Peter Xu <peterx@...hat.com>,
        Catalin Marinas <catalin.marinas@....com>,
        Will Deacon <will@...nel.org>, Hugh Dickins <hughd@...gle.com>,
        Seth Jennings <sjenning@...hat.com>,
        Dan Streetman <ddstreet@...e.org>,
        Vitaly Wool <vitaly.wool@...sulko.com>
Subject: Re: [PATCH mm-unstable v1 2/4] mm/swap: use dedicated entry for swap
 in folio

Reviewed-by: Chris Li <chrisl@...nel.org>

Chris

On Mon, Aug 21, 2023 at 9:09 AM David Hildenbrand <david@...hat.com> wrote:
>
> From: Matthew Wilcox <willy@...radead.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@...radead.org>
> Signed-off-by: David Hildenbrand <david@...hat.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
>
>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ