[PATCH 01/25] xfs: add a per-xfs trace_printk macro

2018-10-12 Thread Darrick J. Wong
From: Darrick J. Wong 

Add a "xfs_tprintk" macro so that developers can use trace_printk to
print out arbitrary debugging information with the XFS device name
attached to the trace output.

Signed-off-by: Darrick J. Wong 
---
 fs/xfs/xfs_error.h |6 ++
 1 file changed, 6 insertions(+)


diff --git a/fs/xfs/xfs_error.h b/fs/xfs/xfs_error.h
index 246d3e989c6c..5caa8bdf6c38 100644
--- a/fs/xfs/xfs_error.h
+++ b/fs/xfs/xfs_error.h
@@ -76,6 +76,11 @@ extern int xfs_errortag_set(struct xfs_mount *mp, unsigned 
int error_tag,
unsigned int tag_value);
 extern int xfs_errortag_add(struct xfs_mount *mp, unsigned int error_tag);
 extern int xfs_errortag_clearall(struct xfs_mount *mp);
+
+/* trace printk version of xfs_err and friends */
+#define xfs_tprintk(mp, fmt, args...) \
+   trace_printk("dev %d:%d " fmt, MAJOR((mp)->m_super->s_dev), \
+   MINOR((mp)->m_super->s_dev), ##args)
 #else
 #define xfs_errortag_init(mp)  (0)
 #define xfs_errortag_del(mp)
@@ -83,6 +88,7 @@ extern int xfs_errortag_clearall(struct xfs_mount *mp);
 #define xfs_errortag_set(mp, tag, val) (ENOSYS)
 #define xfs_errortag_add(mp, tag)  (ENOSYS)
 #define xfs_errortag_clearall(mp)  (ENOSYS)
+#define xfs_tprintk(mp, fmt, args...)  do { } while (0)
 #endif /* DEBUG */
 
 /*



Re: [PATCH 01/25] xfs: add a per-xfs trace_printk macro

2018-10-11 Thread Darrick J. Wong
On Thu, Oct 11, 2018 at 06:39:34AM -0700, Christoph Hellwig wrote:
> On Wed, Oct 10, 2018 at 09:12:23PM -0700, Darrick J. Wong wrote:
> > From: Darrick J. Wong 
> > 
> > Add a "xfs_tprintk" macro so that developers can use trace_printk to
> > print out arbitrary debugging information with the XFS device name
> > attached to the trace output.
> 
> I can't say I'm a fan of this.  trace_printk is a debugging aid,
> and opencoding the file system name really isn't much of a burden.

 I got tired enough of typing it to add a ewwgross macro, and then
got tired enough of maintaining the patch, let's see what Dave says. :)

--D


Re: [PATCH 01/25] xfs: add a per-xfs trace_printk macro

2018-10-11 Thread Christoph Hellwig
On Wed, Oct 10, 2018 at 09:12:23PM -0700, Darrick J. Wong wrote:
> From: Darrick J. Wong 
> 
> Add a "xfs_tprintk" macro so that developers can use trace_printk to
> print out arbitrary debugging information with the XFS device name
> attached to the trace output.

I can't say I'm a fan of this.  trace_printk is a debugging aid,
and opencoding the file system name really isn't much of a burden.


[PATCH 01/25] xfs: add a per-xfs trace_printk macro

2018-10-10 Thread Darrick J. Wong
From: Darrick J. Wong 

Add a "xfs_tprintk" macro so that developers can use trace_printk to
print out arbitrary debugging information with the XFS device name
attached to the trace output.

Signed-off-by: Darrick J. Wong 
---
 fs/xfs/xfs_error.h |6 ++
 1 file changed, 6 insertions(+)


diff --git a/fs/xfs/xfs_error.h b/fs/xfs/xfs_error.h
index 246d3e989c6c..5caa8bdf6c38 100644
--- a/fs/xfs/xfs_error.h
+++ b/fs/xfs/xfs_error.h
@@ -76,6 +76,11 @@ extern int xfs_errortag_set(struct xfs_mount *mp, unsigned 
int error_tag,
unsigned int tag_value);
 extern int xfs_errortag_add(struct xfs_mount *mp, unsigned int error_tag);
 extern int xfs_errortag_clearall(struct xfs_mount *mp);
+
+/* trace printk version of xfs_err and friends */
+#define xfs_tprintk(mp, fmt, args...) \
+   trace_printk("dev %d:%d " fmt, MAJOR((mp)->m_super->s_dev), \
+   MINOR((mp)->m_super->s_dev), ##args)
 #else
 #define xfs_errortag_init(mp)  (0)
 #define xfs_errortag_del(mp)
@@ -83,6 +88,7 @@ extern int xfs_errortag_clearall(struct xfs_mount *mp);
 #define xfs_errortag_set(mp, tag, val) (ENOSYS)
 #define xfs_errortag_add(mp, tag)  (ENOSYS)
 #define xfs_errortag_clearall(mp)  (ENOSYS)
+#define xfs_tprintk(mp, fmt, args...)  do { } while (0)
 #endif /* DEBUG */
 
 /*



Re: [PATCH 01/25] xfs: add a per-xfs trace_printk macro

2018-10-09 Thread Dave Chinner
On Tue, Oct 09, 2018 at 05:10:45PM -0700, Darrick J. Wong wrote:
> From: Darrick J. Wong 
> 
> Add a "xfs_tprintk" macro so that developers can use trace_printk to
> print out arbitrary debugging information with the XFS device name
> attached to the trace output.
> 
> Signed-off-by: Darrick J. Wong 
> ---
>  fs/xfs/xfs_error.h |5 +
>  1 file changed, 5 insertions(+)
> 
> 
> diff --git a/fs/xfs/xfs_error.h b/fs/xfs/xfs_error.h
> index 246d3e989c6c..c3d9546b138c 100644
> --- a/fs/xfs/xfs_error.h
> +++ b/fs/xfs/xfs_error.h
> @@ -99,4 +99,9 @@ extern int xfs_errortag_clearall(struct xfs_mount *mp);
>  #define  XFS_PTAG_SHUTDOWN_LOGERROR  0x0040
>  #define  XFS_PTAG_FSBLOCK_ZERO   0x0080
>  
> +/* trace printk version of xfs_err and friends */
> +#define xfs_tprintk(mp, fmt, args...) \
> + trace_printk("dev %d:%d " fmt, MAJOR((mp)->m_super->s_dev), \
> + MINOR((mp)->m_super->s_dev), ##args)
> +
>  #endif   /* __XFS_ERROR_H__ */

Not convinced this is a good idea.  How are you going to ensure code
calling this trace point is not committed?

If we decide to add this, it needs to be a CONFIG_XFS_DEBUG=y only
definition because trace_printk() is only for temporary debugging
code and has substantial performance overheads even when these trace
points are not being traced.

Cheers,

Dave.
-- 
Dave Chinner
da...@fromorbit.com


[PATCH 01/25] xfs: add a per-xfs trace_printk macro

2018-10-09 Thread Darrick J. Wong
From: Darrick J. Wong 

Add a "xfs_tprintk" macro so that developers can use trace_printk to
print out arbitrary debugging information with the XFS device name
attached to the trace output.

Signed-off-by: Darrick J. Wong 
---
 fs/xfs/xfs_error.h |5 +
 1 file changed, 5 insertions(+)


diff --git a/fs/xfs/xfs_error.h b/fs/xfs/xfs_error.h
index 246d3e989c6c..c3d9546b138c 100644
--- a/fs/xfs/xfs_error.h
+++ b/fs/xfs/xfs_error.h
@@ -99,4 +99,9 @@ extern int xfs_errortag_clearall(struct xfs_mount *mp);
 #defineXFS_PTAG_SHUTDOWN_LOGERROR  0x0040
 #defineXFS_PTAG_FSBLOCK_ZERO   0x0080
 
+/* trace printk version of xfs_err and friends */
+#define xfs_tprintk(mp, fmt, args...) \
+   trace_printk("dev %d:%d " fmt, MAJOR((mp)->m_super->s_dev), \
+   MINOR((mp)->m_super->s_dev), ##args)
+
 #endif /* __XFS_ERROR_H__ */