nilfs2: Use __field_struct() for a bitwise field
Subsystems (2)
PATCH 1/1 nilfs2: Use __field_struct() for a bitwise field
As one can see in include/trace/stages/stage4_event_fields.h, the implementation of __field() uses the is_signed_type() macro. As one can see in commit dcf8e5633e2e ("tracing: Define the is_signed_type() macro once"), there has been an attempt to not make is_signed_type() trigger sparse warnings for bitwise types. Despite that change, sparse complains when passing a bitwise type to is_signed_type(). It is not clear to me why.
Follow the example of <trace/events/initcall.h> and suppress the following sparse warnings by changing __field() into __field_struct():
fs/nilfs2/segment.c: note: in included file (through
include/trace/trace_events.h, include/trace/define_trace.h, include/trace/events/nilfs2.h):
./include/trace/events/nilfs2.h:191:1: warning: cast to restricted
blk_opf_t
./include/trace/events/nilfs2.h:191:1: warning: restricted blk_opf_t
degrades to integer
./include/trace/events/nilfs2.h:191:1: warning: restricted blk_opf_t
degrades to integer
--- include/trace/events/nilfs2.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
include/trace/events/nilfs2.h +5 -1
@@ -200,7 +200,11 @@ TRACE_EVENT(nilfs2_mdt_submit_block, __field(struct inode *, inode) __field(unsigned long, ino) __field(unsigned long, blkoff) - __field(enum req_op, mode) + /* + * Use field_struct() to avoid is_signed_type() on the + * bitwise type enum req_op. + */ + __field_struct(enum req_op, mode) ), TP_fast_assign(
Ryusuke Konishi
maintainerQuoted 38 lines · Bart Van Assche
As one can see in
include/trace/stages/stage4_event_fields.h, the implementation of__field()uses theis_signed_type()macro. As one can see in commitdcf8e5633e2e("tracing: Define theis_signed_type()macro once"), there has been an attempt to not makeis_signed_type()trigger sparse warnings for bitwise types. Despite that change, sparse complains when passing a bitwise type tois_signed_type(). It is not clear to me why.Follow the example of <
trace/events/initcall.h> and suppress the following sparse warnings by changing__field()into__field_struct():
fs/nilfs2/segment.c: note: in included file (through
include/trace/trace_events.h,include/trace/define_trace.h,include/trace/events/nilfs2.h):
./include/trace/events/nilfs2.h:191:1: warning: cast to restricted
blk_opf_t
./include/trace/events/nilfs2.h:191:1: warning: restrictedblk_opf_t
degrades to integer
./include/trace/events/nilfs2.h:191:1: warning: restrictedblk_opf_t
degrades to integerCc Linus Torvalds <[email protected]>Cc Rasmus Villemoes <[email protected]>Cc Ryusuke Konishi <[email protected]>Reported-by Ryusuke Konishi <[email protected]>Signed-off-by Bart Van Assche <[email protected]>--- include/trace/events/nilfs2.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)include/trace/events/nilfs2.h +0
-0@@ -200,7 +200,11 @@ TRACE_EVENT(nilfs2_mdt_submit_block, __field(struct inode *, inode)__field (unsigned long , ino)
include/trace/events/nilfs2.h TRACE_EVENT(nilfs2_mdt_submit_block, · line 210
Quoted 10 lines
include/trace/events/nilfs2.h +5
-1__field(unsigned long, blkoff) -__field (enum req_op , mode) +/* +* Use field_struct() to avoid is_signed_type() on the +* bitwise type enum req_op. +*/ +__field_struct (enum req_op , mode) ), TP_fast_assign(
Bart, thank you very much for all your help.
This is a bit technical and may be debatable. But this can actually eliminate the sparse warnings.
So I'm thinking of having Andrew pick this up instead of my patch currently pending in the mm tree.
If anyone has any objections, please let us know.
Thanks,
Ryusuke Konishi
Quoted 2 lines · Ryusuke Konishi
So I'm thinking of having Andrew pick this up instead of my patch currently pending in the mm tree.
(+Andrew)
The patch Ryusuke is referring to is available here:
https://lore.kernel.org/linux-nilfs/[email protected]/
Thanks,
Bart.
Quoted 3 lines · On Tue, 7 May 2024 05:55:27 -0700 Bart Van Assche <[email protected]> wrote:
Quoted 2 lines · Ryusuke Konishi
So I'm thinking of having Andrew pick this up instead of my patch currently pending in the mm tree.
Please identify "my patch"?
Quoted 5 lines
(+Andrew)
The patch Ryusuke is referring to is available here:
https://lore.kernel.org/linux-nilfs/[email protected]/
I'm not subscribed to linux-nilfs. It's good to cc linux-kernel on everything for this reason. Resend, please?
Quoted 7 lines · Andrew Morton
Quoted 3 lines · On Tue, 7 May 2024 05:55:27 -0700 Bart Van Assche <[email protected]> wrote:
Quoted 2 lines · Ryusuke Konishi
So I'm thinking of having Andrew pick this up instead of my patch currently pending in the mm tree.
Please identify "my patch"?
I think it's this patch from one week ago: "[PATCH -mm 1/2] nilfs2: use integer type instead of enum req_op for event tracing header" (https://lore.kernel.org/linux-nilfs/CAKFNMokwnkku4tHcaAJPmFaBONZqoTMOLtKh_A7kcjzoxj3QZw@mail.gmail.com/T/#mfbbd7edb4a3ecc2d819869e58fb5a460dcb5b4bd)
Thanks,
Bart.