linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: David Hildenbrand <david@redhat.com>
To: Anshuman Khandual <anshuman.khandual@arm.com>,
	Gerald Schaefer <gerald.schaefer@linux.ibm.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	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: Mon, 30 Jun 2025 16:38:24 +0200	[thread overview]
Message-ID: <1df06854-f5e6-493f-98e6-6426bd37da3c@redhat.com> (raw)
In-Reply-To: <e60539ab-e319-4a7c-a7ee-493df3f7f833@arm.com>

On 30.06.25 06:18, Anshuman Khandual wrote:
> 
> 
> On 25/06/25 10:17 PM, David Hildenbrand wrote:
>>> [...]
>>>>> @@ -1166,6 +1173,7 @@ static void __init init_fixed_pfns(struct pgtable_debug_args *args)
>>>>>      static int __init init_args(struct pgtable_debug_args *args)
>>>>>    {
>>>>> +    unsigned long max_swap_offset;
>>>>>        struct page *page = NULL;
>>>>>        int ret = 0;
>>>>>    @@ -1248,6 +1256,11 @@ static int __init init_args(struct pgtable_debug_args *args)
>>>>>          init_fixed_pfns(args);
>>>>>    +    /* See generic_max_swapfile_size(): probe the maximum offset */
>>>>> +    max_swap_offset = swp_offset(pte_to_swp_entry(swp_entry_to_pte(swp_entry(0, ~0UL))));
>>>> Why not directly use generic_max_swapfile_size() which is doing exact same thing.
>>>>
>>>> unsigned long generic_max_swapfile_size(void)
>>>> {
>>>>      return swp_offset(pte_to_swp_entry(
>>>>              swp_entry_to_pte(swp_entry(0, ~0UL)))) + 1;
>>>> }
>>>
>>> Good question. I just moved this code here from pte_swap_exclusive_tests(),
>>> see above, and did not think about that. Now I also wonder why
>>> generic_max_swapfile_size() wasn't used before.
>>>
>>> But it is not exactly the same thing, there is an extra "+ 1" there.
>>> Maybe that is the reason, but I don't really understand the details /
>>> difference, and therefore would not want to change it.
>>>
>>> David, do you remember why you didn't use generic_max_swapfile_size()
>>> in your pte_swap_exclusive_tests()?
>>
>> Excellent question. If only I would remember :)
>>
>> generic_max_swapfile_size() resides in mm/swapfile.c, which is only around with CONFIG_SWAP.
>>
>> It makes sense to have that function only if there are ... actual swapfiles.
>>
>> These checks here are independent of CONFIG_SWAP (at least in theory -- for migration entries etc we don't need CONFIG_SWAP), and we simply want to construct a swap PTE with all possible bits set.
> 
> After this modification of PMD based swap test - there will be now
> two uses for generic_max_swapfile_size(). Rather than refactoring
> these into a similar helper in mm/debug_vm_pgtable.c - should the
> existing helper just be moved outside of CONFIG_SWAP, thus making
> it available in general ?

As I said, having generic_max_swapfile_size() that returns something != 
0 with !CONFIG_SWAP feels rather odd.

No swap -> no swapfile -> no swapfile max size.

No strong opinion though,, but desperately trying to de-duplicate 2 LOC 
might not be worth the churn at all.

-- 
Cheers,

David / dhildenb



  reply	other threads:[~2025-06-30 14:38 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-23 18:43 [RFC PATCH 0/1] " 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
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 [this message]
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=1df06854-f5e6-493f-98e6-6426bd37da3c@redhat.com \
    --to=david@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=anshuman.khandual@arm.com \
    --cc=gerald.schaefer@linux.ibm.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox