Skip to contentSkip to conversation

GFS2: Expand and make useful the log_flush kernel trace point

PATCH New Bob Peterson 2 participants 2 messages Jan 9, 2017 1 message not in the archive GFS2 file system

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw

PATCH 1/1 GFS2: Expand and make useful the log_flush kernel trace point

Hi,

This patch changes the log_flush kernel trace point so that it actually gives you meaningful statistics about the journal:

Output looks like this:
gfs2_logd-10580 [009] .... 1390.398627: gfs2_log_flush: 253,8 log flush start 8532 r:0 cr:0 v:0 f:5002 n:6153 h:5570/5570 t:2380 a1:2 a2:0 o:1 l:0 i:1

r: sd_log_blks_reserved
cr: sd_log_commited_revoke
v: sd_log_num_revoke
f: sd_log_blks_free
n: sd_log_blks_needed
h: sd_log_head / sd_log_flush_head
t: sd_log_tail
a1: count of items on the sd_ail1_list
a2: count of items on the sd_ail2_list
o: count of items on the sd_log_le_ordered list
l: sd_log_in_flight
i: sd_log_idle

---

fs/gfs2/trace_gfs2.h +52 -2
index 49ac55d..cdecd1c 100644
@@ -73,6 +73,16 @@ static inline u8 glock_trace_state(unsigned int state)
 	}
 	return DLM_LOCK_NL;
 }
+
+static inline const unsigned int list_count(const struct list_head *head)
+{
+	const struct list_head *tmp;
+	unsigned int count = 0;
+	list_for_each(tmp, head)
+		count++;
+	return count;
+}
+
 #endif
 
 /* Section 1 - Locking
@@ -359,18 +369,58 @@ TRACE_EVENT(gfs2_log_flush,
 		__field(        dev_t,  dev                     )
 		__field(	int,	start			)
 		__field(	u64,	log_seq			)
+		__field(	unsigned int,	sd_log_blks_reserved	)
+		__field(	int,	sd_log_commited_revoke	)
+		__field(	unsigned int,	sd_log_num_revoke	)
+		__field(	int,	sd_log_blks_free	)
+		__field(	int,	sd_log_blks_needed	)
+		__field(	unsigned int,	sd_log_head	)
+		__field(	unsigned int,	sd_log_flush_head	)
+		__field(	unsigned int,	sd_log_tail	)
+		__field(	unsigned int,	ail1_count	)
+		__field(	unsigned int,	ail2_count	)
+		__field(	unsigned int,	ordered_count	)
+		__field(	int,	sd_log_in_flight	)
+		__field(	int,	sd_log_idle	)
 	),
 
 	TP_fast_assign(
 		__entry->dev            = sdp->sd_vfs->s_dev;
 		__entry->start		= start;
 		__entry->log_seq	= sdp->sd_log_sequence;
+		__entry->sd_log_blks_reserved	= sdp->sd_log_blks_reserved;
+		__entry->sd_log_commited_revoke	= sdp->sd_log_commited_revoke;
+		__entry->sd_log_num_revoke	= sdp->sd_log_num_revoke;
+		__entry->sd_log_blks_free	= atomic_read(&sdp->sd_log_blks_free);
+		__entry->sd_log_blks_needed	= atomic_read(&sdp->sd_log_blks_needed);
+		__entry->sd_log_head	= sdp->sd_log_head;
+		__entry->sd_log_flush_head	= sdp->sd_log_flush_head;
+		__entry->sd_log_tail	= sdp->sd_log_tail;
+		__entry->ail1_count = list_count(&sdp->sd_ail1_list);
+		__entry->ail2_count = list_count(&sdp->sd_ail2_list);
+		__entry->ordered_count = list_count(&sdp->sd_log_le_ordered);
+		__entry->sd_log_in_flight = atomic_read(&sdp->sd_log_in_flight);
+		__entry->sd_log_idle = sdp->sd_log_idle;
 	),
 
-	TP_printk("%u,%u log flush %s %llu",
+	TP_printk("%u,%u log flush %s %llu r:%u cr:%d v:%u "
+		  "f:%d n:%d h:%u/%u t:%u a1:%u a2:%u o:%u l:%d i:%d",
 		  MAJOR(__entry->dev), MINOR(__entry->dev),
 		  __entry->start ? "start" : "end",
-		  (unsigned long long)__entry->log_seq)
+		  (unsigned long long)__entry->log_seq,
+		  __entry->sd_log_blks_reserved,
+		  __entry->sd_log_commited_revoke,
+		  __entry->sd_log_num_revoke,
+		  __entry->sd_log_blks_free,
+		  __entry->sd_log_blks_needed,
+		  __entry->sd_log_head,
+		  __entry->sd_log_flush_head,
+		  __entry->sd_log_tail,
+		  __entry->ail1_count,
+		  __entry->ail2_count,
+		  __entry->ordered_count,
+		  __entry->sd_log_in_flight,
+		  __entry->sd_log_idle)
 );
 
 /* Reserving/releasing blocks in the log */
#2 lore raw

PATCH 1/1 GFS2: Expand and make useful the log_flush kernel trace point

Quoted 8 lines · Bob Peterson

Hi,

This patch changes the log_flush kernel trace point so that it actually gives you meaningful statistics about the journal:

