From: Byungchul Park <byungchul@sk.com>
To: linux-kernel@vger.kernel.org
Cc: kernel_team@skhynix.com, torvalds@linux-foundation.org,
damien.lemoal@opensource.wdc.com, linux-ide@vger.kernel.org,
adilger.kernel@dilger.ca, linux-ext4@vger.kernel.org,
mingo@redhat.com, peterz@infradead.org, will@kernel.org,
tglx@linutronix.de, rostedt@goodmis.org, joel@joelfernandes.org,
sashal@kernel.org, daniel.vetter@ffwll.ch, duyuyang@gmail.com,
johannes.berg@intel.com, tj@kernel.org, tytso@mit.edu,
willy@infradead.org, david@fromorbit.com, amir73il@gmail.com,
gregkh@linuxfoundation.org, kernel-team@lge.com,
linux-mm@kvack.org, akpm@linux-foundation.org, mhocko@kernel.org,
minchan@kernel.org, hannes@cmpxchg.org, vdavydov.dev@gmail.com,
sj@kernel.org, jglisse@redhat.com, dennis@kernel.org,
cl@linux.com, penberg@kernel.org, rientjes@google.com,
vbabka@suse.cz, ngupta@vflare.org, linux-block@vger.kernel.org,
josef@toxicpanda.com, linux-fsdevel@vger.kernel.org,
jack@suse.cz, jlayton@kernel.org, dan.j.williams@intel.com,
hch@infradead.org, djwong@kernel.org,
dri-devel@lists.freedesktop.org, rodrigosiqueiramelo@gmail.com,
melissa.srw@gmail.com, hamohammed.sa@gmail.com,
harry.yoo@oracle.com, chris.p.wilson@intel.com,
gwan-gyeong.mun@intel.com, max.byungchul.park@gmail.com,
boqun.feng@gmail.com, longman@redhat.com, yskelg@gmail.com,
yunseong.kim@ericsson.com, yeoreum.yun@arm.com,
netdev@vger.kernel.org, matthew.brost@intel.com,
her0gyugyu@gmail.com
Subject: [PATCH v15 26/43] dept: print staged wait's stacktrace on report
Date: Tue, 13 May 2025 19:07:13 +0900 [thread overview]
Message-ID: <20250513100730.12664-27-byungchul@sk.com> (raw)
In-Reply-To: <20250513100730.12664-1-byungchul@sk.com>
Currently, print nothing about what event wakes up in report. However,
it makes hard to interpret dept's report.
Make it print wait's stacktrace that the event wakes up.
Signed-off-by: Byungchul Park <byungchul@sk.com>
---
include/linux/dept.h | 5 ++++
include/linux/sched.h | 2 ++
kernel/dependency/dept.c | 59 ++++++++++++++++++++++++++++++++++------
3 files changed, 57 insertions(+), 9 deletions(-)
diff --git a/include/linux/dept.h b/include/linux/dept.h
index 10536418ab41..551168220954 100644
--- a/include/linux/dept.h
+++ b/include/linux/dept.h
@@ -226,6 +226,11 @@ struct dept_ecxt {
*/
unsigned long event_ip;
struct dept_stack *event_stack;
+
+ /*
+ * wait that this event ttwu
+ */
+ struct dept_stack *ewait_stack;
};
};
};
diff --git a/include/linux/sched.h b/include/linux/sched.h
index 541ddacdc3d0..43927e61921b 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -865,6 +865,7 @@ struct dept_task {
const char *stage_w_fn;
unsigned long stage_ip;
bool stage_timeout;
+ struct dept_stack *stage_wait_stack;
arch_spinlock_t stage_lock;
/*
@@ -906,6 +907,7 @@ struct dept_task {
.stage_w_fn = NULL, \
.stage_ip = 0UL, \
.stage_timeout = false, \
+ .stage_wait_stack = NULL, \
.stage_lock = (arch_spinlock_t)__ARCH_SPIN_LOCK_UNLOCKED,\
.missing_ecxt = 0, \
.hardirqs_enabled = false, \
diff --git a/kernel/dependency/dept.c b/kernel/dependency/dept.c
index 27ca8f723ccc..278194093108 100644
--- a/kernel/dependency/dept.c
+++ b/kernel/dependency/dept.c
@@ -522,6 +522,7 @@ static void initialize_ecxt(struct dept_ecxt *e)
e->enirqf = 0UL;
e->event_ip = 0UL;
e->event_stack = NULL;
+ e->ewait_stack = NULL;
}
SET_CONSTRUCTOR(ecxt, initialize_ecxt);
@@ -577,6 +578,8 @@ static void destroy_ecxt(struct dept_ecxt *e)
put_stack(e->ecxt_stack);
if (e->event_stack)
put_stack(e->event_stack);
+ if (e->ewait_stack)
+ put_stack(e->ewait_stack);
}
SET_DESTRUCTOR(ecxt, destroy_ecxt);
@@ -793,6 +796,11 @@ static void print_dep(struct dept_dep *d)
pr_warn("[E] %s(%s:%d):\n", e_fn, fc_n, fc->sub_id);
print_ip_stack(e->event_ip, e->event_stack);
+
+ if (valid_stack(e->ewait_stack)) {
+ pr_warn("(wait to wake up)\n");
+ print_ip_stack(0, e->ewait_stack);
+ }
}
if (!irqf) {
@@ -806,6 +814,11 @@ static void print_dep(struct dept_dep *d)
pr_warn("[E] %s(%s:%d):\n", e_fn, fc_n, fc->sub_id);
print_ip_stack(e->event_ip, e->event_stack);
+
+ if (valid_stack(e->ewait_stack)) {
+ pr_warn("(wait to wake up)\n");
+ print_ip_stack(0, e->ewait_stack);
+ }
}
}
@@ -1656,7 +1669,8 @@ static void add_wait(struct dept_class *c, unsigned long ip,
static struct dept_ecxt_held *add_ecxt(struct dept_map *m,
struct dept_class *c, unsigned long ip, const char *c_fn,
- const char *e_fn, int sub_l)
+ const char *e_fn, int sub_l,
+ struct dept_stack *ewait_stack)
{
struct dept_task *dt = dept_task();
struct dept_ecxt_held *eh;
@@ -1690,6 +1704,7 @@ static struct dept_ecxt_held *add_ecxt(struct dept_map *m,
e->class = get_class(c);
e->ecxt_ip = ip;
e->ecxt_stack = ip ? get_current_stack() : NULL;
+ e->ewait_stack = ewait_stack ? get_stack(ewait_stack) : NULL;
e->event_fn = e_fn;
e->ecxt_fn = c_fn;
@@ -1796,7 +1811,7 @@ static int find_hist_pos(unsigned int wg)
static void do_event(struct dept_map *m, struct dept_map *real_m,
struct dept_class *c, unsigned int wg, unsigned long ip,
- const char *e_fn)
+ const char *e_fn, struct dept_stack *ewait_stack)
{
struct dept_task *dt = dept_task();
struct dept_wait_hist *wh;
@@ -1824,7 +1839,7 @@ static void do_event(struct dept_map *m, struct dept_map *real_m,
*/
if (find_ecxt_pos(real_m, c, false) != -1)
return;
- eh = add_ecxt(m, c, 0UL, NULL, e_fn, 0);
+ eh = add_ecxt(m, c, 0UL, NULL, e_fn, 0, ewait_stack);
if (!eh)
return;
@@ -2361,7 +2376,8 @@ static void __dept_wait(struct dept_map *m, unsigned long w_f,
*/
static void __dept_event(struct dept_map *m, struct dept_map *real_m,
unsigned long e_f, unsigned long ip, const char *e_fn,
- bool sched_map, unsigned int wg)
+ bool sched_map, unsigned int wg,
+ struct dept_stack *ewait_stack)
{
struct dept_class *c;
struct dept_key *k;
@@ -2383,7 +2399,7 @@ static void __dept_event(struct dept_map *m, struct dept_map *real_m,
c = check_new_class(&m->map_key, k, sub_id(m, e), m->name, sched_map);
if (c)
- do_event(m, real_m, c, wg, ip, e_fn);
+ do_event(m, real_m, c, wg, ip, e_fn, ewait_stack);
}
void dept_wait(struct dept_map *m, unsigned long w_f,
@@ -2499,6 +2515,9 @@ static void __dept_clean_stage(struct dept_task *dt)
dt->stage_w_fn = NULL;
dt->stage_ip = 0UL;
dt->stage_timeout = false;
+ if (dt->stage_wait_stack)
+ put_stack(dt->stage_wait_stack);
+ dt->stage_wait_stack = NULL;
}
void dept_clean_stage(void)
@@ -2562,6 +2581,14 @@ void dept_request_event_wait_commit(void)
wg = next_wgen();
WRITE_ONCE(dt->stage_m.wgen, wg);
+
+ /*
+ * __schedule() can be hit multiple times between
+ * dept_stage_wait() and dept_clean_stage(). In that case,
+ * keep the first stacktrace only. That's enough.
+ */
+ if (!dt->stage_wait_stack)
+ dt->stage_wait_stack = get_current_stack();
arch_spin_unlock(&dt->stage_lock);
__dept_wait(&dt->stage_m, 1UL, ip, w_fn, 0, true, sched_map, timeout);
@@ -2580,6 +2607,7 @@ void dept_ttwu_stage_wait(struct task_struct *requestor, unsigned long ip)
struct dept_map m;
struct dept_map *real_m;
bool sched_map;
+ struct dept_stack *ewait_stack;
if (unlikely(!dept_working()))
return;
@@ -2598,6 +2626,10 @@ void dept_ttwu_stage_wait(struct task_struct *requestor, unsigned long ip)
m = dt_req->stage_m;
sched_map = dt_req->stage_sched_map;
real_m = dt_req->stage_real_m;
+ ewait_stack = dt_req->stage_wait_stack;
+ if (ewait_stack)
+ get_stack(ewait_stack);
+
__dept_clean_stage(dt_req);
arch_spin_unlock(&dt_req->stage_lock);
@@ -2608,8 +2640,12 @@ void dept_ttwu_stage_wait(struct task_struct *requestor, unsigned long ip)
if (!m.keys)
goto exit;
- __dept_event(&m, real_m, 1UL, ip, "try_to_wake_up", sched_map, m.wgen);
+ __dept_event(&m, real_m, 1UL, ip, "try_to_wake_up", sched_map,
+ m.wgen, ewait_stack);
exit:
+ if (ewait_stack)
+ put_stack(ewait_stack);
+
dept_exit(flags);
}
@@ -2689,7 +2725,7 @@ void dept_map_ecxt_modify(struct dept_map *m, unsigned long e_f,
k = m->keys ?: &m->map_key;
c = check_new_class(&m->map_key, k, sub_id(m, new_e), m->name, false);
- if (c && add_ecxt(m, c, new_ip, new_c_fn, new_e_fn, new_sub_l))
+ if (c && add_ecxt(m, c, new_ip, new_c_fn, new_e_fn, new_sub_l, NULL))
goto exit;
/*
@@ -2741,7 +2777,7 @@ void dept_ecxt_enter(struct dept_map *m, unsigned long e_f, unsigned long ip,
k = m->keys ?: &m->map_key;
c = check_new_class(&m->map_key, k, sub_id(m, e), m->name, false);
- if (c && add_ecxt(m, c, ip, c_fn, e_fn, sub_l))
+ if (c && add_ecxt(m, c, ip, c_fn, e_fn, sub_l, NULL))
goto exit;
missing_ecxt:
dt->missing_ecxt++;
@@ -2841,7 +2877,7 @@ void dept_event(struct dept_map *m, unsigned long e_f,
flags = dept_enter();
- __dept_event(m, m, e_f, ip, e_fn, false, READ_ONCE(*wg_p));
+ __dept_event(m, m, e_f, ip, e_fn, false, READ_ONCE(*wg_p), NULL);
/*
* Keep the map diabled until the next sleep.
@@ -2913,6 +2949,11 @@ void dept_task_exit(struct task_struct *t)
dt->stack = NULL;
}
+ if (dt->stage_wait_stack) {
+ put_stack(dt->stage_wait_stack);
+ dt->stage_wait_stack = NULL;
+ }
+
for (i = 0; i < dt->ecxt_held_pos; i++) {
if (dt->ecxt_held[i].class) {
put_class(dt->ecxt_held[i].class);
--
2.17.1
next prev parent reply other threads:[~2025-05-13 10:09 UTC|newest]
Thread overview: 55+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-13 10:06 [PATCH v15 00/43] DEPT(DEPendency Tracker) Byungchul Park
2025-05-13 10:06 ` [PATCH v15 01/43] llist: move llist_{head,node} definition to types.h Byungchul Park
2025-05-15 0:14 ` Waiman Long
2025-05-15 3:00 ` Byungchul Park
2025-05-13 10:06 ` [PATCH v15 02/43] dept: implement DEPT(DEPendency Tracker) Byungchul Park
2025-05-14 12:14 ` kernel test robot
2025-05-14 14:22 ` kernel test robot
2025-05-14 20:47 ` ALOK TIWARI
2025-05-15 3:01 ` Byungchul Park
2025-05-13 10:06 ` [PATCH v15 03/43] dept: add single event dependency tracker APIs Byungchul Park
2025-05-13 10:06 ` [PATCH v15 04/43] dept: add lock " Byungchul Park
2025-05-13 10:06 ` [PATCH v15 05/43] dept: tie to lockdep and IRQ tracing Byungchul Park
2025-05-13 10:06 ` [PATCH v15 06/43] dept: add proc knobs to show stats and dependency graph Byungchul Park
2025-05-13 10:06 ` [PATCH v15 07/43] dept: distinguish each kernel context from another Byungchul Park
2025-05-13 10:06 ` [PATCH v15 08/43] x86_64, dept: add support CONFIG_ARCH_HAS_DEPT_SUPPORT to x86_64 Byungchul Park
2025-05-13 10:06 ` [PATCH v15 09/43] arm64, dept: add support CONFIG_ARCH_HAS_DEPT_SUPPORT to arm64 Byungchul Park
2025-05-13 10:06 ` [PATCH v15 10/43] dept: distinguish each work from another Byungchul Park
2025-05-13 10:06 ` [PATCH v15 11/43] dept: add a mechanism to refill the internal memory pools on running out Byungchul Park
2025-05-13 10:06 ` [PATCH v15 12/43] dept: record the latest one out of consecutive waits of the same class Byungchul Park
2025-05-13 10:07 ` [PATCH v15 13/43] dept: apply sdt_might_sleep_{start,end}() to wait_for_completion()/complete() Byungchul Park
2025-05-13 10:07 ` [PATCH v15 14/43] dept: apply sdt_might_sleep_{start,end}() to swait Byungchul Park
2025-05-13 10:07 ` [PATCH v15 15/43] dept: apply sdt_might_sleep_{start,end}() to waitqueue wait Byungchul Park
2025-05-13 10:07 ` [PATCH v15 16/43] dept: apply sdt_might_sleep_{start,end}() to hashed-waitqueue wait Byungchul Park
2025-05-13 10:07 ` [PATCH v15 17/43] dept: apply sdt_might_sleep_{start,end}() to dma fence Byungchul Park
2025-05-13 10:07 ` [PATCH v15 18/43] dept: track timeout waits separately with a new Kconfig Byungchul Park
2025-05-13 10:07 ` [PATCH v15 19/43] dept: apply timeout consideration to wait_for_completion()/complete() Byungchul Park
2025-05-13 10:07 ` [PATCH v15 20/43] dept: apply timeout consideration to swait Byungchul Park
2025-05-13 10:07 ` [PATCH v15 21/43] dept: apply timeout consideration to waitqueue wait Byungchul Park
2025-05-13 10:07 ` [PATCH v15 22/43] dept: apply timeout consideration to hashed-waitqueue wait Byungchul Park
2025-05-13 10:07 ` [PATCH v15 23/43] dept: apply timeout consideration to dma fence wait Byungchul Park
2025-05-13 10:07 ` [PATCH v15 24/43] dept: make dept able to work with an external wgen Byungchul Park
2025-05-13 10:07 ` [PATCH v15 25/43] dept: track PG_locked with dept Byungchul Park
2025-05-13 10:07 ` Byungchul Park [this message]
2025-05-13 10:07 ` [PATCH v15 27/43] locking/lockdep: prevent various lockdep assertions when lockdep_off()'ed Byungchul Park
2025-05-13 10:07 ` [PATCH v15 28/43] dept: suppress reports with classes that have been already reported Byungchul Park
2025-05-13 10:07 ` [PATCH v15 29/43] dept: add documentation for dept Byungchul Park
2025-05-13 10:07 ` [PATCH v15 30/43] cpu/hotplug: use a weaker annotation in AP thread Byungchul Park
2025-05-13 10:07 ` [PATCH v15 31/43] fs/jbd2: use a weaker annotation in journal handling Byungchul Park
2025-05-13 10:07 ` [PATCH v15 32/43] dept: assign dept map to mmu notifier invalidation synchronization Byungchul Park
2025-05-13 10:07 ` [PATCH v15 33/43] dept: assign unique dept_key to each distinct dma fence caller Byungchul Park
2025-05-13 22:49 ` kernel test robot
2025-05-16 8:07 ` Byungchul Park
2025-05-14 12:46 ` kernel test robot
2025-05-13 10:07 ` [PATCH v15 34/43] dept: make dept aware of lockdep_set_lock_cmp_fn() annotation Byungchul Park
2025-05-14 16:20 ` kernel test robot
2025-05-13 10:07 ` [PATCH v15 35/43] dept: make dept stop from working on debug_locks_off() Byungchul Park
2025-05-13 10:07 ` [PATCH v15 36/43] i2c: rename wait_for_completion callback to wait_for_completion_cb Byungchul Park
2025-05-13 10:07 ` [PATCH v15 37/43] dept: assign unique dept_key to each distinct wait_for_completion() caller Byungchul Park
2025-05-13 10:07 ` [PATCH v15 38/43] completion, dept: introduce init_completion_dmap() API Byungchul Park
2025-05-13 10:07 ` [PATCH v15 39/43] dept: introduce a new type of dependency tracking between multi event sites Byungchul Park
2025-05-13 10:07 ` [PATCH v15 40/43] dept: add module support for struct dept_event_site and dept_event_site_dep Byungchul Park
2025-05-13 10:07 ` [PATCH v15 41/43] dept: introduce event_site() to disable event tracking if it's recoverable Byungchul Park
2025-05-13 10:07 ` [PATCH v15 42/43] dept: implement a basic unit test for dept Byungchul Park
2025-05-13 10:07 ` [PATCH v15 43/43] dept: call dept_hardirqs_off() in local_irq_*() regardless of irq state Byungchul Park
2025-05-14 3:07 ` [PATCH v15 00/43] DEPT(DEPendency Tracker) Byungchul Park
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=20250513100730.12664-27-byungchul@sk.com \
--to=byungchul@sk.com \
--cc=adilger.kernel@dilger.ca \
--cc=akpm@linux-foundation.org \
--cc=amir73il@gmail.com \
--cc=boqun.feng@gmail.com \
--cc=chris.p.wilson@intel.com \
--cc=cl@linux.com \
--cc=damien.lemoal@opensource.wdc.com \
--cc=dan.j.williams@intel.com \
--cc=daniel.vetter@ffwll.ch \
--cc=david@fromorbit.com \
--cc=dennis@kernel.org \
--cc=djwong@kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=duyuyang@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=gwan-gyeong.mun@intel.com \
--cc=hamohammed.sa@gmail.com \
--cc=hannes@cmpxchg.org \
--cc=harry.yoo@oracle.com \
--cc=hch@infradead.org \
--cc=her0gyugyu@gmail.com \
--cc=jack@suse.cz \
--cc=jglisse@redhat.com \
--cc=jlayton@kernel.org \
--cc=joel@joelfernandes.org \
--cc=johannes.berg@intel.com \
--cc=josef@toxicpanda.com \
--cc=kernel-team@lge.com \
--cc=kernel_team@skhynix.com \
--cc=linux-block@vger.kernel.org \
--cc=linux-ext4@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-ide@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=longman@redhat.com \
--cc=matthew.brost@intel.com \
--cc=max.byungchul.park@gmail.com \
--cc=melissa.srw@gmail.com \
--cc=mhocko@kernel.org \
--cc=minchan@kernel.org \
--cc=mingo@redhat.com \
--cc=netdev@vger.kernel.org \
--cc=ngupta@vflare.org \
--cc=penberg@kernel.org \
--cc=peterz@infradead.org \
--cc=rientjes@google.com \
--cc=rodrigosiqueiramelo@gmail.com \
--cc=rostedt@goodmis.org \
--cc=sashal@kernel.org \
--cc=sj@kernel.org \
--cc=tglx@linutronix.de \
--cc=tj@kernel.org \
--cc=torvalds@linux-foundation.org \
--cc=tytso@mit.edu \
--cc=vbabka@suse.cz \
--cc=vdavydov.dev@gmail.com \
--cc=will@kernel.org \
--cc=willy@infradead.org \
--cc=yeoreum.yun@arm.com \
--cc=yskelg@gmail.com \
--cc=yunseong.kim@ericsson.com \
/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