All the mail mirrored from lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] nilfs2: Use __field_struct() for a bitwise field
@ 2024-05-06 23:24 Bart Van Assche
  2024-05-07  4:10 ` Ryusuke Konishi
  0 siblings, 1 reply; 5+ messages in thread
From: Bart Van Assche @ 2024-05-06 23:24 UTC (permalink / raw
  To: Ryusuke Konishi
  Cc: linux-nilfs, Bart Van Assche, Linus Torvalds, Rasmus Villemoes

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

Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Rasmus Villemoes <linux@rasmusvillemoes.dk>
Cc: Ryusuke Konishi <konishi.ryusuke@gmail.com>
Reported-by: Ryusuke Konishi <konishi.ryusuke@gmail.com>
Closes: https://lore.kernel.org/all/20240430080019.4242-2-konishi.ryusuke@gmail.com/
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 include/trace/events/nilfs2.h | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/include/trace/events/nilfs2.h b/include/trace/events/nilfs2.h
index 8efc6236f57c..8880c11733dd 100644
--- a/include/trace/events/nilfs2.h
+++ b/include/trace/events/nilfs2.h
@@ -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(

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

* Re: [PATCH] nilfs2: Use __field_struct() for a bitwise field
  2024-05-06 23:24 [PATCH] nilfs2: Use __field_struct() for a bitwise field Bart Van Assche
@ 2024-05-07  4:10 ` Ryusuke Konishi
  2024-05-07 12:55   ` Bart Van Assche
  0 siblings, 1 reply; 5+ messages in thread
From: Ryusuke Konishi @ 2024-05-07  4:10 UTC (permalink / raw
  To: Bart Van Assche; +Cc: Rasmus Villemoes, Linus Torvalds, linux-nilfs

On Tue, May 7, 2024 at 8:24 AM Bart Van Assche wrote:
>
> 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
>
> Cc: Linus Torvalds <torvalds@linux-foundation.org>
> Cc: Rasmus Villemoes <linux@rasmusvillemoes.dk>
> Cc: Ryusuke Konishi <konishi.ryusuke@gmail.com>
> Reported-by: Ryusuke Konishi <konishi.ryusuke@gmail.com>
> Closes: https://lore.kernel.org/all/20240430080019.4242-2-konishi.ryusuke@gmail.com/
> Signed-off-by: Bart Van Assche <bvanassche@acm.org>
> ---
>  include/trace/events/nilfs2.h | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/include/trace/events/nilfs2.h b/include/trace/events/nilfs2.h
> index 8efc6236f57c..8880c11733dd 100644
> --- a/include/trace/events/nilfs2.h
> +++ b/include/trace/events/nilfs2.h
> @@ -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(

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

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

* Re: [PATCH] nilfs2: Use __field_struct() for a bitwise field
  2024-05-07  4:10 ` Ryusuke Konishi
@ 2024-05-07 12:55   ` Bart Van Assche
  2024-05-07 16:01     ` Andrew Morton
  0 siblings, 1 reply; 5+ messages in thread
From: Bart Van Assche @ 2024-05-07 12:55 UTC (permalink / raw
  To: Ryusuke Konishi
  Cc: Rasmus Villemoes, Linus Torvalds, linux-nilfs, Andrew Morton

On 5/6/24 21:10, Ryusuke Konishi wrote:
> 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/20240506232437.21264-1-bvanassche@acm.org/

Thanks,

Bart.	

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

* Re: [PATCH] nilfs2: Use __field_struct() for a bitwise field
  2024-05-07 12:55   ` Bart Van Assche
@ 2024-05-07 16:01     ` Andrew Morton
  2024-05-07 18:16       ` Bart Van Assche
  0 siblings, 1 reply; 5+ messages in thread
From: Andrew Morton @ 2024-05-07 16:01 UTC (permalink / raw
  To: Bart Van Assche
  Cc: Ryusuke Konishi, Rasmus Villemoes, Linus Torvalds, linux-nilfs

On Tue, 7 May 2024 05:55:27 -0700 Bart Van Assche <bvanassche@acm.org> wrote:

> On 5/6/24 21:10, Ryusuke Konishi wrote:
> > So I'm thinking of having Andrew pick this up instead of my patch
> > currently pending in the mm tree.

Please identify "my patch"?

> (+Andrew)
> 
> The patch Ryusuke is referring to is available here:
> https://lore.kernel.org/linux-nilfs/20240506232437.21264-1-bvanassche@acm.org/
> 

I'm not subscribed to linux-nilfs.  It's good to cc linux-kernel on
everything for this reason.  Resend, please?

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

* Re: [PATCH] nilfs2: Use __field_struct() for a bitwise field
  2024-05-07 16:01     ` Andrew Morton
@ 2024-05-07 18:16       ` Bart Van Assche
  0 siblings, 0 replies; 5+ messages in thread
From: Bart Van Assche @ 2024-05-07 18:16 UTC (permalink / raw
  To: Andrew Morton
  Cc: Ryusuke Konishi, Rasmus Villemoes, Linus Torvalds, linux-nilfs

On 5/7/24 9:01 AM, Andrew Morton wrote:
> On Tue, 7 May 2024 05:55:27 -0700 Bart Van Assche <bvanassche@acm.org> wrote:
> 
>> On 5/6/24 21:10, Ryusuke Konishi wrote:
>>> 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.

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

end of thread, other threads:[~2024-05-07 18:16 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-05-06 23:24 [PATCH] nilfs2: Use __field_struct() for a bitwise field Bart Van Assche
2024-05-07  4:10 ` Ryusuke Konishi
2024-05-07 12:55   ` Bart Van Assche
2024-05-07 16:01     ` Andrew Morton
2024-05-07 18:16       ` Bart Van Assche

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.