All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH gmem FIXUP] mm, compaction: make testing mapping_unmovable() safe
@ 2023-09-01  8:20 ` Vlastimil Babka
  0 siblings, 0 replies; 20+ messages in thread
From: Vlastimil Babka @ 2023-09-01  8:20 UTC (permalink / raw)
  To: seanjc
  Cc: ackerleytng, akpm, anup, aou, chao.p.peng, chenhuacai, david,
	isaku.yamahata, jarkko, jmorris, kirill.shutemov, kvm-riscv, kvm,
	kvmarm, liam.merwick, linux-arm-kernel, linux-fsdevel,
	linux-kernel, linux-mips, linux-mm, linux-riscv,
	linux-security-module, linuxppc-dev, mail, maz, michael.roth,
	mpe, oliver.upton, palmer, paul.walmsley, paul, pbonzini,
	qperret, serge, tabba, vannapurve, vbabka, wei.w.wang, willy,
	yu.c.zhang

As Kirill pointed out, mapping can be removed under us due to
truncation. Test it under folio lock as already done for the async
compaction / dirty folio case. To prevent locking every folio with
mapping to do the test, do it only for unevictable folios, as we can
expect the unmovable mapping folios are also unevictable - it is the
case for guest memfd folios.

Also incorporate comment update suggested by Matthew.

Fixes: 3424873596ce ("mm: Add AS_UNMOVABLE to mark mapping as completely unmovable")
Signed-off-by: Vlastimil Babka <vbabka@suse.cz>
---
Feel free to squash into 3424873596ce.

 mm/compaction.c | 49 ++++++++++++++++++++++++++++++++-----------------
 1 file changed, 32 insertions(+), 17 deletions(-)

diff --git a/mm/compaction.c b/mm/compaction.c
index a3d2b132df52..e0e439b105b5 100644
--- a/mm/compaction.c
+++ b/mm/compaction.c
@@ -862,6 +862,7 @@ isolate_migratepages_block(struct compact_control *cc, unsigned long low_pfn,
 
 	/* Time to isolate some pages for migration */
 	for (; low_pfn < end_pfn; low_pfn++) {
+		bool is_dirty, is_unevictable;
 
 		if (skip_on_failure && low_pfn >= next_skip_pfn) {
 			/*
@@ -1047,10 +1048,6 @@ isolate_migratepages_block(struct compact_control *cc, unsigned long low_pfn,
 		if (!mapping && (folio_ref_count(folio) - 1) > folio_mapcount(folio))
 			goto isolate_fail_put;
 
-		/* The mapping truly isn't movable. */
-		if (mapping && mapping_unmovable(mapping))
-			goto isolate_fail_put;
-
 		/*
 		 * Only allow to migrate anonymous pages in GFP_NOFS context
 		 * because those do not depend on fs locks.
@@ -1062,8 +1059,10 @@ isolate_migratepages_block(struct compact_control *cc, unsigned long low_pfn,
 		if (!folio_test_lru(folio))
 			goto isolate_fail_put;
 
+		is_unevictable = folio_test_unevictable(folio);
+
 		/* Compaction might skip unevictable pages but CMA takes them */
-		if (!(mode & ISOLATE_UNEVICTABLE) && folio_test_unevictable(folio))
+		if (!(mode & ISOLATE_UNEVICTABLE) && is_unevictable)
 			goto isolate_fail_put;
 
 		/*
@@ -1075,26 +1074,42 @@ isolate_migratepages_block(struct compact_control *cc, unsigned long low_pfn,
 		if ((mode & ISOLATE_ASYNC_MIGRATE) && folio_test_writeback(folio))
 			goto isolate_fail_put;
 
-		if ((mode & ISOLATE_ASYNC_MIGRATE) && folio_test_dirty(folio)) {
-			bool migrate_dirty;
+		is_dirty = folio_test_dirty(folio);
+
+		if (((mode & ISOLATE_ASYNC_MIGRATE) && is_dirty)
+		    || (mapping && is_unevictable)) {
+			bool migrate_dirty = true;
+			bool is_unmovable;
 
 			/*
-			 * Only pages without mappings or that have a
-			 * ->migrate_folio callback are possible to migrate
-			 * without blocking. However, we can be racing with
-			 * truncation so it's necessary to lock the page
-			 * to stabilise the mapping as truncation holds
-			 * the page lock until after the page is removed
-			 * from the page cache.
+			 * Only folios without mappings or that have
+			 * a ->migrate_folio callback are possible to migrate
+			 * without blocking.
+			 *
+			 * Folios from unmovable mappings are not migratable.
+			 *
+			 * However, we can be racing with truncation, which can
+			 * free the mapping that we need to check. Truncation
+			 * holds the folio lock until after the folio is removed
+			 * from the page so holding it ourselves is sufficient.
+			 *
+			 * To avoid this folio locking to inspect every folio
+			 * with mapping for being unmovable, we assume every
+			 * such folio is also unevictable, which is a cheaper
+			 * test. If our assumption goes wrong, it's not a bug,
+			 * just potentially wasted cycles.
 			 */
 			if (!folio_trylock(folio))
 				goto isolate_fail_put;
 
 			mapping = folio_mapping(folio);
-			migrate_dirty = !mapping ||
-					mapping->a_ops->migrate_folio;
+			if ((mode & ISOLATE_ASYNC_MIGRATE) && is_dirty) {
+				migrate_dirty = !mapping ||
+						mapping->a_ops->migrate_folio;
+			}
+			is_unmovable = mapping && mapping_unmovable(mapping);
 			folio_unlock(folio);
-			if (!migrate_dirty)
+			if (!migrate_dirty || is_unmovable)
 				goto isolate_fail_put;
 		}
 
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH gmem FIXUP] mm, compaction: make testing mapping_unmovable() safe
@ 2023-09-01  8:20 ` Vlastimil Babka
  0 siblings, 0 replies; 20+ messages in thread
From: Vlastimil Babka @ 2023-09-01  8:20 UTC (permalink / raw)
  To: seanjc
  Cc: ackerleytng, akpm, anup, aou, chao.p.peng, chenhuacai, david,
	isaku.yamahata, jarkko, jmorris, kirill.shutemov, kvm-riscv, kvm,
	kvmarm, liam.merwick, linux-arm-kernel, linux-fsdevel,
	linux-kernel, linux-mips, linux-mm, linux-riscv,
	linux-security-module, linuxppc-dev, mail, maz, michael.roth,
	mpe, oliver.upton, palmer, paul.walmsley, paul, pbonzini,
	qperret, serge, tabba, vannapurve, vbabka, wei.w.wang, willy,
	yu.c.zhang

