diff mbox series

xfs: fix sparse checker warnings on kmem tracepoints

Message ID 7c2af866-5a8e-3f48-ac07-041c3085c545@redhat.com (mailing list archive)
State New, archived
Headers show
Series xfs: fix sparse checker warnings on kmem tracepoints | expand

Commit Message

Eric Sandeen Dec. 18, 2019, 10:18 p.m. UTC
Sparse checker doesn't like kmem.c tracepoints:

kmem.c:18:32: warning: incorrect type in argument 2 (different base types)
kmem.c:18:32:    expected int [signed] flags
kmem.c:18:32:    got restricted xfs_km_flags_t [usertype] flags

So take an xfs_km_flags_t, and cast it to an int when we print it.

Fixes: 0ad95687c3ad ("xfs: add kmem allocation trace points")
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
---

Comments

Darrick J. Wong Dec. 18, 2019, 11:11 p.m. UTC | #1
On Wed, Dec 18, 2019 at 04:18:16PM -0600, Eric Sandeen wrote:
> Sparse checker doesn't like kmem.c tracepoints:
> 
> kmem.c:18:32: warning: incorrect type in argument 2 (different base types)
> kmem.c:18:32:    expected int [signed] flags
> kmem.c:18:32:    got restricted xfs_km_flags_t [usertype] flags
> 
> So take an xfs_km_flags_t, and cast it to an int when we print it.
> 
> Fixes: 0ad95687c3ad ("xfs: add kmem allocation trace points")
> Signed-off-by: Eric Sandeen <sandeen@redhat.com>

Looks ok insofar as cem will eventually kill these off, right?
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>

--D

> ---
> 
> diff --git a/fs/xfs/xfs_trace.h b/fs/xfs/xfs_trace.h
> index c13bb3655e48..dd165b6d2289 100644
> --- a/fs/xfs/xfs_trace.h
> +++ b/fs/xfs/xfs_trace.h
> @@ -3545,11 +3545,11 @@ TRACE_EVENT(xfs_pwork_init,
>  )
>  
>  DECLARE_EVENT_CLASS(xfs_kmem_class,
> -	TP_PROTO(ssize_t size, int flags, unsigned long caller_ip),
> +	TP_PROTO(ssize_t size, xfs_km_flags_t flags, unsigned long caller_ip),
>  	TP_ARGS(size, flags, caller_ip),
>  	TP_STRUCT__entry(
>  		__field(ssize_t, size)
> -		__field(int, flags)
> +		__field(xfs_km_flags_t, flags)
>  		__field(unsigned long, caller_ip)
>  	),
>  	TP_fast_assign(
> @@ -3559,13 +3559,13 @@ DECLARE_EVENT_CLASS(xfs_kmem_class,
>  	),
>  	TP_printk("size %zd flags 0x%x caller %pS",
>  		  __entry->size,
> -		  __entry->flags,
> +		  (int)__entry->flags,
>  		  (char *)__entry->caller_ip)
>  )
>  
>  #define DEFINE_KMEM_EVENT(name) \
>  DEFINE_EVENT(xfs_kmem_class, name, \
> -	TP_PROTO(ssize_t size, int flags, unsigned long caller_ip), \
> +	TP_PROTO(ssize_t size, xfs_km_flags_t flags, unsigned long caller_ip), \
>  	TP_ARGS(size, flags, caller_ip))
>  DEFINE_KMEM_EVENT(kmem_alloc);
>  DEFINE_KMEM_EVENT(kmem_alloc_io);
>
Eric Sandeen Dec. 18, 2019, 11:27 p.m. UTC | #2
On 12/18/19 5:11 PM, Darrick J. Wong wrote:
> On Wed, Dec 18, 2019 at 04:18:16PM -0600, Eric Sandeen wrote:
>> Sparse checker doesn't like kmem.c tracepoints:
>>
>> kmem.c:18:32: warning: incorrect type in argument 2 (different base types)
>> kmem.c:18:32:    expected int [signed] flags
>> kmem.c:18:32:    got restricted xfs_km_flags_t [usertype] flags
>>
>> So take an xfs_km_flags_t, and cast it to an int when we print it.
>>
>> Fixes: 0ad95687c3ad ("xfs: add kmem allocation trace points")
>> Signed-off-by: Eric Sandeen <sandeen@redhat.com>
> 
> Looks ok insofar as cem will eventually kill these off, right?
> Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>

Oh, I guess so - if you want to just wait for that and drop this
patch, it's fine.

-Eric
diff mbox series

Patch

diff --git a/fs/xfs/xfs_trace.h b/fs/xfs/xfs_trace.h
index c13bb3655e48..dd165b6d2289 100644
--- a/fs/xfs/xfs_trace.h
+++ b/fs/xfs/xfs_trace.h
@@ -3545,11 +3545,11 @@  TRACE_EVENT(xfs_pwork_init,
 )
 
 DECLARE_EVENT_CLASS(xfs_kmem_class,
-	TP_PROTO(ssize_t size, int flags, unsigned long caller_ip),
+	TP_PROTO(ssize_t size, xfs_km_flags_t flags, unsigned long caller_ip),
 	TP_ARGS(size, flags, caller_ip),
 	TP_STRUCT__entry(
 		__field(ssize_t, size)
-		__field(int, flags)
+		__field(xfs_km_flags_t, flags)
 		__field(unsigned long, caller_ip)
 	),
 	TP_fast_assign(
@@ -3559,13 +3559,13 @@  DECLARE_EVENT_CLASS(xfs_kmem_class,
 	),
 	TP_printk("size %zd flags 0x%x caller %pS",
 		  __entry->size,
-		  __entry->flags,
+		  (int)__entry->flags,
 		  (char *)__entry->caller_ip)
 )
 
 #define DEFINE_KMEM_EVENT(name) \
 DEFINE_EVENT(xfs_kmem_class, name, \
-	TP_PROTO(ssize_t size, int flags, unsigned long caller_ip), \
+	TP_PROTO(ssize_t size, xfs_km_flags_t flags, unsigned long caller_ip), \
 	TP_ARGS(size, flags, caller_ip))
 DEFINE_KMEM_EVENT(kmem_alloc);
 DEFINE_KMEM_EVENT(kmem_alloc_io);