linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mm, slab: Use kmem_cache_zalloc() instead of kmem_cache_alloc() with flag GFP_ZERO.
@ 2020-06-17  7:15 Yi Wang
  2020-06-17 10:43 ` Vlastimil Babka
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Yi Wang @ 2020-06-17  7:15 UTC (permalink / raw)
  To: cl
  Cc: penberg, rientjes, iamjoonsoo.kim, akpm, linux-mm, linux-kernel,
	xue.zhihong, wang.yi59, wang.liang82, Liao Pingfang

From: Liao Pingfang <liao.pingfang@zte.com.cn>

Use kmem_cache_zalloc instead of manually calling kmem_cache_alloc
with flag GFP_ZERO.

Signed-off-by: Liao Pingfang <liao.pingfang@zte.com.cn>
---
 include/linux/slab.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/linux/slab.h b/include/linux/slab.h
index 6d45488..1fa62d9 100644
--- a/include/linux/slab.h
+++ b/include/linux/slab.h
@@ -656,7 +656,7 @@ extern void *__kmalloc_node_track_caller(size_t, gfp_t, int, unsigned long);
  */
 static inline void *kmem_cache_zalloc(struct kmem_cache *k, gfp_t flags)
 {
-	return kmem_cache_alloc(k, flags | __GFP_ZERO);
+	return kmem_cache_zalloc(k, flags);
 }
 
 /**
-- 
2.9.5



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

* Re: [PATCH] mm, slab: Use kmem_cache_zalloc() instead of kmem_cache_alloc() with flag GFP_ZERO.
  2020-06-17  7:15 [PATCH] mm, slab: Use kmem_cache_zalloc() instead of kmem_cache_alloc() with flag GFP_ZERO Yi Wang
@ 2020-06-17 10:43 ` Vlastimil Babka
  2020-06-17 11:18 ` kernel test robot
  2020-06-17 23:40 ` kernel test robot
  2 siblings, 0 replies; 4+ messages in thread
From: Vlastimil Babka @ 2020-06-17 10:43 UTC (permalink / raw)
  To: Yi Wang, cl
  Cc: penberg, rientjes, iamjoonsoo.kim, akpm, linux-mm, linux-kernel,
	xue.zhihong, wang.liang82, Liao Pingfang

