Skip to contentSkip to conversation

mm/vmalloc: Separate put pages and flush VM flags

PATCH Superseded Rick Edgecombe 4 participants 5 messages Jan 21, 2021

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mm/vmalloc: Separate put pages and flush VM flags

When VM_MAP_PUT_PAGES was added, it was defined with the same value as VM_FLUSH_RESET_PERMS. This doesn't seem like it will cause any big functional problems other than some excess flushing for VM_MAP_PUT_PAGES allocations.

Redefine VM_MAP_PUT_PAGES to have its own value. Also, move the comment and remove whitespace for VM_KASAN such that the flags lower down are less likely to be missed in the future.

Fixes b944afc9d64d ("mm: add a VM_MAP_PUT_PAGES flag for vmap")
---
 include/linux/vmalloc.h | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
include/linux/vmalloc.h +2 -4
index 80c0181c411d..0b3dd135aa5d 100644
@@ -23,9 +23,6 @@ struct notifier_block;		/* in notifier.h */
 #define VM_DMA_COHERENT		0x00000010	/* dma_alloc_coherent */
 #define VM_UNINITIALIZED	0x00000020	/* vm_struct is not fully initialized */
 #define VM_NO_GUARD		0x00000040      /* don't add guard page */
-#define VM_KASAN		0x00000080      /* has allocated kasan shadow memory */
-#define VM_MAP_PUT_PAGES	0x00000100	/* put pages and free array in vfree */
-
 /*
  * VM_KASAN is used slighly differently depending on CONFIG_KASAN_VMALLOC.
  *
@@ -36,12 +33,13 @@ struct notifier_block;		/* in notifier.h */
  * Otherwise, VM_KASAN is set for kasan_module_alloc() allocations and used to
  * determine which allocations need the module shadow freed.
  */
-
+#define VM_KASAN		0x00000080      /* has allocated kasan shadow memory */
 /*
  * Memory with VM_FLUSH_RESET_PERMS cannot be freed in an interrupt or with
  * vfree_atomic().
  */
 #define VM_FLUSH_RESET_PERMS	0x00000100      /* Reset direct map and flush TLB on unmap */
+#define VM_MAP_PUT_PAGES	0x00000200	/* put pages and free array in vfree */
 
 /* bits [20..32] reserved for arch specific ioremap internals */
 
Signature · 1 line
2.20.1
Reviewed-by on v1 1/1
#1 lore raw

Hi:

Quoted 2 lines · Rick Edgecombe

When VM_MAP_PUT_PAGES was added, it was defined with the same value as VM_FLUSH_RESET_PERMS. This doesn't seem like it will cause any big

Good catch!

Quoted 7 lines

functional problems other than some excess flushing for VM_MAP_PUT_PAGES allocations.

Redefine VM_MAP_PUT_PAGES to have its own value. Also, move the comment and remove whitespace for VM_KASAN such that the flags lower down are less likely to be missed in the future.

Quoted 1 line
Fixes b944afc9d64d ("mm: add a VM_MAP_PUT_PAGES flag for vmap")

Is this worth a Cc stable ?

Quoted 25 lines
---
 include/linux/vmalloc.h | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
include/linux/vmalloc.h +0 -4
index 80c0181c411d..0b3dd135aa5d 100644
@@ -23,9 +23,6 @@ struct notifier_block;		/* in notifier.h */
 #define VM_DMA_COHERENT		0x00000010	/* dma_alloc_coherent */
 #define VM_UNINITIALIZED	0x00000020	/* vm_struct is not fully initialized */
 #define VM_NO_GUARD		0x00000040      /* don't add guard page */
-#define VM_KASAN		0x00000080      /* has allocated kasan shadow memory */
-#define VM_MAP_PUT_PAGES	0x00000100	/* put pages and free array in vfree */
-
 /*
  * VM_KASAN is used slighly differently depending on CONFIG_KASAN_VMALLOC.
  *
@@ -36,12 +33,13 @@ struct notifier_block;		/* in notifier.h */
  * Otherwise, VM_KASAN is set for kasan_module_alloc() allocations and used to
  * determine which allocations need the module shadow freed.
  */
-

include/linux/vmalloc.h struct notifier_block; /* in notifier.h */ · line 45

