lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <cb8fee50-4dd2-4362-b716-bf1e921bdfa2@redhat.com>
Date: Wed, 9 Apr 2025 11:53:13 +0200
From: David Hildenbrand <david@...hat.com>
To: Baolin Wang <baolin.wang@...ux.alibaba.com>, akpm@...ux-foundation.org
Cc: willy@...radead.org, hannes@...xchg.org, 21cnbao@...il.com,
 ryan.roberts@....com, ziy@...dia.com, linux-mm@...ck.org,
 linux-kernel@...r.kernel.org
Subject: Re: [PATCH] mm: huge_memory: add folio_mark_accessed() when zapping
 file THP

On 09.04.25 11:49, Baolin Wang wrote:
> 
> 
> On 2025/4/9 17:46, David Hildenbrand wrote:
>> On 09.04.25 11:38, Baolin Wang wrote:
>>> When investigating performance issues during file folio unmap, I
>>> noticed some
>>> behavioral differences in handling non-PMD-sized folios and PMD-sized
>>> folios.
>>> For non-PMD-sized file folios, it will call folio_mark_accessed() to
>>> mark the
>>> folio as having seen activity, but this is not done for PMD-sized folios.
>>>
>>> This might not cause obvious issues, but a potential problem could be
>>> that,
>>> it might lead to reclaim hot file folios under memory pressure, as quoted
>>> from Johannes:
>>>
>>> "
>>> Sometimes file contents are only accessed through relatively short-lived
>>> mappings. But they can nevertheless be accessed a lot and be hot. It's
>>> important to not lose that information on unmap, and end up kicking out a
>>> frequently used cache page.
>>> "
>>>
>>> Therefore, we should also add folio_mark_accessed() for PMD-sized file
>>> folios when unmapping.
>>>
>>> Signed-off-by: Baolin Wang <baolin.wang@...ux.alibaba.com>
>>> Acked-by: Johannes Weiner <hannes@...xchg.org>
>>> Acked-by: Zi Yan <ziy@...dia.com>
>>> ---
>>> Changes from RFC:
>>>    - Update the commit message, per Johannes.
>>>    - Collect Acked tags from Johannes and Zi. Thanks.
>>> ---
>>>    mm/huge_memory.c | 4 ++++
>>>    1 file changed, 4 insertions(+)
>>>
>>> diff --git a/mm/huge_memory.c b/mm/huge_memory.c
>>> index 2a47682d1ab7..955781b4e946 100644
>>> --- a/mm/huge_memory.c
>>> +++ b/mm/huge_memory.c
>>> @@ -2260,6 +2260,10 @@ int zap_huge_pmd(struct mmu_gather *tlb, struct
>>> vm_area_struct *vma,
>>>                    zap_deposited_table(tlb->mm, pmd);
>>>                add_mm_counter(tlb->mm, mm_counter_file(folio),
>>>                           -HPAGE_PMD_NR);
>>> +
>>> +            if (flush_needed && pmd_young(orig_pmd) &&
>>> +                likely(vma_has_recency(vma)))
>>> +                folio_mark_accessed(folio);
>>
>> So the flush_needed check is really just a pmd_present() check. (the
>> latter would be clearer, but I don't mind)
> 
> Yes, we've already checked pmd_present() before, so I assume the
> flush_needed check is cheaper:)

Maybe :)

-- 
Cheers,

David / dhildenb


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