Re: [linux-next:master 2760/3682] include/trace/events/kmem.h:54:1: sparse: sparse: restricted gfp_t degrades to integer

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 8/28/22 18:30, kernel test robot wrote:
> tree:   https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git master
> head:   8d0c42c9e80791e8baba2932d2cbd2dcead50d47
> commit: 86431e299ca5a0e16405201535b6060936146215 [2760/3682] mm/slab_common: drop kmem_alloc & avoid dereferencing fields when not using
> config: openrisc-randconfig-s033-20220828 (https://download.01.org/0day-ci/archive/20220829/202208290041.W6s9gjtG-lkp@xxxxxxxxx/config)
> compiler: or1k-linux-gcc (GCC) 12.1.0
> reproduce:
>         wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
>         chmod +x ~/bin/make.cross
>         # apt-get install sparse
>         # sparse version: v0.6.4-39-gce1a6720-dirty
>         # https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/?id=86431e299ca5a0e16405201535b6060936146215
>         git remote add linux-next https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
>         git fetch --no-tags linux-next master
>         git checkout 86431e299ca5a0e16405201535b6060936146215
>         # save the config file
>         mkdir build_dir && cp config build_dir/.config
>         COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' O=build_dir ARCH=openrisc SHELL=/bin/bash
> 
> If you fix the issue, kindly add following tag where applicable
> Reported-by: kernel test robot <lkp@xxxxxxxxx>
> 
> sparse warnings: (new ones prefixed by >>)
>    mm/slab_common.c: note: in included file (through include/trace/trace_events.h, include/trace/define_trace.h, include/trace/events/kmem.h):
>>> include/trace/events/kmem.h:54:1: sparse: sparse: restricted gfp_t degrades to integer
> 
> vim +54 include/trace/events/kmem.h
> 
>     53	
>   > 54	TRACE_EVENT(kmalloc,
>     55	
>     56		TP_PROTO(unsigned long call_site,
>     57			 const void *ptr,
>     58			 size_t bytes_req,
>     59			 size_t bytes_alloc,
>     60			 gfp_t gfp_flags,
>     61			 int node),
>     62	
>     63		TP_ARGS(call_site, ptr, bytes_req, bytes_alloc, gfp_flags, node),
>     64	
>     65		TP_STRUCT__entry(
>     66			__field(	unsigned long,	call_site	)
>     67			__field(	const void *,	ptr		)
>     68			__field(	size_t,		bytes_req	)
>     69			__field(	size_t,		bytes_alloc	)
>     70			__field(	unsigned long,	gfp_flags	)
>     71			__field(	int,		node		)
>     72		),
>     73	
>     74		TP_fast_assign(
>     75			__entry->call_site	= call_site;
>     76			__entry->ptr		= ptr;
>     77			__entry->bytes_req	= bytes_req;
>     78			__entry->bytes_alloc	= bytes_alloc;
>     79			__entry->gfp_flags	= (__force unsigned long)gfp_flags;
>     80			__entry->node		= node;
>     81		),
>     82	
>     83		TP_printk("call_site=%pS ptr=%p bytes_req=%zu bytes_alloc=%zu gfp_flags=%s node=%d accounted=%s",
>     84			(void *)__entry->call_site,
>     85			__entry->ptr,
>     86			__entry->bytes_req,
>     87			__entry->bytes_alloc,
>     88			show_gfp_flags(__entry->gfp_flags),
>     89			__entry->node,
>     90			(IS_ENABLED(CONFIG_MEMCG_KMEM) &&
>     91			 (__entry->gfp_flags & __GFP_ACCOUNT)) ? "true" : "false")
>     92	);
>     93	

Amending the commit with
diff --git a/include/trace/events/kmem.h b/include/trace/events/kmem.h
index 8c6f96604244..243073cfc29d 100644
--- a/include/trace/events/kmem.h
+++ b/include/trace/events/kmem.h
@@ -88,7 +88,7 @@ TRACE_EVENT(kmalloc,
                show_gfp_flags(__entry->gfp_flags),
                __entry->node,
                (IS_ENABLED(CONFIG_MEMCG_KMEM) &&
-                (__entry->gfp_flags & __GFP_ACCOUNT)) ? "true" : "false")
+                (__entry->gfp_flags & (__force unsigned long)__GFP_ACCOUNT)) ? "true" : "false")
 );

 





[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux