* [PATCH] mm: Fixed incorrect comment for _kmem_cache_create function
@ 2023-04-10 9:01 zhaoxinchao
2023-04-10 14:05 ` Bagas Sanjaya
0 siblings, 1 reply; 8+ messages in thread
From: zhaoxinchao @ 2023-04-10 9:01 UTC (permalink / raw)
To: cl, penberg, rientjes, iamjoonsoo.kim, akpm, vbabka, linux-mm,
linux-kernel
Cc: zhaoxinchao
From: zhaoxinchao <chrisxinchao@outlook.com>
Actually __kmem_cache_create() returns a status :
0 is success
others are failed.
Signed-off-by: zhaoxinchao <chrisxinchao@outlook.com>
---
mm/slab.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/mm/slab.c b/mm/slab.c
index ca4822f6b..65985f767 100644
--- a/mm/slab.c
+++ b/mm/slab.c
@@ -1901,7 +1901,7 @@ static bool set_on_slab_cache(struct kmem_cache *cachep,
* @cachep: cache management descriptor
* @flags: SLAB flags
*
- * Returns a ptr to the cache on success, NULL on failure.
+ * Returns zero on success, others on failure.
* Cannot be called within a int, but can be interrupted.
* The @ctor is run when new pages are allocated by the cache.
*
--
2.39.2
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] mm: Fixed incorrect comment for _kmem_cache_create function
2023-04-10 9:01 [PATCH] mm: Fixed incorrect comment for _kmem_cache_create function zhaoxinchao
@ 2023-04-10 14:05 ` Bagas Sanjaya
2023-04-11 9:13 ` [PATCH v2] " zhaoxinchao
0 siblings, 1 reply; 8+ messages in thread
From: Bagas Sanjaya @ 2023-04-10 14:05 UTC (permalink / raw)
To: zhaoxinchao
Cc: cl, penberg, rientjes, iamjoonsoo.kim, akpm, vbabka, linux-mm,
linux-kernel
[-- Attachment #1: Type: text/plain, Size: 390 bytes --]
On Mon, Apr 10, 2023 at 05:01:42PM +0800, zhaoxinchao wrote:
> - * Returns a ptr to the cache on success, NULL on failure.
> + * Returns zero on success, others on failure.
Can you explain what these other return values are? I have skimmed on
__kmem_cache_create() kerneldoc and the function returns error in that
case.
--
An old man doll... just what I always wanted! - Clara
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH v2] mm: Fixed incorrect comment for _kmem_cache_create function
2023-04-10 14:05 ` Bagas Sanjaya
@ 2023-04-11 9:13 ` zhaoxinchao
2023-04-12 3:40 ` Bagas Sanjaya
2023-04-17 15:47 ` Vlastimil Babka
0 siblings, 2 replies; 8+ messages in thread
From: zhaoxinchao @ 2023-04-11 9:13 UTC (permalink / raw)
To: bagasdotme
Cc: ChrisXinchao, akpm, cl, iamjoonsoo.kim, linux-kernel, linux-mm,
penberg, rientjes, vbabka, zhaoxinchao
From: zhaoxinchao <chrisxinchao@outlook.com>
Actually __kmem_cache_create() returns a status :
0 is success
nonezero are failed.
This function has three return positions. In addition to successfully
return 0, the first failed position will return - E2BIG, and the second
position will return nonzero value for setup_cpu_cache function failure.
Signed-off-by: zhaoxinchao <chrisxinchao@outlook.com>
---
mm/slab.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/mm/slab.c b/mm/slab.c
index edbe722fb..399daa4d0 100644
--- a/mm/slab.c
+++ b/mm/slab.c
@@ -1893,7 +1893,12 @@ static bool set_on_slab_cache(struct kmem_cache *cachep,
* @cachep: cache management descriptor
* @flags: SLAB flags
*
- * Returns a ptr to the cache on success, NULL on failure.
+ * Returns zero on success, nonzero on failure.
+ * This function has three return positions.
+ * In addition to successfully return 0, the
+ * first failed position will return - E2BIG,
+ * and the second position will return nonzero
+ * value for setup_cpu_cache function failure.
* Cannot be called within an int, but can be interrupted.
* The @ctor is run when new pages are allocated by the cache.
*
--
2.39.2
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v2] mm: Fixed incorrect comment for _kmem_cache_create function
2023-04-11 9:13 ` [PATCH v2] " zhaoxinchao
@ 2023-04-12 3:40 ` Bagas Sanjaya
2023-04-12 6:17 ` 答复: " zhao xinchao
2023-04-17 15:47 ` Vlastimil Babka
1 sibling, 1 reply; 8+ messages in thread
From: Bagas Sanjaya @ 2023-04-12 3:40 UTC (permalink / raw)
To: zhaoxinchao
Cc: akpm, cl, iamjoonsoo.kim, linux-kernel, linux-mm, penberg,
rientjes, vbabka
On 4/11/23 16:13, zhaoxinchao wrote:
> diff --git a/mm/slab.c b/mm/slab.c
> index edbe722fb..399daa4d0 100644
> --- a/mm/slab.c
> +++ b/mm/slab.c
> @@ -1893,7 +1893,12 @@ static bool set_on_slab_cache(struct kmem_cache *cachep,
> * @cachep: cache management descriptor
> * @flags: SLAB flags
> *
> - * Returns a ptr to the cache on success, NULL on failure.
> + * Returns zero on success, nonzero on failure.
> + * This function has three return positions.
> + * In addition to successfully return 0, the
> + * first failed position will return - E2BIG,
> + * and the second position will return nonzero
> + * value for setup_cpu_cache function failure.
> * Cannot be called within an int, but can be interrupted.
> * The @ctor is run when new pages are allocated by the cache.
> *
I don't see any visible changes in my htmldocs build (since the
kernel-doc is for inline version of kmem_cache_create()).
You will also need to update kernel-doc comment for
kmem_cache_create_usercopy() and kmem_cache_create() in
mm/slab_common.c. Since the latter function is actually a wrapper
on the former, the return value description (Return: field)
should be same on both.
Thanks.
--
An old man doll... just what I always wanted! - Clara
^ permalink raw reply [flat|nested] 8+ messages in thread
* 答复: [PATCH v2] mm: Fixed incorrect comment for _kmem_cache_create function
2023-04-12 3:40 ` Bagas Sanjaya
@ 2023-04-12 6:17 ` zhao xinchao
0 siblings, 0 replies; 8+ messages in thread
From: zhao xinchao @ 2023-04-12 6:17 UTC (permalink / raw)
To: Bagas Sanjaya
Cc: akpm, cl, iamjoonsoo.kim, linux-kernel, linux-mm, penberg,
rientjes, vbabka
I don't think kmem_cache_create is associated with __kmem_cache_create,
__kmem_cache_create is not exported as an API, it is a function called internally by the kernel.
So the kernel documentation does not document this internal interface.
-----邮件原件-----
发件人: Bagas Sanjaya [mailto:bagasdotme@gmail.com]
发送时间: 2023年4月12日 11:40
收件人: zhaoxinchao <ChrisXinchao@outlook.com>
抄送: akpm@linux-foundation.org; cl@linux.com; iamjoonsoo.kim@lge.com; linux-kernel@vger.kernel.org; linux-mm@kvack.org; penberg@kernel.org; rientjes@google.com; vbabka@suse.cz
主题: Re: [PATCH v2] mm: Fixed incorrect comment for _kmem_cache_create function
On 4/11/23 16:13, zhaoxinchao wrote:
> diff --git a/mm/slab.c b/mm/slab.c
> index edbe722fb..399daa4d0 100644
> --- a/mm/slab.c
> +++ b/mm/slab.c
> @@ -1893,7 +1893,12 @@ static bool set_on_slab_cache(struct kmem_cache *cachep,
> * @cachep: cache management descriptor
> * @flags: SLAB flags
> *
> - * Returns a ptr to the cache on success, NULL on failure.
> + * Returns zero on success, nonzero on failure.
> + * This function has three return positions.
> + * In addition to successfully return 0, the
> + * first failed position will return - E2BIG,
> + * and the second position will return nonzero
> + * value for setup_cpu_cache function failure.
> * Cannot be called within an int, but can be interrupted.
> * The @ctor is run when new pages are allocated by the cache.
> *
I don't see any visible changes in my htmldocs build (since the kernel-doc is for inline version of kmem_cache_create()).
You will also need to update kernel-doc comment for
kmem_cache_create_usercopy() and kmem_cache_create() in mm/slab_common.c. Since the latter function is actually a wrapper on the former, the return value description (Return: field) should be same on both.
Thanks.
--
An old man doll... just what I always wanted! - Clara
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v2] mm: Fixed incorrect comment for _kmem_cache_create function
2023-04-11 9:13 ` [PATCH v2] " zhaoxinchao
2023-04-12 3:40 ` Bagas Sanjaya
@ 2023-04-17 15:47 ` Vlastimil Babka
2023-04-18 2:05 ` [PATCH v3] " zhaoxinchao
1 sibling, 1 reply; 8+ messages in thread
From: Vlastimil Babka @ 2023-04-17 15:47 UTC (permalink / raw)
To: zhaoxinchao, bagasdotme
Cc: akpm, cl, iamjoonsoo.kim, linux-kernel, linux-mm, penberg, rientjes
On 4/11/23 11:13, zhaoxinchao wrote:
> From: zhaoxinchao <chrisxinchao@outlook.com>
>
> Actually __kmem_cache_create() returns a status :
> 0 is success
> nonezero are failed.
>
> This function has three return positions. In addition to successfully
> return 0, the first failed position will return - E2BIG, and the second
> position will return nonzero value for setup_cpu_cache function failure.
>
> Signed-off-by: zhaoxinchao <chrisxinchao@outlook.com>
> ---
> mm/slab.c | 7 ++++++-
> 1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/mm/slab.c b/mm/slab.c
> index edbe722fb..399daa4d0 100644
> --- a/mm/slab.c
> +++ b/mm/slab.c
> @@ -1893,7 +1893,12 @@ static bool set_on_slab_cache(struct kmem_cache *cachep,
> * @cachep: cache management descriptor
> * @flags: SLAB flags
> *
> - * Returns a ptr to the cache on success, NULL on failure.
> + * Returns zero on success, nonzero on failure.
OK.
> + * This function has three return positions.
> + * In addition to successfully return 0, the
> + * first failed position will return - E2BIG,
> + * and the second position will return nonzero
> + * value for setup_cpu_cache function failure.
I don't think we need to be so specific here, so we can drop this block.
> * Cannot be called within an int, but can be interrupted.
> * The @ctor is run when new pages are allocated by the cache.
> *
You missed that there's also:
* Return: a pointer to the created cache or %NULL in case of error
*/
int __kmem_cache_create(struct kmem_cache *cachep, slab_flags_t flags)
I guess we can drop the first mention of returns and fix up this one.
Also I'd make this a non-kerneldoc comment (/* instead of /**) as
it's for a SLAB-specific internal implementation only. Only
kmem_cache_create() is meant as an API.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH v3] mm: Fixed incorrect comment for _kmem_cache_create function
2023-04-17 15:47 ` Vlastimil Babka
@ 2023-04-18 2:05 ` zhaoxinchao
2023-04-18 7:10 ` Vlastimil Babka
0 siblings, 1 reply; 8+ messages in thread
From: zhaoxinchao @ 2023-04-18 2:05 UTC (permalink / raw)
To: vbabka
Cc: ChrisXinchao, akpm, bagasdotme, cl, iamjoonsoo.kim, linux-kernel,
linux-mm, penberg, rientjes, zhaoxinchao
From: zhaoxinchao <chrisxinchao@outlook.com>
Actually __kmem_cache_create() returns a status :
0 is success
nonezero are failed.
This function has three return positions. In addition to successfully
return 0, the first failed position will return - E2BIG, and the second
position will return nonzero value for setup_cpu_cache function failure.
Signed-off-by: zhaoxinchao <chrisxinchao@outlook.com>
---
mm/slab.c | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)
diff --git a/mm/slab.c b/mm/slab.c
index edbe722fb..ebd326f07 100644
--- a/mm/slab.c
+++ b/mm/slab.c
@@ -1888,14 +1888,17 @@ static bool set_on_slab_cache(struct kmem_cache *cachep,
return true;
}
-/**
+/*
* __kmem_cache_create - Create a cache.
* @cachep: cache management descriptor
* @flags: SLAB flags
*
- * Returns a ptr to the cache on success, NULL on failure.
- * Cannot be called within an int, but can be interrupted.
- * The @ctor is run when new pages are allocated by the cache.
+ * Returns zero on success, nonzero on failure.
+ * This function has three return positions.
+ * In addition to successfully return 0, the
+ * first failed position will return - E2BIG,
+ * and the second position will return nonzero
+ * value for setup_cpu_cache function failure.
*
* The flags are
*
@@ -1908,8 +1911,6 @@ static bool set_on_slab_cache(struct kmem_cache *cachep,
* %SLAB_HWCACHE_ALIGN - Align the objects in this cache to a hardware
* cacheline. This can be beneficial if you're counting cycles as closely
* as davem.
- *
- * Return: a pointer to the created cache or %NULL in case of error
*/
int __kmem_cache_create(struct kmem_cache *cachep, slab_flags_t flags)
{
--
2.39.2
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v3] mm: Fixed incorrect comment for _kmem_cache_create function
2023-04-18 2:05 ` [PATCH v3] " zhaoxinchao
@ 2023-04-18 7:10 ` Vlastimil Babka
0 siblings, 0 replies; 8+ messages in thread
From: Vlastimil Babka @ 2023-04-18 7:10 UTC (permalink / raw)
To: zhaoxinchao
Cc: akpm, bagasdotme, cl, iamjoonsoo.kim, linux-kernel, linux-mm,
penberg, rientjes
On 4/18/23 04:05, zhaoxinchao wrote:
> From: zhaoxinchao <chrisxinchao@outlook.com>
>
> Actually __kmem_cache_create() returns a status :
> 0 is success
> nonezero are failed.
>
> This function has three return positions. In addition to successfully
> return 0, the first failed position will return - E2BIG, and the second
> position will return nonzero value for setup_cpu_cache function failure.
Adjusted a bit.
> Signed-off-by: zhaoxinchao <chrisxinchao@outlook.com>
> ---
> mm/slab.c | 13 +++++++------
> 1 file changed, 7 insertions(+), 6 deletions(-)
>
> diff --git a/mm/slab.c b/mm/slab.c
> index edbe722fb..ebd326f07 100644
> --- a/mm/slab.c
> +++ b/mm/slab.c
> @@ -1888,14 +1888,17 @@ static bool set_on_slab_cache(struct kmem_cache *cachep,
> return true;
> }
>
> -/**
> +/*
> * __kmem_cache_create - Create a cache.
> * @cachep: cache management descriptor
> * @flags: SLAB flags
> *
> - * Returns a ptr to the cache on success, NULL on failure.
> - * Cannot be called within an int, but can be interrupted.
> - * The @ctor is run when new pages are allocated by the cache.
> + * Returns zero on success, nonzero on failure.
> + * This function has three return positions.
> + * In addition to successfully return 0, the
> + * first failed position will return - E2BIG,
> + * and the second position will return nonzero
> + * value for setup_cpu_cache function failure.
In v2 I recommended dropping the detailed description. Removed it when
merging. The result is merged for 6.5 here:
https://git.kernel.org/pub/scm/linux/kernel/git/vbabka/slab.git/log/?h=slab/for-6.5/trivial
Thanks!
> *
> * The flags are
> *
> @@ -1908,8 +1911,6 @@ static bool set_on_slab_cache(struct kmem_cache *cachep,
> * %SLAB_HWCACHE_ALIGN - Align the objects in this cache to a hardware
> * cacheline. This can be beneficial if you're counting cycles as closely
> * as davem.
> - *
> - * Return: a pointer to the created cache or %NULL in case of error
> */
> int __kmem_cache_create(struct kmem_cache *cachep, slab_flags_t flags)
> {
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2023-04-18 7:10 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-10 9:01 [PATCH] mm: Fixed incorrect comment for _kmem_cache_create function zhaoxinchao
2023-04-10 14:05 ` Bagas Sanjaya
2023-04-11 9:13 ` [PATCH v2] " zhaoxinchao
2023-04-12 3:40 ` Bagas Sanjaya
2023-04-12 6:17 ` 答复: " zhao xinchao
2023-04-17 15:47 ` Vlastimil Babka
2023-04-18 2:05 ` [PATCH v3] " zhaoxinchao
2023-04-18 7:10 ` Vlastimil Babka
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox