All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] mm, slab: rename kmalloc-node cache to kmalloc-<size>
@ 2017-02-03 18:10 ` Vlastimil Babka
  0 siblings, 0 replies; 26+ messages in thread
From: Vlastimil Babka @ 2017-02-03 18:10 UTC (permalink / raw)
  To: Andrew Morton
  Cc: linux-mm, linux-kernel, Joonsoo Kim, David Rientjes,
	Pekka Enberg, Christoph Lameter, Vlastimil Babka

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

^ permalink raw reply	[flat|nested] 26+ messages in thread

* [PATCH] mm, slab: rename kmalloc-node cache to kmalloc-<size>
@ 2017-02-03 18:10 ` Vlastimil Babka
  0 siblings, 0 replies; 26+ messages in thread
From: Vlastimil Babka @ 2017-02-03 18:10 UTC (permalink / raw)
  To: Andrew Morton
  Cc: linux-mm, linux-kernel, Joonsoo Kim, David Rientjes,
	Pekka Enberg, Christoph Lameter, Vlastimil Babka

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

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH] mm, slab: rename kmalloc-node cache to kmalloc-<size>
  2017-02-03 18:10 ` Vlastimil Babka
@ 2017-02-04  2:26   ` kbuild test robot
  -1 siblings, 0 replies; 26+ messages in thread
From: kbuild test robot @ 2017-02-04  2:26 UTC (permalink / raw)
  To: Vlastimil Babka
  Cc: kbuild-all, Andrew Morton, linux-mm, linux-kernel, Joonsoo Kim,
	David Rientjes, Pekka Enberg, Christoph Lameter, Vlastimil Babka

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

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH] mm, slab: rename kmalloc-node cache to kmalloc-<size>
@ 2017-02-04  2:26   ` kbuild test robot
  0 siblings, 0 replies; 26+ messages in thread
From: kbuild test robot @ 2017-02-04  2:26 UTC (permalink / raw)
  To: Vlastimil Babka
  Cc: kbuild-all, Andrew Morton, linux-mm, linux-kernel, Joonsoo Kim,
	David Rientjes, Pekka Enberg, Christoph Lameter

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

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH] mm, slab: rename kmalloc-node cache to kmalloc-<size>
  2017-02-04  2:26   ` kbuild test robot
@ 2017-02-04  8:27     ` Vlastimil Babka
  -1 siblings, 0 replies; 26+ messages in thread
From: Vlastimil Babka @ 2017-02-04  8:27 UTC (permalink / raw)
  To: kbuild test robot, kbuild-all
  Cc: Andrew Morton, linux-mm, linux-kernel, Joonsoo Kim,
	David Rientjes, Pekka Enberg, Christoph Lameter

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
> 

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH] mm, slab: rename kmalloc-node cache to kmalloc-<size>
@ 2017-02-04  8:27     ` Vlastimil Babka
  0 siblings, 0 replies; 26+ messages in thread
From: Vlastimil Babka @ 2017-02-04  8:27 UTC (permalink / raw)
  To: kbuild test robot, kbuild-all
  Cc: Andrew Morton, linux-mm, linux-kernel, Joonsoo Kim,
	David Rientjes, Pekka Enberg, Christoph Lameter

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
> 

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH] mm, slab: rename kmalloc-node cache to kmalloc-<size>
  2017-02-03 18:10 ` Vlastimil Babka
@ 2017-02-06 14:47   ` Christoph Lameter
  -1 siblings, 0 replies; 26+ messages in thread
From: Christoph Lameter @ 2017-02-06 14:47 UTC (permalink / raw)
  To: Vlastimil Babka
  Cc: Andrew Morton, linux-mm, linux-kernel, Joonsoo Kim,
	David Rientjes, Pekka Enberg


Acked-by: Christoph Lameter <cl@linux.com>

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH] mm, slab: rename kmalloc-node cache to kmalloc-<size>
@ 2017-02-06 14:47   ` Christoph Lameter
  0 siblings, 0 replies; 26+ messages in thread
From: Christoph Lameter @ 2017-02-06 14:47 UTC (permalink / raw)
  To: Vlastimil Babka
  Cc: Andrew Morton, linux-mm, linux-kernel, Joonsoo Kim,
	David Rientjes, Pekka Enberg


Acked-by: Christoph Lameter <cl@linux.com>

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH] mm, slab: rename kmalloc-node cache to kmalloc-<size>
  2017-02-03 18:10 ` Vlastimil Babka
@ 2017-02-06 14:52   ` Matthew Wilcox
  -1 siblings, 0 replies; 26+ messages in thread
From: Matthew Wilcox @ 2017-02-06 14:52 UTC (permalink / raw)
  To: Vlastimil Babka
  Cc: Andrew Morton, linux-mm, linux-kernel, Joonsoo Kim,
	David Rientjes, Pekka Enberg, Christoph Lameter

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>

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH] mm, slab: rename kmalloc-node cache to kmalloc-<size>
@ 2017-02-06 14:52   ` Matthew Wilcox
  0 siblings, 0 replies; 26+ messages in thread
