Thread (22 messages) 22 messages, 4 authors, 2022-05-10

Re: [PATCH 3/3] mm: rmap: Fix CONT-PTE/PMD size hugetlb issue when unmapping

From: Baolin Wang <baolin.wang@linux.alibaba.com>
Date: 2022-05-10 01:27:47
Also in: linux-arch, linux-arm-kernel, linux-mips, linux-mm, linux-s390, linux-sh, lkml, sparclinux


On 5/10/2022 12:41 AM, Peter Xu wrote:
On Fri, May 06, 2022 at 12:07:13PM -0700, Mike Kravetz wrote:
quoted
On 5/3/22 03:03, Gerald Schaefer wrote:
quoted
On Tue, 3 May 2022 10:19:46 +0800
Baolin Wang [off-list ref] wrote:
quoted
On 5/2/2022 10:02 PM, Gerald Schaefer wrote:
[...]
quoted
quoted
quoted
Please see previous code, we'll use the original pte value to check if
it is uffd-wp armed, and if need to mark it dirty though the hugetlbfs
is set noop_dirty_folio().

pte_install_uffd_wp_if_needed(vma, address, pvmw.pte, pteval);
Uh, ok, that wouldn't work on s390, but we also don't have
CONFIG_PTE_MARKER_UFFD_WP / HAVE_ARCH_USERFAULTFD_WP set, so
I guess we will be fine (for now).

Still, I find it a bit unsettling that pte_install_uffd_wp_if_needed()
would work on a potential hugetlb *pte, directly de-referencing it
instead of using huge_ptep_get().

The !pte_none(*pte) check at the beginning would be broken in the
hugetlb case for s390 (not sure about other archs, but I think s390
might be the only exception strictly requiring huge_ptep_get()
for de-referencing hugetlb *pte pointers).
We could have used is_vm_hugetlb_page(vma) within the helper so as to
properly use either generic pte or hugetlb version of pte fetching.  We may
want to conditionally do set_[huge_]pte_at() too at the end.

I could prepare a patch for that even if it's not really anything urgently
needed. I assume that won't need to block this patchset since we need the
pteval for pte_dirty() check anyway and uffd-wp definitely needs it too.
OK. Thanks Peter.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help