mirror of
https://github.com/adulau/aha.git
synced 2024-12-29 04:06:22 +00:00
jbd2: convert instrumentation from markers to tracepoints
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
This commit is contained in:
parent
65795efbd3
commit
879c5e6b7c
5 changed files with 252 additions and 9 deletions
|
@ -20,9 +20,9 @@
|
||||||
#include <linux/time.h>
|
#include <linux/time.h>
|
||||||
#include <linux/fs.h>
|
#include <linux/fs.h>
|
||||||
#include <linux/jbd2.h>
|
#include <linux/jbd2.h>
|
||||||
#include <linux/marker.h>
|
|
||||||
#include <linux/errno.h>
|
#include <linux/errno.h>
|
||||||
#include <linux/slab.h>
|
#include <linux/slab.h>
|
||||||
|
#include <trace/events/jbd2.h>
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Unlink a buffer from a transaction checkpoint list.
|
* Unlink a buffer from a transaction checkpoint list.
|
||||||
|
@ -358,8 +358,7 @@ int jbd2_log_do_checkpoint(journal_t *journal)
|
||||||
* journal straight away.
|
* journal straight away.
|
||||||
*/
|
*/
|
||||||
result = jbd2_cleanup_journal_tail(journal);
|
result = jbd2_cleanup_journal_tail(journal);
|
||||||
trace_mark(jbd2_checkpoint, "dev %s need_checkpoint %d",
|
trace_jbd2_checkpoint(journal, result);
|
||||||
journal->j_devname, result);
|
|
||||||
jbd_debug(1, "cleanup_journal_tail returned %d\n", result);
|
jbd_debug(1, "cleanup_journal_tail returned %d\n", result);
|
||||||
if (result <= 0)
|
if (result <= 0)
|
||||||
return result;
|
return result;
|
||||||
|
|
|
@ -16,7 +16,6 @@
|
||||||
#include <linux/time.h>
|
#include <linux/time.h>
|
||||||
#include <linux/fs.h>
|
#include <linux/fs.h>
|
||||||
#include <linux/jbd2.h>
|
#include <linux/jbd2.h>
|
||||||
#include <linux/marker.h>
|
|
||||||
#include <linux/errno.h>
|
#include <linux/errno.h>
|
||||||
#include <linux/slab.h>
|
#include <linux/slab.h>
|
||||||
#include <linux/mm.h>
|
#include <linux/mm.h>
|
||||||
|
@ -26,6 +25,7 @@
|
||||||
#include <linux/writeback.h>
|
#include <linux/writeback.h>
|
||||||
#include <linux/backing-dev.h>
|
#include <linux/backing-dev.h>
|
||||||
#include <linux/bio.h>
|
#include <linux/bio.h>
|
||||||
|
#include <trace/events/jbd2.h>
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Default IO end handler for temporary BJ_IO buffer_heads.
|
* Default IO end handler for temporary BJ_IO buffer_heads.
|
||||||
|
@ -253,6 +253,7 @@ static int journal_submit_data_buffers(journal_t *journal,
|
||||||
* block allocation with delalloc. We need to write
|
* block allocation with delalloc. We need to write
|
||||||
* only allocated blocks here.
|
* only allocated blocks here.
|
||||||
*/
|
*/
|
||||||
|
trace_jbd2_submit_inode_data(jinode->i_vfs_inode);
|
||||||
err = journal_submit_inode_data_buffers(mapping);
|
err = journal_submit_inode_data_buffers(mapping);
|
||||||
if (!ret)
|
if (!ret)
|
||||||
ret = err;
|
ret = err;
|
||||||
|
@ -394,8 +395,7 @@ void jbd2_journal_commit_transaction(journal_t *journal)
|
||||||
commit_transaction = journal->j_running_transaction;
|
commit_transaction = journal->j_running_transaction;
|
||||||
J_ASSERT(commit_transaction->t_state == T_RUNNING);
|
J_ASSERT(commit_transaction->t_state == T_RUNNING);
|
||||||
|
|
||||||
trace_mark(jbd2_start_commit, "dev %s transaction %d",
|
trace_jbd2_start_commit(journal, commit_transaction);
|
||||||
journal->j_devname, commit_transaction->t_tid);
|
|
||||||
jbd_debug(1, "JBD: starting commit of transaction %d\n",
|
jbd_debug(1, "JBD: starting commit of transaction %d\n",
|
||||||
commit_transaction->t_tid);
|
commit_transaction->t_tid);
|
||||||
|
|
||||||
|
@ -409,6 +409,7 @@ void jbd2_journal_commit_transaction(journal_t *journal)
|
||||||
*/
|
*/
|
||||||
if (commit_transaction->t_synchronous_commit)
|
if (commit_transaction->t_synchronous_commit)
|
||||||
write_op = WRITE_SYNC_PLUG;
|
write_op = WRITE_SYNC_PLUG;
|
||||||
|
trace_jbd2_commit_locking(journal, commit_transaction);
|
||||||
stats.u.run.rs_wait = commit_transaction->t_max_wait;
|
stats.u.run.rs_wait = commit_transaction->t_max_wait;
|
||||||
stats.u.run.rs_locked = jiffies;
|
stats.u.run.rs_locked = jiffies;
|
||||||
stats.u.run.rs_running = jbd2_time_diff(commit_transaction->t_start,
|
stats.u.run.rs_running = jbd2_time_diff(commit_transaction->t_start,
|
||||||
|
@ -484,6 +485,7 @@ void jbd2_journal_commit_transaction(journal_t *journal)
|
||||||
*/
|
*/
|
||||||
jbd2_journal_switch_revoke_table(journal);
|
jbd2_journal_switch_revoke_table(journal);
|
||||||
|
|
||||||
|
trace_jbd2_commit_flushing(journal, commit_transaction);
|
||||||
stats.u.run.rs_flushing = jiffies;
|
stats.u.run.rs_flushing = jiffies;
|
||||||
stats.u.run.rs_locked = jbd2_time_diff(stats.u.run.rs_locked,
|
stats.u.run.rs_locked = jbd2_time_diff(stats.u.run.rs_locked,
|
||||||
stats.u.run.rs_flushing);
|
stats.u.run.rs_flushing);
|
||||||
|
@ -520,6 +522,7 @@ void jbd2_journal_commit_transaction(journal_t *journal)
|
||||||
commit_transaction->t_state = T_COMMIT;
|
commit_transaction->t_state = T_COMMIT;
|
||||||
spin_unlock(&journal->j_state_lock);
|
spin_unlock(&journal->j_state_lock);
|
||||||
|
|
||||||
|
trace_jbd2_commit_logging(journal, commit_transaction);
|
||||||
stats.u.run.rs_logging = jiffies;
|
stats.u.run.rs_logging = jiffies;
|
||||||
stats.u.run.rs_flushing = jbd2_time_diff(stats.u.run.rs_flushing,
|
stats.u.run.rs_flushing = jbd2_time_diff(stats.u.run.rs_flushing,
|
||||||
stats.u.run.rs_logging);
|
stats.u.run.rs_logging);
|
||||||
|
@ -1054,9 +1057,7 @@ restart_loop:
|
||||||
if (journal->j_commit_callback)
|
if (journal->j_commit_callback)
|
||||||
journal->j_commit_callback(journal, commit_transaction);
|
journal->j_commit_callback(journal, commit_transaction);
|
||||||
|
|
||||||
trace_mark(jbd2_end_commit, "dev %s transaction %d head %d",
|
trace_jbd2_end_commit(journal, commit_transaction);
|
||||||
journal->j_devname, commit_transaction->t_tid,
|
|
||||||
journal->j_tail_sequence);
|
|
||||||
jbd_debug(1, "JBD: commit %d complete, head %d\n",
|
jbd_debug(1, "JBD: commit %d complete, head %d\n",
|
||||||
journal->j_commit_sequence, journal->j_tail_sequence);
|
journal->j_commit_sequence, journal->j_tail_sequence);
|
||||||
if (to_free)
|
if (to_free)
|
||||||
|
|
|
@ -38,6 +38,10 @@
|
||||||
#include <linux/debugfs.h>
|
#include <linux/debugfs.h>
|
||||||
#include <linux/seq_file.h>
|
#include <linux/seq_file.h>
|
||||||
#include <linux/math64.h>
|
#include <linux/math64.h>
|
||||||
|
#include <linux/hash.h>
|
||||||
|
|
||||||
|
#define CREATE_TRACE_POINTS
|
||||||
|
#include <trace/events/jbd2.h>
|
||||||
|
|
||||||
#include <asm/uaccess.h>
|
#include <asm/uaccess.h>
|
||||||
#include <asm/page.h>
|
#include <asm/page.h>
|
||||||
|
@ -2377,6 +2381,71 @@ static void __exit journal_exit(void)
|
||||||
jbd2_journal_destroy_caches();
|
jbd2_journal_destroy_caches();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* jbd2_dev_to_name is a utility function used by the jbd2 and ext4
|
||||||
|
* tracing infrastructure to map a dev_t to a device name.
|
||||||
|
*
|
||||||
|
* The caller should use rcu_read_lock() in order to make sure the
|
||||||
|
* device name stays valid until its done with it. We use
|
||||||
|
* rcu_read_lock() as well to make sure we're safe in case the caller
|
||||||
|
* gets sloppy, and because rcu_read_lock() is cheap and can be safely
|
||||||
|
* nested.
|
||||||
|
*/
|
||||||
|
struct devname_cache {
|
||||||
|
struct rcu_head rcu;
|
||||||
|
dev_t device;
|
||||||
|
char devname[BDEVNAME_SIZE];
|
||||||
|
};
|
||||||
|
#define CACHE_SIZE_BITS 6
|
||||||
|
static struct devname_cache *devcache[1 << CACHE_SIZE_BITS];
|
||||||
|
static DEFINE_SPINLOCK(devname_cache_lock);
|
||||||
|
|
||||||
|
static void free_devcache(struct rcu_head *rcu)
|
||||||
|
{
|
||||||
|
kfree(rcu);
|
||||||
|
}
|
||||||
|
|
||||||
|
const char *jbd2_dev_to_name(dev_t device)
|
||||||
|
{
|
||||||
|
int i = hash_32(device, CACHE_SIZE_BITS);
|
||||||
|
char *ret;
|
||||||
|
struct block_device *bd;
|
||||||
|
|
||||||
|
rcu_read_lock();
|
||||||
|
if (devcache[i] && devcache[i]->device == device) {
|
||||||
|
ret = devcache[i]->devname;
|
||||||
|
rcu_read_unlock();
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
rcu_read_unlock();
|
||||||
|
|
||||||
|
spin_lock(&devname_cache_lock);
|
||||||
|
if (devcache[i]) {
|
||||||
|
if (devcache[i]->device == device) {
|
||||||
|
ret = devcache[i]->devname;
|
||||||
|
spin_unlock(&devname_cache_lock);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
call_rcu(&devcache[i]->rcu, free_devcache);
|
||||||
|
}
|
||||||
|
devcache[i] = kmalloc(sizeof(struct devname_cache), GFP_KERNEL);
|
||||||
|
if (!devcache[i]) {
|
||||||
|
spin_unlock(&devname_cache_lock);
|
||||||
|
return "NODEV-ALLOCFAILURE"; /* Something non-NULL */
|
||||||
|
}
|
||||||
|
devcache[i]->device = device;
|
||||||
|
bd = bdget(device);
|
||||||
|
if (bd) {
|
||||||
|
bdevname(bd, devcache[i]->devname);
|
||||||
|
bdput(bd);
|
||||||
|
} else
|
||||||
|
__bdevname(device, devcache[i]->devname);
|
||||||
|
ret = devcache[i]->devname;
|
||||||
|
spin_unlock(&devname_cache_lock);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
EXPORT_SYMBOL(jbd2_dev_to_name);
|
||||||
|
|
||||||
MODULE_LICENSE("GPL");
|
MODULE_LICENSE("GPL");
|
||||||
module_init(journal_init);
|
module_init(journal_init);
|
||||||
module_exit(journal_exit);
|
module_exit(journal_exit);
|
||||||
|
|
|
@ -1315,6 +1315,12 @@ extern int jbd_blocks_per_page(struct inode *inode);
|
||||||
#define BUFFER_TRACE2(bh, bh2, info) do {} while (0)
|
#define BUFFER_TRACE2(bh, bh2, info) do {} while (0)
|
||||||
#define JBUFFER_TRACE(jh, info) do {} while (0)
|
#define JBUFFER_TRACE(jh, info) do {} while (0)
|
||||||
|
|
||||||
|
/*
|
||||||
|
* jbd2_dev_to_name is a utility function used by the jbd2 and ext4
|
||||||
|
* tracing infrastructure to map a dev_t to a device name.
|
||||||
|
*/
|
||||||
|
extern const char *jbd2_dev_to_name(dev_t device);
|
||||||
|
|
||||||
#endif /* __KERNEL__ */
|
#endif /* __KERNEL__ */
|
||||||
|
|
||||||
#endif /* _LINUX_JBD2_H */
|
#endif /* _LINUX_JBD2_H */
|
||||||
|
|
168
include/trace/events/jbd2.h
Normal file
168
include/trace/events/jbd2.h
Normal file
|
@ -0,0 +1,168 @@
|
||||||
|
#if !defined(_TRACE_JBD2_H) || defined(TRACE_HEADER_MULTI_READ)
|
||||||
|
#define _TRACE_JBD2_H
|
||||||
|
|
||||||
|
#include <linux/jbd2.h>
|
||||||
|
#include <linux/tracepoint.h>
|
||||||
|
|
||||||
|
#undef TRACE_SYSTEM
|
||||||
|
#define TRACE_SYSTEM jbd2
|
||||||
|
|
||||||
|
TRACE_EVENT(jbd2_checkpoint,
|
||||||
|
|
||||||
|
TP_PROTO(journal_t *journal, int result),
|
||||||
|
|
||||||
|
TP_ARGS(journal, result),
|
||||||
|
|
||||||
|
TP_STRUCT__entry(
|
||||||
|
__field( dev_t, dev )
|
||||||
|
__field( int, result )
|
||||||
|
),
|
||||||
|
|
||||||
|
TP_fast_assign(
|
||||||
|
__entry->dev = journal->j_fs_dev->bd_dev;
|
||||||
|
__entry->result = result;
|
||||||
|
),
|
||||||
|
|
||||||
|
TP_printk("dev %s result %d",
|
||||||
|
jbd2_dev_to_name(__entry->dev), __entry->result)
|
||||||
|
);
|
||||||
|
|
||||||
|
TRACE_EVENT(jbd2_start_commit,
|
||||||
|
|
||||||
|
TP_PROTO(journal_t *journal, transaction_t *commit_transaction),
|
||||||
|
|
||||||
|
TP_ARGS(journal, commit_transaction),
|
||||||
|
|
||||||
|
TP_STRUCT__entry(
|
||||||
|
__field( dev_t, dev )
|
||||||
|
__field( char, sync_commit )
|
||||||
|
__field( int, transaction )
|
||||||
|
),
|
||||||
|
|
||||||
|
TP_fast_assign(
|
||||||
|
__entry->dev = journal->j_fs_dev->bd_dev;
|
||||||
|
__entry->sync_commit = commit_transaction->t_synchronous_commit;
|
||||||
|
__entry->transaction = commit_transaction->t_tid;
|
||||||
|
),
|
||||||
|
|
||||||
|
TP_printk("dev %s transaction %d sync %d",
|
||||||
|
jbd2_dev_to_name(__entry->dev), __entry->transaction,
|
||||||
|
__entry->sync_commit)
|
||||||
|
);
|
||||||
|
|
||||||
|
TRACE_EVENT(jbd2_commit_locking,
|
||||||
|
|
||||||
|
TP_PROTO(journal_t *journal, transaction_t *commit_transaction),
|
||||||
|
|
||||||
|
TP_ARGS(journal, commit_transaction),
|
||||||
|
|
||||||
|
TP_STRUCT__entry(
|
||||||
|
__field( dev_t, dev )
|
||||||
|
__field( char, sync_commit )
|
||||||
|
__field( int, transaction )
|
||||||
|
),
|
||||||
|
|
||||||
|
TP_fast_assign(
|
||||||
|
__entry->dev = journal->j_fs_dev->bd_dev;
|
||||||
|
__entry->sync_commit = commit_transaction->t_synchronous_commit;
|
||||||
|
__entry->transaction = commit_transaction->t_tid;
|
||||||
|
),
|
||||||
|
|
||||||
|
TP_printk("dev %s transaction %d sync %d",
|
||||||
|
jbd2_dev_to_name(__entry->dev), __entry->transaction,
|
||||||
|
__entry->sync_commit)
|
||||||
|
);
|
||||||
|
|
||||||
|
TRACE_EVENT(jbd2_commit_flushing,
|
||||||
|
|
||||||
|
TP_PROTO(journal_t *journal, transaction_t *commit_transaction),
|
||||||
|
|
||||||
|
TP_ARGS(journal, commit_transaction),
|
||||||
|
|
||||||
|
TP_STRUCT__entry(
|
||||||
|
__field( dev_t, dev )
|
||||||
|
__field( char, sync_commit )
|
||||||
|
__field( int, transaction )
|
||||||
|
),
|
||||||
|
|
||||||
|
TP_fast_assign(
|
||||||
|
__entry->dev = journal->j_fs_dev->bd_dev;
|
||||||
|
__entry->sync_commit = commit_transaction->t_synchronous_commit;
|
||||||
|
__entry->transaction = commit_transaction->t_tid;
|
||||||
|
),
|
||||||
|
|
||||||
|
TP_printk("dev %s transaction %d sync %d",
|
||||||
|
jbd2_dev_to_name(__entry->dev), __entry->transaction,
|
||||||
|
__entry->sync_commit)
|
||||||
|
);
|
||||||
|
|
||||||
|
TRACE_EVENT(jbd2_commit_logging,
|
||||||
|
|
||||||
|
TP_PROTO(journal_t *journal, transaction_t *commit_transaction),
|
||||||
|
|
||||||
|
TP_ARGS(journal, commit_transaction),
|
||||||
|
|
||||||
|
TP_STRUCT__entry(
|
||||||
|
__field( dev_t, dev )
|
||||||
|
__field( char, sync_commit )
|
||||||
|
__field( int, transaction )
|
||||||
|
),
|
||||||
|
|
||||||
|
TP_fast_assign(
|
||||||
|
__entry->dev = journal->j_fs_dev->bd_dev;
|
||||||
|
__entry->sync_commit = commit_transaction->t_synchronous_commit;
|
||||||
|
__entry->transaction = commit_transaction->t_tid;
|
||||||
|
),
|
||||||
|
|
||||||
|
TP_printk("dev %s transaction %d sync %d",
|
||||||
|
jbd2_dev_to_name(__entry->dev), __entry->transaction,
|
||||||
|
__entry->sync_commit)
|
||||||
|
);
|
||||||
|
|
||||||
|
TRACE_EVENT(jbd2_end_commit,
|
||||||
|
TP_PROTO(journal_t *journal, transaction_t *commit_transaction),
|
||||||
|
|
||||||
|
TP_ARGS(journal, commit_transaction),
|
||||||
|
|
||||||
|
TP_STRUCT__entry(
|
||||||
|
__field( dev_t, dev )
|
||||||
|
__field( char, sync_commit )
|
||||||
|
__field( int, transaction )
|
||||||
|
__field( int, head )
|
||||||
|
),
|
||||||
|
|
||||||
|
TP_fast_assign(
|
||||||
|
__entry->dev = journal->j_fs_dev->bd_dev;
|
||||||
|
__entry->sync_commit = commit_transaction->t_synchronous_commit;
|
||||||
|
__entry->transaction = commit_transaction->t_tid;
|
||||||
|
__entry->head = journal->j_tail_sequence;
|
||||||
|
),
|
||||||
|
|
||||||
|
TP_printk("dev %s transaction %d sync %d head %d",
|
||||||
|
jbd2_dev_to_name(__entry->dev), __entry->transaction,
|
||||||
|
__entry->sync_commit, __entry->head)
|
||||||
|
);
|
||||||
|
|
||||||
|
TRACE_EVENT(jbd2_submit_inode_data,
|
||||||
|
TP_PROTO(struct inode *inode),
|
||||||
|
|
||||||
|
TP_ARGS(inode),
|
||||||
|
|
||||||
|
TP_STRUCT__entry(
|
||||||
|
__field( dev_t, dev )
|
||||||
|
__field( ino_t, ino )
|
||||||
|
),
|
||||||
|
|
||||||
|
TP_fast_assign(
|
||||||
|
__entry->dev = inode->i_sb->s_dev;
|
||||||
|
__entry->ino = inode->i_ino;
|
||||||
|
),
|
||||||
|
|
||||||
|
TP_printk("dev %s ino %lu",
|
||||||
|
jbd2_dev_to_name(__entry->dev), __entry->ino)
|
||||||
|
);
|
||||||
|
|
||||||
|
#endif /* _TRACE_JBD2_H */
|
||||||
|
|
||||||
|
/* This part must be outside protection */
|
||||||
|
#include <trace/define_trace.h>
|
Loading…
Reference in a new issue