From: Chao Yu <chao@kernel.org>
To: jaegeuk@kernel.org
Cc: linux-f2fs-devel@lists.sourceforge.net,
linux-kernel@vger.kernel.org, Chao Yu <chao@kernel.org>
Subject: [PATCH 2/2] f2fs: introduce trace_f2fs_priority_update
Date: Fri, 30 Jan 2026 21:28:09 +0800 [thread overview]
Message-ID: <20260130132809.59707-2-chao@kernel.org> (raw)
In-Reply-To: <20260130132809.59707-1-chao@kernel.org>
This patch introduces two new tracepoints for debug purpose.
Signed-off-by: Chao Yu <chao@kernel.org>
---
fs/f2fs/checkpoint.c | 17 +++++++----
include/trace/events/f2fs.h | 57 +++++++++++++++++++++++++++++++++++++
2 files changed, 69 insertions(+), 5 deletions(-)
diff --git a/fs/f2fs/checkpoint.c b/fs/f2fs/checkpoint.c
index 2f5a03e29d0b..4afa5d9a19fc 100644
--- a/fs/f2fs/checkpoint.c
+++ b/fs/f2fs/checkpoint.c
@@ -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);
}
diff --git a/include/trace/events/f2fs.h b/include/trace/events/f2fs.h
index c3b6b509472f..9364e6775562 100644
--- a/include/trace/events/f2fs.h
+++ b/include/trace/events/f2fs.h
@@ -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 */
--
2.40.1
next prev parent reply other threads:[~2026-01-31 2:26 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-30 13:28 [PATCH 1/2] f2fs: fix lock priority inversion issue Chao Yu
2026-01-30 13:28 ` Chao Yu [this message]
2026-01-31 2:50 ` Barry Song
2026-02-03 7:00 ` Chao Yu
2026-02-10 21:28 ` [f2fs-dev] " patchwork-bot+f2fs
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260130132809.59707-2-chao@kernel.org \
--to=chao@kernel.org \
--cc=jaegeuk@kernel.org \
--cc=linux-f2fs-devel@lists.sourceforge.net \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox