mirror of
https://github.com/torvalds/linux.git
synced 2026-05-30 18:13:41 +02:00
f2fs: introduce trace_f2fs_priority_update
This patch introduces two new tracepoints for debug purpose. Signed-off-by: Chao Yu <chao@kernel.org> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
This commit is contained in:
parent
07de55cbf5
commit
bc367775f6
|
|
@ -130,9 +130,13 @@ static void uplift_priority(struct f2fs_rwsem *sem, struct f2fs_lock_context *lc
|
|||
return;
|
||||
set_user_nice(current, lc->new_nice);
|
||||
lc->need_restore = true;
|
||||
|
||||
trace_f2fs_priority_uplift(sem->sbi, sem->name, is_write, current,
|
||||
NICE_TO_PRIO(lc->orig_nice), NICE_TO_PRIO(lc->new_nice));
|
||||
}
|
||||
|
||||
static void restore_priority(struct f2fs_lock_context *lc)
|
||||
static void restore_priority(struct f2fs_rwsem *sem, struct f2fs_lock_context *lc,
|
||||
bool is_write)
|
||||
{
|
||||
if (!lc->need_restore)
|
||||
return;
|
||||
|
|
@ -140,6 +144,9 @@ static void restore_priority(struct f2fs_lock_context *lc)
|
|||
if (task_nice(current) != lc->new_nice)
|
||||
return;
|
||||
set_user_nice(current, lc->orig_nice);
|
||||
|
||||
trace_f2fs_priority_restore(sem->sbi, sem->name, is_write, current,
|
||||
NICE_TO_PRIO(lc->orig_nice), NICE_TO_PRIO(lc->new_nice));
|
||||
}
|
||||
|
||||
void f2fs_down_read_trace(struct f2fs_rwsem *sem, struct f2fs_lock_context *lc)
|
||||
|
|
@ -153,7 +160,7 @@ int f2fs_down_read_trylock_trace(struct f2fs_rwsem *sem, struct f2fs_lock_contex
|
|||
{
|
||||
uplift_priority(sem, lc, false);
|
||||
if (!f2fs_down_read_trylock(sem)) {
|
||||
restore_priority(lc);
|
||||
restore_priority(sem, lc, false);
|
||||
return 0;
|
||||
}
|
||||
trace_lock_elapsed_time_start(sem, lc);
|
||||
|
|
@ -163,7 +170,7 @@ int f2fs_down_read_trylock_trace(struct f2fs_rwsem *sem, struct f2fs_lock_contex
|
|||
void f2fs_up_read_trace(struct f2fs_rwsem *sem, struct f2fs_lock_context *lc)
|
||||
{
|
||||
f2fs_up_read(sem);
|
||||
restore_priority(lc);
|
||||
restore_priority(sem, lc, false);
|
||||
trace_lock_elapsed_time_end(sem, lc, false);
|
||||
}
|
||||
|
||||
|
|
@ -178,7 +185,7 @@ int f2fs_down_write_trylock_trace(struct f2fs_rwsem *sem, struct f2fs_lock_conte
|
|||
{
|
||||
uplift_priority(sem, lc, true);
|
||||
if (!f2fs_down_write_trylock(sem)) {
|
||||
restore_priority(lc);
|
||||
restore_priority(sem, lc, true);
|
||||
return 0;
|
||||
}
|
||||
trace_lock_elapsed_time_start(sem, lc);
|
||||
|
|
@ -188,7 +195,7 @@ int f2fs_down_write_trylock_trace(struct f2fs_rwsem *sem, struct f2fs_lock_conte
|
|||
void f2fs_up_write_trace(struct f2fs_rwsem *sem, struct f2fs_lock_context *lc)
|
||||
{
|
||||
f2fs_up_write(sem);
|
||||
restore_priority(lc);
|
||||
restore_priority(sem, lc, true);
|
||||
trace_lock_elapsed_time_end(sem, lc, true);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2525,6 +2525,63 @@ TRACE_EVENT(f2fs_lock_elapsed_time,
|
|||
__entry->other_time)
|
||||
);
|
||||
|
||||
DECLARE_EVENT_CLASS(f2fs_priority_update,
|
||||
|
||||
TP_PROTO(struct f2fs_sb_info *sbi, enum f2fs_lock_name lock_name,
|
||||
bool is_write, struct task_struct *p, int orig_prio,
|
||||
int new_prio),
|
||||
|
||||
TP_ARGS(sbi, lock_name, is_write, p, orig_prio, new_prio),
|
||||
|
||||
TP_STRUCT__entry(
|
||||
__field(dev_t, dev)
|
||||
__array(char, comm, TASK_COMM_LEN)
|
||||
__field(pid_t, pid)
|
||||
__field(unsigned int, lock_name)
|
||||
__field(bool, is_write)
|
||||
__field(int, orig_prio)
|
||||
__field(int, new_prio)
|
||||
),
|
||||
|
||||
TP_fast_assign(
|
||||
__entry->dev = sbi->sb->s_dev;
|
||||
memcpy(__entry->comm, p->comm, TASK_COMM_LEN);
|
||||
__entry->pid = p->pid;
|
||||
__entry->lock_name = lock_name;
|
||||
__entry->is_write = is_write;
|
||||
__entry->orig_prio = orig_prio;
|
||||
__entry->new_prio = new_prio;
|
||||
),
|
||||
|
||||
TP_printk("dev = (%d,%d), comm: %s, pid: %d, lock_name: %s, "
|
||||
"lock_type: %s, orig_prio: %d, new_prio: %d",
|
||||
show_dev(__entry->dev),
|
||||
__entry->comm,
|
||||
__entry->pid,
|
||||
show_lock_name(__entry->lock_name),
|
||||
__entry->is_write ? "wlock" : "rlock",
|
||||
__entry->orig_prio,
|
||||
__entry->new_prio)
|
||||
);
|
||||
|
||||
DEFINE_EVENT(f2fs_priority_update, f2fs_priority_uplift,
|
||||
|
||||
TP_PROTO(struct f2fs_sb_info *sbi, enum f2fs_lock_name lock_name,
|
||||
bool is_write, struct task_struct *p, int orig_prio,
|
||||
int new_prio),
|
||||
|
||||
TP_ARGS(sbi, lock_name, is_write, p, orig_prio, new_prio)
|
||||
);
|
||||
|
||||
DEFINE_EVENT(f2fs_priority_update, f2fs_priority_restore,
|
||||
|
||||
TP_PROTO(struct f2fs_sb_info *sbi, enum f2fs_lock_name lock_name,
|
||||
bool is_write, struct task_struct *p, int orig_prio,
|
||||
int new_prio),
|
||||
|
||||
TP_ARGS(sbi, lock_name, is_write, p, orig_prio, new_prio)
|
||||
);
|
||||
|
||||
#endif /* _TRACE_F2FS_H */
|
||||
|
||||
/* This part must be outside protection */
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user