As Kirill pointed out, mapping can be removed under us due to
truncation. Test it under folio lock as already done for the async
compaction / dirty folio case. To prevent locking every folio with
mapping to do the test, do it only for unevictable folios, as we can
expect the unmovable mapping folios are also unevictable - it is the
case for guest memfd folios.

Also incorporate comment update suggested by Matthew.

Fixes: 3424873596ce ("mm: Add AS_UNMOVABLE to mark mapping as completely unmovable")
Signed-off-by: Vlastimil Babka <vbabka@suse.cz>
---
Feel free to squash into 3424873596ce.

 mm/compaction.c | 49 ++++++++++++++++++++++++++++++++-----------------
 1 file changed, 32 insertions(+), 17 deletions(-)

diff --git a/mm/compaction.c b/mm/compaction.c
index a3d2b132df52..e0e439b105b5 100644
--- a/mm/compaction.c
+++ b/mm/compaction.c
@@ -862,6 +862,7 @@ isolate_migratepages_block(struct compact_control *cc, unsigned long low_pfn,
 
 	/* Time to isolate some pages for migration */
 	for (; low_pfn < end_pfn; low_pfn++) {
+		bool is_dirty, is_unevictable;
 
 		if (skip_on_failure && low_pfn >= next_skip_pfn) {
 			/*
@@ -1047,10 +1048,6 @@ isolate_migratepages_block(struct compact_control *cc, unsigned long low_pfn,
 		if (!mapping && (folio_ref_count(folio) - 1) > folio_mapcount(folio))
 			goto isolate_fail_put;
 
-		/* The mapping truly isn't movable. */
-		if (mapping && mapping_unmovable(mapping))
-			goto isolate_fail_put;
-
 		/*
 		 * Only allow to migrate anonymous pages in GFP_NOFS context
 		 * because those do not depend on fs locks.
@@ -1062,8 +1059,10 @@ isolate_migratepages_block(struct compact_control *cc, unsigned long low_pfn,
 		if (!folio_test_lru(folio))
 			goto isolate_fail_put;
 
+		is_unevictable = folio_test_unevictable(folio);
+
 		/* Compaction might skip unevictable pages but CMA takes them */
-		if (!(mode & ISOLATE_UNEVICTABLE) && folio_test_unevictable(folio))
+		if (!(mode & ISOLATE_UNEVICTABLE) && is_unevictable)
 			goto isolate_fail_put;
 
 		/*
@@ -1075,26 +1074,42 @@ isolate_migratepages_block(struct compact_control *cc, unsigned long low_pfn,
 		if ((mode & ISOLATE_ASYNC_MIGRATE) && folio_test_writeback(folio))
 			goto isolate_fail_put;
 
-		if ((mode & ISOLATE_ASYNC_MIGRATE) && folio_test_dirty(folio)) {
-			bool migrate_dirty;
+		is_dirty = folio_test_dirty(folio);
+
+		if (((mode & ISOLATE_ASYNC_MIGRATE) && is_dirty)
+		    || (mapping && is_unevictable)) {
+			bool migrate_dirty = true;
+			bool is_unmovable;
 
 			/*
-			 * Only pages without mappings or that have a
-			 * ->migrate_folio callback are possible to migrate
-			 * without blocking. However, we can be racing with
-			 * truncation so it's necessary to lock the page
-			 * to stabilise the mapping as truncation holds
-			 * the page lock until after the page is removed
-			 * from the page cache.
+			 * Only folios without mappings or that have
+			 * a ->migrate_folio callback are possible to migrate
+			 * without blocking.
+			 *
+			 * Folios from unmovable mappings are not migratable.
+			 *
+			 * However, we can be racing with truncation, which can
+			 * free the mapping that we need to check. Truncation
+			 * holds the folio lock until after the folio is removed
+			 * from the page so holding it ourselves is sufficient.
+			 *
+			 * To avoid this folio locking to inspect every folio
+			 * with mapping for being unmovable, we assume every
+			 * such folio is also unevictable, which is a cheaper
+			 * test. If our assumption goes wrong, it's not a bug,
+			 * just potentially wasted cycles.
 			 */
 			if (!folio_trylock(folio))
 				goto isolate_fail_put;
 
 			mapping = folio_mapping(folio);
-			migrate_dirty = !mapping ||
-					mapping->a_ops->migrate_folio;
+			if ((mode & ISOLATE_ASYNC_MIGRATE) && is_dirty) {
+				migrate_dirty = !mapping ||
+						mapping->a_ops->migrate_folio;
+			}
+			is_unmovable = mapping && mapping_unmovable(mapping);
 			folio_unlock(folio);
-			if (!migrate_dirty)
+			if (!migrate_dirty || is_unmovable)
 				goto isolate_fail_put;
 		}
 
-- 
2.41.0


_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH gmem FIXUP] mm, compaction: make testing mapping_unmovable() safe
@ 2023-09-01  8:20 ` Vlastimil Babka
  0 siblings, 0 replies; 20+ messages in thread
From: Vlastimil Babka @ 2023-09-01  8:20 UTC (permalink / raw)
  To: seanjc
  Cc: kvm, david, yu.c.zhang, linux-mips, linux-mm, pbonzini,
	chao.p.peng, linux-riscv, isaku.yamahata, paul, anup, chenhuacai,
	jmorris, willy, wei.w.wang, tabba, jarkko, serge, mail, aou,
	vbabka, michael.roth, ackerleytng, paul.walmsley, kvmarm,
	linux-arm-kernel, qperret, linux-kernel, oliver.upton,
	linux-security-module, palmer, kvm-riscv, maz, linux-fsdevel,
	liam.merwick, akpm, vannapurve, linuxppc-dev, kirill.shutemov

As Kirill pointed out, mapping can be removed under us due to
truncation. Test it under folio lock as already done for the async
compaction / dirty folio case. To prevent locking every folio with
mapping to do the test, do it only for unevictable folios, as we can
expect the unmovable mapping folios are also unevictable - it is the
case for guest memfd folios.

Also incorporate comment update suggested by Matthew.

Fixes: 3424873596ce ("mm: Add AS_UNMOVABLE to mark mapping as completely unmovable")
Signed-off-by: Vlastimil Babka <vbabka@suse.cz>
---
Feel free to squash into 3424873596ce.

 mm/compaction.c | 49 ++++++++++++++++++++++++++++++++-----------------
 1 file changed, 32 insertions(+), 17 deletions(-)

diff --git a/mm/compaction.c b/mm/compaction.c
index a3d2b132df52..e0e439b105b5 100644
--- a/mm/compaction.c
+++ b/mm/compaction.c
@@ -862,6 +862,7 @@ isolate_migratepages_block(struct compact_control *cc, unsigned long low_pfn,
 
 	/* Time to isolate some pages for migration */
 	for (; low_pfn < end_pfn; low_pfn++) {
+		bool is_dirty, is_unevictable;
 
 		if (skip_on_failure && low_pfn >= next_skip_pfn) {
 			/*
@@ -1047,10 +1048,6 @@ isolate_migratepages_block(struct compact_control *cc, unsigned long low_pfn,
 		if (!mapping && (folio_ref_count(folio) - 1) > folio_mapcount(folio))
 			goto isolate_fail_put;
 
-		/* The mapping truly isn't movable. */
-		if (mapping && mapping_unmovable(mapping))
-			goto isolate_fail_put;
-
 		/*
 		 * Only allow to migrate anonymous pages in GFP_NOFS context
 		 * because those do not depend on fs locks.
@@ -1062,8 +1059,10 @@ isolate_migratepages_block(struct compact_control *cc, unsigned long low_pfn,
 		if (!folio_test_lru(folio))
 			goto isolate_fail_put;
 
+		is_unevictable = folio_test_unevictable(folio);
+
 		/* Compaction might skip unevictable pages but CMA takes them */
-		if (!(mode & ISOLATE_UNEVICTABLE) && folio_test_unevictable(folio))
+		if (!(mode & ISOLATE_UNEVICTABLE) && is_unevictable)
 			goto isolate_fail_put;
 
 		/*
@@ -1075,26 +1074,42 @@ isolate_migratepages_block(struct compact_control *cc, unsigned long low_pfn,
 		if ((mode & ISOLATE_ASYNC_MIGRATE) && folio_test_writeback(folio))
 			goto isolate_fail_put;
 
-		if ((mode & ISOLATE_ASYNC_MIGRATE) && folio_test_dirty(folio)) {
-			bool migrate_dirty;
+		is_dirty = folio_test_dirty(folio);
+
+		if (((mode & ISOLATE_ASYNC_MIGRATE) && is_dirty)
+		    || (mapping && is_unevictable)) {
+			bool migrate_dirty = true;
+			bool is_unmovable;
 
 			/*
-			 * Only pages without mappings or that have a
-			 * ->migrate_folio callback are possible to migrate
-			 * without blocking. However, we can be racing with
-			 * truncation so it's necessary to lock the page
-			 * to stabilise the mapping as truncation holds
-			 * the page lock until after the page is removed
-			 * from the page cache.
+			 * Only folios without mappings or that have
+			 * a ->migrate_folio callback are possible to migrate
+			 * without blocking.
+			 *
+			 * Folios from unmovable mappings are not migratable.
+			 *
+			 * However, we can be racing with truncation, which can
+			 * free the mapping that we need to check. Truncation
+			 * holds the folio lock until after the folio is removed
+			 * from the page so holding it ourselves is sufficient.
+			 *
+			 * To avoid this folio locking to inspect every folio
+			 * with mapping for being unmovable, we assume every
+			 * such folio is also unevictable, which is a cheaper
+			 * test. If our assumption goes wrong, it's not a bug,
+			 * just potentially wasted cycles.
 			 */
 			if (!folio_trylock(folio))
 				goto isolate_fail_put;
 
 			mapping = folio_mapping(folio);
-			migrate_dirty = !mapping ||
-					mapping->a_ops->migrate_folio;
+			if ((mode & ISOLATE_ASYNC_MIGRATE) && is_dirty) {
+				migrate_dirty = !mapping ||
+						mapping->a_ops->migrate_folio;
+			}
+			is_unmovable = mapping && mapping_unmovable(mapping);
 			folio_unlock(folio);
-			if (!migrate_dirty)
+			if (!migrate_dirty || is_unmovable)
 				goto isolate_fail_put;
 		}
 
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH gmem FIXUP] mm, compaction: make testing mapping_unmovable() safe
@ 2023-09-01  8:20 ` Vlastimil Babka
  0 siblings, 0 replies; 20+ messages in thread
From: Vlastimil Babka @ 2023-09-01  8:20 UTC (permalink / raw)
  To: seanjc
  Cc: ackerleytng, akpm, anup, aou, chao.p.peng, chenhuacai, david,
	isaku.yamahata, jarkko, jmorris, kirill.shutemov, kvm-riscv, kvm,
	kvmarm, liam.merwick, linux-arm-kernel, linux-fsdevel,
	linux-kernel, linux-mips, linux-mm, linux-riscv,
	linux-security-module, linuxppc-dev, mail, maz, michael.roth,
	mpe, oliver.upton, palmer, paul.walmsley, paul, pbonzini,
	qperret, serge, tabba, vannapurve, vbabka, wei.w.wang, willy,
	yu.c.zhang

As Kirill pointed out, mapping can be removed under us due to
truncation. Test it under folio lock as already done for the async
compaction / dirty folio case. To prevent locking every folio with
mapping to do the test, do it only for unevictable folios, as we can
expect the unmovable mapping folios are also unevictable - it is the
case for guest memfd folios.

Also incorporate comment update suggested by Matthew.

Fixes: 3424873596ce ("mm: Add AS_UNMOVABLE to mark mapping as completely unmovable")
Signed-off-by: Vlastimil Babka <vbabka@suse.cz>
---
Feel free to squash into 3424873596ce.

 mm/compaction.c | 49 ++++++++++++++++++++++++++++++++-----------------
 1 file changed, 32 insertions(+), 17 deletions(-)

diff --git a/mm/compaction.c b/mm/compaction.c
index a3d2b132df52..e0e439b105b5 100644
--- a/mm/compaction.c
+++ b/mm/compaction.c
@@ -862,6 +862,7 @@ isolate_migratepages_block(struct compact_control *cc, unsigned long low_pfn,
 
 	/* Time to isolate some pages for migration */
 	for (; low_pfn < end_pfn; low_pfn++) {
+		bool is_dirty, is_unevictable;
 
 		if (skip_on_failure && low_pfn >= next_skip_pfn) {
 			/*
@@ -1047,10 +1048,6 @@ isolate_migratepages_block(struct compact_control *cc, unsigned long low_pfn,
 		if (!mapping && (folio_ref_count(folio) - 1) > folio_mapcount(folio))
 			goto isolate_fail_put;
 
-		/* The mapping truly isn't movable. */
-		if (mapping && mapping_unmovable(mapping))
-			goto isolate_fail_put;
-
 		/*
 		 * Only allow to migrate anonymous pages in GFP_NOFS context
 		 * because those do not depend on fs locks.
@@ -1062,8 +1059,10 @@ isolate_migratepages_block(struct compact_control *cc, unsigned long low_pfn,
 		if (!folio_test_lru(folio))
 			goto isolate_fail_put;
 
+		is_unevictable = folio_test_unevictable(folio);
+
 		/* Compaction might skip unevictable pages but CMA takes them */
-		if (!(mode & ISOLATE_UNEVICTABLE) && folio_test_unevictable(folio))
+		if (!(mode & ISOLATE_UNEVICTABLE) && is_unevictable)
 			goto isolate_fail_put;
 
 		/*
@@ -1075,26 +1074,42 @@ isolate_migratepages_block(struct compact_control *cc, unsigned long low_pfn,
 		if ((mode & ISOLATE_ASYNC_MIGRATE) && folio_test_writeback(folio))
 			goto isolate_fail_put;
 
-		if ((mode & ISOLATE_ASYNC_MIGRATE) && folio_test_dirty(folio)) {
-			bool migrate_dirty;
+		is_dirty = folio_test_dirty(folio);
+
+		if (((mode & ISOLATE_ASYNC_MIGRATE) && is_dirty)
+		    || (mapping && is_unevictable)) {
+			bool migrate_dirty = true;
+			bool is_unmovable;
 
 			/*
-			 * Only pages without mappings or that have a
-			 * ->migrate_folio callback are possible to migrate
-			 * without blocking. However, we can be racing with
-			 * truncation so it's necessary to lock the page
-			 * to stabilise the mapping as truncation holds
-			 * the page lock until after the page is removed
-			 * from the page cache.
+			 * Only folios without mappings or that have
+			 * a ->migrate_folio callback are possible to migrate
+			 * without blocking.
+			 *
+			 * Folios from unmovable mappings are not migratable.
+			 *
+			 * However, we can be racing with truncation, which can
+			 * free the mapping that we need to check. Truncation
+			 * holds the folio lock until after the folio is removed
+			 * from the page so holding it ourselves is sufficient.
+			 *
+			 * To avoid this folio locking to inspect every folio
+			 * with mapping for being unmovable, we assume every
+			 * such folio is also unevictable, which is a cheaper
+			 * test. If our assumption goes wrong, it's not a bug,
+			 * just potentially wasted cycles.
 			 */
 			if (!folio_trylock(folio))
 				goto isolate_fail_put;
 
 			mapping = folio_mapping(folio);
-			migrate_dirty = !mapping ||
-					mapping->a_ops->migrate_folio;
+			if ((mode & ISOLATE_ASYNC_MIGRATE) && is_dirty) {
+				migrate_dirty = !mapping ||
+						mapping->a_ops->migrate_folio;
+			}
+			is_unmovable = mapping && mapping_unmovable(mapping);
 			folio_unlock(folio);
-			if (!migrate_dirty)
+			if (!migrate_dirty || is_unmovable)
 				goto isolate_fail_put;
 		}
 
-- 
2.41.0


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 20+ messages in thread

* Re: [PATCH gmem FIXUP] mm, compaction: make testing mapping_unmovable() safe
  2023-09-01  8:20 ` Vlastimil Babka
  (?)
  (?)
@ 2023-09-01 21:05   ` kirill.shutemov
  -1 siblings, 0 replies; 20+ messages in thread
From: kirill.shutemov @ 2023-09-01 21:05 UTC (permalink / raw)
  To: Vlastimil Babka
  Cc: seanjc, ackerleytng, akpm, anup, aou, chao.p.peng, chenhuacai,
	david, isaku.yamahata, jarkko, jmorris, kvm-riscv, kvm, kvmarm,
	liam.merwick, linux-arm-kernel, linux-fsdevel, linux-kernel,
	linux-mips, linux-mm, linux-riscv, linux-security-module,
	linuxppc-dev, mail, maz, michael.roth, mpe, oliver.upton, palmer,
	paul.walmsley, paul, pbonzini, qperret, serge, tabba, vannapurve,
	wei.w.wang, willy, yu.c.zhang

On Fri, Sep 01, 2023 at 10:20:26AM +0200, Vlastimil Babka wrote:
> As Kirill pointed out, mapping can be removed under us due to
> truncation. Test it under folio lock as already done for the async
> compaction / dirty folio case. To prevent locking every folio with
> mapping to do the test, do it only for unevictable folios, as we can
> expect the unmovable mapping folios are also unevictable - it is the
> case for guest memfd folios.
> 
> Also incorporate comment update suggested by Matthew.
> 
> Fixes: 3424873596ce ("mm: Add AS_UNMOVABLE to mark mapping as completely unmovable")
> Signed-off-by: Vlastimil Babka <vbabka@suse.cz>

Superficially looks good to me. But I don't really understand this
code path to Ack.

-- 
  Kiryl Shutsemau / Kirill A. Shutemov

_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH gmem FIXUP] mm, compaction: make testing mapping_unmovable() safe
@ 2023-09-01 21:05   ` kirill.shutemov
  0 siblings, 0 replies; 20+ messages in thread
From: kirill.shutemov @ 2023-09-01 21:05 UTC (permalink / raw)
  To: Vlastimil Babka
  Cc: seanjc, ackerleytng, akpm, anup, aou, chao.p.peng, chenhuacai,
	david, isaku.yamahata, jarkko, jmorris, kvm-riscv, kvm, kvmarm,
	liam.merwick, linux-arm-kernel, linux-fsdevel, linux-kernel,
	linux-mips, linux-mm, linux-riscv, linux-security-module,
	linuxppc-dev, mail, maz, michael.roth, mpe, oliver.upton, palmer,
	paul.walmsley, paul, pbonzini, qperret, serge, tabba, vannapurve,
	wei.w.wang, willy, yu.c.zhang

On Fri, Sep 01, 2023 at 10:20:26AM +0200, Vlastimil Babka wrote:
> As Kirill pointed out, mapping can be removed under us due to
> truncation. Test it under folio lock as already done for the async
> compaction / dirty folio case. To prevent locking every folio with
> mapping to do the test, do it only for unevictable folios, as we can
> expect the unmovable mapping folios are also unevictable - it is the
> case for guest memfd folios.
> 
> Also incorporate comment update suggested by Matthew.
> 
> Fixes: 3424873596ce ("mm: Add AS_UNMOVABLE to mark mapping as completely unmovable")
> Signed-off-by: Vlastimil Babka <vbabka@suse.cz>

Superficially looks good to me. But I don't really understand this
code path to Ack.

-- 
  Kiryl Shutsemau / Kirill A. Shutemov

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH gmem FIXUP] mm, compaction: make testing mapping_unmovable() safe
@ 2023-09-01 21:05   ` kirill.shutemov
  0 siblings, 0 replies; 20+ messages in thread
From: kirill.shutemov @ 2023-09-01 21:05 UTC (permalink / raw)
  To: Vlastimil Babka
  Cc: seanjc, ackerleytng, akpm, anup, aou, chao.p.peng, chenhuacai,
	david, isaku.yamahata, jarkko, jmorris, kvm-riscv, kvm, kvmarm,
	liam.merwick, linux-arm-kernel, linux-fsdevel, linux-kernel,
	linux-mips, linux-mm, linux-riscv, linux-security-module,
	linuxppc-dev, mail, maz, michael.roth, mpe, oliver.upton, palmer,
	paul.walmsley, paul, pbonzini, qperret, serge, tabba, vannapurve,
	wei.w.wang, willy, yu.c.zhang

On Fri, Sep 01, 2023 at 10:20:26AM +0200, Vlastimil Babka wrote:
> As Kirill pointed out, mapping can be removed under us due to
> truncation. Test it under folio lock as already done for the async
> compaction / dirty folio case. To prevent locking every folio with
> mapping to do the test, do it only for unevictable folios, as we can
> expect the unmovable mapping folios are also unevictable - it is the
> case for guest memfd folios.
> 
> Also incorporate comment update suggested by Matthew.
> 
> Fixes: 3424873596ce ("mm: Add AS_UNMOVABLE to mark mapping as completely unmovable")
> Signed-off-by: Vlastimil Babka <vbabka@suse.cz>

Superficially looks good to me. But I don't really understand this
code path to Ack.

-- 
  Kiryl Shutsemau / Kirill A. Shutemov

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH gmem FIXUP] mm, compaction: make testing mapping_unmovable() safe
@ 2023-09-01 21:05   ` kirill.shutemov
  0 siblings, 0 replies; 20+ messages in thread
From: kirill.shutemov @ 2023-09-01 21:05 UTC (permalink / raw)
  To: Vlastimil Babka
  Cc: kvm, david, yu.c.zhang, linux-mips, linux-mm, pbonzini,
	chao.p.peng, linux-riscv, isaku.yamahata, paul, anup, chenhuacai,
	jmorris, willy, wei.w.wang, tabba, jarkko, serge, mail, aou,
	michael.roth, ackerleytng, paul.walmsley, kvmarm,
	linux-arm-kernel, qperret, seanjc, linux-kernel, oliver.upton,
	linux-security-module, palmer, kvm-riscv, maz, linux-fsdevel,
	liam.merwick, akpm, vannapurve, linuxppc-dev

On Fri, Sep 01, 2023 at 10:20:26AM +0200, Vlastimil Babka wrote:
> As Kirill pointed out, mapping can be removed under us due to
> truncation. Test it under folio lock as already done for the async
> compaction / dirty folio case. To prevent locking every folio with
> mapping to do the test, do it only for unevictable folios, as we can
> expect the unmovable mapping folios are also unevictable - it is the
> case for guest memfd folios.
> 
> Also incorporate comment update suggested by Matthew.
> 
> Fixes: 3424873596ce ("mm: Add AS_UNMOVABLE to mark mapping as completely unmovable")
> Signed-off-by: Vlastimil Babka <vbabka@suse.cz>

Superficially looks good to me. But I don't really understand this
code path to Ack.

-- 
  Kiryl Shutsemau / Kirill A. Shutemov

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH gmem FIXUP] mm, compaction: make testing mapping_unmovable() safe
  2023-09-01  8:20 ` Vlastimil Babka
  (?)
  (?)
@ 2023-09-02 13:59   ` Matthew Wilcox
  -1 siblings, 0 replies; 20+ messages in thread
From: Matthew Wilcox @ 2023-09-02 13:59 UTC (permalink / raw)
  To: Vlastimil Babka
  Cc: seanjc, ackerleytng, akpm, anup, aou, chao.p.peng, chenhuacai,
	david, isaku.yamahata, jarkko, jmorris, kirill.shutemov,
	kvm-riscv, kvm, kvmarm, liam.merwick, linux-arm-kernel,
	linux-fsdevel, linux-kernel, linux-mips, linux-mm, linux-riscv,
	linux-security-module, linuxppc-dev, mail, maz, michael.roth,
	mpe, oliver.upton, palmer, paul.walmsley, paul, pbonzini,
	qperret, serge, tabba, vannapurve, wei.w.wang, yu.c.zhang

On Fri, Sep 01, 2023 at 10:20:26AM +0200, Vlastimil Babka wrote:
> As Kirill pointed out, mapping can be removed under us due to
> truncation. Test it under folio lock as already done for the async
> compaction / dirty folio case. To prevent locking every folio with
> mapping to do the test, do it only for unevictable folios, as we can
> expect the unmovable mapping folios are also unevictable - it is the
> case for guest memfd folios.
> 
> Also incorporate comment update suggested by Matthew.

In the meantime, 866ff80176aa went upstream earlier this merge window,
so it's going to have some conflicts.


^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH gmem FIXUP] mm, compaction: make testing mapping_unmovable() safe
@ 2023-09-02 13:59   ` Matthew Wilcox
  0 siblings, 0 replies; 20+ messages in thread
From: Matthew Wilcox @ 2023-09-02 13:59 UTC (permalink / raw)
  To: Vlastimil Babka
  Cc: seanjc, ackerleytng, akpm, anup, aou, chao.p.peng, chenhuacai,
	david, isaku.yamahata, jarkko, jmorris, kirill.shutemov,
	kvm-riscv, kvm, kvmarm, liam.merwick, linux-arm-kernel,
	linux-fsdevel, linux-kernel, linux-mips, linux-mm, linux-riscv,
	linux-security-module, linuxppc-dev, mail, maz, michael.roth,
	mpe, oliver.upton, palmer, paul.walmsley, paul, pbonzini,
	qperret, serge, tabba, vannapurve, wei.w.wang, yu.c.zhang

On Fri, Sep 01, 2023 at 10:20:26AM +0200, Vlastimil Babka wrote:
> As Kirill pointed out, mapping can be removed under us due to
> truncation. Test it under folio lock as already done for the async
> compaction / dirty folio case. To prevent locking every folio with
> mapping to do the test, do it only for unevictable folios, as we can
> expect the unmovable mapping folios are also unevictable - it is the
> case for guest memfd folios.
> 
> Also incorporate comment update suggested by Matthew.

In the meantime, 866ff80176aa went upstream earlier this merge window,
so it's going to have some conflicts.


_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH gmem FIXUP] mm, compaction: make testing mapping_unmovable() safe
@ 2023-09-02 13:59   ` Matthew Wilcox
  0 siblings, 0 replies; 20+ messages in thread
From: Matthew Wilcox @ 2023-09-02 13:59 UTC (permalink / raw)
  To: Vlastimil Babka
  Cc: seanjc, ackerleytng, akpm, anup, aou, chao.p.peng, chenhuacai,
	david, isaku.yamahata, jarkko, jmorris, kirill.shutemov,
	kvm-riscv, kvm, kvmarm, liam.merwick, linux-arm-kernel,
	linux-fsdevel, linux-kernel, linux-mips, linux-mm, linux-riscv,
	linux-security-module, linuxppc-dev, mail, maz, michael.roth,
	mpe, oliver.upton, palmer, paul.walmsley, paul, pbonzini,
	qperret, serge, tabba, vannapurve, wei.w.wang, yu.c.zhang

On Fri, Sep 01, 2023 at 10:20:26AM +0200, Vlastimil Babka wrote:
> As Kirill pointed out, mapping can be removed under us due to
> truncation. Test it under folio lock as already done for the async
> compaction / dirty folio case. To prevent locking every folio with
> mapping to do the test, do it only for unevictable folios, as we can
> expect the unmovable mapping folios are also unevictable - it is the
> case for guest memfd folios.
> 
> Also incorporate comment update suggested by Matthew.

In the meantime, 866ff80176aa went upstream earlier this merge window,
so it's going to have some conflicts.


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH gmem FIXUP] mm, compaction: make testing mapping_unmovable() safe
@ 2023-09-02 13:59   ` Matthew Wilcox
  0 siblings, 0 replies; 20+ messages in thread
