From: David Hildenbrand <david@redhat.com>
To: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
Cc: Dev Jain <dev.jain@arm.com>,
akpm@linux-foundation.org, ziy@nvidia.com,
baolin.wang@linux.alibaba.com, Liam.Howlett@oracle.com,
npache@redhat.com, ryan.roberts@arm.com, baohua@kernel.org,
linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] khugepaged: Optimize __collapse_huge_page_copy_succeeded() for large folios by PTE batching
Date: Wed, 18 Jun 2025 19:23:29 +0200 [thread overview]
Message-ID: <4c7dc187-bd04-47c5-b619-b91b83cca913@redhat.com> (raw)
In-Reply-To: <42aa7d12-3f84-4ee6-a067-5aee30ec677d@lucifer.local>
On 18.06.25 19:10, Lorenzo Stoakes wrote:
> On Wed, Jun 18, 2025 at 06:14:22PM +0200, David Hildenbrand wrote:
>> On 18.06.25 12:26, Dev Jain wrote:
>>> +
>>> /*
>>> * ptl mostly unnecessary, but preempt has to
>>> * be disabled to update the per-cpu stats
>>> * inside folio_remove_rmap_pte().
>>> */
>>> spin_lock(ptl);
>>
>> Existing code: The PTL locking should just be moved outside of the loop.
>
> Do we really want to hold the PTL for the duration of the loop? Are we sure
> it's safe to do so? Are there any locks taken in other functions that might
> sleep that'd mean holding a spinlock would be a problem?
It's a very weird thing to not hold the PTL while walking page tables,
and then only grabbing it for clearing entries just to make selected
functions happy ...
I mostly spotted the release_pte_folio(), which I think should be fine
with a spinlock held. I missed the free_folio_and_swap_cache(), not sure
if that is problematic.
Interestingly, release_pte_folio() does a
a) node_stat_mod_folio
b) folio_unlock
c) folio_putback_lru
... and folio_putback_lru() is documented to "lru_lock must not be held,
interrupts must be enabled". Hmmmm. I suspect that doc is wrong.
So yeah, maybe better keep that weird looking locking like it is :)
--
Cheers,
David / dhildenb
next prev parent reply other threads:[~2025-06-18 17:23 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-18 10:26 Dev Jain
2025-06-18 16:14 ` David Hildenbrand
2025-06-18 17:10 ` Lorenzo Stoakes
2025-06-18 17:23 ` David Hildenbrand [this message]
2025-06-18 17:26 ` David Hildenbrand
2025-06-19 3:54 ` Dev Jain
2025-06-18 17:26 ` Lorenzo Stoakes
2025-06-18 17:29 ` David Hildenbrand
2025-06-19 12:52 ` Lorenzo Stoakes
2025-06-19 3:22 ` Dev Jain
2025-06-19 12:53 ` Lorenzo Stoakes
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=4c7dc187-bd04-47c5-b619-b91b83cca913@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=dev.jain@arm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=lorenzo.stoakes@oracle.com \
--cc=npache@redhat.com \
--cc=ryan.roberts@arm.com \
--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