From: Matthew Wilcox @ 2017-02-06 14:52 UTC (permalink / raw)
  To: Vlastimil Babka
  Cc: Andrew Morton, linux-mm, linux-kernel, Joonsoo Kim,
	David Rientjes, Pekka Enberg, Christoph Lameter

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>

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH] mm, slab: rename kmalloc-node cache to kmalloc-<size>
  2017-02-06 14:52   ` Matthew Wilcox
@ 2017-02-06 14:55     ` Christoph Lameter
  -1 siblings, 0 replies; 26+ messages in thread
From: Christoph Lameter @ 2017-02-06 14:55 UTC (permalink / raw)
  To: Matthew Wilcox
  Cc: Vlastimil Babka, Andrew Morton, linux-mm, linux-kernel,
	Joonsoo Kim, David Rientjes, Pekka Enberg

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.

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH] mm, slab: rename kmalloc-node cache to kmalloc-<size>
@ 2017-02-06 14:55     ` Christoph Lameter
  0 siblings, 0 replies; 26+ messages in thread
From: Christoph Lameter @ 2017-02-06 14:55 UTC (permalink / raw)
  To: Matthew Wilcox
  Cc: Vlastimil Babka, Andrew Morton, linux-mm, linux-kernel,
	Joonsoo Kim, David Rientjes, Pekka Enberg

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.

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH] mm, slab: rename kmalloc-node cache to kmalloc-<size>
  2017-02-03 18:10 ` Vlastimil Babka
@ 2017-02-07 17:15   ` kbuild test robot
  -1 siblings, 0 replies; 26+ messages in thread
From: kbuild test robot @ 2017-02-07 17:15 UTC (permalink / raw)
  To: Vlastimil Babka
  Cc: kbuild-all, Andrew Morton, linux-mm, linux-kernel, Joonsoo Kim,
	David Rientjes, Pekka Enberg, Christoph Lameter, Vlastimil Babka

[-- Attachment #1: Type: text/plain, Size: 1346 bytes --]

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.

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 60245 bytes --]

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH] mm, slab: rename kmalloc-node cache to kmalloc-<size>
@ 2017-02-07 17:15   ` kbuild test robot
  0 siblings, 0 replies; 26+ messages in thread
From: kbuild test robot @ 2017-02-07 17:15 UTC (permalink / raw)
  To: Vlastimil Babka
  Cc: kbuild-all, Andrew Morton, linux-mm, linux-kernel, Joonsoo Kim,
	David Rientjes, Pekka Enberg, Christoph Lameter

[-- Attachment #1: Type: text/plain, Size: 1346 bytes --]

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.

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 60245 bytes --]

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH] mm, slab: rename kmalloc-node cache to kmalloc-<size>
  2017-02-07 17:15   ` kbuild test robot
@ 2017-02-07 21:38     ` Andrew Morton
  -1 siblings, 0 replies; 26+ messages in thread
From: Andrew Morton @ 2017-02-07 21:38 UTC (permalink / raw)
  To: kbuild test robot
  Cc: Vlastimil Babka, kbuild-all, linux-mm, linux-kernel, Joonsoo Kim,
	David Rientjes, Pekka Enberg, Christoph Lameter

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;
 }
_

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH] mm, slab: rename kmalloc-node cache to kmalloc-<size>
@ 2017-02-07 21:38     ` Andrew Morton
  0 siblings, 0 replies; 26+ messages in thread
From: Andrew Morton @ 2017-02-07 21:38 UTC (permalink / raw)
  To: kbuild test robot
  Cc: Vlastimil Babka, kbuild-all, linux-mm, linux-kernel, Joonsoo Kim,
	David Rientjes, Pekka Enberg, Christoph Lameter

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;
 }
_

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH] mm, slab: rename kmalloc-node cache to kmalloc-<size>
  2017-02-07 21:38     ` Andrew Morton
@ 2017-02-08  9:12       ` Vlastimil Babka
  -1 siblings, 0 replies; 26+ messages in thread
From: Vlastimil Babka @ 2017-02-08  9:12 UTC (permalink / raw)
  To: Andrew Morton, kbuild test robot
  Cc: kbuild-all, linux-mm, linux-kernel, Joonsoo Kim, David Rientjes,
	Pekka Enberg, Christoph Lameter, Matthew Wilcox

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

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH] mm, slab: rename kmalloc-node cache to kmalloc-<size>
@ 2017-02-08  9:12       ` Vlastimil Babka
  0 siblings, 0 replies; 26+ messages in thread