From: Matthew Wilcox @ 2023-09-02 13:59 UTC (permalink / raw)
  To: Vlastimil Babka
  Cc: kvm, david, linux-mips, linux-mm, pbonzini, chao.p.peng,
	linux-riscv, isaku.yamahata, linux-security-module, paul, anup,
	chenhuacai, jmorris, wei.w.wang, tabba, yu.c.zhang, serge, mail,
	aou, michael.roth, ackerleytng, paul.walmsley, kvmarm,
	linux-arm-kernel, qperret, seanjc, linux-kernel, oliver.upton,
	jarkko, palmer, kvm-riscv, maz, linux-fsdevel, liam.merwick,
	akpm, vannapurve, linuxppc-dev, kirill.shutemov

On Fri, Sep 01, 2023 at 10:20:26AM +0200, Vlastimil Babka wrote:
> As Kirill pointed out, mapping can be removed under us due to
> truncation. Test it under folio lock as already done for the async
> compaction / dirty folio case. To prevent locking every folio with
> mapping to do the test, do it only for unevictable folios, as we can
> expect the unmovable mapping folios are also unevictable - it is the
> case for guest memfd folios.
> 
> Also incorporate comment update suggested by Matthew.

In the meantime, 866ff80176aa went upstream earlier this merge window,
so it's going to have some conflicts.


