From: "David Hildenbrand (Red Hat)" <david@kernel.org>
To: Pedro Demarchi Gomes <pedrodemargomes@gmail.com>,
David Hildenbrand <david@redhat.com>,
Andrew Morton <akpm@linux-foundation.org>
Cc: Xu Xin <xu.xin16@zte.com.cn>,
Chengming Zhou <chengming.zhou@linux.dev>,
linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 2/3] ksm: perform a range-walk in break_ksm
Date: Mon, 3 Nov 2025 18:06:26 +0100 [thread overview]
Message-ID: <cd632ad0-c73e-4e6d-872b-2f4dad285e9d@kernel.org> (raw)
In-Reply-To: <20251031174625.127417-3-pedrodemargomes@gmail.com>
On 31.10.25 18:46, Pedro Demarchi Gomes wrote:
> Make break_ksm() receive an address range and change
> break_ksm_pmd_entry() to perform a range-walk and return the address of
> the first ksm page found.
>
> This change allows break_ksm() to skip unmapped regions instead of
> iterating every page address. When unmerging large sparse VMAs, this
> significantly reduces runtime.
>
> In a benchmark unmerging a 32 TiB sparse virtual address space where
> only one page was populated, the runtime dropped from 9 minutes to less
> then 5 seconds.
>
> Suggested-by: David Hildenbrand <david@redhat.com>
> Signed-off-by: Pedro Demarchi Gomes <pedrodemargomes@gmail.com>
> ---
> mm/ksm.c | 88 ++++++++++++++++++++++++++++++--------------------------
> 1 file changed, 48 insertions(+), 40 deletions(-)
>
> diff --git a/mm/ksm.c b/mm/ksm.c
> index 922d2936e206..64d66699133d 100644
> --- a/mm/ksm.c
> +++ b/mm/ksm.c
> @@ -607,35 +607,55 @@ static inline bool ksm_test_exit(struct mm_struct *mm)
> return atomic_read(&mm->mm_users) == 0;
> }
>
> -static int break_ksm_pmd_entry(pmd_t *pmd, unsigned long addr, unsigned long next,
> +struct break_ksm_arg {
> + unsigned long addr;
> +};
Leftover? :)
> +
> +static int break_ksm_pmd_entry(pmd_t *pmdp, unsigned long addr, unsigned long end,
> struct mm_walk *walk)
> {
> - struct folio *folio = NULL;
> + unsigned long *found_addr = (unsigned long *) walk->private;
> + struct mm_struct *mm = walk->mm;
> + pte_t *start_ptep, *ptep;
> spinlock_t *ptl;
> - pte_t *pte;
> - pte_t ptent;
> - int ret;
> + int found = 0;
Best to perform the ret -> found rename already in patch #1.
With both things
Acked-by: David Hildenbrand (Red Hat) <david@kernel.org>
--
Cheers
David
next prev parent reply other threads:[~2025-11-03 17:06 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-31 17:46 [PATCH v2 0/3] ksm: perform a range-walk to jump over holes in break_ksm Pedro Demarchi Gomes
2025-10-31 17:46 ` [PATCH v2 1/3] Revert "mm/ksm: convert break_ksm() from walk_page_range_vma() to folio_walk" Pedro Demarchi Gomes
2025-11-03 17:00 ` David Hildenbrand (Red Hat)
2025-11-05 13:28 ` Pedro Demarchi Gomes
2025-11-05 14:21 ` David Hildenbrand (Red Hat)
2025-10-31 17:46 ` [PATCH v2 2/3] ksm: perform a range-walk in break_ksm Pedro Demarchi Gomes
2025-11-03 17:06 ` David Hildenbrand (Red Hat) [this message]
2025-11-05 13:32 ` Pedro Demarchi Gomes
2025-10-31 17:46 ` [PATCH v2 3/3] ksm: replace function unmerge_ksm_pages with break_ksm Pedro Demarchi Gomes
2025-11-03 17:06 ` David Hildenbrand (Red Hat)
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=cd632ad0-c73e-4e6d-872b-2f4dad285e9d@kernel.org \
--to=david@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=chengming.zhou@linux.dev \
--cc=david@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=pedrodemargomes@gmail.com \
--cc=xu.xin16@zte.com.cn \
/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;
as well as URLs for NNTP newsgroup(s).