Re: [PATCH v2 1/3] mm: extend rmap flags arguments for folio_add_new_anon_rmap

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



>
> From: Barry Song <v-songbaohua@xxxxxxxx>
>
> In the case of a swap-in, a new anonymous folio is not necessarily
> exclusive. This patch updates the rmap flags to allow a new anonymous
> folio to be treated as either exclusive or non-exclusive. To maintain
> the existing behavior, we always use EXCLUSIVE as the default setting.
>
> Suggested-by: David Hildenbrand <david@xxxxxxxxxx>
> Signed-off-by: Barry Song <v-songbaohua@xxxxxxxx>
> Tested-by: Shuai Yuan <yuanshuai@xxxxxxxx>
> ---

Hi Andrew,

Could you please help squash the following change (a documentation
enhancement suggested by David) into this patch?

From: Barry Song <v-songbaohua@xxxxxxxx>
Date: Sat, 22 Jun 2024 14:51:38 +1200
Subject: [PATCH] mm: enhence doc for extend rmap flags arguments for
 folio_add_new_anon_rmap

Suggested-by: David Hildenbrand <david@xxxxxxxxxx>
Signed-off-by: Barry Song <v-songbaohua@xxxxxxxx>
---
 mm/rmap.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/mm/rmap.c b/mm/rmap.c
index df1a43295c85..9a8d9c848168 100644
--- a/mm/rmap.c
+++ b/mm/rmap.c
@@ -1394,7 +1394,9 @@ void folio_add_anon_rmap_pmd(struct folio *folio, struct page *page,
  *
  * Like folio_add_anon_rmap_*() but must only be called on *new* folios.
  * This means the inc-and-test can be bypassed.
- * The folio does not have to be locked.
+ * The folio doesn't necessarily need to be locked while it's exclusive
+ * unless two threads map it concurrently. However, the folio must be
+ * locked if it's shared.
  *
  * If the folio is pmd-mappable, it is accounted as a THP.
  */
@@ -1406,6 +1408,7 @@ void folio_add_new_anon_rmap(struct folio *folio, struct vm_area_struct *vma,
 	int nr_pmdmapped = 0;
 
 	VM_WARN_ON_FOLIO(folio_test_hugetlb(folio), folio);
+	VM_WARN_ON_FOLIO(!exclusive && !folio_test_locked(folio), folio);
 	VM_BUG_ON_VMA(address < vma->vm_start ||
 			address + (nr << PAGE_SHIFT) > vma->vm_end, vma);
 	__folio_set_swapbacked(folio);
-- 
2.34.1




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux