Skip to content

Commit 4f1e0c1

Browse files
committed
Merge tag 'linux-watchdog-6.1-rc2' of git://www.linux-watchdog.org/linux-watchdog
Pull watchdog updates from Wim Van Sebroeck: - Add tracing events for the most common watchdog events * tag 'linux-watchdog-6.1-rc2' of git://www.linux-watchdog.org/linux-watchdog: watchdog: Add tracing events for the most usual watchdog events
2 parents e35184f + e25b091 commit 4f1e0c1

File tree

4 files changed

+81
-2
lines changed

4 files changed

+81
-2
lines changed

MAINTAINERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22124,6 +22124,7 @@ F: Documentation/watchdog/
2212422124
F: drivers/watchdog/
2212522125
F: include/linux/watchdog.h
2212622126
F: include/uapi/linux/watchdog.h
22127+
F: include/trace/events/watchdog.h
2212722128

2212822129
WHISKEYCOVE PMIC GPIO DRIVER
2212922130
M: Kuppuswamy Sathyanarayanan <[email protected]>

drivers/watchdog/watchdog_core.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@
3838

3939
#include "watchdog_core.h" /* For watchdog_dev_register/... */
4040

41+
#define CREATE_TRACE_POINTS
42+
#include <trace/events/watchdog.h>
43+
4144
static DEFINE_IDA(watchdog_ida);
4245

4346
static int stop_on_reboot = -1;
@@ -163,6 +166,7 @@ static int watchdog_reboot_notifier(struct notifier_block *nb,
163166
int ret;
164167

165168
ret = wdd->ops->stop(wdd);
169+
trace_watchdog_stop(wdd, ret);
166170
if (ret)
167171
return NOTIFY_BAD;
168172
}

drivers/watchdog/watchdog_dev.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@
4747
#include "watchdog_core.h"
4848
#include "watchdog_pretimeout.h"
4949

50+
#include <trace/events/watchdog.h>
51+
5052
/* the dev_t structure to store the dynamically allocated watchdog devices */
5153
static dev_t watchdog_devt;
5254
/* Reference to watchdog device behind /dev/watchdog */
@@ -157,10 +159,13 @@ static int __watchdog_ping(struct watchdog_device *wdd)
157159

158160
wd_data->last_hw_keepalive = now;
159161

160-
if (wdd->ops->ping)
162+
if (wdd->ops->ping) {
161163
err = wdd->ops->ping(wdd); /* ping the watchdog */
162-
else
164+
trace_watchdog_ping(wdd, err);
165+
} else {
163166
err = wdd->ops->start(wdd); /* restart watchdog */
167+
trace_watchdog_start(wdd, err);
168+
}
164169

165170
if (err == 0)
166171
watchdog_hrtimer_pretimeout_start(wdd);
@@ -259,6 +264,7 @@ static int watchdog_start(struct watchdog_device *wdd)
259264
}
260265
} else {
261266
err = wdd->ops->start(wdd);
267+
trace_watchdog_start(wdd, err);
262268
if (err == 0) {
263269
set_bit(WDOG_ACTIVE, &wdd->status);
264270
wd_data->last_keepalive = started_at;
@@ -297,6 +303,7 @@ static int watchdog_stop(struct watchdog_device *wdd)
297303
if (wdd->ops->stop) {
298304
clear_bit(WDOG_HW_RUNNING, &wdd->status);
299305
err = wdd->ops->stop(wdd);
306+
trace_watchdog_stop(wdd, err);
300307
} else {
301308
set_bit(WDOG_HW_RUNNING, &wdd->status);
302309
}
@@ -369,6 +376,7 @@ static int watchdog_set_timeout(struct watchdog_device *wdd,
369376

370377
if (wdd->ops->set_timeout) {
371378
err = wdd->ops->set_timeout(wdd, timeout);
379+
trace_watchdog_set_timeout(wdd, timeout, err);
372380
} else {
373381
wdd->timeout = timeout;
374382
/* Disable pretimeout if it doesn't fit the new timeout */

include/trace/events/watchdog.h

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
/* SPDX-License-Identifier: GPL-2.0-only */
2+
#undef TRACE_SYSTEM
3+
#define TRACE_SYSTEM watchdog
4+
5+
#if !defined(_TRACE_WATCHDOG_H) || defined(TRACE_HEADER_MULTI_READ)
6+
#define _TRACE_WATCHDOG_H
7+
8+
#include <linux/watchdog.h>
9+
#include <linux/tracepoint.h>
10+
11+
DECLARE_EVENT_CLASS(watchdog_template,
12+
13+
TP_PROTO(struct watchdog_device *wdd, int err),
14+
15+
TP_ARGS(wdd, err),
16+
17+
TP_STRUCT__entry(
18+
__field(int, id)
19+
__field(int, err)
20+
),
21+
22+
TP_fast_assign(
23+
__entry->id = wdd->id;
24+
__entry->err = err;
25+
),
26+
27+
TP_printk("watchdog%d err=%d", __entry->id, __entry->err)
28+
);
29+
30+
DEFINE_EVENT(watchdog_template, watchdog_start,
31+
TP_PROTO(struct watchdog_device *wdd, int err),
32+
TP_ARGS(wdd, err));
33+
34+
DEFINE_EVENT(watchdog_template, watchdog_ping,
35+
TP_PROTO(struct watchdog_device *wdd, int err),
36+
TP_ARGS(wdd, err));
37+
38+
DEFINE_EVENT(watchdog_template, watchdog_stop,
39+
TP_PROTO(struct watchdog_device *wdd, int err),
40+
TP_ARGS(wdd, err));
41+
42+
TRACE_EVENT(watchdog_set_timeout,
43+
44+
TP_PROTO(struct watchdog_device *wdd, unsigned int timeout, int err),
45+
46+
TP_ARGS(wdd, timeout, err),
47+
48+
TP_STRUCT__entry(
49+
__field(int, id)
50+
__field(unsigned int, timeout)
51+
__field(int, err)
52+
),
53+
54+
TP_fast_assign(
55+
__entry->id = wdd->id;
56+
__entry->timeout = timeout;
57+
__entry->err = err;
58+
),
59+
60+
TP_printk("watchdog%d timeout=%u err=%d", __entry->id, __entry->timeout, __entry->err)
61+
);
62+
63+
#endif /* !defined(_TRACE_WATCHDOG_H) || defined(TRACE_HEADER_MULTI_READ) */
64+
65+
/* This part must be outside protection */
66+
#include <trace/define_trace.h>

0 commit comments

Comments
 (0)