^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH gmem FIXUP] mm, compaction: make testing mapping_unmovable() safe
  2023-09-01  8:20 ` Vlastimil Babka
  (?)
  (?)
@ 2023-09-05 23:56   ` Sean Christopherson
  -1 siblings, 0 replies; 20+ messages in thread
From: Sean Christopherson @ 2023-09-05 23:56 UTC (permalink / raw)
  To: Vlastimil Babka
  Cc: ackerleytng, akpm, anup, aou, chao.p.peng, chenhuacai, david,
	isaku.yamahata, jarkko, jmorris, kirill.shutemov, kvm-riscv, kvm,
	kvmarm, liam.merwick, linux-arm-kernel, linux-fsdevel,
	linux-kernel, linux-mips, linux-mm, linux-riscv,
	linux-security-module, linuxppc-dev, mail, maz, michael.roth,
	mpe, oliver.upton, palmer, paul.walmsley, paul, pbonzini,
	qperret, serge, tabba, vannapurve, wei.w.wang, willy, yu.c.zhang

On Fri, Sep 01, 2023, Vlastimil Babka wrote:
> As Kirill pointed out, mapping can be removed under us due to
> truncation. Test it under folio lock as already done for the async
> compaction / dirty folio case. To prevent locking every folio with
> mapping to do the test, do it only for unevictable folios, as we can
> expect the unmovable mapping folios are also unevictable - it is the
> case for guest memfd folios.

