From: Stephen Boyd <swboyd@chromium.org>
To: John Stultz <john.stultz@linaro.org>,
Thomas Gleixner <tglx@linutronix.de>
Cc: linux-kernel@vger.kernel.org, patches@lists.linux.dev,
Tejun Heo <tj@kernel.org>, Lai Jiangshan <jiangshanlai@gmail.com>,
Guenter Roeck <groeck@chromium.org>
Subject: [PATCH] timers: Provide a better debugobjects hint for delayed works
Date: Wed, 4 May 2022 15:31:48 -0700 [thread overview]
Message-ID: <20220504223148.644228-1-swboyd@chromium.org> (raw)
With debugobjects enabled the timer hint for freeing of active timers
embedded inside delayed works is always the same, i.e. the hint is
delayed_work_timer_fn(), even though the function the delayed work is
going to run can be wildly different depending on what work was
scheduled. Enabling workqueue debugobjects doesn't help either because
the delayed work isn't considered active until it is actually queued to
run on a workqueue. That's because if the work is freed while the timer
is pending the work isn't considered active to debugobjects so we don't
get any information about freeing an active work.
Provide better information here by special casing delayed works in the
timer debugobjects hint logic so that the work function is returned
instead of the timer function delayed_work_timer_fn(). This will help us
understand what delayed work was pending that got freed, leading to
faster bug resolutions.
Cc: Tejun Heo <tj@kernel.org>
Cc: Lai Jiangshan <jiangshanlai@gmail.com>
Cc: Guenter Roeck <groeck@chromium.org>
Signed-off-by: Stephen Boyd <swboyd@chromium.org>
---
I have an alternative approach which is to treat delayed works with a
different debug_obj_descr structure but it basically boils down to
another version of timer debugobjects in the workqueue code. The idea is
to make the delayed work active once the timer is queued and then
convert it over from a delayed work descriptor to a work descriptor once
the timer runs delayed_work_timer_fn() or when we pull it off to flush
out.
kernel/time/timer.c | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/kernel/time/timer.c b/kernel/time/timer.c
index 9dd2a39cb3b0..7b3c1019835c 100644
--- a/kernel/time/timer.c
+++ b/kernel/time/timer.c
@@ -44,6 +44,7 @@
#include <linux/slab.h>
#include <linux/compat.h>
#include <linux/random.h>
+#include <linux/workqueue.h>
#include <linux/uaccess.h>
#include <asm/unistd.h>
@@ -617,7 +618,17 @@ static const struct debug_obj_descr timer_debug_descr;
static void *timer_debug_hint(void *addr)
{
- return ((struct timer_list *) addr)->function;
+ struct timer_list *timer = addr;
+
+ if (timer->function == delayed_work_timer_fn) {
+ struct delayed_work *dwork;
+
+ dwork = container_of(timer, struct delayed_work, timer);
+
+ return dwork->work.func;
+ }
+
+ return timer->function;
}
static bool timer_is_static_object(void *addr)
base-commit: 672c0c5173427e6b3e2a9bbb7be51ceeec78093a
--
https://chromeos.dev
next reply other threads:[~2022-05-04 22:31 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-04 22:31 Stephen Boyd [this message]
2022-05-10 9:20 ` [PATCH] timers: Provide a better debugobjects hint for delayed works Thomas Gleixner
2022-05-11 20:02 ` Stephen Boyd
2022-05-11 22:57 ` Thomas Gleixner
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=20220504223148.644228-1-swboyd@chromium.org \
--to=swboyd@chromium.org \
--cc=groeck@chromium.org \
--cc=jiangshanlai@gmail.com \
--cc=john.stultz@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=patches@lists.linux.dev \
--cc=tglx@linutronix.de \
--cc=tj@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.