lkml.org 
[lkml]   [2023]   [Aug]   [1]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
SubjectRe: [PATCH v3 1/2] mm: Provide empty function for kmem_dump_obj() when CONFIG_PRINTK=n
On Wed, Aug 02, 2023 at 11:45:16AM +0800, thunder.leizhen@huaweicloud.com wrote:
> +++ b/include/linux/slab.h
> @@ -246,6 +246,9 @@ size_t ksize(const void *objp);
> #ifdef CONFIG_PRINTK
> bool kmem_valid_obj(void *object);
> void kmem_dump_obj(void *object);
> +#else
> +static inline bool kmem_valid_obj(void *object) { return false; }

That is very confusing. kmem_valid_obj() looks like a function which
should exist regardless of CONFIG_PRINTK and to have it always return
false if CONFIG_PRINTK isn't set seems weird.

I see we have one caller of kmem_valid_obj() right now. Which means it
shouldn't be an EXPORT_SYMBOL since that caller is not a module.

I think the right solution is to convert kmem_dump_obj() to
work the same way as vmalloc_dump_obj(). ie:

+++ b/mm/util.c
@@ -1057,11 +1057,8 @@ void mem_dump_obj(void *object)
{
const char *type;

- if (kmem_valid_obj(object)) {
- kmem_dump_obj(object);
+ if (kmem_dump_obj(object))
return;
- }
-
if (vmalloc_dump_obj(object))
return;

... with corresponding changes to eliminate kmem_valid_obj() as a
symbol.
\
 
 \ /
  Last update: 2023-08-02 05:59    [W:0.098 / U:0.224 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site