Rather than expect/assume that unmovable mappings are always unevictable, how about
requiring that?  E.g. either through a VM_WARN_ON in mapping_set_unmovable(), or by
simply having that helper forcefully set AS_UNEVICTABLE as well.

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH gmem FIXUP] mm, compaction: make testing mapping_unmovable() safe
@ 2023-09-05 23:56   ` Sean Christopherson
  0 siblings, 0 replies; 20+ messages in thread
From: Sean Christopherson @ 2023-09-05 23:56 UTC (permalink / raw)
  To: Vlastimil Babka
  Cc: ackerleytng, akpm, anup, aou, chao.p.peng, chenhuacai, david,
	isaku.yamahata, jarkko, jmorris, kirill.shutemov, kvm-riscv, kvm,
	kvmarm, liam.merwick, linux-arm-kernel, linux-fsdevel,
	linux-kernel, linux-mips, linux-mm, linux-riscv,
	linux-security-module, linuxppc-dev, mail, maz, michael.roth,
	mpe, oliver.upton, palmer, paul.walmsley, paul, pbonzini,
	qperret, serge, tabba, vannapurve, wei.w.wang, willy, yu.c.zhang

On Fri, Sep 01, 2023, Vlastimil Babka wrote:
> As Kirill pointed out, mapping can be removed under us due to
> truncation. Test it under folio lock as already done for the async
> compaction / dirty folio case. To prevent locking every folio with
> mapping to do the test, do it only for unevictable folios, as we can
> expect the unmovable mapping folios are also unevictable - it is the
> case for guest memfd folios.

Rather than expect/assume that unmovable mappings are always unevictable, how about
requiring that?  E.g. either through a VM_WARN_ON in mapping_set_unmovable(), or by
simply having that helper forcefully set AS_UNEVICTABLE as well.

_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH gmem FIXUP] mm, compaction: make testing mapping_unmovable() safe
@ 2023-09-05 23:56   ` Sean Christopherson
  0 siblings, 0 replies; 20+ messages in thread
