GFS2: Tracing support
Subsystems (2)
From c154c0500fa6f5fad6eb95cf9f1b578a5cd24525 Mon Sep 17 00:00:00 2001
From: Steven Whitehouse <[email protected]>
Date: Tue, 14 Apr 2009 16:13:55 +0100
Subject: [PATCH] GFS2: Tracing support
This is my initial attempt at tracing support for GFS2. There are three major themes covering glocks, logging and bmap/alloc. It seems to work ok on its own, although the plan is to be able to use it in conjunction with blktrace in order to provide a means of testing correctness and performance analysis of GFS2.
fs/gfs2/bmap.c +5 -0
@@ -13,6 +13,7 @@#include <linux/buffer_head.h> #include <linux/gfs2_ondisk.h> #include <linux/crc32.h> +#include <trace/gfs2.h> #include "gfs2.h" #include "incore.h"
@@ -27,6 +28,8 @@#include "util.h" #include "ops_address.h" +DEFINE_TRACE (gfs2_bmap); +/* This doesn't need to be that large as max 64 bit pointers in a 4k * block is 512, so __u16 is fine for that. It saves stack space to * keep it small.
@@ -585,6 +588,7 @@ int gfs2_block_map(struct inode *inode, sector_t lblock,clear_buffer_mapped (bh_map);clear_buffer_new (bh_map);clear_buffer_boundary (bh_map); +trace_gfs2_bmap (ip, bh_map, lblock, create,1 );if (gfs2_is_dir (ip)) { bsize = sdp->sd_jbsize; arr = sdp->sd_jheightsize;
@@ -619,6 +623,7 @@ int gfs2_block_map(struct inode *inode, sector_t lblock, ret =0 ; out:release_metapath (&mp); +trace_gfs2_bmap (ip, bh_map, lblock, create, ret);bmap_unlock (ip, create);return ret;
fs/gfs2/glock.c +16 -1
@@ -27,6 +27,7 @@#include <linux/freezer.h> #include <linux/workqueue.h> #include <linux/jiffies.h> +#include <trace/gfs2.h> #include "gfs2.h" #include "incore.h"
@@ -40,6 +41,12 @@#include "util.h" #include "bmap.h" +DEFINE_TRACE (gfs2_glock_state_change); +DEFINE_TRACE (gfs2_glock_put); +DEFINE_TRACE (gfs2_demote_rq); +DEFINE_TRACE (gfs2_promote); +DEFINE_TRACE (gfs2_glock_queue); +struct gfs2_gl_hash_bucket {struct hlist_head hb_list; };
@@ -155,7 +162,7 @@ static void glock_free(struct gfs2_glock *gl)if (aspace)gfs2_aspace_put (aspace); - +trace_gfs2_glock_put (gl); sdp->sd_lockstruct.ls_ops->lm_put_lock (gfs2_glock_cachep, gl); }
@@ -317,14 +324,17 @@ restart:return 2 ; gh->gh_error = ret;list_del_init (&gh->gh_list); +trace_gfs2_glock_queue (gh,0 );gfs2_holder_wake (gh); goto restart; }set_bit (HIF_HOLDER , &gh->gh_iflags); +trace_gfs2_promote (gh,1 );gfs2_holder_wake (gh); goto restart; }set_bit (HIF_HOLDER , &gh->gh_iflags); +trace_gfs2_promote (gh,0 );gfs2_holder_wake (gh);continue ; }
@@ -354,6 +364,7 @@ static inline void do_error(struct gfs2_glock *gl, const int ret)else continue ;list_del_init (&gh->gh_list); +trace_gfs2_glock_queue (gh,0 );gfs2_holder_wake (gh); } }
@@ -422,6 +433,7 @@ static void finish_xmote(struct gfs2_glock *gl, unsigned int ret)int rv;spin_lock (&gl->gl_spin); +trace_gfs2_glock_state_change (gl, state);state_change (gl, state); gh =find_first_waiter (gl);
@@ -836,6 +848,7 @@ static void handle_callback(struct gfs2_glock *gl, unsigned int state, gl->gl_demote_state != state) { gl->gl_demote_state =LM_ST_UNLOCKED ; } +trace_gfs2_demote_rq (gl); }/**
@@ -921,6 +934,7 @@ fail: goto do_cancel;return ; } +trace_gfs2_glock_queue (gh,1 );list_add_tail (&gh->gh_list, insert_pt); do_cancel: gh = list_entry(gl->gl_holders.next, struct gfs2_holder, gh_list);
@@ -1017,6 +1031,7 @@ void gfs2_glock_dq(struct gfs2_holder *gh) !test_bit(GLF_DEMOTE, &gl->gl_flags)) fast_path =1 ; } +trace_gfs2_glock_queue (gh,0 );spin_unlock (&gl->gl_spin);if (likely (fast_path))return ;
fs/gfs2/glock.h +29 -0
@@ -260,4 +260,33 @@ void gfs2_unregister_debugfs(void);extern const struct lm_lockops gfs2_dlm_ops; +static inline u8 glock_trace_state (unsigned int state) +{ +switch (state) { +case LM_ST_SHARED : +return DLM_LOCK_PR ; +case LM_ST_DEFERRED : +return DLM_LOCK_CW ; +case LM_ST_EXCLUSIVE : +return DLM_LOCK_EX ; + } +return DLM_LOCK_NL ; +} + +static inline const char *glock_trace_name (u8 state) +{ +switch (state) { +case DLM_LOCK_PR : +return "PR" ; +case DLM_LOCK_CW : +return "CW" ; +case DLM_LOCK_EX : +return "EX" ; +case DLM_LOCK_NL : +return "NL" ; +default : +return "--" ; + } +} +#endif /* __GLOCK_DOT_H__ */
fs/gfs2/incore.h +15 -0
@@ -667,5 +667,20 @@ struct gfs2_sbd { struct dentry *debugfs_dentry_glocks; /* for debugfs */ }; +static inline const char *gfs2_blkst_name (u8 state) +{ +switch (state) { +case GFS2_BLKST_FREE : +return "free" ; +case GFS2_BLKST_USED : +return "used" ; +case GFS2_BLKST_DINODE : +return "dinode" ; +case GFS2_BLKST_UNLINKED : +return "unlinked" ; + } +return "???" ; +} +#endif /* __INCORE_DOT_H__ */
fs/gfs2/inode.c +0 -1
@@ -383,7 +383,6 @@ int gfs2_dinode_dealloc(struct gfs2_inode *ip)set_bit (GLF_LFLUSH , &ip->i_gl->gl_flags);gfs2_free_di (rgd, ip); -gfs2_trans_end (sdp); out_rg_gunlock:
fs/gfs2/log.c +11 -0
@@ -18,6 +18,7 @@#include <linux/kthread.h> #include <linux/freezer.h> #include <linux/bio.h> +#include <trace/gfs2.h> #include "gfs2.h" #include "incore.h"
@@ -29,6 +30,9 @@#include "util.h" #include "dir.h" +DEFINE_TRACE (gfs2_log_flush); +DEFINE_TRACE (gfs2_log_blocks); +#define PULL 1/**
@@ -313,6 +317,7 @@ int gfs2_log_reserve(struct gfs2_sbd *sdp, unsigned int blks)gfs2_log_lock (sdp); }atomic_sub (blks, &sdp->sd_log_blks_free); +trace_gfs2_log_blocks (sdp, -blks);gfs2_log_unlock (sdp);mutex_unlock (&sdp->sd_log_reserve_mutex);
@@ -333,6 +338,7 @@ void gfs2_log_release(struct gfs2_sbd *sdp, unsigned int blks)gfs2_log_lock (sdp);atomic_add (blks, &sdp->sd_log_blks_free); +trace_gfs2_log_blocks (sdp, blks);gfs2_assert_withdraw (sdp,atomic_read (&sdp->sd_log_blks_free) <= sdp->sd_jdesc->jd_blocks);gfs2_log_unlock (sdp);
@@ -558,6 +564,7 @@ static void log_pull_tail(struct gfs2_sbd *sdp, unsigned int new_tail)gfs2_log_lock (sdp);atomic_add (dist, &sdp->sd_log_blks_free); +trace_gfs2_log_blocks (sdp, dist);gfs2_assert_withdraw (sdp,atomic_read (&sdp->sd_log_blks_free) <= sdp->sd_jdesc->jd_blocks);gfs2_log_unlock (sdp);
@@ -715,6 +722,7 @@ void __gfs2_log_flush(struct gfs2_sbd *sdp, struct gfs2_glock *gl)up_write (&sdp->sd_log_flush_lock);return ; } +trace_gfs2_log_flush (sdp,1 ); ai =kzalloc (sizeof (struct gfs2_ail ),GFP_NOFS | __GFP_NOFAIL);INIT_LIST_HEAD (&ai->ai_ail1_list);
@@ -746,6 +754,7 @@ void __gfs2_log_flush(struct gfs2_sbd *sdp, struct gfs2_glock *gl)else if (sdp->sd_log_tail !=current_tail (sdp) && !sdp->sd_log_idle){gfs2_log_lock (sdp);atomic_dec (&sdp->sd_log_blks_free);/* Adjust for unreserved buffer */ +trace_gfs2_log_blocks (sdp,-1 );gfs2_log_unlock (sdp);log_write_header (sdp,0 ,PULL ); }
@@ -765,6 +774,7 @@ void __gfs2_log_flush(struct gfs2_sbd *sdp, struct gfs2_glock *gl)gfs2_log_unlock (sdp); sdp->sd_vfs->s_dirt =0 ; +trace_gfs2_log_flush (sdp,0 );up_write (&sdp->sd_log_flush_lock);kfree (ai);
@@ -788,6 +798,7 @@ static void log_refund(struct gfs2_sbd *sdp, struct gfs2_trans *tr)gfs2_assert_withdraw (sdp, sdp->sd_log_blks_reserved + tr->tr_reserved >= reserved); unused = sdp->sd_log_blks_reserved - reserved + tr->tr_reserved;atomic_add (unused, &sdp->sd_log_blks_free); +trace_gfs2_log_blocks (sdp, unused);gfs2_assert_withdraw (sdp,atomic_read (&sdp->sd_log_blks_free) <= sdp->sd_jdesc->jd_blocks); sdp->sd_log_blks_reserved = reserved;
fs/gfs2/lops.c +5 -0
@@ -15,6 +15,7 @@#include <linux/gfs2_ondisk.h> #include <linux/bio.h> #include <linux/fs.h> +#include <trace/gfs2.h> #include "gfs2.h" #include "incore.h"
@@ -28,6 +29,8 @@#include "trans.h" #include "util.h" +DEFINE_TRACE (gfs2_pin); +/** * gfs2_pin - Pin a buffer in memory * @sdp: The superblock
@@ -53,6 +56,7 @@ static void gfs2_pin(struct gfs2_sbd *sdp, struct buffer_head *bh)if (bd->bd_ail)list_move (&bd->bd_ail_st_list, &bd->bd_ail->ai_ail2_list);get_bh (bh); +trace_gfs2_pin (bd,1 ); }/**
@@ -89,6 +93,7 @@ static void gfs2_unpin(struct gfs2_sbd *sdp, struct buffer_head *bh, bd->bd_ail = ai;list_add (&bd->bd_ail_st_list, &ai->ai_ail1_list);clear_bit (GLF_LFLUSH , &bd->bd_gl->gl_flags); +trace_gfs2_pin (bd,0 );gfs2_log_unlock (sdp);unlock_buffer (bh); }
fs/gfs2/ops_fstype.c +2 -0
@@ -17,6 +17,7 @@#include <linux/namei.h> #include <linux/mount.h> #include <linux/gfs2_ondisk.h> +#include <trace/gfs2.h> #include "gfs2.h" #include "incore.h"
@@ -781,6 +782,7 @@ static int init_journal(struct gfs2_sbd *sdp, int undo)/* Map the extents for this journal's blocks */ map_journal_extents (sdp); } +trace_gfs2_log_blocks (sdp,atomic_read (&sdp->sd_log_blks_free));if (sdp->sd_lockstruct.ls_first) {unsigned int x;
fs/gfs2/rgrp.c +9 -4
@@ -15,6 +15,7 @@#include <linux/gfs2_ondisk.h> #include <linux/prefetch.h> #include <linux/blkdev.h> +#include <trace/gfs2.h> #include "gfs2.h" #include "incore.h"
@@ -31,6 +32,8 @@#include "inode.h" #include "ops_address.h" +DEFINE_TRACE (gfs2_block_alloc); +#define BFITNOENT ((u32)~0)#define NO_BLOCK ((u64)~0)
@@ -1431,7 +1434,6 @@ static struct gfs2_rgrpd *rgblk_free(struct gfs2_sbd *sdp, u64 bstart,gfs2_setbit (rgd, bi->bi_bh->b_data,NULL , bi->bi_offset, bi->bi_len, buf_blk, new_state); } -return rgd; }
@@ -1476,7 +1478,7 @@ u64 gfs2_alloc_block(struct gfs2_inode *ip, unsigned int *n)spin_lock (&sdp->sd_rindex_spin); rgd->rd_free_clone -= *n;spin_unlock (&sdp->sd_rindex_spin); - +trace_gfs2_block_alloc (ip, block, *n,GFS2_BLKST_USED );return block; }
@@ -1519,7 +1521,7 @@ u64 gfs2_alloc_di(struct gfs2_inode *dip, u64 *generation)spin_lock (&sdp->sd_rindex_spin); rgd->rd_free_clone--;spin_unlock (&sdp->sd_rindex_spin); - +trace_gfs2_block_alloc (dip, block,1 ,GFS2_BLKST_DINODE );return block; }
@@ -1539,7 +1541,7 @@ void gfs2_free_data(struct gfs2_inode *ip, u64 bstart, u32 blen) rgd =rgblk_free (sdp, bstart, blen,GFS2_BLKST_FREE );if (!rgd)return ; - +trace_gfs2_block_alloc (ip, bstart, blen,GFS2_BLKST_FREE ); rgd->rd_free += blen;gfs2_trans_add_bh (rgd->rd_gl, rgd->rd_bits[0 ].bi_bh,1 );
@@ -1567,6 +1569,7 @@ void gfs2_free_meta(struct gfs2_inode *ip, u64 bstart, u32 blen) rgd =rgblk_free (sdp, bstart, blen,GFS2_BLKST_FREE );if (!rgd)return ; +trace_gfs2_block_alloc (ip, bstart, blen,GFS2_BLKST_FREE ); rgd->rd_free += blen;
@@ -1590,6 +1593,7 @@ void gfs2_unlink_di(struct inode *inode) rgd =rgblk_free (sdp, blkno,1 ,GFS2_BLKST_UNLINKED );if (!rgd)return ; +trace_gfs2_block_alloc (ip, blkno,1 ,GFS2_BLKST_UNLINKED );gfs2_trans_add_bh (rgd->rd_gl, rgd->rd_bits[0 ].bi_bh,1 );gfs2_rgrp_out (rgd, rgd->rd_bits[0 ].bi_bh->b_data);gfs2_trans_add_rg (rgd);
@@ -1621,6 +1625,7 @@ static void gfs2_free_uninit_di(struct gfs2_rgrpd *rgd, u64 blkno)void gfs2_free_di (struct gfs2_rgrpd *rgd,struct gfs2_inode *ip) {gfs2_free_uninit_di (rgd, ip->i_no_addr); +trace_gfs2_block_alloc (ip, ip->i_no_addr,1 ,GFS2_BLKST_FREE );gfs2_quota_change (ip,-1 , ip->i_inode.i_uid, ip->i_inode.i_gid);gfs2_meta_wipe (ip, ip->i_no_addr,1 ); }
include/trace/gfs2.h new file +9 -0
@@ -0,0 +1,9 @@ +#ifndef _TRACE_GFS2_H +#define _TRACE_GFS2_H + +#include <linux/sched.h> +#include <linux/tracepoint.h> + +#include <trace/gfs2_event_types.h> + +#endif /* _TRACE_GFS2_H */
include/trace/gfs2_event_types.h new file +391 -0
391 lines not on this page · raw message
include/trace/trace_event_types.h +2 -0
@@ -3,3 +3,5 @@#include <trace/sched_event_types.h> #include <trace/irq_event_types.h> #include <trace/lockdep_event_types.h> +#include <trace/gfs2_event_types.h> +
include/trace/trace_events.h +2 -0
@@ -3,3 +3,5 @@#include <trace/sched.h> #include <trace/irq.h> #include <trace/lockdep.h> +#include <trace/gfs2.h> +
Signature · 1 line
1.6.0.6
Hi,
Quoted 5 lines · Steven Whitehouse
Quoted 1 line
From
c154c0500fa6f5fad6eb95cf9f1b578a5cd24525Mon Sep 17 00:00:00 2001From: Steven Whitehouse <[email protected]>
Date: Tue, 14 Apr 2009 16:13:55 +0100
Subject: [PATCH] GFS2: Tracing support
Quoted 8 lines
This is my initial attempt at tracing support for GFS2. There are three major themes covering glocks, logging and bmap/alloc. It seems to work ok on its own, although the plan is to be able to use it in conjunction with blktrace in order to provide a means of testing correctness and performance analysis of GFS2.
Signed-off-by Steven Whitehouse <[email protected]>
Some further notes:
Firstly there seems to be an issue with formatting when blktrace and one or more of the events tracers are used in combination. There are patches being proposed at the moment to solve this issue, so it shouldn't be too long before that is fixed.
Also there are patches in the works to merge the two tracing headers into one. That means that this patch will have to change too. It might be easier for me to submit this via the tracing tree, rather than the gfs2 tree bearing in mind the number of changes going on in the tracing tree right now.
Steve.