Quoted 10 lines
include/linux/vmalloc.h +2 -0
+#define VM_KASAN		0x00000080      /* has allocated kasan shadow memory */
 /*
  * Memory with VM_FLUSH_RESET_PERMS cannot be freed in an interrupt or with
  * vfree_atomic().
  */
 #define VM_FLUSH_RESET_PERMS	0x00000100      /* Reset direct map and flush TLB on unmap */
+#define VM_MAP_PUT_PAGES	0x00000200	/* put pages and free array in vfree */
 
 /* bits [20..32] reserved for arch specific ioremap internals */
 

Looks good to me.

Reviewed-by on v1 1/1
#2 lore raw
In reply to Rick Edgecombe
Quoted 11 lines · Rick Edgecombe

When VM_MAP_PUT_PAGES was added, it was defined with the same value as VM_FLUSH_RESET_PERMS. This doesn't seem like it will cause any big functional problems other than some excess flushing for VM_MAP_PUT_PAGES allocations.

Redefine VM_MAP_PUT_PAGES to have its own value. Also, move the comment and remove whitespace for VM_KASAN such that the flags lower down are less likely to be missed in the future.

Fixes b944afc9d64d ("mm: add a VM_MAP_PUT_PAGES flag for vmap")

Ooops. Looks good:

#3 lore raw
In reply to Rick Edgecombe
Quoted 8 lines · Rick Edgecombe

When VM_MAP_PUT_PAGES was added, it was defined with the same value as VM_FLUSH_RESET_PERMS. This doesn't seem like it will cause any big functional problems other than some excess flushing for VM_MAP_PUT_PAGES allocations.

Redefine VM_MAP_PUT_PAGES to have its own value. Also, move the comment and remove whitespace for VM_KASAN such that the flags lower down are less likely to be missed in the future.

Er ... I think the problem was that VM_FLUSH_RESET_PERMS was put away from all the other flags!

Why not this?

include/linux/vmalloc.h +2 -7
index 938eaf9517e26..458c41b99215e 100644
@@ -24,7 +24,8 @@ struct notifier_block;		/* in notifier.h */
 #define VM_UNINITIALIZED	0x00000020	/* vm_struct is not fully initialized */
 #define VM_NO_GUARD		0x00000040      /* don't add guard page */
 #define VM_KASAN		0x00000080      /* has allocated kasan shadow memory */
-#define VM_MAP_PUT_PAGES	0x00000100	/* put pages and free array in vfree */
+#define VM_FLUSH_RESET_PERMS	0x00000100      /* Reset direct map and flush TLB on unmap. cannot be freed in atomic context */
+#define VM_MAP_PUT_PAGES	0x00000200	/* put pages and free array in vfree */
 
 /*
  * VM_KASAN is used slighly differently depending on CONFIG_KASAN_VMALLOC.
@@ -37,12 +38,6 @@ struct notifier_block;		/* in notifier.h */
  * determine which allocations need the module shadow freed.
  */
 
-/*
- * Memory with VM_FLUSH_RESET_PERMS cannot be freed in an interrupt or with
- * vfree_atomic().
- */
-#define VM_FLUSH_RESET_PERMS	0x00000100      /* Reset direct map and flush TLB on unmap */
-
 /* bits [20..32] reserved for arch specific ioremap internals */
 
 /*
#4 lore raw
Quoted 14 lines · Matthew Wilcox
Quoted 7 lines · Rick Edgecombe

When VM_MAP_PUT_PAGES was added, it was defined with the same value as
VM_FLUSH_RESET_PERMS. This doesn't seem like it will cause any big functional problems other than some excess flushing for VM_MAP_PUT_PAGES
allocations.

Quoted 5 lines

Redefine VM_MAP_PUT_PAGES to have its own value. Also, move the comment
and remove whitespace for VM_KASAN such that the flags lower down are less
likely to be missed in the future.

Quoted 3 lines

Er ... I think the problem was that VM_FLUSH_RESET_PERMS was put away from
all the other flags!

Well it wasn't that far away at the time, the VM_KASAN comment and whitespace got added later. But yes not ideal.

Quoted 1 line

Why not this?

128 char line, but looks better to me.