All of lore.kernel.org
 help / color / mirror / Atom feed
From: Yosry Ahmed <yosryahmed@google.com>
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 1/4] mm/swap: stop using page->private on tail pages for THP_SWAP
Date: Wed, 23 Aug 2023 08:21:01 -0700	[thread overview]
Message-ID: <CAJD7tkbjPdk8xSGJG_BGaiNyPdh0-A58vwt7TwjsB4Mjh6RscA@mail.gmail.com> (raw)
In-Reply-To: <b00e2d3a-8601-924c-241c-4373b9dea0cb@redhat.com>

On Wed, Aug 23, 2023 at 8:17 AM David Hildenbrand <david@redhat.com> wrote:
>
> On 23.08.23 17:12, Yosry Ahmed wrote:
> > On Mon, Aug 21, 2023 at 9:09 AM David Hildenbrand <david@redhat.com> wrote:
> >>
> >> Let's stop using page->private on tail pages, making it possible to
> >> just unconditionally reuse that field in the tail pages of large folios.
> >>
> >> The remaining usage of the private field for THP_SWAP is in the THP
> >> splitting code (mm/huge_memory.c), that we'll handle separately later.
> >>
> >> Update the THP_SWAP documentation and sanity checks in mm_types.h and
> >> __split_huge_page_tail().
> >>
> >> Signed-off-by: David Hildenbrand <david@redhat.com>
> >
> > The mm part looks good to me (with the added fixup):
> >
> > Reviewed-by: Yosry Ahmed <yosryahmed@google.com>
>
> Thanks!
>
> >>   /**
> >> diff --git a/include/linux/swap.h b/include/linux/swap.h
> >> index bb5adc604144..84fe0e94f5cd 100644
> >> --- a/include/linux/swap.h
> >> +++ b/include/linux/swap.h
> >> @@ -339,6 +339,15 @@ static inline swp_entry_t folio_swap_entry(struct folio *folio)
> >>          return entry;
> >>   }
> >>
> >> +static inline swp_entry_t page_swap_entry(struct page *page)
> >> +{
> >> +       struct folio *folio = page_folio(page);
> >> +       swp_entry_t entry = folio_swap_entry(folio);
> >> +
> >> +       entry.val += page - &folio->page;
> >> +       return entry;
> >> +}
> >> +
> >>   static inline void folio_set_swap_entry(struct folio *folio, swp_entry_t entry)
> >>   {
> >>          folio->private = (void *)entry.val;
> >> diff --git a/mm/huge_memory.c b/mm/huge_memory.c
> >> index cc2f65f8cc62..c04702ae71d2 100644
> >> --- a/mm/huge_memory.c
> >> +++ b/mm/huge_memory.c
> >> @@ -2446,18 +2446,15 @@ static void __split_huge_page_tail(struct page *head, int tail,
> >>          page_tail->index = head->index + tail;
> >>
> >>          /*
> >> -        * page->private should not be set in tail pages with the exception
> >> -        * of swap cache pages that store the swp_entry_t in tail pages.
> >> -        * Fix up and warn once if private is unexpectedly set.
> >> -        *
> >> -        * What of 32-bit systems, on which folio->_pincount overlays
> >> -        * head[1].private?  No problem: THP_SWAP is not enabled on 32-bit, and
> >> -        * pincount must be 0 for folio_ref_freeze() to have succeeded.
> >> +        * page->private should not be set in tail pages. Fix up and warn once
> >> +        * if private is unexpectedly set.
> >>           */
> >> -       if (!folio_test_swapcache(page_folio(head))) {
> >> -               VM_WARN_ON_ONCE_PAGE(page_tail->private != 0, page_tail);
> >> +       if (unlikely(page_tail->private)) {
> >> +               VM_WARN_ON_ONCE_PAGE(true, page_tail);
> >>                  page_tail->private = 0;
> >>          }
> >
> > Could probably save a couple of lines here:
> >
> > if (VM_WARN_ON_ONCE_PAGE(page_tail->private != 0, page_tail))
> >
> >         page_tail->private = 0;
> >
>
> That would mean that we eventually compile out the runtime check
>
> #define VM_WARN_ON_ONCE_PAGE(cond, page)  BUILD_BUG_ON_INVALID(cond)

I thought the warning would be compiled out but not the check, my bad.

>
> --
> Cheers,
>
> David / dhildenb
>

WARNING: multiple messages have this Message-ID (diff)
From: Yosry Ahmed <yosryahmed@google.com>
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 1/4] mm/swap: stop using page->private on tail pages for THP_SWAP
Date: Wed, 23 Aug 2023 08:21:01 -0700	[thread overview]
Message-ID: <CAJD7tkbjPdk8xSGJG_BGaiNyPdh0-A58vwt7TwjsB4Mjh6RscA@mail.gmail.com> (raw)
In-Reply-To: <b00e2d3a-8601-924c-241c-4373b9dea0cb@redhat.com>

