Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1573344 > unrolled thread
| Started by | Vlastimil Babka <vbabka@suse.cz> |
|---|---|
| First post | 2017-02-03 19:20 +0100 |
| Last post | 2017-02-09 10:40 +0100 |
| Articles | 12 — 5 participants |
Back to article view | Back to linux.kernel
[PATCH] mm, slab: rename kmalloc-node cache to kmalloc-<size> Vlastimil Babka <vbabka@suse.cz> - 2017-02-03 19:20 +0100
Re: [PATCH] mm, slab: rename kmalloc-node cache to kmalloc-<size> kbuild test robot <lkp@intel.com> - 2017-02-04 03:30 +0100
Re: [PATCH] mm, slab: rename kmalloc-node cache to kmalloc-<size> Vlastimil Babka <vbabka@suse.cz> - 2017-02-04 09:30 +0100
Re: [PATCH] mm, slab: rename kmalloc-node cache to kmalloc-<size> Christoph Lameter <cl@linux.com> - 2017-02-06 15:50 +0100
Re: [PATCH] mm, slab: rename kmalloc-node cache to kmalloc-<size> Matthew Wilcox <willy@infradead.org> - 2017-02-06 16:00 +0100
Re: [PATCH] mm, slab: rename kmalloc-node cache to kmalloc-<size> Christoph Lameter <cl@linux.com> - 2017-02-06 16:00 +0100
Re: [PATCH] mm, slab: rename kmalloc-node cache to kmalloc-<size> Andrew Morton <akpm@linux-foundation.org> - 2017-02-07 22:50 +0100
Re: [PATCH] mm, slab: rename kmalloc-node cache to kmalloc-<size> Vlastimil Babka <vbabka@suse.cz> - 2017-02-08 10:20 +0100
Re: [PATCH] mm, slab: rename kmalloc-node cache to kmalloc-<size> Vlastimil Babka <vbabka@suse.cz> - 2017-02-08 10:50 +0100
Re: [PATCH] mm, slab: rename kmalloc-node cache to kmalloc-<size> Christoph Lameter <cl@linux.com> - 2017-02-08 16:30 +0100
Re: [PATCH] mm, slab: rename kmalloc-node cache to kmalloc-<size> Andrew Morton <akpm@linux-foundation.org> - 2017-02-08 23:00 +0100
Re: [PATCH] mm, slab: rename kmalloc-node cache to kmalloc-<size> Vlastimil Babka <vbabka@suse.cz> - 2017-02-09 10:40 +0100
| From | Vlastimil Babka <vbabka@suse.cz> |
|---|---|
| Date | 2017-02-03 19:20 +0100 |
| Subject | [PATCH] mm, slab: rename kmalloc-node cache to kmalloc-<size> |
| Message-ID | <t6QCK-5b2-9@gated-at.bofh.it> |
SLAB as part of its bootstrap pre-creates one kmalloc cache that can fit the
kmem_cache_node management structure, and puts it into the generic kmalloc
cache array (e.g. for 128b objects). The name of this cache is "kmalloc-node",
which is confusing for readers of /proc/slabinfo as the cache is used for
generic allocations (and not just the kmem_cache_node struct) and it appears as
the kmalloc-128 cache is missing.
An easy solution is to use the kmalloc-<size> name when pre-creating the cache,
which we can get from the kmalloc_info array.
Example /proc/slabinfo before the patch:
...
kmalloc-256 1647 1984 256 16 1 : tunables 120 60 8 : slabdata 124 124 828
kmalloc-192 1974 1974 192 21 1 : tunables 120 60 8 : slabdata 94 94 133
kmalloc-96 1332 1344 128 32 1 : tunables 120 60 8 : slabdata 42 42 219
kmalloc-64 2505 5952 64 64 1 : tunables 120 60 8 : slabdata 93 93 715
kmalloc-32 4278 4464 32 124 1 : tunables 120 60 8 : slabdata 36 36 346
kmalloc-node 1352 1376 128 32 1 : tunables 120 60 8 : slabdata 43 43 53
kmem_cache 132 147 192 21 1 : tunables 120 60 8 : slabdata 7 7 0
After the patch:
...
kmalloc-256 1672 2160 256 16 1 : tunables 120 60 8 : slabdata 135 135 807
kmalloc-192 1992 2016 192 21 1 : tunables 120 60 8 : slabdata 96 96 203
kmalloc-96 1159 1184 128 32 1 : tunables 120 60 8 : slabdata 37 37 116
kmalloc-64 2561 4864 64 64 1 : tunables 120 60 8 : slabdata 76 76 785
kmalloc-32 4253 4340 32 124 1 : tunables 120 60 8 : slabdata 35 35 270
kmalloc-128 1256 1280 128 32 1 : tunables 120 60 8 : slabdata 40 40 39
kmem_cache 125 147 192 21 1 : tunables 120 60 8 : slabdata 7 7 0
Signed-off-by: Vlastimil Babka <vbabka@suse.cz>
---
mm/slab.c | 3 ++-
mm/slab.h | 1 +
mm/slab_common.c | 5 +++++
3 files changed, 8 insertions(+), 1 deletion(-)
diff --git a/mm/slab.c b/mm/slab.c
index a95fd4fed0a8..ede31b59bb9f 100644
--- a/mm/slab.c
+++ b/mm/slab.c
@@ -1293,7 +1293,8 @@ void __init kmem_cache_init(void)
* Initialize the caches that provide memory for the kmem_cache_node
* structures first. Without this, further allocations will bug.
*/
- kmalloc_caches[INDEX_NODE] = create_kmalloc_cache("kmalloc-node",
+ kmalloc_caches[INDEX_NODE] = create_kmalloc_cache(
+ get_kmalloc_cache_name(INDEX_NODE),
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 de6579dc362c..5708c548c6f7 100644
--- a/mm/slab.h
+++ b/mm/slab.h
@@ -78,6 +78,7 @@ 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 1dfc209431f2..36a8547de699 100644
--- a/mm/slab_common.c
+++ b/mm/slab_common.c
@@ -937,6 +937,11 @@ 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
[toc] | [next] | [standalone]
| From | kbuild test robot <lkp@intel.com> |
|---|---|
| Date | 2017-02-04 03:30 +0100 |
| Message-ID | <t6YgW-2gd-13@gated-at.bofh.it> |
| In reply to | #1573344 |
Hi Vlastimil,
[auto build test WARNING on mmotm/master]
[also build test WARNING on v4.10-rc6]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
url: https://github.com/0day-ci/linux/commits/Vlastimil-Babka/mm-slab-rename-kmalloc-node-cache-to-kmalloc-size/20170204-021843
base: git://git.cmpxchg.org/linux-mmotm.git master
config: i386-allmodconfig
compiler: gcc-6 (Debian 6.2.0-3) 6.2.0 20160901
reproduce:
make ARCH=i386 allmodconfig
make ARCH=i386
All warnings (new ones prefixed by >>):
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
[toc] | [prev] | [next] | [standalone]
| From | Vlastimil Babka <vbabka@suse.cz> |
|---|---|
| Date | 2017-02-04 09:30 +0100 |
| Message-ID | <t73Tj-6cb-7@gated-at.bofh.it> |
| In reply to | #1573577 |
On 4.2.2017 3:26, kbuild test robot wrote: > Hi Vlastimil, > > [auto build test WARNING on mmotm/master] > [also build test WARNING on v4.10-rc6] > [if your patch is applied to the wrong git tree, please drop us a note to help improve the system] Hi, there are no warnings below? Vlastimil > > url: https://github.com/0day-ci/linux/commits/Vlastimil-Babka/mm-slab-rename-kmalloc-node-cache-to-kmalloc-size/20170204-021843 > base: git://git.cmpxchg.org/linux-mmotm.git master > config: i386-allmodconfig > compiler: gcc-6 (Debian 6.2.0-3) 6.2.0 20160901 > reproduce: > make ARCH=i386 allmodconfig > make ARCH=i386 > > All warnings (new ones prefixed by >>): > > --- > 0-DAY kernel test infrastructure Open Source Technology Center > https://lists.01.org/pipermail/kbuild-all Intel Corporation >
[toc] | [prev] | [next] | [standalone]
| From | Christoph Lameter <cl@linux.com> |
|---|---|
| Date | 2017-02-06 15:50 +0100 |
| Message-ID | <t7SMa-6cu-27@gated-at.bofh.it> |
| In reply to | #1573344 |
Acked-by: Christoph Lameter <cl@linux.com>
[toc] | [prev] | [next] | [standalone]
| From | Matthew Wilcox <willy@infradead.org> |
|---|---|
| Date | 2017-02-06 16:00 +0100 |
| Message-ID | <t7SVP-6g8-9@gated-at.bofh.it> |
| In reply to | #1573344 |
On Fri, Feb 03, 2017 at 07:10:08PM +0100, Vlastimil Babka wrote:
> diff --git a/mm/slab.c b/mm/slab.c
> index a95fd4fed0a8..ede31b59bb9f 100644
> --- a/mm/slab.c
> +++ b/mm/slab.c
> @@ -1293,7 +1293,8 @@ void __init kmem_cache_init(void)
> * Initialize the caches that provide memory for the kmem_cache_node
> * structures first. Without this, further allocations will bug.
> */
> - kmalloc_caches[INDEX_NODE] = create_kmalloc_cache("kmalloc-node",
> + kmalloc_caches[INDEX_NODE] = create_kmalloc_cache(
> + get_kmalloc_cache_name(INDEX_NODE),
Could we lose the 'get_' from the front? I think 'kmalloc_cache_name()' is
just as informative.
Reviewed-by: Matthew Wilcox <mawilcox@microsoft.com>
[toc] | [prev] | [next] | [standalone]
| From | Christoph Lameter <cl@linux.com> |
|---|---|
| Date | 2017-02-06 16:00 +0100 |
| Message-ID | <t7SVP-6g8-13@gated-at.bofh.it> |
| In reply to | #1574865 |
On Mon, 6 Feb 2017, Matthew Wilcox wrote: > Could we lose the 'get_' from the front? I think 'kmalloc_cache_name()' is > just as informative. Hmmm.. Expose the static array in mm/slab.h instead? There may be other cases in which the allocator specific code may need that information.
[toc] | [prev] | [next] | [standalone]
| From | Andrew Morton <akpm@linux-foundation.org> |
|---|---|
| Date | 2017-02-07 22:50 +0100 |
| Message-ID | <t8lO9-8hG-7@gated-at.bofh.it> |
| In reply to | #1573344 |
On Wed, 8 Feb 2017 01:15:17 +0800 kbuild test robot <lkp@intel.com> wrote:
> Hi Vlastimil,
>
> [auto build test WARNING on mmotm/master]
> [also build test WARNING on v4.10-rc7 next-20170207]
> [if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
>
> url: https://github.com/0day-ci/linux/commits/Vlastimil-Babka/mm-slab-rename-kmalloc-node-cache-to-kmalloc-size/20170204-021843
> base: git://git.cmpxchg.org/linux-mmotm.git master
> config: arm-allyesconfig (attached as .config)
> compiler: arm-linux-gnueabi-gcc (Debian 6.1.1-9) 6.1.1 20160705
> reproduce:
> wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross
> chmod +x ~/bin/make.cross
> # save the attached .config to linux build tree
> make.cross ARCH=arm
>
> All warnings (new ones prefixed by >>):
>
> >> WARNING: mm/built-in.o(.text+0x3b49c): Section mismatch in reference from the function get_kmalloc_cache_name() to the (unknown reference) .init.rodata:(unknown)
> The function get_kmalloc_cache_name() references
> the (unknown reference) __initconst (unknown).
> This is often because get_kmalloc_cache_name lacks a __initconst
> annotation or the annotation of (unknown) is wrong.
yup, thanks.
--- a/mm/slab_common.c~mm-slab-rename-kmalloc-node-cache-to-kmalloc-size-fix
+++ a/mm/slab_common.c
@@ -935,7 +935,7 @@ static struct {
{"kmalloc-67108864", 67108864}
};
-const char *get_kmalloc_cache_name(int index)
+const char * __init get_kmalloc_cache_name(int index)
{
return kmalloc_info[index].name;
}
_
[toc] | [prev] | [next] | [standalone]
| From | Vlastimil Babka <vbabka@suse.cz> |
|---|---|
| Date | 2017-02-08 10:20 +0100 |
| Message-ID | <t8wzU-6Sa-21@gated-at.bofh.it> |
| In reply to | #1576080 |
On 02/07/2017 10:38 PM, Andrew Morton wrote:
> On Wed, 8 Feb 2017 01:15:17 +0800 kbuild test robot <lkp@intel.com> wrote:
>
>> Hi Vlastimil,
>>
>> [auto build test WARNING on mmotm/master]
>> [also build test WARNING on v4.10-rc7 next-20170207]
>> [if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
>>
>> url: https://github.com/0day-ci/linux/commits/Vlastimil-Babka/mm-slab-rename-kmalloc-node-cache-to-kmalloc-size/20170204-021843
>> base: git://git.cmpxchg.org/linux-mmotm.git master
>> config: arm-allyesconfig (attached as .config)
>> compiler: arm-linux-gnueabi-gcc (Debian 6.1.1-9) 6.1.1 20160705
>> reproduce:
>> wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross
>> chmod +x ~/bin/make.cross
>> # save the attached .config to linux build tree
>> make.cross ARCH=arm
>>
>> All warnings (new ones prefixed by >>):
>>
>> >> WARNING: mm/built-in.o(.text+0x3b49c): Section mismatch in reference from the function get_kmalloc_cache_name() to the (unknown reference) .init.rodata:(unknown)
>> The function get_kmalloc_cache_name() references
>> the (unknown reference) __initconst (unknown).
>> This is often because get_kmalloc_cache_name lacks a __initconst
>> annotation or the annotation of (unknown) is wrong.
>
> yup, thanks.
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.
Vlastimil
----8<----
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..e6b4cf74be86 100644
--- 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[];
+
unsigned long calculate_alignment(unsigned long flags,
unsigned long align, unsigned long size);
@@ -78,7 +85,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..ab3872ed623e 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 kmalloc_info_t 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
[toc] | [prev] | [next] | [standalone]
| From | Vlastimil Babka <vbabka@suse.cz> |
|---|---|
| Date | 2017-02-08 10:50 +0100 |
| Message-ID | <t8x2W-74c-3@gated-at.bofh.it> |
| In reply to | #1576378 |
Sorry, used old Willy's address.
On 02/08/2017 10:12 AM, Vlastimil Babka wrote:
> On 02/07/2017 10:38 PM, Andrew Morton wrote:
>> On Wed, 8 Feb 2017 01:15:17 +0800 kbuild test robot <lkp@intel.com> wrote:
>>
>>> Hi Vlastimil,
>>>
>>> [auto build test WARNING on mmotm/master]
>>> [also build test WARNING on v4.10-rc7 next-20170207]
>>> [if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
>>>
>>> url: https://github.com/0day-ci/linux/commits/Vlastimil-Babka/mm-slab-rename-kmalloc-node-cache-to-kmalloc-size/20170204-021843
>>> base: git://git.cmpxchg.org/linux-mmotm.git master
>>> config: arm-allyesconfig (attached as .config)
>>> compiler: arm-linux-gnueabi-gcc (Debian 6.1.1-9) 6.1.1 20160705
>>> reproduce:
>>> wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross
>>> chmod +x ~/bin/make.cross
>>> # save the attached .config to linux build tree
>>> make.cross ARCH=arm
>>>
>>> All warnings (new ones prefixed by >>):
>>>
>>> >> WARNING: mm/built-in.o(.text+0x3b49c): Section mismatch in reference from the function get_kmalloc_cache_name() to the (unknown reference) .init.rodata:(unknown)
>>> The function get_kmalloc_cache_name() references
>>> the (unknown reference) __initconst (unknown).
>>> This is often because get_kmalloc_cache_name lacks a __initconst
>>> annotation or the annotation of (unknown) is wrong.
>>
>> yup, thanks.
>
> 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.
>
> Vlastimil
>
> ----8<----
> 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..e6b4cf74be86 100644
> --- 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[];
> +
> unsigned long calculate_alignment(unsigned long flags,
> unsigned long align, unsigned long size);
>
> @@ -78,7 +85,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..ab3872ed623e 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 kmalloc_info_t 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
>
[toc] | [prev] | [next] | [standalone]
| From | Christoph Lameter <cl@linux.com> |
|---|---|
| Date | 2017-02-08 16:30 +0100 |
| Message-ID | <t8ClY-20B-29@gated-at.bofh.it> |
| In reply to | #1576378 |
On Wed, 8 Feb 2017, Vlastimil Babka wrote: > 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. Looks good to me.
[toc] | [prev] | [next] | [standalone]
| From | Andrew Morton <akpm@linux-foundation.org> |
|---|---|
| Date | 2017-02-08 23:00 +0100 |
| Message-ID | <t8Iro-5Hm-19@gated-at.bofh.it> |
| In reply to | #1576378 |
On Wed, 8 Feb 2017 10:12:13 +0100 Vlastimil Babka <vbabka@suse.cz> wrote:
> On 02/07/2017 10:38 PM, Andrew Morton wrote:
> > On Wed, 8 Feb 2017 01:15:17 +0800 kbuild test robot <lkp@intel.com> wrote:
> >
> >> Hi Vlastimil,
> >>
> >> [auto build test WARNING on mmotm/master]
> >> [also build test WARNING on v4.10-rc7 next-20170207]
> >> [if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
> >>
> >> url: https://github.com/0day-ci/linux/commits/Vlastimil-Babka/mm-slab-rename-kmalloc-node-cache-to-kmalloc-size/20170204-021843
> >> base: git://git.cmpxchg.org/linux-mmotm.git master
> >> config: arm-allyesconfig (attached as .config)
> >> compiler: arm-linux-gnueabi-gcc (Debian 6.1.1-9) 6.1.1 20160705
> >> reproduce:
> >> wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross
> >> chmod +x ~/bin/make.cross
> >> # save the attached .config to linux build tree
> >> make.cross ARCH=arm
> >>
> >> All warnings (new ones prefixed by >>):
> >>
> >> >> WARNING: mm/built-in.o(.text+0x3b49c): Section mismatch in reference from the function get_kmalloc_cache_name() to the (unknown reference) .init.rodata:(unknown)
> >> The function get_kmalloc_cache_name() references
> >> the (unknown reference) __initconst (unknown).
> >> This is often because get_kmalloc_cache_name lacks a __initconst
> >> annotation or the annotation of (unknown) is wrong.
> >
> > yup, thanks.
>
> 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
extern const struct kmalloc_info_struct {
const char *name;
unsigned long size;
} kmalloc_info[];
...
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},
...
{"kmalloc-67108864", 67108864}
};
[toc] | [prev] | [next] | [standalone]
| From | Vlastimil Babka <vbabka@suse.cz> |
|---|---|
| Date | 2017-02-09 10:40 +0100 |
| Message-ID | <t8TmN-4qm-1@gated-at.bofh.it> |
| In reply to | #1577134 |
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
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web