From: "David Hildenbrand (Arm)" <david@kernel.org>
To: xu.xin16@zte.com.cn, xialonglong2025@163.com
Cc: akpm@linux-foundation.org, linux-mm@kvack.org,
chengming.zhou@linux.dev, linux-kernel@vger.kernel.org,
xialonglong@kylinos.cn
Subject: Re: [PATCH 1/1] mm/ksm: trylock the mmap lock in the unstable tree walk
Date: Wed, 9 Sep 2026 17:17:08 +0200 [thread overview]
Message-ID: <91cf8129-d705-4ebd-b420-129bab7ed261@kernel.org> (raw)
In-Reply-To: <20260909110228828hKTCgUeuZkOujOBaVtUcL@zte.com.cn>
>> index 49d48d1e0998..3cfb09a926ff 100644
>> --- a/mm/ksm.c
>> +++ b/mm/ksm.c
>> @@ -820,7 +820,14 @@ static struct page *get_mergeable_page(struct ksm_rmap_item *rmap_item)
>> struct folio_walk fw;
>> struct folio *folio;
>>
>> - mmap_read_lock(mm);
>> + /*
>> + * We trylock because we don't want ksmd to wait for an mm that is
>> + * busy changing its memory layout: we prefer to skip this page and
>> + * let the next full scan retry it, like the folio trylock in
>> + * try_to_merge_one_page().
>> + */
>> + if (!mmap_read_trylock(mm))
>> + return NULL;
>> vma = find_mergeable_vma(mm, addr);
>> if (!vma)
>> goto out;
>> --
>> 2.43.0
> Sorry, NACK
Agreed. Likely the answer is to switch to per-vma locks here. All we do is a
folio_walk_start() to look up a page, that's not too crazy :)
--
Cheers,
David
next prev parent reply other threads:[~2026-09-09 15:17 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-09 2:35 Longlong Xia
2026-09-09 3:02 ` xu.xin16
2026-09-09 15:17 ` David Hildenbrand (Arm) [this message]
2026-09-10 0:51 ` Longlong Xia
2026-09-10 0:47 ` Longlong Xia
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=91cf8129-d705-4ebd-b420-129bab7ed261@kernel.org \
--to=david@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=chengming.zhou@linux.dev \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=xialonglong2025@163.com \
--cc=xialonglong@kylinos.cn \
--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
all inboxes | Powered by JetHome®