On Wed, Aug 23, 2023 at 8:17 AM David Hildenbrand <david@redhat.com> wrote:
>
> On 23.08.23 17:12, Yosry Ahmed wrote:
> > On Mon, Aug 21, 2023 at 9:09 AM David Hildenbrand <david@redhat.com> wrote:
> >>
> >> Let's stop using page->private on tail pages, making it possible to
> >> just unconditionally reuse that field in the tail pages of large folios.
> >>
> >> The remaining usage of the private field for THP_SWAP is in the THP
> >> splitting code (mm/huge_memory.c), that we'll handle separately later.
> >>
> >> Update the THP_SWAP documentation and sanity checks in mm_types.h and
> >> __split_huge_page_tail().
> >>
> >> Signed-off-by: David Hildenbrand <david@redhat.com>
> >
> > The mm part looks good to me (with the added fixup):
> >
> > Reviewed-by: Yosry Ahmed <yosryahmed@google.com>
>
> Thanks!
>
> >>   /**
> >> diff --git a/include/linux/swap.h b/include/linux/swap.h
> >> index bb5adc604144..84fe0e94f5cd 100644
> >> --- a/include/linux/swap.h
> >> +++ b/include/linux/swap.h
> >> @@ -339,6 +339,15 @@ static inline swp_entry_t folio_swap_entry(struct folio *folio)
> >>          return entry;
> >>   }
> >>
> >> +static inline swp_entry_t page_swap_entry(struct page *page)
> >> +{
> >> +       struct folio *folio = page_folio(page);
> >> +       swp_entry_t entry = folio_swap_entry(folio);
> >> +
> >> +       entry.val += page - &folio->page;
> >> +       return entry;
> >> +}
> >> +
> >>   static inline void folio_set_swap_entry(struct folio *folio, swp_entry_t entry)
> >>   {
> >>          folio->private = (void *)entry.val;
> >> diff --git a/mm/huge_memory.c b/mm/huge_memory.c
> >> index cc2f65f8cc62..c04702ae71d2 100644
> >> --- a/mm/huge_memory.c
> >> +++ b/mm/huge_memory.c
> >> @@ -2446,18 +2446,15 @@ static void __split_huge_page_tail(struct page *head, int tail,
> >>          page_tail->index = head->index + tail;
> >>
> >>          /*
> >> -        * page->private should not be set in tail pages with the exception
> >> -        * of swap cache pages that store the swp_entry_t in tail pages.
> >> -        * Fix up and warn once if private is unexpectedly set.
> >> -        *
> >> -        * What of 32-bit systems, on which folio->_pincount overlays
> >> -        * head[1].private?  No problem: THP_SWAP is not enabled on 32-bit, and
> >> -        * pincount must be 0 for folio_ref_freeze() to have succeeded.
> >> +        * page->private should not be set in tail pages. Fix up and warn once
> >> +        * if private is unexpectedly set.
> >>           */
> >> -       if (!folio_test_swapcache(page_folio(head))) {
> >> -               VM_WARN_ON_ONCE_PAGE(page_tail->private != 0, page_tail);
> >> +       if (unlikely(page_tail->private)) {
> >> +               VM_WARN_ON_ONCE_PAGE(true, page_tail);
> >>                  page_tail->private = 0;
> >>          }
> >
> > Could probably save a couple of lines here:
> >
> > if (VM_WARN_ON_ONCE_PAGE(page_tail->private != 0, page_tail))
> >
> >         page_tail->private = 0;
> >
>
> That would mean that we eventually compile out the runtime check
>
> #define VM_WARN_ON_ONCE_PAGE(cond, page)  BUILD_BUG_ON_INVALID(cond)

I thought the warning would be compiled out but not the check, my bad.

>
> --
> Cheers,
>
> David / dhildenb
>

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  reply	other threads:[~2023-08-23 15:22 UTC|newest]

Thread overview: 34+ 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 ` 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-21 16:08   ` David Hildenbrand
2023-08-22 16:24   ` Catalin Marinas
2023-08-22 16:24     ` Catalin Marinas
2023-08-22 17:00   ` Yosry Ahmed
2023-08-22 17:00     ` Yosry Ahmed
2023-08-22 17:14     ` David Hildenbrand
2023-08-22 17:14       ` David Hildenbrand
2023-08-23 12:15   ` David Hildenbrand
2023-08-23 12:15     ` David Hildenbrand
2023-08-23 15:12   ` Yosry Ahmed
2023-08-23 15:12     ` Yosry Ahmed
2023-08-23 15:17     ` David Hildenbrand
2023-08-23 15:17       ` David Hildenbrand
2023-08-23 15:21       ` Yosry Ahmed [this message]
2023-08-23 15:21         ` Yosry Ahmed
2023-08-23 15:26         ` David Hildenbrand
2023-08-23 15:26           ` David Hildenbrand
2023-08-23 15:31           ` Yosry Ahmed
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-21 16:08   ` David Hildenbrand
2023-08-23 13:15   ` Chris Li
2023-08-23 13:15     ` Chris Li
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-21 16:08   ` David Hildenbrand
2023-08-23 13:15   ` Chris Li
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-21 16:08   ` David Hildenbrand
2023-08-23 13:16   ` Chris Li
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=CAJD7tkbjPdk8xSGJG_BGaiNyPdh0-A58vwt7TwjsB4Mjh6RscA@mail.gmail.com \
    --to=yosryahmed@google.com \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.