On 6/17/20 9:15 AM, Yi Wang wrote:
> From: Liao Pingfang <liao.pingfang@zte.com.cn>
> 
> Use kmem_cache_zalloc instead of manually calling kmem_cache_alloc
> with flag GFP_ZERO.
> 
> Signed-off-by: Liao Pingfang <liao.pingfang@zte.com.cn>
> ---
>  include/linux/slab.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/include/linux/slab.h b/include/linux/slab.h
> index 6d45488..1fa62d9 100644
> --- a/include/linux/slab.h
> +++ b/include/linux/slab.h
> @@ -656,7 +656,7 @@ extern void *__kmalloc_node_track_caller(size_t, gfp_t, int, unsigned long);
>   */
>  static inline void *kmem_cache_zalloc(struct kmem_cache *k, gfp_t flags)
>  {
> -	return kmem_cache_alloc(k, flags | __GFP_ZERO);
> +	return kmem_cache_zalloc(k, flags);

Did you test this patch?

>  }
>  
>  /**
> 



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

* Re: [PATCH] mm, slab: Use kmem_cache_zalloc() instead of kmem_cache_alloc() with flag GFP_ZERO.
  2020-06-17  7:15 [PATCH] mm, slab: Use kmem_cache_zalloc() instead of kmem_cache_alloc() with flag GFP_ZERO Yi Wang
  2020-06-17 10:43 ` Vlastimil Babka
@ 2020-06-17 11:18 ` kernel test robot
  2020-06-17 23:40 ` kernel test robot
  2 siblings, 0 replies; 4+ messages in thread
From: kernel test robot @ 2020-06-17 11:18 UTC (permalink / raw)
  To: Yi Wang, cl
  Cc: kbuild-all, penberg, rientjes, iamjoonsoo.kim, akpm, linux-mm,
	linux-kernel, xue.zhihong, wang.yi59, wang.liang82

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

Hi Yi,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on mmotm/master]

url:    https://github.com/0day-ci/linux/commits/Yi-Wang/mm-slab-Use-kmem_cache_zalloc-instead-of-kmem_cache_alloc-with-flag-GFP_ZERO/20200617-151513
base:   git://git.cmpxchg.org/linux-mmotm.git master
config: nds32-defconfig (attached as .config)
compiler: nds32le-linux-gcc (GCC) 9.3.0
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=nds32 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All errors (new ones prefixed by >>, old ones prefixed by <<):

In file included from include/linux/irq.h:21,
from include/asm-generic/hardirq.h:13,
from ./arch/nds32/include/generated/asm/hardirq.h:1,
from include/linux/hardirq.h:9,
from include/linux/highmem.h:10,
from include/linux/pagemap.h:11,
from fs//crypto/crypto.c:23:
include/linux/slab.h: In function 'kmem_cache_zalloc':
>> include/linux/slab.h:678:21: error: inlining failed in call to always_inline 'kmem_cache_zalloc': recursive inlining
678 | static inline void *kmem_cache_zalloc(struct kmem_cache *k, gfp_t flags)
|                     ^~~~~~~~~~~~~~~~~
include/linux/slab.h:680:9: note: called from here
680 |  return kmem_cache_zalloc(k, flags);
|         ^~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/slab.h: In function 'fscrypt_get_ctx':
>> include/linux/slab.h:678:21: error: inlining failed in call to always_inline 'kmem_cache_zalloc': recursive inlining
678 | static inline void *kmem_cache_zalloc(struct kmem_cache *k, gfp_t flags)
|                     ^~~~~~~~~~~~~~~~~
include/linux/slab.h:680:9: note: called from here
680 |  return kmem_cache_zalloc(k, flags);
|         ^~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/slab.h: In function 'fscrypt_initialize':
>> include/linux/slab.h:678:21: error: inlining failed in call to always_inline 'kmem_cache_zalloc': recursive inlining
678 | static inline void *kmem_cache_zalloc(struct kmem_cache *k, gfp_t flags)
|                     ^~~~~~~~~~~~~~~~~
include/linux/slab.h:680:9: note: called from here
680 |  return kmem_cache_zalloc(k, flags);
|         ^~~~~~~~~~~~~~~~~~~~~~~~~~~
--
In file included from include/linux/irq.h:21,
from include/asm-generic/hardirq.h:13,
from ./arch/nds32/include/generated/asm/hardirq.h:1,
from include/linux/hardirq.h:9,
from include/linux/highmem.h:10,
from include/linux/pagemap.h:11,
from fs//ext4/page-io.c:13:
include/linux/slab.h: In function 'kmem_cache_zalloc':
>> include/linux/slab.h:678:21: error: inlining failed in call to always_inline 'kmem_cache_zalloc': recursive inlining
678 | static inline void *kmem_cache_zalloc(struct kmem_cache *k, gfp_t flags)
|                     ^~~~~~~~~~~~~~~~~
include/linux/slab.h:680:9: note: called from here
680 |  return kmem_cache_zalloc(k, flags);
|         ^~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/slab.h: In function 'ext4_init_io_end':
>> include/linux/slab.h:678:21: error: inlining failed in call to always_inline 'kmem_cache_zalloc': recursive inlining
678 | static inline void *kmem_cache_zalloc(struct kmem_cache *k, gfp_t flags)
|                     ^~~~~~~~~~~~~~~~~
include/linux/slab.h:680:9: note: called from here
680 |  return kmem_cache_zalloc(k, flags);
|         ^~~~~~~~~~~~~~~~~~~~~~~~~~~
--
In file included from include/linux/genhd.h:16,
from include/linux/blkdev.h:11,
from include/linux/backing-dev.h:15,
from fs//fuse/fuse_i.h:23,
from fs//fuse/dev.c:9:
include/linux/slab.h: In function 'kmem_cache_zalloc':
>> include/linux/slab.h:678:21: error: inlining failed in call to always_inline 'kmem_cache_zalloc': recursive inlining
678 | static inline void *kmem_cache_zalloc(struct kmem_cache *k, gfp_t flags)
|                     ^~~~~~~~~~~~~~~~~
include/linux/slab.h:680:9: note: called from here
680 |  return kmem_cache_zalloc(k, flags);
|         ^~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/slab.h: In function '__fuse_request_alloc':
>> include/linux/slab.h:678:21: error: inlining failed in call to always_inline 'kmem_cache_zalloc': recursive inlining
678 | static inline void *kmem_cache_zalloc(struct kmem_cache *k, gfp_t flags)
|                     ^~~~~~~~~~~~~~~~~
include/linux/slab.h:680:9: note: called from here
680 |  return kmem_cache_zalloc(k, flags);
|         ^~~~~~~~~~~~~~~~~~~~~~~~~~~
--
In file included from include/linux/irq.h:21,
from include/asm-generic/hardirq.h:13,
from ./arch/nds32/include/generated/asm/hardirq.h:1,
from include/linux/hardirq.h:9,
from include/linux/highmem.h:10,
from include/linux/pagemap.h:11,
from include/linux/buffer_head.h:14,
from include/linux/jbd2.h:23,
from fs//jbd2/transaction.c:19:
include/linux/slab.h: In function 'kmem_cache_zalloc':
>> include/linux/slab.h:678:21: error: inlining failed in call to always_inline 'kmem_cache_zalloc': recursive inlining
678 | static inline void *kmem_cache_zalloc(struct kmem_cache *k, gfp_t flags)
|                     ^~~~~~~~~~~~~~~~~
include/linux/slab.h:680:9: note: called from here
680 |  return kmem_cache_zalloc(k, flags);
|         ^~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/slab.h: In function 'start_this_handle':
>> include/linux/slab.h:678:21: error: inlining failed in call to always_inline 'kmem_cache_zalloc': recursive inlining
678 | static inline void *kmem_cache_zalloc(struct kmem_cache *k, gfp_t flags)
|                     ^~~~~~~~~~~~~~~~~
include/linux/slab.h:680:9: note: called from here
680 |  return kmem_cache_zalloc(k, flags);
|         ^~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/slab.h: In function 'jbd2__journal_start':
>> include/linux/slab.h:678:21: error: inlining failed in call to always_inline 'kmem_cache_zalloc': recursive inlining
678 | static inline void *kmem_cache_zalloc(struct kmem_cache *k, gfp_t flags)
|                     ^~~~~~~~~~~~~~~~~
include/linux/slab.h:680:9: note: called from here
680 |  return kmem_cache_zalloc(k, flags);
|         ^~~~~~~~~~~~~~~~~~~~~~~~~~~
--
In file included from include/linux/irq.h:21,
from include/asm-generic/hardirq.h:13,
from ./arch/nds32/include/generated/asm/hardirq.h:1,
from include/linux/hardirq.h:9,
from include/linux/highmem.h:10,
from include/linux/pagemap.h:11,
from include/linux/buffer_head.h:14,
from include/linux/jbd2.h:23,
from fs//jbd2/journal.c:25:
include/linux/slab.h: In function 'kmem_cache_zalloc':
>> include/linux/slab.h:678:21: error: inlining failed in call to always_inline 'kmem_cache_zalloc': recursive inlining
678 | static inline void *kmem_cache_zalloc(struct kmem_cache *k, gfp_t flags)
|                     ^~~~~~~~~~~~~~~~~
include/linux/slab.h:680:9: note: called from here
680 |  return kmem_cache_zalloc(k, flags);
|         ^~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/slab.h: In function 'jbd2_journal_add_journal_head':
>> include/linux/slab.h:678:21: error: inlining failed in call to always_inline 'kmem_cache_zalloc': recursive inlining
678 | static inline void *kmem_cache_zalloc(struct kmem_cache *k, gfp_t flags)
|                     ^~~~~~~~~~~~~~~~~
include/linux/slab.h:680:9: note: called from here
680 |  return kmem_cache_zalloc(k, flags);
|         ^~~~~~~~~~~~~~~~~~~~~~~~~~~
>> include/linux/slab.h:678:21: error: inlining failed in call to always_inline 'kmem_cache_zalloc': recursive inlining
678 | static inline void *kmem_cache_zalloc(struct kmem_cache *k, gfp_t flags)
|                     ^~~~~~~~~~~~~~~~~
include/linux/slab.h:680:9: note: called from here
680 |  return kmem_cache_zalloc(k, flags);
|         ^~~~~~~~~~~~~~~~~~~~~~~~~~~

vim +/kmem_cache_zalloc +678 include/linux/slab.h

10cef602950291 Matt Mackall      2006-01-08  674  
81cda6626178cd Christoph Lameter 2007-07-17  675  /*
81cda6626178cd Christoph Lameter 2007-07-17  676   * Shortcuts
81cda6626178cd Christoph Lameter 2007-07-17  677   */
81cda6626178cd Christoph Lameter 2007-07-17 @678  static inline void *kmem_cache_zalloc(struct kmem_cache *k, gfp_t flags)
81cda6626178cd Christoph Lameter 2007-07-17  679  {
3b0c169b666d29 Liao Pingfang     2020-06-17  680  	return kmem_cache_zalloc(k, flags);
81cda6626178cd Christoph Lameter 2007-07-17  681  }
81cda6626178cd Christoph Lameter 2007-07-17  682  