Output looks like this:

    gfs2_logd-10580 [009] ....  1390.398627: gfs2_log_flush: 253,8 log flush start 8532 r:0 cr:0 v:0 f:5002 n:6153 h:5570/5570 t:2380 a1:2 a2:0 o:1 l:0 i:1
Quoted 12 lines

r: sd_log_blks_reserved
cr: sd_log_commited_revoke
v: sd_log_num_revoke
f: sd_log_blks_free
n: sd_log_blks_needed
h: sd_log_head / sd_log_flush_head
t: sd_log_tail
a1: count of items on the sd_ail1_list
a2: count of items on the sd_ail2_list
o: count of items on the sd_log_le_ordered list
l: sd_log_in_flight
i: sd_log_idle

I think several of those letters have been used before. Another concern is that a lot of those numbers are very implementation specific, and might have to change in due course. Adding the head/tail of the log seems like a useful thing to do though. No point adding "log in flight" since that will be 0 on both entry and exit to a log flush because we always wait for all the I/O.

Another issue is the tracepoints are supposed to be fast, counting the number of items in a list which is already so long that it causes performance issues upon occasion is definitely not a good plan.

We already have a pin/unpin tracepoint to track pinned blocks, so that is already tracking what is going into the AIL, so maybe we just need something when blocks exit the AIL? Perhaps better to keep AIL tracking separate from log tracing too.

The only other possible thing we might want to track is writes to the log which are not associated with pinned blocks, such as log headers, etc.,

Steve.

Quoted 85 lines

---

fs/gfs2/trace_gfs2.h +52 -2
index 49ac55d..cdecd1c 100644
@@ -73,6 +73,16 @@ static inline u8 glock_trace_state(unsigned int state)
  	}
  	return DLM_LOCK_NL;
  }
+
+static inline const unsigned int list_count(const struct list_head *head)
+{
+	const struct list_head *tmp;
+	unsigned int count = 0;
+	list_for_each(tmp, head)
+		count++;
+	return count;
+}
+
  #endif
 
  /* Section 1 - Locking
@@ -359,18 +369,58 @@ TRACE_EVENT(gfs2_log_flush,
  		__field(        dev_t,  dev                     )
  		__field(	int,	start			)
  		__field(	u64,	log_seq			)
+		__field(	unsigned int,	sd_log_blks_reserved	)
+		__field(	int,	sd_log_commited_revoke	)
+		__field(	unsigned int,	sd_log_num_revoke	)
+		__field(	int,	sd_log_blks_free	)
+		__field(	int,	sd_log_blks_needed	)
+		__field(	unsigned int,	sd_log_head	)
+		__field(	unsigned int,	sd_log_flush_head	)
+		__field(	unsigned int,	sd_log_tail	)
+		__field(	unsigned int,	ail1_count	)
+		__field(	unsigned int,	ail2_count	)
+		__field(	unsigned int,	ordered_count	)
+		__field(	int,	sd_log_in_flight	)
+		__field(	int,	sd_log_idle	)
  	),
 
  	TP_fast_assign(
  		__entry->dev            = sdp->sd_vfs->s_dev;
  		__entry->start		= start;
  		__entry->log_seq	= sdp->sd_log_sequence;
+		__entry->sd_log_blks_reserved	= sdp->sd_log_blks_reserved;
+		__entry->sd_log_commited_revoke	= sdp->sd_log_commited_revoke;
+		__entry->sd_log_num_revoke	= sdp->sd_log_num_revoke;
+		__entry->sd_log_blks_free	= atomic_read(&sdp->sd_log_blks_free);
+		__entry->sd_log_blks_needed	= atomic_read(&sdp->sd_log_blks_needed);
+		__entry->sd_log_head	= sdp->sd_log_head;
+		__entry->sd_log_flush_head	= sdp->sd_log_flush_head;
+		__entry->sd_log_tail	= sdp->sd_log_tail;
+		__entry->ail1_count = list_count(&sdp->sd_ail1_list);
+		__entry->ail2_count = list_count(&sdp->sd_ail2_list);
+		__entry->ordered_count = list_count(&sdp->sd_log_le_ordered);
+		__entry->sd_log_in_flight = atomic_read(&sdp->sd_log_in_flight);
+		__entry->sd_log_idle = sdp->sd_log_idle;
  	),
 
-	TP_printk("%u,%u log flush %s %llu",
+	TP_printk("%u,%u log flush %s %llu r:%u cr:%d v:%u "
+		  "f:%d n:%d h:%u/%u t:%u a1:%u a2:%u o:%u l:%d i:%d",
  		  MAJOR(__entry->dev), MINOR(__entry->dev),
  		  __entry->start ? "start" : "end",
-		  (unsigned long long)__entry->log_seq)
+		  (unsigned long long)__entry->log_seq,
+		  __entry->sd_log_blks_reserved,
+		  __entry->sd_log_commited_revoke,
+		  __entry->sd_log_num_revoke,
+		  __entry->sd_log_blks_free,
+		  __entry->sd_log_blks_needed,
+		  __entry->sd_log_head,
+		  __entry->sd_log_flush_head,
+		  __entry->sd_log_tail,
+		  __entry->ail1_count,
+		  __entry->ail2_count,
+		  __entry->ordered_count,
+		  __entry->sd_log_in_flight,
+		  __entry->sd_log_idle)
  );
 
  /* Reserving/releasing blocks in the log */