diff mbox series

[RFC,8/9] ext4: Convert ext4_fc_track_dentry type events to use event class

Message ID bf55f9a22a67f8619ffe5f1af47bebb43f5ed372.1645558375.git.riteshh@linux.ibm.com (mailing list archive)
State New, archived
Headers show
Series ext4: Improve FC trace events and discuss one FC failure | expand

Commit Message

Ritesh Harjani Feb. 22, 2022, 8:34 p.m. UTC
One should use DECLARE_EVENT_CLASS for similar event types instead of
defining TRACE_EVENT for each event type. This is helpful in reducing
the text section footprint for e.g. [1]

[1]: https://lwn.net/Articles/381064/

Signed-off-by: Ritesh Harjani <riteshh@linux.ibm.com>
---
 include/trace/events/ext4.h | 57 +++++++++++++++++++++----------------
 1 file changed, 32 insertions(+), 25 deletions(-)

Comments

Jan Kara Feb. 23, 2022, 9:49 a.m. UTC | #1
On Wed 23-02-22 02:04:16, Ritesh Harjani wrote:
> One should use DECLARE_EVENT_CLASS for similar event types instead of
> defining TRACE_EVENT for each event type. This is helpful in reducing
> the text section footprint for e.g. [1]
> 
> [1]: https://lwn.net/Articles/381064/
> 
> Signed-off-by: Ritesh Harjani <riteshh@linux.ibm.com>

Looks good. Feel free to add:

Reviewed-by: Jan Kara <jack@suse.cz>

								Honza