:::::: The code at line 678 was first introduced by commit
:::::: 81cda6626178cd55297831296ba8ecedbfd8b52d Slab allocators: Cleanup zeroing allocations

:::::: TO: Christoph Lameter <clameter@sgi.com>
:::::: CC: Linus Torvalds <torvalds@woody.linux-foundation.org>

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org

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

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

* Re: [PATCH] mm, slab: Use kmem_cache_zalloc() instead of kmem_cache_alloc() with flag GFP_ZERO.
  2020-06-17  7:15 [PATCH] mm, slab: Use kmem_cache_zalloc() instead of kmem_cache_alloc() with flag GFP_ZERO Yi Wang
  2020-06-17 10:43 ` Vlastimil Babka
  2020-06-17 11:18 ` kernel test robot
@ 2020-06-17 23:40 ` kernel test robot
  2 siblings, 0 replies; 4+ messages in thread
From: kernel test robot @ 2020-06-17 23:40 UTC (permalink / raw)
  To: Yi Wang, cl
  Cc: kbuild-all, penberg, rientjes, iamjoonsoo.kim, akpm, linux-mm,
	linux-kernel, xue.zhihong, wang.yi59, wang.liang82

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

Hi Yi,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on mmotm/master]

url:    https://github.com/0day-ci/linux/commits/Yi-Wang/mm-slab-Use-kmem_cache_zalloc-instead-of-kmem_cache_alloc-with-flag-GFP_ZERO/20200617-151513
base:   git://git.cmpxchg.org/linux-mmotm.git master
config: x86_64-rhel-7.6 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-13) 9.3.0
reproduce (this is a W=1 build):
        # save the attached .config to linux build tree
        make W=1 ARCH=x86_64 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All warnings (new ones prefixed by >>, old ones prefixed by <<):

>> drivers/mtd/ubi/attach.o: warning: objtool: ubi_add_to_av()+0x1c4: unreachable instruction
--
>> mm/slab_common.o: warning: objtool: create_kmalloc_caches()+0x44: unreachable instruction
--
>> fs/btrfs/free-space-cache.o: warning: objtool: btrfs_trim_block_group()+0x201: unreachable instruction
--
>> drivers/acpi/acpica/psutils.o: warning: objtool: acpi_ps_create_scope_op()+0x12: unreachable instruction
--
>> fs/fuse/dev.o: warning: objtool: fuse_force_forget()+0x42: unreachable instruction

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org

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

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

end of thread, other threads:[~2020-06-17 23:41 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-17  7:15 [PATCH] mm, slab: Use kmem_cache_zalloc() instead of kmem_cache_alloc() with flag GFP_ZERO Yi Wang
2020-06-17 10:43 ` Vlastimil Babka
2020-06-17 11:18 ` kernel test robot
2020-06-17 23:40 ` kernel test robot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).