Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

mm: mprotect: always skip dma pinned folio in prot_numa_skip()

Patch series "mm: some optimizations for prot numa", v5.


This patch (of 4):

If the folio (even not CoW folio) is dma pinned, it can't be migrated due
to the elevated reference count. So always skip a pinned folio to avoid
wasting cycles when folios are migrated.

Link: https://lkml.kernel.org/r/20251023113737.3572790-1-wangkefeng.wang@huawei.com
Link: https://lkml.kernel.org/r/20251023113737.3572790-2-wangkefeng.wang@huawei.com
Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
Acked-by: Zi Yan <ziy@nvidia.com>
Acked-by: David Hildenbrand <david@redhat.com>
Reviewed-by: Barry Song <baohua@kernel.org>
Reviewed-by: Dev Jain <dev.jain@arm.com>
Reviewed-by: Lance Yang <lance.yang@linux.dev>
Reviewed-by: Sidhartha Kumar <sidhartha.kumar@oracle.com>
Reviewed-by: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
Cc: Baolin Wang <baolin.wang@linux.alibaba.com>
Cc: Liam Howlett <liam.howlett@oracle.com>
Cc: Ryan Roberts <ryan.roberts@arm.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Kefeng Wang and committed by
Andrew Morton
03aa8e4f d945667d

+6 -3
+6 -3
mm/mprotect.c
··· 136 136 if (folio_is_zone_device(folio) || folio_test_ksm(folio)) 137 137 goto skip; 138 138 139 - /* Also skip shared copy-on-write pages */ 140 - if (is_cow_mapping(vma->vm_flags) && 141 - (folio_maybe_dma_pinned(folio) || folio_maybe_mapped_shared(folio))) 139 + /* Also skip shared copy-on-write folios */ 140 + if (is_cow_mapping(vma->vm_flags) && folio_maybe_mapped_shared(folio)) 141 + goto skip; 142 + 143 + /* Folios are pinned and can't be migrated */ 144 + if (folio_maybe_dma_pinned(folio)) 142 145 goto skip; 143 146 144 147 /*