> ---
>  include/trace/events/ext4.h | 57 +++++++++++++++++++++----------------
>  1 file changed, 32 insertions(+), 25 deletions(-)
> 
> diff --git a/include/trace/events/ext4.h b/include/trace/events/ext4.h
> index 233dbffa5ceb..33a059d845d6 100644
> --- a/include/trace/events/ext4.h
> +++ b/include/trace/events/ext4.h
> @@ -2783,33 +2783,40 @@ TRACE_EVENT(ext4_fc_stats,
>  		  __entry->fc_numblks)
>  );
>  
> -#define DEFINE_TRACE_DENTRY_EVENT(__type)				\
> -	TRACE_EVENT(ext4_fc_track_##__type,				\
> -	    TP_PROTO(struct inode *inode, struct dentry *dentry, int ret), \
> -									\
> -	    TP_ARGS(inode, dentry, ret),				\
> -									\
> -	    TP_STRUCT__entry(						\
> -		    __field(dev_t, dev)					\
> -		    __field(int, ino)					\
> -		    __field(int, error)					\
> -		    ),							\
> -									\
> -	    TP_fast_assign(						\
> -		    __entry->dev = inode->i_sb->s_dev;			\
> -		    __entry->ino = inode->i_ino;			\
> -		    __entry->error = ret;				\
> -		    ),							\
> -									\
> -	    TP_printk("dev %d:%d, inode %d, error %d, fc_%s",		\
> -		      MAJOR(__entry->dev), MINOR(__entry->dev),		\
> -		      __entry->ino, __entry->error,			\
> -		      #__type)						\
> +DECLARE_EVENT_CLASS(ext4_fc_track_dentry,
> +
> +	TP_PROTO(struct inode *inode, struct dentry *dentry, int ret),
> +
> +	TP_ARGS(inode, dentry, ret),
> +
> +	TP_STRUCT__entry(
> +		__field(dev_t, dev)
> +		__field(int, ino)
> +		__field(int, error)
> +	),
> +
> +	TP_fast_assign(
> +		__entry->dev = inode->i_sb->s_dev;
> +		__entry->ino = inode->i_ino;
> +		__entry->error = ret;
> +	),
> +
> +	TP_printk("dev %d,%d, inode %d, error %d",
> +		  MAJOR(__entry->dev), MINOR(__entry->dev),
> +		  __entry->ino, __entry->error
>  	)
> +);
> +
> +#define DEFINE_EVENT_CLASS_TYPE(__type)					\
> +DEFINE_EVENT(ext4_fc_track_dentry, ext4_fc_track_##__type,		\
> +	TP_PROTO(struct inode *inode, struct dentry *dentry, int ret),	\
> +	TP_ARGS(inode, dentry, ret)					\
> +)
> +
>  
> -DEFINE_TRACE_DENTRY_EVENT(create);
> -DEFINE_TRACE_DENTRY_EVENT(link);
> -DEFINE_TRACE_DENTRY_EVENT(unlink);
> +DEFINE_EVENT_CLASS_TYPE(create);
> +DEFINE_EVENT_CLASS_TYPE(link);
> +DEFINE_EVENT_CLASS_TYPE(unlink);
>  
>  TRACE_EVENT(ext4_fc_track_inode,
>  	    TP_PROTO(struct inode *inode, int ret),
> -- 
> 2.31.1
>
harshad shirwadkar Feb. 27, 2022, 6:35 p.m. UTC | #2
Nice! Thanks for fixing this.

Reviewed-by: Harshad Shirwadkar <harshadshirwadkar@gmail.com>


- Harshad

On Wed, 23 Feb 2022 at 01:49, Jan Kara <jack@suse.cz> wrote:
>
> On Wed 23-02-22 02:04:16, Ritesh Harjani wrote:
> > One should use DECLARE_EVENT_CLASS for similar event types instead of
> > defining TRACE_EVENT for each event type. This is helpful in reducing
> > the text section footprint for e.g. [1]
> >
> > [1]: https://lwn.net/Articles/381064/
> >
> > Signed-off-by: Ritesh Harjani <riteshh@linux.ibm.com>
>
> Looks good. Feel free to add:
>
> Reviewed-by: Jan Kara <jack@suse.cz>
>
>                                                                 Honza
>
> > ---
> >  include/trace/events/ext4.h | 57 +++++++++++++++++++++----------------
> >  1 file changed, 32 insertions(+), 25 deletions(-)
> >
> > diff --git a/include/trace/events/ext4.h b/include/trace/events/ext4.h
> > index 233dbffa5ceb..33a059d845d6 100644
> > --- a/include/trace/events/ext4.h
> > +++ b/include/trace/events/ext4.h
> > @@ -2783,33 +2783,40 @@ TRACE_EVENT(ext4_fc_stats,
> >                 __entry->fc_numblks)
> >  );
> >
> > -#define DEFINE_TRACE_DENTRY_EVENT(__type)                            \
> > -     TRACE_EVENT(ext4_fc_track_##__type,                             \
> > -         TP_PROTO(struct inode *inode, struct dentry *dentry, int ret), \
> > -                                                                     \
> > -         TP_ARGS(inode, dentry, ret),                                \
> > -                                                                     \
> > -         TP_STRUCT__entry(                                           \
> > -                 __field(dev_t, dev)                                 \
> > -                 __field(int, ino)                                   \
> > -                 __field(int, error)                                 \
> > -                 ),                                                  \
> > -                                                                     \
> > -         TP_fast_assign(                                             \
> > -                 __entry->dev = inode->i_sb->s_dev;                  \
> > -                 __entry->ino = inode->i_ino;                        \
> > -                 __entry->error = ret;                               \
> > -                 ),                                                  \
> > -                                                                     \
> > -         TP_printk("dev %d:%d, inode %d, error %d, fc_%s",           \
> > -                   MAJOR(__entry->dev), MINOR(__entry->dev),         \
> > -                   __entry->ino, __entry->error,                     \
> > -                   #__type)                                          \
> > +DECLARE_EVENT_CLASS(ext4_fc_track_dentry,
> > +
> > +     TP_PROTO(struct inode *inode, struct dentry *dentry, int ret),
> > +
> > +     TP_ARGS(inode, dentry, ret),
> > +
> > +     TP_STRUCT__entry(
> > +             __field(dev_t, dev)
> > +             __field(int, ino)
> > +             __field(int, error)
> > +     ),
> > +
> > +     TP_fast_assign(
> > +             __entry->dev = inode->i_sb->s_dev;
> > +             __entry->ino = inode->i_ino;
> > +             __entry->error = ret;
> > +     ),
> > +
> > +     TP_printk("dev %d,%d, inode %d, error %d",
> > +               MAJOR(__entry->dev), MINOR(__entry->dev),
> > +               __entry->ino, __entry->error
> >       )
> > +);
> > +
> > +#define DEFINE_EVENT_CLASS_TYPE(__type)                                      \
> > +DEFINE_EVENT(ext4_fc_track_dentry, ext4_fc_track_##__type,           \
> > +     TP_PROTO(struct inode *inode, struct dentry *dentry, int ret),  \
> > +     TP_ARGS(inode, dentry, ret)                                     \
> > +)
> > +
> >
> > -DEFINE_TRACE_DENTRY_EVENT(create);
> > -DEFINE_TRACE_DENTRY_EVENT(link);
> > -DEFINE_TRACE_DENTRY_EVENT(unlink);
> > +DEFINE_EVENT_CLASS_TYPE(create);
> > +DEFINE_EVENT_CLASS_TYPE(link);
> > +DEFINE_EVENT_CLASS_TYPE(unlink);
> >
> >  TRACE_EVENT(ext4_fc_track_inode,
> >           TP_PROTO(struct inode *inode, int ret),
> > --
> > 2.31.1
> >
> --
> Jan Kara <jack@suse.com>
> SUSE Labs, CR
diff mbox series

Patch

diff --git a/include/trace/events/ext4.h b/include/trace/events/ext4.h
index 233dbffa5ceb..33a059d845d6 100644
--- a/include/trace/events/ext4.h
+++ b/include/trace/events/ext4.h
@@ -2783,33 +2783,40 @@  TRACE_EVENT(ext4_fc_stats,
 		  __entry->fc_numblks)
 );
 
-#define DEFINE_TRACE_DENTRY_EVENT(__type)				\
-	TRACE_EVENT(ext4_fc_track_##__type,				\
-	    TP_PROTO(struct inode *inode, struct dentry *dentry, int ret), \
-									\
-	    TP_ARGS(inode, dentry, ret),				\
-									\
-	    TP_STRUCT__entry(						\
-		    __field(dev_t, dev)					\
-		    __field(int, ino)					\
-		    __field(int, error)					\
-		    ),							\
-									\
-	    TP_fast_assign(						\
-		    __entry->dev = inode->i_sb->s_dev;			\
-		    __entry->ino = inode->i_ino;			\
-		    __entry->error = ret;				\
-		    ),							\
-									\
-	    TP_printk("dev %d:%d, inode %d, error %d, fc_%s",		\
-		      MAJOR(__entry->dev), MINOR(__entry->dev),		\
-		      __entry->ino, __entry->error,			\
-		      #__type)						\
+DECLARE_EVENT_CLASS(ext4_fc_track_dentry,
+
+	TP_PROTO(struct inode *inode, struct dentry *dentry, int ret),
+
+	TP_ARGS(inode, dentry, ret),
+
+	TP_STRUCT__entry(
+		__field(dev_t, dev)
+		__field(int, ino)
+		__field(int, error)
+	),
+
+	TP_fast_assign(
+		__entry->dev = inode->i_sb->s_dev;
+		__entry->ino = inode->i_ino;
+		__entry->error = ret;
+	),
+
+	TP_printk("dev %d,%d, inode %d, error %d",
+		  MAJOR(__entry->dev), MINOR(__entry->dev),
+		  __entry->ino, __entry->error
 	)
+);
+
+#define DEFINE_EVENT_CLASS_TYPE(__type)					\
+DEFINE_EVENT(ext4_fc_track_dentry, ext4_fc_track_##__type,		\
+	TP_PROTO(struct inode *inode, struct dentry *dentry, int ret),	\
+	TP_ARGS(inode, dentry, ret)					\
+)
+
 
-DEFINE_TRACE_DENTRY_EVENT(create);
-DEFINE_TRACE_DENTRY_EVENT(link);
-DEFINE_TRACE_DENTRY_EVENT(unlink);
+DEFINE_EVENT_CLASS_TYPE(create);
+DEFINE_EVENT_CLASS_TYPE(link);
+DEFINE_EVENT_CLASS_TYPE(unlink);
 
 TRACE_EVENT(ext4_fc_track_inode,
 	    TP_PROTO(struct inode *inode, int ret),