Skip to content

Commit bc36777

Browse files
chaseyuJaegeuk Kim
authored andcommitted
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>
1 parent 07de55c commit bc36777

2 files changed

Lines changed: 69 additions & 5 deletions

File tree

fs/f2fs/checkpoint.c

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -130,16 +130,23 @@ static void uplift_priority(struct f2fs_rwsem *sem, struct f2fs_lock_context *lc
130130
return;
131131
set_user_nice(current, lc->new_nice);
132132
lc->need_restore = true;
133+
134+
trace_f2fs_priority_uplift(sem->sbi, sem->name, is_write, current,
135+
NICE_TO_PRIO(lc->orig_nice), NICE_TO_PRIO(lc->new_nice));
133136
}
134137

135-
static void restore_priority(struct f2fs_lock_context *lc)
138+
static void restore_priority(struct f2fs_rwsem *sem, struct f2fs_lock_context *lc,
139+
bool is_write)
136140
{
137141
if (!lc->need_restore)
138142
return;
139143
/* someone has updated the priority */
140144
if (task_nice(current) != lc->new_nice)
141145
return;
142146
set_user_nice(current, lc->orig_nice);
147+
148+
trace_f2fs_priority_restore(sem->sbi, sem->name, is_write, current,
149+
NICE_TO_PRIO(lc->orig_nice), NICE_TO_PRIO(lc->new_nice));
143150
}
144151

145152
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
153160
{
154161
uplift_priority(sem, lc, false);
155162
if (!f2fs_down_read_trylock(sem)) {
156-
restore_priority(lc);
163+
restore_priority(sem, lc, false);
157164
return 0;
158165
}
159166
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
163170
void f2fs_up_read_trace(struct f2fs_rwsem *sem, struct f2fs_lock_context *lc)
164171
{
165172
f2fs_up_read(sem);
166-
restore_priority(lc);
173+
restore_priority(sem, lc, false);
167174
trace_lock_elapsed_time_end(sem, lc, false);
168175
}
169176

@@ -178,7 +185,7 @@ int f2fs_down_write_trylock_trace(struct f2fs_rwsem *sem, struct f2fs_lock_conte
178185
{
179186
uplift_priority(sem, lc, true);
180187
if (!f2fs_down_write_trylock(sem)) {
181-
restore_priority(lc);
188+
restore_priority(sem, lc, true);
182189
return 0;
183190
}
184191
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
188195
void f2fs_up_write_trace(struct f2fs_rwsem *sem, struct f2fs_lock_context *lc)
189196
{
190197
f2fs_up_write(sem);
191-
restore_priority(lc);
198+
restore_priority(sem, lc, true);
192199
trace_lock_elapsed_time_end(sem, lc, true);
193200
}
194201

include/trace/events/f2fs.h

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2525,6 +2525,63 @@ TRACE_EVENT(f2fs_lock_elapsed_time,
25252525
__entry->other_time)
25262526
);
25272527

2528+
DECLARE_EVENT_CLASS(f2fs_priority_update,
2529+
2530+
TP_PROTO(struct f2fs_sb_info *sbi, enum f2fs_lock_name lock_name,
2531+
bool is_write, struct task_struct *p, int orig_prio,
2532+
int new_prio),
2533+
2534+
TP_ARGS(sbi, lock_name, is_write, p, orig_prio, new_prio),
2535+
2536+
TP_STRUCT__entry(
2537+
__field(dev_t, dev)
2538+
__array(char, comm, TASK_COMM_LEN)
2539+
__field(pid_t, pid)
2540+
__field(unsigned int, lock_name)
2541+
__field(bool, is_write)
2542+
__field(int, orig_prio)
2543+
__field(int, new_prio)
2544+
),
2545+
2546+
TP_fast_assign(
2547+
__entry->dev = sbi->sb->s_dev;
2548+
memcpy(__entry->comm, p->comm, TASK_COMM_LEN);
2549+
__entry->pid = p->pid;
2550+
__entry->lock_name = lock_name;
2551+
__entry->is_write = is_write;
2552+
__entry->orig_prio = orig_prio;
2553+
__entry->new_prio = new_prio;
2554+
),
2555+
2556+
TP_printk("dev = (%d,%d), comm: %s, pid: %d, lock_name: %s, "
2557+
"lock_type: %s, orig_prio: %d, new_prio: %d",
2558+
show_dev(__entry->dev),
2559+
__entry->comm,
2560+
__entry->pid,
2561+
show_lock_name(__entry->lock_name),
2562+
__entry->is_write ? "wlock" : "rlock",
2563+
__entry->orig_prio,
2564+
__entry->new_prio)
2565+
);
2566+
2567+
DEFINE_EVENT(f2fs_priority_update, f2fs_priority_uplift,
2568+
2569+
TP_PROTO(struct f2fs_sb_info *sbi, enum f2fs_lock_name lock_name,
2570+
bool is_write, struct task_struct *p, int orig_prio,
2571+
int new_prio),
2572+
2573+
TP_ARGS(sbi, lock_name, is_write, p, orig_prio, new_prio)
2574+
);
2575+
2576+
DEFINE_EVENT(f2fs_priority_update, f2fs_priority_restore,
2577+
2578+
TP_PROTO(struct f2fs_sb_info *sbi, enum f2fs_lock_name lock_name,
2579+
bool is_write, struct task_struct *p, int orig_prio,
2580+
int new_prio),
2581+
2582+
TP_ARGS(sbi, lock_name, is_write, p, orig_prio, new_prio)
2583+
);
2584+
25282585
#endif /* _TRACE_F2FS_H */
25292586

25302587
/* This part must be outside protection */

0 commit comments

Comments
 (0)