[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <91233a90-94bb-0318-3bcb-10a4403cd526@huaweicloud.com>
Date: Wed, 2 Aug 2023 19:11:04 +0800
From: "Leizhen (ThunderTown)" <thunder.leizhen@...weicloud.com>
To: Matthew Wilcox <willy@...radead.org>
Cc: Christoph Lameter <cl@...ux.com>,
Pekka Enberg <penberg@...nel.org>,
David Rientjes <rientjes@...gle.com>,
Joonsoo Kim <iamjoonsoo.kim@....com>,
Andrew Morton <akpm@...ux-foundation.org>,
Vlastimil Babka <vbabka@...e.cz>,
Roman Gushchin <roman.gushchin@...ux.dev>,
Hyeonggon Yoo <42.hyeyoo@...il.com>, linux-mm@...ck.org,
"Paul E . McKenney" <paulmck@...nel.org>,
Frederic Weisbecker <frederic@...nel.org>,
Neeraj Upadhyay <quic_neeraju@...cinc.com>,
Joel Fernandes <joel@...lfernandes.org>,
Josh Triplett <josh@...htriplett.org>,
Boqun Feng <boqun.feng@...il.com>,
Steven Rostedt <rostedt@...dmis.org>,
Mathieu Desnoyers <mathieu.desnoyers@...icios.com>,
Lai Jiangshan <jiangshanlai@...il.com>,
Zqiang <qiang.zhang1211@...il.com>, rcu@...r.kernel.org,
linux-kernel@...r.kernel.org, openeuler <kernel@...neuler.org>
Subject: Re: [PATCH v3 1/2] mm: Provide empty function for kmem_dump_obj()
when CONFIG_PRINTK=n
On 2023/8/2 11:57, Matthew Wilcox wrote:
> On Wed, Aug 02, 2023 at 11:45:16AM +0800, thunder.leizhen@...weicloud.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.
Yes, I noticed it, but I didn't come up with a good idea.
>
> 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:
Okay, it's a good suggestion.
In fact, kmem_dump_obj() also does what kmem_valid_obj() does, except
that it will print warning if the check fails. So, do as you suggest,
the duplicated code can be eliminated.
>
> +++ 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.
>
> .
>
--
Regards,
Zhen Lei
Powered by blists - more mailing lists