All of lore.kernel.org
 help / color / mirror / Atom feed
From: Gerald Schaefer <gerald.schaefer@linux.ibm.com>
To: David Hildenbrand <david@redhat.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	Anshuman Khandual <anshuman.khandual@arm.com>,
	Matthew Wilcox <willy@infradead.org>,
	LKML <linux-kernel@vger.kernel.org>,
	linux-mm <linux-mm@kvack.org>,
	linux-s390@vger.kernel.org
Subject: Re: [RFC PATCH 1/1] mm/debug_vm_pgtable: Use a swp_entry_t input value for swap tests
Date: Tue, 24 Jun 2025 12:40:42 +0200	[thread overview]
Message-ID: <20250624124042.45beda75@thinkpad-T15> (raw)
In-Reply-To: <9bd91df8-e548-4ecc-bd30-f1ab611ecf4c@redhat.com>

On Mon, 23 Jun 2025 21:10:54 +0200
David Hildenbrand <david@redhat.com> wrote:

> On 23.06.25 20:43, Gerald Schaefer wrote:
> > The various __pte/pmd_to_swp_entry and __swp_entry_to_pte/pmd helper
> > functions are expected to operate on swapped PTE/PMD entries, not on
> > present and mapped entries.
> > 
> > Reflect this in the swap tests by using a swp_entry_t as input value,
> > similar to how it is already done in pte_swap_exclusive_tests().
> > Move the swap entry creation to init_args() and store it in args, so
> > it can also be used in other functions.
> > 
> > The pte/pmd_swap_tests() are also changed to compare entries instead of
> > pfn values, because pte/pmd_pfn() helpers are not expected to operate on
> > swapped entries. E.g. on s390, pmd_pfn() needs different shifts for leaf
> > (large) and non-leaf PMDs.
> > 
> > Also update documentation, to reflect that the helpers operate on
> > swapped and not mapped entries, and use correct names, i.e.
> > __swp_to_pte/pmd_entry -> __swp_entry_to_pte/pmd.
> > 
> > For consistency, also change pte/pmd_swap_soft_dirty_tests() to use
> > args->swp_entry instead of a present and mapped PTE/PMD.
> > 
> > Signed-off-by: Gerald Schaefer <gerald.schaefer@linux.ibm.com>
> > ---
> >   Documentation/mm/arch_pgtable_helpers.rst |  8 ++--
> >   mm/debug_vm_pgtable.c                     | 55 ++++++++++++++---------
> >   2 files changed, 38 insertions(+), 25 deletions(-)
> > 
> > diff --git a/Documentation/mm/arch_pgtable_helpers.rst b/Documentation/mm/arch_pgtable_helpers.rst
> > index af245161d8e7..e2ac76202a85 100644
> > --- a/Documentation/mm/arch_pgtable_helpers.rst
> > +++ b/Documentation/mm/arch_pgtable_helpers.rst
> > @@ -242,13 +242,13 @@ SWAP Page Table Helpers
> >   ========================
> >   
> >   +---------------------------+--------------------------------------------------+
> > -| __pte_to_swp_entry        | Creates a swapped entry (arch) from a mapped PTE |
> > +| __pte_to_swp_entry        | Creates a swap entry (arch) from a swapped PTE   |  
> 
> Maybe something like:
> 
> "from a swap (!none && !present) PTE"
> 
> or short
> 
> "swap PTE".
> 
> "swapped" might be misleading.
> 
> Same for the other cases below.

Right, it already felt awkward when I wrote it, not sure why I only changed
it for "swapped entry (arch)". I think I like "swap PTE/PMD", naming the actual
entries in the page table, vs. "swap entry (arch)", naming the (arch-dependent)
representation of the swap PTE/PMD as swp_entry_t.

Will change, and also adjust my description, where I also used possibly
misleading "swapped".

> 
> >   +---------------------------+--------------------------------------------------+
> > -| __swp_to_pte_entry        | Creates a mapped PTE from a swapped entry (arch) |
> > +| __swp_entry_to_pte        | Creates a swapped PTE from a swap entry (arch)   |
> >   +---------------------------+--------------------------------------------------+
> > -| __pmd_to_swp_entry        | Creates a swapped entry (arch) from a mapped PMD |
> > +| __pmd_to_swp_entry        | Creates a swap entry (arch) from a swapped PMD   |
> >   +---------------------------+--------------------------------------------------+
> > -| __swp_to_pmd_entry        | Creates a mapped PMD from a swapped entry (arch) |
> > +| __swp_entry_to_pmd        | Creates a swapped PMD from a swap entry (arch)   |
> >   +---------------------------+--------------------------------------------------+
> >   | is_migration_entry        | Tests a migration (read or write) swapped entry  |
> >   +-------------------------------+----------------------------------------------+
> > diff --git a/mm/debug_vm_pgtable.c b/mm/debug_vm_pgtable.c
> > index 7731b238b534..3b0f83ed6c2e 100644
> > --- a/mm/debug_vm_pgtable.c
> > +++ b/mm/debug_vm_pgtable.c
> > @@ -73,6 +73,8 @@ struct pgtable_debug_args {
> >   	unsigned long		fixed_pud_pfn;
> >   	unsigned long		fixed_pmd_pfn;
> >   	unsigned long		fixed_pte_pfn;
> > +
> > +	swp_entry_t		swp_entry;
> >   };
> >     
> 
> Nothing else jumped at me, so LGTM.
> 

Thanks!

  reply	other threads:[~2025-06-24 10:40 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-23 18:43 [RFC PATCH 0/1] mm/debug_vm_pgtable: Use a swp_entry_t input value for swap tests Gerald Schaefer
2025-06-23 18:43 ` [RFC PATCH 1/1] " Gerald Schaefer
2025-06-23 19:10   ` David Hildenbrand
2025-06-24 10:40     ` Gerald Schaefer [this message]
2025-06-25  4:28   ` Anshuman Khandual
2025-06-25 16:28     ` Gerald Schaefer
2025-06-25 16:47       ` David Hildenbrand
2025-06-30  4:18         ` Anshuman Khandual
2025-06-30 14:38           ` David Hildenbrand
2025-06-23 19:06 ` [RFC PATCH 0/1] " David Hildenbrand
2025-06-24  7:50 ` Anshuman Khandual
2025-06-24 10:35   ` Gerald Schaefer

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=20250624124042.45beda75@thinkpad-T15 \
    --to=gerald.schaefer@linux.ibm.com \
    --cc=akpm@linux-foundation.org \
    --cc=anshuman.khandual@arm.com \
    --cc=david@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=linux-s390@vger.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.