From: Vlastimil Babka @ 2017-02-08  9:12 UTC (permalink / raw)
  To: Andrew Morton, kbuild test robot
  Cc: kbuild-all, linux-mm, linux-kernel, Joonsoo Kim, David Rientjes,
	Pekka Enberg, Christoph Lameter, Matthew Wilcox

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

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH] mm, slab: rename kmalloc-node cache to kmalloc-<size>
  2017-02-08  9:12       ` Vlastimil Babka
@ 2017-02-08  9:26         ` Vlastimil Babka
  -1 siblings, 0 replies; 26+ messages in thread
From: Vlastimil Babka @ 2017-02-08  9:26 UTC (permalink / raw)
  To: Andrew Morton, kbuild test robot
  Cc: kbuild-all, linux-mm, linux-kernel, Joonsoo Kim, David Rientjes,
	Pekka Enberg, Christoph Lameter, Matthew Wilcox

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
>

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH] mm, slab: rename kmalloc-node cache to kmalloc-<size>
@ 2017-02-08  9:26         ` Vlastimil Babka
  0 siblings, 0 replies; 26+ messages in thread
From: Vlastimil Babka @ 2017-02-08  9:26 UTC (permalink / raw)
  To: Andrew Morton, kbuild test robot
  Cc: kbuild-all, linux-mm, linux-kernel, Joonsoo Kim, David Rientjes,
	Pekka Enberg, Christoph Lameter, Matthew Wilcox

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
>

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH] mm, slab: rename kmalloc-node cache to kmalloc-<size>
  2017-02-08  9:12       ` Vlastimil Babka
@ 2017-02-08 15:13         ` Christoph Lameter
  -1 siblings, 0 replies; 26+ messages in thread
From: Christoph Lameter @ 2017-02-08 15:13 UTC (permalink / raw)
  To: Vlastimil Babka
  Cc: Andrew Morton, kbuild test robot, kbuild-all, linux-mm,
	linux-kernel, Joonsoo Kim, David Rientjes, Pekka Enberg,
	Matthew Wilcox

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.

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH] mm, slab: rename kmalloc-node cache to kmalloc-<size>
@ 2017-02-08 15:13         ` Christoph Lameter
  0 siblings, 0 replies; 26+ messages in thread
From: Christoph Lameter @ 2017-02-08 15:13 UTC (permalink / raw)
  To: Vlastimil Babka
  Cc: Andrew Morton, kbuild test robot, kbuild-all, linux-mm,
	linux-kernel, Joonsoo Kim, David Rientjes, Pekka Enberg,
	Matthew Wilcox

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.

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH] mm, slab: rename kmalloc-node cache to kmalloc-<size>
  2017-02-08  9:12       ` Vlastimil Babka
@ 2017-02-08 21:54         ` Andrew Morton
  -1 siblings, 0 replies; 26+ messages in thread
From: Andrew Morton @ 2017-02-08 21:54 UTC (permalink / raw)
  To: Vlastimil Babka
  Cc: kbuild test robot, kbuild-all, linux-mm, linux-kernel,
	Joonsoo Kim, David Rientjes, Pekka Enberg, Christoph Lameter,
	Matthew Wilcox

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}
};

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH] mm, slab: rename kmalloc-node cache to kmalloc-<size>
@ 2017-02-08 21:54         ` Andrew Morton
  0 siblings, 0 replies; 26+ messages in thread
From: Andrew Morton @ 2017-02-08 21:54 UTC (permalink / raw)
  To: Vlastimil Babka
  Cc: kbuild test robot, kbuild-all, linux-mm, linux-kernel,
	Joonsoo Kim, David Rientjes, Pekka Enberg, Christoph Lameter,
	Matthew Wilcox

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}
};

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH] mm, slab: rename kmalloc-node cache to kmalloc-<size>
  2017-02-08 21:54         ` Andrew Morton
@ 2017-02-09  9:12           ` Vlastimil Babka
  -1 siblings, 0 replies; 26+ messages in thread
From: Vlastimil Babka @ 2017-02-09  9:12 UTC (permalink / raw)
  To: Andrew Morton
  Cc: kbuild test robot, kbuild-all, linux-mm, linux-kernel,
	Joonsoo Kim, David Rientjes, Pekka Enberg, Christoph Lameter,
	Matthew Wilcox

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

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH] mm, slab: rename kmalloc-node cache to kmalloc-<size>
@ 2017-02-09  9:12           ` Vlastimil Babka
  0 siblings, 0 replies; 26+ messages in thread
From: Vlastimil Babka @ 2017-02-09  9:12 UTC (permalink / raw)
  To: Andrew Morton
  Cc: kbuild test robot, kbuild-all, linux-mm, linux-kernel,
	Joonsoo Kim, David Rientjes, Pekka Enberg, Christoph Lameter,
	Matthew Wilcox

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<----

^ permalink raw reply	[flat|nested] 26+ messages in thread

end of thread, other threads:[~2017-02-09  9:36 UTC | newest]

Thread overview: 26+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-02-03 18:10 [PATCH] mm, slab: rename kmalloc-node cache to kmalloc-<size> 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
2017-02-09  9:12           ` Vlastimil Babka

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.