linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mm: slab: comment __GFP_ZERO case for kmem_cache_alloc
@ 2022-10-08  2:03 Alexander Aring
  2022-10-08  4:38 ` Hyeonggon Yoo
  2022-10-10  3:48 ` David Rientjes
  0 siblings, 2 replies; 3+ messages in thread
From: Alexander Aring @ 2022-10-08  2:03 UTC (permalink / raw)
  To: cl
  Cc: penberg, rientjes, iamjoonsoo.kim, akpm, vbabka, roman.gushchin,
	42.hyeyoo, linux-mm, linux-kernel, cluster-devel, aahringo

This patch will add a comment for the __GFP_ZERO flag case for
kmem_cache_alloc(). As the current comment mentioned that the flags only
matters if the cache has no available objects it's different for the
__GFP_ZERO flag which will ensure that the returned object is always
zeroed in any case.

I have the feeling I run into this question already two times if the
user need to zero the object or not, but the user does not need to zero
the object afterwards. However another use of __GFP_ZERO and only zero
the object if the cache has no available objects would also make no
sense.

Signed-off-by: Alexander Aring <aahringo@redhat.com>
---
 mm/slab.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/mm/slab.c b/mm/slab.c
index 10e96137b44f..7a84c2aae85a 100644
--- a/mm/slab.c
+++ b/mm/slab.c
@@ -3482,7 +3482,8 @@ void *__kmem_cache_alloc_lru(struct kmem_cache *cachep, struct list_lru *lru,
  * @flags: See kmalloc().
  *
  * Allocate an object from this cache.  The flags are only relevant
- * if the cache has no available objects.
+ * if the cache has no available objects. Except flag __GFP_ZERO which
+ * will zero the returned object.
  *
  * Return: pointer to the new object or %NULL in case of error
  */
-- 
2.31.1


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

* Re: [PATCH] mm: slab: comment __GFP_ZERO case for kmem_cache_alloc
  2022-10-08  2:03 [PATCH] mm: slab: comment __GFP_ZERO case for kmem_cache_alloc Alexander Aring
@ 2022-10-08  4:38 ` Hyeonggon Yoo
  2022-10-10  3:48 ` David Rientjes
  1 sibling, 0 replies; 3+ messages in thread
From: Hyeonggon Yoo @ 2022-10-08  4:38 UTC (permalink / raw)
  To: Alexander Aring
  Cc: cl, penberg, rientjes, iamjoonsoo.kim, akpm, vbabka,
	roman.gushchin, linux-mm, linux-kernel, cluster-devel

On Fri, Oct 07, 2022 at 10:03:12PM -0400, Alexander Aring wrote:
> This patch will add a comment for the __GFP_ZERO flag case for
> kmem_cache_alloc(). As the current comment mentioned that the flags only
> matters if the cache has no available objects it's different for the
> __GFP_ZERO flag which will ensure that the returned object is always
> zeroed in any case.
> 
> I have the feeling I run into this question already two times if the
> user need to zero the object or not, but the user does not need to zero
> the object afterwards. However another use of __GFP_ZERO and only zero
> the object if the cache has no available objects would also make no
> sense.
> 
> Signed-off-by: Alexander Aring <aahringo@redhat.com>
> ---
>  mm/slab.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/mm/slab.c b/mm/slab.c
> index 10e96137b44f..7a84c2aae85a 100644
> --- a/mm/slab.c
> +++ b/mm/slab.c
> @@ -3482,7 +3482,8 @@ void *__kmem_cache_alloc_lru(struct kmem_cache *cachep, struct list_lru *lru,
>   * @flags: See kmalloc().
>   *
>   * Allocate an object from this cache.  The flags are only relevant
> - * if the cache has no available objects.
> + * if the cache has no available objects. Except flag __GFP_ZERO which
> + * will zero the returned object.
>   *
>   * Return: pointer to the new object or %NULL in case of error
>   */
> -- 
> 2.31.1
> 

Acked-by: Hyeonggon Yoo <42.hyeyoo@gmail.com>

Thanks!

-- 
Thanks,
Hyeonggon

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

* Re: [PATCH] mm: slab: comment __GFP_ZERO case for kmem_cache_alloc
  2022-10-08  2:03 [PATCH] mm: slab: comment __GFP_ZERO case for kmem_cache_alloc Alexander Aring
  2022-10-08  4:38 ` Hyeonggon Yoo
@ 2022-10-10  3:48 ` David Rientjes
  1 sibling, 0 replies; 3+ messages in thread
From: David Rientjes @ 2022-10-10  3:48 UTC (permalink / raw)
  To: Alexander Aring
  Cc: cl, penberg, iamjoonsoo.kim, akpm, vbabka, roman.gushchin,
	42.hyeyoo, linux-mm, linux-kernel, cluster-devel

On Fri, 7 Oct 2022, Alexander Aring wrote:

> diff --git a/mm/slab.c b/mm/slab.c
> index 10e96137b44f..7a84c2aae85a 100644
> --- a/mm/slab.c
> +++ b/mm/slab.c
> @@ -3482,7 +3482,8 @@ void *__kmem_cache_alloc_lru(struct kmem_cache *cachep, struct list_lru *lru,
>   * @flags: See kmalloc().
>   *
>   * Allocate an object from this cache.  The flags are only relevant
> - * if the cache has no available objects.
> + * if the cache has no available objects. Except flag __GFP_ZERO which
> + * will zero the returned object.

Minor nit: it's probably better to do "... has no available objects, 
except flag ..." and not seperate sentences.  After that is done, feel 
free to add

	Acked-by: David Rientjes <rientjes@google.com>

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

end of thread, other threads:[~2022-10-10  3:48 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-08  2:03 [PATCH] mm: slab: comment __GFP_ZERO case for kmem_cache_alloc Alexander Aring
2022-10-08  4:38 ` Hyeonggon Yoo
2022-10-10  3:48 ` David Rientjes

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