From: Vlastimil Babka <vbabka@suse.cz>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: kbuild test robot <lkp@intel.com>,
kbuild-all@01.org, linux-mm@kvack.org,
linux-kernel@vger.kernel.org,
Joonsoo Kim <iamjoonsoo.kim@lge.com>,
David Rientjes <rientjes@google.com>,
Pekka Enberg <penberg@kernel.org>,
Christoph Lameter <cl@linux.com>,
Matthew Wilcox <willy@linux.intel.com>
Subject: Re: [PATCH] mm, slab: rename kmalloc-node cache to kmalloc-<size>
Date: Thu, 9 Feb 2017 10:12:24 +0100 [thread overview]
Message-ID: <54e80303-b814-4232-66d4-95b34d3eb9d0@suse.cz> (raw)
In-Reply-To: <20170208135404.fa003c62eb6b75cefbe13d49@linux-foundation.org>
On 02/08/2017 10:54 PM, Andrew Morton wrote:
> On Wed, 8 Feb 2017 10:12:13 +0100 Vlastimil Babka <vbabka@suse.cz> wrote:
>
>> Thanks for the fix.
>>
>> I was going to implement Christoph's suggestion and export the whole structure
>> in mm/slab.h, but gcc was complaining that I'm redefining it, until I created a
>> typedef first. Is it worth the trouble? Below is how it would look like.
>>
>> ...
>>
>> --- a/mm/slab.h
>> +++ b/mm/slab.h
>> @@ -71,6 +71,13 @@ extern struct list_head slab_caches;
>> /* The slab cache that manages slab cache information */
>> extern struct kmem_cache *kmem_cache;
>>
>> +/* A table of kmalloc cache names and sizes */
>> +typedef struct {
>> + const char *name;
>> + unsigned long size;
>> +} kmalloc_info_t;
>> +extern const kmalloc_info_t kmalloc_info[];
>
> Why is the typedef needed? Can't we use something like
Duh, right, I can't C. Thanks.
----8<----
>From 15fc08501ddaaf1a6cf2c2d37755c61e1e5c1341 Mon Sep 17 00:00:00 2001
From: Vlastimil Babka <vbabka@suse.cz>
Date: Wed, 8 Feb 2017 11:00:11 +0100
Subject: [PATCH] mm, slab: rename kmalloc-node cache to kmalloc-<size>-fix2
Export the whole kmalloc_info structure instead of just a name accessor,
per Christoph Lameter.
Signed-off-by: Vlastimil Babka <vbabka@suse.cz>
---
mm/slab.c | 2 +-
mm/slab.h | 7 ++++++-
mm/slab_common.c | 10 +---------
3 files changed, 8 insertions(+), 11 deletions(-)
diff --git a/mm/slab.c b/mm/slab.c
index ede31b59bb9f..9d66b3d6791e 100644
--- a/mm/slab.c
+++ b/mm/slab.c
@@ -1294,7 +1294,7 @@ void __init kmem_cache_init(void)
* structures first. Without this, further allocations will bug.
*/
kmalloc_caches[INDEX_NODE] = create_kmalloc_cache(
- get_kmalloc_cache_name(INDEX_NODE),
+ kmalloc_info[INDEX_NODE].name,
kmalloc_size(INDEX_NODE), ARCH_KMALLOC_FLAGS);
slab_state = PARTIAL_NODE;
setup_kmalloc_cache_index_table();
diff --git a/mm/slab.h b/mm/slab.h
index 5708c548c6f7..2fa824335a50 100644
--- a/mm/slab.h
+++ b/mm/slab.h
@@ -71,6 +71,12 @@ extern struct list_head slab_caches;
/* The slab cache that manages slab cache information */
extern struct kmem_cache *kmem_cache;
+/* A table of kmalloc cache names and sizes */
+extern const struct kmalloc_info_struct {
+ const char *name;
+ unsigned long size;
+} kmalloc_info[];
+
unsigned long calculate_alignment(unsigned long flags,
unsigned long align, unsigned long size);
@@ -78,7 +84,6 @@ unsigned long calculate_alignment(unsigned long flags,
/* Kmalloc array related functions */
void setup_kmalloc_cache_index_table(void);
void create_kmalloc_caches(unsigned long);
-const char *get_kmalloc_cache_name(int index);
/* Find the kmalloc slab corresponding for a certain size */
struct kmem_cache *kmalloc_slab(size_t, gfp_t);
diff --git a/mm/slab_common.c b/mm/slab_common.c
index 36a8547de699..be5dce23037d 100644
--- a/mm/slab_common.c
+++ b/mm/slab_common.c
@@ -917,10 +917,7 @@ struct kmem_cache *kmalloc_slab(size_t size, gfp_t flags)
* kmalloc_index() supports up to 2^26=64MB, so the final entry of the table is
* kmalloc-67108864.
*/
-static struct {
- const char *name;
- unsigned long size;
-} const kmalloc_info[] __initconst = {
+const struct kmalloc_info_struct kmalloc_info[] __initconst = {
{NULL, 0}, {"kmalloc-96", 96},
{"kmalloc-192", 192}, {"kmalloc-8", 8},
{"kmalloc-16", 16}, {"kmalloc-32", 32},
@@ -937,11 +934,6 @@ static struct {
{"kmalloc-67108864", 67108864}
};
-const char *get_kmalloc_cache_name(int index)
-{
- return kmalloc_info[index].name;
-}
-
/*
* Patch up the size_index table if we have strange large alignment
* requirements for the kmalloc array. This is only the case for
--
2.11.0
WARNING: multiple messages have this Message-ID
From: Vlastimil Babka <vbabka@suse.cz>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: kbuild test robot <lkp@intel.com>,
kbuild-all@01.org, linux-mm@kvack.org,
linux-kernel@vger.kernel.org,
Joonsoo Kim <iamjoonsoo.kim@lge.com>,
David Rientjes <rientjes@google.com>,
Pekka Enberg <penberg@kernel.org>,
Christoph Lameter <cl@linux.com>,
Matthew Wilcox <willy@linux.intel.com>
Subject: Re: [PATCH] mm, slab: rename kmalloc-node cache to kmalloc-<size>
Date: Thu, 9 Feb 2017 10:12:24 +0100 [thread overview]
Message-ID: <54e80303-b814-4232-66d4-95b34d3eb9d0@suse.cz> (raw)
In-Reply-To: <20170208135404.fa003c62eb6b75cefbe13d49@linux-foundation.org>
On 02/08/2017 10:54 PM, Andrew Morton wrote:
> On Wed, 8 Feb 2017 10:12:13 +0100 Vlastimil Babka <vbabka@suse.cz> wrote:
>
>> Thanks for the fix.
>>
>> I was going to implement Christoph's suggestion and export the whole structure
>> in mm/slab.h, but gcc was complaining that I'm redefining it, until I created a
>> typedef first. Is it worth the trouble? Below is how it would look like.
>>
>> ...
>>
>> --- a/mm/slab.h
>> +++ b/mm/slab.h
>> @@ -71,6 +71,13 @@ extern struct list_head slab_caches;
>> /* The slab cache that manages slab cache information */
>> extern struct kmem_cache *kmem_cache;
>>
>> +/* A table of kmalloc cache names and sizes */
>> +typedef struct {
>> + const char *name;
>> + unsigned long size;
>> +} kmalloc_info_t;
>> +extern const kmalloc_info_t kmalloc_info[];
>
> Why is the typedef needed? Can't we use something like
Duh, right, I can't C. Thanks.
----8<----
next prev parent reply other threads:[~2017-02-09 9:36 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-02-03 18:10 Vlastimil Babka
2017-02-03 18:10 ` Vlastimil Babka
2017-02-04 2:26 ` kbuild test robot
2017-02-04 2:26 ` kbuild test robot
2017-02-04 8:27 ` Vlastimil Babka
2017-02-04 8:27 ` Vlastimil Babka
2017-02-06 14:47 ` Christoph Lameter
2017-02-06 14:47 ` Christoph Lameter
2017-02-06 14:52 ` Matthew Wilcox
2017-02-06 14:52 ` Matthew Wilcox
2017-02-06 14:55 ` Christoph Lameter
2017-02-06 14:55 ` Christoph Lameter
2017-02-07 17:15 ` kbuild test robot
2017-02-07 17:15 ` kbuild test robot
2017-02-07 21:38 ` Andrew Morton
2017-02-07 21:38 ` Andrew Morton
2017-02-08 9:12 ` Vlastimil Babka
2017-02-08 9:12 ` Vlastimil Babka
2017-02-08 9:26 ` Vlastimil Babka
2017-02-08 9:26 ` Vlastimil Babka
2017-02-08 15:13 ` Christoph Lameter
2017-02-08 15:13 ` Christoph Lameter
2017-02-08 21:54 ` Andrew Morton
2017-02-08 21:54 ` Andrew Morton
2017-02-09 9:12 ` Vlastimil Babka [this message]
2017-02-09 9:12 ` Vlastimil Babka
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=54e80303-b814-4232-66d4-95b34d3eb9d0@suse.cz \
--to=vbabka@suse.cz \
--cc=akpm@linux-foundation.org \
--cc=cl@linux.com \
--cc=iamjoonsoo.kim@lge.com \
--cc=kbuild-all@01.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=lkp@intel.com \
--cc=penberg@kernel.org \
--cc=rientjes@google.com \
--cc=willy@linux.intel.com \
--subject='Re: [PATCH] mm, slab: rename kmalloc-node cache to kmalloc-<size>' \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.