From: Sean Christopherson @ 2023-09-05 23:56 UTC (permalink / raw)
  To: Vlastimil Babka
  Cc: ackerleytng, akpm, anup, aou, chao.p.peng, chenhuacai, david,
	isaku.yamahata, jarkko, jmorris, kirill.shutemov, kvm-riscv, kvm,
	kvmarm, liam.merwick, linux-arm-kernel, linux-fsdevel,
	linux-kernel, linux-mips, linux-mm, linux-riscv,
	linux-security-module, linuxppc-dev, mail, maz, michael.roth,
	mpe, oliver.upton, palmer, paul.walmsley, paul, pbonzini,
	qperret, serge, tabba, vannapurve, wei.w.wang, willy, yu.c.zhang

On Fri, Sep 01, 2023, Vlastimil Babka wrote:
> As Kirill pointed out, mapping can be removed under us due to
> truncation. Test it under folio lock as already done for the async
> compaction / dirty folio case. To prevent locking every folio with
> mapping to do the test, do it only for unevictable folios, as we can
> expect the unmovable mapping folios are also unevictable - it is the
> case for guest memfd folios.

Rather than expect/assume that unmovable mappings are always unevictable, how about
requiring that?  E.g. either through a VM_WARN_ON in mapping_set_unmovable(), or by
simply having that helper forcefully set AS_UNEVICTABLE as well.

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH gmem FIXUP] mm, compaction: make testing mapping_unmovable() safe
@ 2023-09-05 23:56   ` Sean Christopherson
  0 siblings, 0 replies; 20+ messages in thread
From: Sean Christopherson @ 2023-09-05 23:56 UTC (permalink / raw)
  To: Vlastimil Babka
  Cc: kvm, david, yu.c.zhang, linux-mips, linux-mm, pbonzini,
	chao.p.peng, linux-riscv, isaku.yamahata, paul, anup, chenhuacai,
	jmorris, willy, wei.w.wang, tabba, jarkko, serge, mail, aou,
	michael.roth, ackerleytng, paul.walmsley, kvmarm,
	linux-arm-kernel, qperret, linux-kernel, oliver.upton,
	linux-security-module, palmer, kvm-riscv, maz, linux-fsdevel,
	liam.merwick, akpm, vannapurve, linuxppc-dev, kirill.shutemov

On Fri, Sep 01, 2023, Vlastimil Babka wrote:
> As Kirill pointed out, mapping can be removed under us due to
> truncation. Test it under folio lock as already done for the async
> compaction / dirty folio case. To prevent locking every folio with
> mapping to do the test, do it only for unevictable folios, as we can
> expect the unmovable mapping folios are also unevictable - it is the
> case for guest memfd folios.

Rather than expect/assume that unmovable mappings are always unevictable, how about
requiring that?  E.g. either through a VM_WARN_ON in mapping_set_unmovable(), or by
simply having that helper forcefully set AS_UNEVICTABLE as well.

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH gmem FIXUP] mm, compaction: make testing mapping_unmovable() safe
  2023-09-05 23:56   ` Sean Christopherson
  (?)
  (?)
