Skip to contentSkip to conversation

xfs: fix sparse checker warnings on kmem tracepoints

PATCH In review Eric Sandeen 2 participants 3 messages Dec 18, 2019 XFS filesystem

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xfs: fix sparse checker warnings on kmem tracepoints

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

---

fs/xfs/xfs_trace.h +4 -4
index c13bb3655e48..dd165b6d2289 100644
@@ -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);
Reviewed-by on v1 1/1
#1 lore raw
Quoted 10 lines · Eric Sandeen

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

Looks ok insofar as cem will eventually kill these off, right?

--D

Quoted 37 lines

---

fs/xfs/xfs_trace.h +4 -4
index c13bb3655e48..dd165b6d2289 100644
@@ -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);
#2 lore raw
Quoted 7 lines · Darrick J. Wong
Quoted 6 lines · Eric Sandeen

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

Quoted 7 lines
Quoted 4 lines

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

Looks ok insofar as cem will eventually kill these off, right?

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

-Eric