From: David Hildenbrand <david@redhat.com>
To: Wei Yang <richard.weiyang@gmail.com>,
akpm@linux-foundation.org, lorenzo.stoakes@oracle.com,
ziy@nvidia.com, baolin.wang@linux.alibaba.com,
Liam.Howlett@oracle.com, npache@redhat.com, ryan.roberts@arm.com,
dev.jain@arm.com, baohua@kernel.org, lance.yang@linux.dev,
xu.xin16@zte.com.cn, chengming.zhou@linux.dev
Cc: linux-mm@kvack.org, Kiryl Shutsemau <kirill@shutemov.name>,
SeongJae Park <sj@kernel.org>
Subject: Re: [Patch v3 2/2] mm/khugepaged: remove definition of struct khugepaged_mm_slot
Date: Wed, 24 Sep 2025 11:39:44 +0200 [thread overview]
Message-ID: <1d593bac-0d9a-4cc5-8002-932e4ba88edd@redhat.com> (raw)
In-Reply-To: <20250924004854.29889-3-richard.weiyang@gmail.com>
On 24.09.25 02:48, Wei Yang wrote:
> Current code is not correct to get struct khugepaged_mm_slot by
> mm_slot_entry() without checking mm_slot is !NULL.
"Current code calls mm_slot_entry() even when we don't have a valid
slot, which is not future proof."
There is no problem
> reported since slot is the first element of struct khugepaged_mm_slot.
"Currently, this is not a problem because "slot" is the first member in
struct khugepaged_mm_slot."
>
> While struct khugepaged_mm_slot is just a wrapper of struct mm_slot, there
> is no need to define it.
>
> Remove the definition of struct khugepaged_mm_slot, so there is not chance
> to miss use mm_slot_entry().
>
> Signed-off-by: Wei Yang <richard.weiyang@gmail.com>
> Cc: Lance Yang <lance.yang@linux.dev>
> Cc: David Hildenbrand <david@redhat.com>
> Cc: Dev Jain <dev.jain@arm.com>
> Cc: Kiryl Shutsemau <kirill@shutemov.name>
> Cc: xu xin <xu.xin16@zte.com.cn>
> Cc: SeongJae Park <sj@kernel.org>
> Cc: Nico Pache <npache@redhat.com>
>
> ---
> v3:
> * fix a PF reported by SeongJae, where slot is changed to next one
> ---
> mm/khugepaged.c | 58 ++++++++++++++++++-------------------------------
> 1 file changed, 21 insertions(+), 37 deletions(-)
>
> diff --git a/mm/khugepaged.c b/mm/khugepaged.c
> index 204ce3059267..e3f7d1760567 100644
> --- a/mm/khugepaged.c
> +++ b/mm/khugepaged.c
> @@ -103,14 +103,6 @@ struct collapse_control {
> nodemask_t alloc_nmask;
> };
>
> -/**
> - * struct khugepaged_mm_slot - khugepaged information per mm that is being scanned
> - * @slot: hash lookup from mm to mm_slot
> - */
> -struct khugepaged_mm_slot {
> - struct mm_slot slot;
> -};
> -
> /**
> * struct khugepaged_scan - cursor for scanning
> * @mm_head: the head of the mm list to scan
> @@ -121,7 +113,7 @@ struct khugepaged_mm_slot {
> */
> struct khugepaged_scan {
> struct list_head mm_head;
> - struct khugepaged_mm_slot *mm_slot;
> + struct mm_slot *mm_slot;
> unsigned long address;
> };
>
> @@ -384,7 +376,10 @@ int hugepage_madvise(struct vm_area_struct *vma,
>
> int __init khugepaged_init(void)
> {
> - mm_slot_cache = KMEM_CACHE(khugepaged_mm_slot, 0);
> + mm_slot_cache = kmem_cache_create("khugepaged_mm_slot",
> + sizeof(struct mm_slot),
> + __alignof__(struct mm_slot),
> + 0, NULL);
Just wondering: do we really have to maintain the old name? Could we
instead just have
mm_slot_cache = KMEM_CACHE(mm_slot, 0);
?
--
Cheers
David / dhildenb
next prev parent reply other threads:[~2025-09-24 9:39 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-24 0:48 [Patch v3 0/2] mm_slot: fix the usage of mm_slot_entry Wei Yang
2025-09-24 0:48 ` [Patch v3 1/2] mm/ksm: get mm_slot by mm_slot_entry() when slot is !NULL Wei Yang
2025-09-24 2:19 ` Chengming Zhou
2025-09-24 9:35 ` Kiryl Shutsemau
2025-09-24 9:40 ` David Hildenbrand
2025-09-24 10:06 ` Kiryl Shutsemau
2025-09-24 10:09 ` David Hildenbrand
2025-09-24 10:15 ` Kiryl Shutsemau
2025-09-24 10:42 ` David Hildenbrand
2025-09-24 14:52 ` Wei Yang
2025-09-24 9:35 ` David Hildenbrand
2025-09-24 0:48 ` [Patch v3 2/2] mm/khugepaged: remove definition of struct khugepaged_mm_slot Wei Yang
2025-09-24 3:18 ` Lance Yang
2025-09-24 5:51 ` Dev Jain
2025-09-24 9:39 ` David Hildenbrand [this message]
2025-09-24 14:59 ` Wei Yang
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=1d593bac-0d9a-4cc5-8002-932e4ba88edd@redhat.com \
--to=david@redhat.com \
--cc=Liam.Howlett@oracle.com \
--cc=akpm@linux-foundation.org \
--cc=baohua@kernel.org \
--cc=baolin.wang@linux.alibaba.com \
--cc=chengming.zhou@linux.dev \
--cc=dev.jain@arm.com \
--cc=kirill@shutemov.name \
--cc=lance.yang@linux.dev \
--cc=linux-mm@kvack.org \
--cc=lorenzo.stoakes@oracle.com \
--cc=npache@redhat.com \
--cc=richard.weiyang@gmail.com \
--cc=ryan.roberts@arm.com \
--cc=sj@kernel.org \
--cc=xu.xin16@zte.com.cn \
--cc=ziy@nvidia.com \
/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