@ 2023-09-06  8:00     ` Vlastimil Babka
  -1 siblings, 0 replies; 20+ messages in thread
From: Vlastimil Babka @ 2023-09-06  8:00 UTC (permalink / raw)
  To: Sean Christopherson
  Cc: ackerleytng, akpm, anup, aou, chao.p.peng, chenhuacai, david,
	isaku.yamahata, jarkko, jmorris, kirill.shutemov, kvm-riscv, kvm,
	kvmarm, liam.merwick, linux-arm-kernel, linux-fsdevel,
	linux-kernel, linux-mips, linux-mm, linux-riscv,
	linux-security-module, linuxppc-dev, mail, maz, michael.roth,
	mpe, oliver.upton, palmer, paul.walmsley, paul, pbonzini,
	qperret, serge, tabba, vannapurve, wei.w.wang, willy, yu.c.zhang

On 9/6/23 01:56, Sean Christopherson wrote:
> On Fri, Sep 01, 2023, Vlastimil Babka wrote:
>> As Kirill pointed out, mapping can be removed under us due to
>> truncation. Test it under folio lock as already done for the async
>> compaction / dirty folio case. To prevent locking every folio with
>> mapping to do the test, do it only for unevictable folios, as we can
>> expect the unmovable mapping folios are also unevictable - it is the
>> case for guest memfd folios.
> 
> Rather than expect/assume that unmovable mappings are always unevictable, how about
> requiring that?  E.g. either through a VM_WARN_ON in mapping_set_unmovable(), or by
> simply having that helper forcefully set AS_UNEVICTABLE as well.

Yeah I guess we could make the helper do that, with a comment, as gmem is
the only user right now. And if in the future somebody has case where it
makes sense to have unmovable without unevictable, we can discuss what to do
about it then.

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH gmem FIXUP] mm, compaction: make testing mapping_unmovable() safe
@ 2023-09-06  8:00     ` Vlastimil Babka
  0 siblings, 0 replies; 20+ messages in thread
