Re: [PATCH] watchdog: Add tracing events for the most usual watchdog events

From: Steven Rostedt
Date: Mon Oct 03 2022 - 12:29:16 EST


On Fri, 30 Sep 2022 16:49:35 +0200
Uwe Kleine-König <u.kleine-koenig@xxxxxxxxxxxxxx> wrote:


> --- /dev/null
> +++ b/include/trace/events/watchdog.h
> @@ -0,0 +1,92 @@
> +/* SPDX-License-Identifier: GPL-2.0-only */
> +#undef TRACE_SYSTEM
> +#define TRACE_SYSTEM watchdog
> +
> +#if !defined(_TRACE_WATCHDOG_H) || defined(TRACE_HEADER_MULTI_READ)
> +#define _TRACE_WATCHDOG_H
> +
> +#include <linux/watchdog.h>
> +#include <linux/tracepoint.h>
> +
> +TRACE_EVENT(watchdog_start,
> +
> + TP_PROTO(struct watchdog_device *wdd, int err),
> +
> + TP_ARGS(wdd, err),
> +
> + TP_STRUCT__entry(
> + __field(int, id)
> + __field(int, err)
> + ),
> +
> + TP_fast_assign(
> + __entry->id = wdd->id;
> + __entry->err = err;
> + ),
> +
> + TP_printk("watchdog%d err=%d", __entry->id, __entry->err)
> +);
> +

[..]

> +
> +TRACE_EVENT(watchdog_ping,
> +
> + TP_PROTO(struct watchdog_device *wdd, int err),
> +
> + TP_ARGS(wdd, err),
> +
> + TP_STRUCT__entry(
> + __field(int, id)
> + __field(int, err)
> + ),
> +
> + TP_fast_assign(
> + __entry->id = wdd->id;
> + __entry->err = err;
> + ),
> +
> + TP_printk("watchdog%d err=%d", __entry->id, __entry->err)
> +);
> +
> +TRACE_EVENT(watchdog_stop,
> +
> + TP_PROTO(struct watchdog_device *wdd, int err),
> +
> + TP_ARGS(wdd, err),
> +
> + TP_STRUCT__entry(
> + __field(int, id)
> + __field(int, err)
> + ),
> +
> + TP_fast_assign(
> + __entry->id = wdd->id;
> + __entry->err = err;
> + ),
> +
> + TP_printk("watchdog%d err=%d", __entry->id, __entry->err)
> +);

These three events are identical. Please replace them with:

DECLARE_EVENT_CLASS(watchdog_template,

TP_PROTO(struct watchdog_device *wdd, int err),

TP_ARGS(wdd, err),

TP_STRUCT__entry(
__field(int, id)
__field(int, err)
),

TP_fast_assign(
__entry->id = wdd->id;
__entry->err = err;
),

TP_printk("watchdog%d err=%d", __entry->id, __entry->err)
);

DEFINE_EVENT(watchdog_template, watchdog_start,
TP_PROTO(struct watchdog_device *wdd, int err),
TP_ARGS(wdd, err));

DEFINE_EVENT(watchdog_template, watchdog_ping,
TP_PROTO(struct watchdog_device *wdd, int err),
TP_ARGS(wdd, err));

DEFINE_EVENT(watchdog_template, watchdog_stop,
TP_PROTO(struct watchdog_device *wdd, int err),
TP_ARGS(wdd, err));


Each TRACE_EVENT() is defined as
DECLARE_EVENT_CLASS(..)
DEFINE_EVENT(..)

Where the DECLARE_EVENT_CLASS takes up most of the memory (5KB worth), and
each DEFINE_EVENT() takes up just around 500 bytes to implement.

Using multiple DEFINE_EVENTS() can save 10KB from the above.

-- Steve


> +
> +#endif /* !defined(_TRACE_WATCHDOG_H) || defined(TRACE_HEADER_MULTI_READ) */
> +
> +/* This part must be outside protection */
> +#include <trace/define_trace.h>
>
> base-commit: 568035b01cfb107af8d2e4bd2fb9aea22cf5b868