[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20240123153707.550795-6-tobias@waldekranz.com>
Date: Tue, 23 Jan 2024 16:37:07 +0100
From: Tobias Waldekranz <tobias@...dekranz.com>
To: davem@...emloft.net,
kuba@...nel.org
Cc: jiri@...nulli.us,
ivecera@...hat.com,
netdev@...r.kernel.org,
roopa@...dia.com,
razor@...ckwall.org,
bridge@...ts.linux.dev,
rostedt@...dmis.org,
mhiramat@...nel.org,
linux-trace-kernel@...r.kernel.org
Subject: [PATCH net-next 5/5] net: switchdev: Add tracepoints
Add a basic set of tracepoints:
- switchdev_defer: Triggers whenever an operation is enqueued to the
switchdev workqueue.
- switchdev_call_atomic/switchdev_call_blocking: Triggers whenever a
notification is sent on the corresponding notifier block.
- switchdev_call_replay: Triggers whenever a notification is sent back
to a driver's own notifier block, in response to a replay request.
Signed-off-by: Tobias Waldekranz <tobias@...dekranz.com>
---
include/trace/events/switchdev.h | 89 ++++++++++++++++++++++++++++++++
net/switchdev/switchdev.c | 24 +++++++--
2 files changed, 109 insertions(+), 4 deletions(-)
create mode 100644 include/trace/events/switchdev.h
diff --git a/include/trace/events/switchdev.h b/include/trace/events/switchdev.h
new file mode 100644
index 000000000000..b587965da2f6
--- /dev/null
+++ b/include/trace/events/switchdev.h
@@ -0,0 +1,89 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#undef TRACE_SYSTEM
+#define TRACE_SYSTEM switchdev
+
+#if !defined(_TRACE_SWITCHDEV_H) || defined(TRACE_HEADER_MULTI_READ)
+#define _TRACE_SWITCHDEV_H
+
+#include <linux/tracepoint.h>
+#include <net/switchdev.h>
+
+#define SWITCHDEV_TRACE_MSG_MAX 128
+
+TRACE_EVENT(switchdev_defer,
+ TP_PROTO(unsigned long val,
+ const struct switchdev_notifier_info *info),
+
+ TP_ARGS(val, info),
+
+ TP_STRUCT__entry(
+ __field(unsigned long, val)
+ __string(dev, info->dev ? netdev_name(info->dev) : "(null)")
+ __field(const struct switchdev_notifier_info *, info)
+ __array(char, msg, SWITCHDEV_TRACE_MSG_MAX)
+ ),
+
+ TP_fast_assign(
+ __entry->val = val;
+ __assign_str(dev, info->dev ? netdev_name(info->dev) : "(null)");
+ __entry->info = info;
+ switchdev_notifier_str(val, info, __entry->msg, SWITCHDEV_TRACE_MSG_MAX);
+ ),
+
+ TP_printk("dev %s %s", __get_str(dev), __entry->msg)
+);
+
+DECLARE_EVENT_CLASS(switchdev_call,
+ TP_PROTO(unsigned long val,
+ const struct switchdev_notifier_info *info,
+ int err),
+
+ TP_ARGS(val, info, err),
+
+ TP_STRUCT__entry(
+ __field(unsigned long, val)
+ __string(dev, info->dev ? netdev_name(info->dev) : "(null)")
+ __field(const struct switchdev_notifier_info *, info)
+ __field(int, err)
+ __array(char, msg, SWITCHDEV_TRACE_MSG_MAX)
+ ),
+
+ TP_fast_assign(
+ __entry->val = val;
+ __assign_str(dev, info->dev ? netdev_name(info->dev) : "(null)");
+ __entry->info = info;
+ __entry->err = err;
+ switchdev_notifier_str(val, info, __entry->msg, SWITCHDEV_TRACE_MSG_MAX);
+ ),
+
+ TP_printk("dev %s %s -> %d", __get_str(dev), __entry->msg, __entry->err)
+);
+
+DEFINE_EVENT(switchdev_call, switchdev_call_atomic,
+ TP_PROTO(unsigned long val,
+ const struct switchdev_notifier_info *info,
+ int err),
+
+ TP_ARGS(val, info, err)
+);
+
+DEFINE_EVENT(switchdev_call, switchdev_call_blocking,
+ TP_PROTO(unsigned long val,
+ const struct switchdev_notifier_info *info,
+ int err),
+
+ TP_ARGS(val, info, err)
+);
+
+DEFINE_EVENT(switchdev_call, switchdev_call_replay,
+ TP_PROTO(unsigned long val,
+ const struct switchdev_notifier_info *info,
+ int err),
+
+ TP_ARGS(val, info, err)
+);
+
+#endif /* _TRACE_SWITCHDEV_H */
+
+/* This part must be outside protection */
+#include <trace/define_trace.h>
diff --git a/net/switchdev/switchdev.c b/net/switchdev/switchdev.c
index 6612f8bc79c9..dfd9cf75f397 100644
--- a/net/switchdev/switchdev.c
+++ b/net/switchdev/switchdev.c
@@ -19,6 +19,9 @@
#include <linux/rtnetlink.h>
#include <net/switchdev.h>
+#define CREATE_TRACE_POINTS
+#include <trace/events/switchdev.h>
+
static LIST_HEAD(deferred);
static DEFINE_SPINLOCK(deferred_lock);
@@ -171,6 +174,7 @@ static int switchdev_deferred_enqueue(struct switchdev_deferred_item *dfitem)
spin_lock_bh(&deferred_lock);
list_add_tail(&dfitem->list, &deferred);
spin_unlock_bh(&deferred_lock);
+ trace_switchdev_defer(dfitem->nt, &dfitem->info);
schedule_work(&deferred_process_work);
return 0;
}
@@ -325,7 +329,11 @@ EXPORT_SYMBOL_GPL(switchdev_port_obj_del);
int switchdev_call_replay(struct notifier_block *nb, unsigned long type,
struct switchdev_notifier_info *info)
{
- return nb->notifier_call(nb, type, info);
+ int ret;
+
+ ret = nb->notifier_call(nb, type, info);
+ trace_switchdev_call_replay(type, info, notifier_to_errno(ret));
+ return ret;
}
EXPORT_SYMBOL_GPL(switchdev_call_replay);
@@ -368,9 +376,13 @@ int call_switchdev_notifiers(unsigned long val, struct net_device *dev,
struct switchdev_notifier_info *info,
struct netlink_ext_ack *extack)
{
+ int ret;
+
info->dev = dev;
info->extack = extack;
- return atomic_notifier_call_chain(&switchdev_notif_chain, val, info);
+ ret = atomic_notifier_call_chain(&switchdev_notif_chain, val, info);
+ trace_switchdev_call_atomic(val, info, notifier_to_errno(ret));
+ return ret;
}
EXPORT_SYMBOL_GPL(call_switchdev_notifiers);
@@ -394,10 +406,14 @@ int call_switchdev_blocking_notifiers(unsigned long val, struct net_device *dev,
struct switchdev_notifier_info *info,
struct netlink_ext_ack *extack)
{
+ int ret;
+
info->dev = dev;
info->extack = extack;
- return blocking_notifier_call_chain(&switchdev_blocking_notif_chain,
- val, info);
+ ret = blocking_notifier_call_chain(&switchdev_blocking_notif_chain,
+ val, info);
+ trace_switchdev_call_blocking(val, info, notifier_to_errno(ret));
+ return ret;
}
EXPORT_SYMBOL_GPL(call_switchdev_blocking_notifiers);
--
2.34.1
Powered by blists - more mailing lists