From: Vlastimil Babka @ 2023-09-06  8:00 UTC (permalink / raw)
  To: Sean Christopherson
  Cc: kvm, david, yu.c.zhang, linux-mips, linux-mm, pbonzini,
	chao.p.peng, linux-riscv, isaku.yamahata, paul, anup, chenhuacai,
	jmorris, willy, wei.w.wang, tabba, jarkko, serge, mail, aou,
	michael.roth, ackerleytng, paul.walmsley, kvmarm,
	linux-arm-kernel, qperret, linux-kernel, oliver.upton,
	linux-security-module, palmer, kvm-riscv, maz, linux-fsdevel,
	liam.merwick, akpm, vannapurve, linuxppc-dev, kirill.shutemov

On 9/6/23 01:56, Sean Christopherson wrote:
> On Fri, Sep 01, 2023, Vlastimil Babka wrote:
>> As Kirill pointed out, mapping can be removed under us due to
>> truncation. Test it under folio lock as already done for the async
>> compaction / dirty folio case. To prevent locking every folio with
>> mapping to do the test, do it only for unevictable folios, as we can
>> expect the unmovable mapping folios are also unevictable - it is the
>> case for guest memfd folios.
> 
> Rather than expect/assume that unmovable mappings are always unevictable, how about
> requiring that?  E.g. either through a VM_WARN_ON in mapping_set_unmovable(), or by
> simply having that helper forcefully set AS_UNEVICTABLE as well.

Yeah I guess we could make the helper do that, with a comment, as gmem is
the only user right now. And if in the future somebody has case where it
makes sense to have unmovable without unevictable, we can discuss what to do
about it then.

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH gmem FIXUP] mm, compaction: make testing mapping_unmovable() safe
@ 2023-09-06  8:00     ` Vlastimil Babka
  0 siblings, 0 replies; 20+ messages in thread
From: Vlastimil Babka @ 2023-09-06  8:00 UTC (permalink / raw)
  To: Sean Christopherson
  Cc: ackerleytng, akpm, anup, aou, chao.p.peng, chenhuacai, david,
	isaku.yamahata, jarkko, jmorris, kirill.shutemov, kvm-riscv, kvm,
	kvmarm, liam.merwick, linux-arm-kernel, linux-fsdevel,
	linux-kernel, linux-mips, linux-mm, linux-riscv,
	linux-security-module, linuxppc-dev, mail, maz, michael.roth,
	mpe, oliver.upton, palmer, paul.walmsley, paul, pbonzini,
	qperret, serge, tabba, vannapurve, wei.w.wang, willy, yu.c.zhang

On 9/6/23 01:56, Sean Christopherson wrote:
> On Fri, Sep 01, 2023, Vlastimil Babka wrote:
>> As Kirill pointed out, mapping can be removed under us due to
>> truncation. Test it under folio lock as already done for the async
>> compaction / dirty folio case. To prevent locking every folio with
>> mapping to do the test, do it only for unevictable folios, as we can
>> expect the unmovable mapping folios are also unevictable - it is the
>> case for guest memfd folios.
> 
> Rather than expect/assume that unmovable mappings are always unevictable, how about
> requiring that?  E.g. either through a VM_WARN_ON in mapping_set_unmovable(), or by
> simply having that helper forcefully set AS_UNEVICTABLE as well.

Yeah I guess we could make the helper do that, with a comment, as gmem is
the only user right now. And if in the future somebody has case where it
makes sense to have unmovable without unevictable, we can discuss what to do
about it then.

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH gmem FIXUP] mm, compaction: make testing mapping_unmovable() safe
@ 2023-09-06  8:00     ` Vlastimil Babka
  0 siblings, 0 replies; 20+ messages in thread
From: Vlastimil Babka @ 2023-09-06  8:00 UTC (permalink / raw)
  To: Sean Christopherson
  Cc: ackerleytng, akpm, anup, aou, chao.p.peng, chenhuacai, david,
	isaku.yamahata, jarkko, jmorris, kirill.shutemov, kvm-riscv, kvm,
	kvmarm, liam.merwick, linux-arm-kernel, linux-fsdevel,
	linux-kernel, linux-mips, linux-mm, linux-riscv,
	linux-security-module, linuxppc-dev, mail, maz, michael.roth,
	mpe, oliver.upton, palmer, paul.walmsley, paul, pbonzini,
	qperret, serge, tabba, vannapurve, wei.w.wang, willy, yu.c.zhang

On 9/6/23 01:56, Sean Christopherson wrote:
> On Fri, Sep 01, 2023, Vlastimil Babka wrote:
>> As Kirill pointed out, mapping can be removed under us due to
>> truncation. Test it under folio lock as already done for the async
>> compaction / dirty folio case. To prevent locking every folio with
>> mapping to do the test, do it only for unevictable folios, as we can
>> expect the unmovable mapping folios are also unevictable - it is the
>> case for guest memfd folios.
> 
> Rather than expect/assume that unmovable mappings are always unevictable, how about
> requiring that?  E.g. either through a VM_WARN_ON in mapping_set_unmovable(), or by
> simply having that helper forcefully set AS_UNEVICTABLE as well.

Yeah I guess we could make the helper do that, with a comment, as gmem is
the only user right now. And if in the future somebody has case where it
makes sense to have unmovable without unevictable, we can discuss what to do
about it then.

_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

^ permalink raw reply	[flat|nested] 20+ messages in thread

end of thread, other threads:[~2023-09-06 11:16 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-09-01  8:20 [PATCH gmem FIXUP] mm, compaction: make testing mapping_unmovable() safe Vlastimil Babka
2023-09-01  8:20 ` Vlastimil Babka
2023-09-01  8:20 ` Vlastimil Babka
2023-09-01  8:20 ` Vlastimil Babka
2023-09-01 21:05 ` kirill.shutemov
2023-09-01 21:05   ` kirill.shutemov
2023-09-01 21:05   ` kirill.shutemov
2023-09-01 21:05   ` kirill.shutemov
2023-09-02 13:59 ` Matthew Wilcox
2023-09-02 13:59   ` Matthew Wilcox
2023-09-02 13:59   ` Matthew Wilcox
2023-09-02 13:59   ` Matthew Wilcox
2023-09-05 23:56 ` Sean Christopherson
2023-09-05 23:56   ` Sean Christopherson
2023-09-05 23:56   ` Sean Christopherson
2023-09-05 23:56   ` Sean Christopherson
2023-09-06  8:00   ` Vlastimil Babka
2023-09-06  8:00     ` Vlastimil Babka
2023-09-06  8:00     ` Vlastimil Babka
2023-09-06  8:00     ` Vlastimil Babka

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.