linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mm/vmalloc: Separate put pages and flush VM flags
@ 2021-01-21  1:41 Rick Edgecombe
  2021-01-21  2:44 ` Miaohe Lin
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Rick Edgecombe @ 2021-01-21  1:41 UTC (permalink / raw)
  To: akpm; +Cc: hch, dja, linux-mm, linux-kernel, 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")
Signed-off-by: Rick Edgecombe <rick.p.edgecombe@intel.com>
---
 include/linux/vmalloc.h | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/include/linux/vmalloc.h b/include/linux/vmalloc.h
index 80c0181c411d..0b3dd135aa5d 100644
--- a/include/linux/vmalloc.h
+++ b/include/linux/vmalloc.h
@@ -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 */
 
-- 
2.20.1


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

* Re: [PATCH] mm/vmalloc: Separate put pages and flush VM flags
  2021-01-21  1:41 [PATCH] mm/vmalloc: Separate put pages and flush VM flags Rick Edgecombe
@ 2021-01-21  2:44 ` Miaohe Lin
  2021-01-21  7:08 ` Christoph Hellwig
  2021-01-21 13:19 ` Matthew Wilcox
  2 siblings, 0 replies; 5+ messages in thread
From: Miaohe Lin @ 2021-01-21  2:44 UTC (permalink / raw)
  To: Rick Edgecombe; +Cc: hch, dja, linux-mm, linux-kernel, Andrew Morton

Hi:
On 2021/1/21 9:41, Rick Edgecombe wrote:
> 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!

> 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")

Is this worth a Cc stable ?

> Signed-off-by: Rick Edgecombe <rick.p.edgecombe@intel.com>
> ---
>  include/linux/vmalloc.h | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/include/linux/vmalloc.h b/include/linux/vmalloc.h
> index 80c0181c411d..0b3dd135aa5d 100644
> --- a/include/linux/vmalloc.h
> +++ b/include/linux/vmalloc.h
> @@ -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 */
>  
> 

Looks good to me.

Reviewed-by: Miaohe Lin <linmiaohe@huawei.com>

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

* Re: [PATCH] mm/vmalloc: Separate put pages and flush VM flags
  2021-01-21  1:41 [PATCH] mm/vmalloc: Separate put pages and flush VM flags Rick Edgecombe
  2021-01-21  2:44 ` Miaohe Lin
@ 2021-01-21  7:08 ` Christoph Hellwig
  2021-01-21 13:19 ` Matthew Wilcox
  2 siblings, 0 replies; 5+ messages in thread
From: Christoph Hellwig @ 2021-01-21  7:08 UTC (permalink / raw)
  To: Rick Edgecombe; +Cc: akpm, hch, dja, linux-mm, linux-kernel

On Wed, Jan 20, 2021 at 05:41:18PM -0800, Rick Edgecombe wrote:
> 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")
> Signed-off-by: Rick Edgecombe <rick.p.edgecombe@intel.com>

Ooops.  Looks good:

Reviewed-by: Christoph Hellwig <hch@lst.de>

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

* Re: [PATCH] mm/vmalloc: Separate put pages and flush VM flags
  2021-01-21  1:41 [PATCH] mm/vmalloc: Separate put pages and flush VM flags Rick Edgecombe
  2021-01-21  2:44 ` Miaohe Lin
  2021-01-21  7:08 ` Christoph Hellwig
@ 2021-01-21 13:19 ` Matthew Wilcox
  2021-01-21 23:57   ` Edgecombe, Rick P
  2 siblings, 1 reply; 5+ messages in thread
From: Matthew Wilcox @ 2021-01-21 13:19 UTC (permalink / raw)
  To: Rick Edgecombe; +Cc: akpm, hch, dja, linux-mm, linux-kernel

On Wed, Jan 20, 2021 at 05:41:18PM -0800, Rick Edgecombe wrote:
> 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?

diff --git a/include/linux/vmalloc.h b/include/linux/vmalloc.h
index 938eaf9517e26..458c41b99215e 100644
--- a/include/linux/vmalloc.h
+++ b/include/linux/vmalloc.h
@@ -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 */
 
 /*


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

* Re: [PATCH] mm/vmalloc: Separate put pages and flush VM flags
  2021-01-21 13:19 ` Matthew Wilcox
@ 2021-01-21 23:57   ` Edgecombe, Rick P
  0 siblings, 0 replies; 5+ messages in thread
From: Edgecombe, Rick P @ 2021-01-21 23:57 UTC (permalink / raw)
  To: willy; +Cc: hch, linux-kernel, linux-mm, dja, akpm

On Thu, 2021-01-21 at 13:19 +0000, Matthew Wilcox wrote:
> On Wed, Jan 20, 2021 at 05:41:18PM -0800, Rick Edgecombe wrote:
> > 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!

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

> Why not this?

128 char line, but looks better to me.

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

end of thread, other threads:[~2021-01-21 23:59 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-21  1:41 [PATCH] mm/vmalloc: Separate put pages and flush VM flags Rick Edgecombe
2021-01-21  2:44 ` Miaohe Lin
2021-01-21  7:08 ` Christoph Hellwig
2021-01-21 13:19 ` Matthew Wilcox
2021-01-21 23:57   ` Edgecombe, Rick P

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).