Commit 5c8ad599 authored by Bryan O'Donoghue's avatar Bryan O'Donoghue Committed by Greg Kroah-Hartman

greybus: operation, core: hook tracepoints into message opertions

This patch hooks tracepoints for greybus messages

- trace_gb_message_send
- trace_gb_message_recv_request
- trace_gb_message_recv_response
- trace_gb_message_cancel_outgoing
- trace_gb_message_cancel_incoming

It provides standard tracepoints at

/sys/kernel/debug/tracing/events/greybus/gb_message_send
/sys/kernel/debug/tracing/events/greybus/gb_message_recv_response
/sys/kernel/debug/tracing/events/greybus/gb_message_recv_request
/sys/kernel/debug/tracing/events/greybus/gb_message_cancel_outgoing
/sys/kernel/debug/tracing/events/greybus/gb_message_cancel_incoming

Giving outputs like

gb_message_recv_request: greybus:1-1.1:0 op=0001 if_id=0000 hd_id=0000 l=2
gb_message_send: greybus:1-1.1:0 op=0001 if_id=0000 hd_id=0000 l=2

Similarly perf events can be viewed with standard perf tools e.g.

root@beaglebone:~# perf list 'greybus:*'
  greybus:gb_message_send                            [Tracepoint event]
  greybus:gb_message_recv_request                    [Tracepoint event]
  greybus:gb_message_recv_response                   [Tracepoint event]
  greybus:gb_message_cancel_outgoing                 [Tracepoint event]
  greybus:gb_message_cancel_incoming                 [Tracepoint event]
Signed-off-by: default avatarBryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@google.com>
parent bb03ed92
...@@ -82,6 +82,9 @@ endif ...@@ -82,6 +82,9 @@ endif
# add -Wall to try to catch everything we can. # add -Wall to try to catch everything we can.
ccflags-y := -Wall ccflags-y := -Wall
# needed for trace events
ccflags-y += -I$(src)
all: module all: module
module: module:
......
...@@ -9,7 +9,9 @@ ...@@ -9,7 +9,9 @@
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
#define CREATE_TRACE_POINTS
#include "greybus.h" #include "greybus.h"
#include "greybus_trace.h"
/* Allow greybus to be disabled at boot if needed */ /* Allow greybus to be disabled at boot if needed */
static bool nogreybus; static bool nogreybus;
...@@ -347,6 +349,7 @@ static void __exit gb_exit(void) ...@@ -347,6 +349,7 @@ static void __exit gb_exit(void)
gb_operation_exit(); gb_operation_exit();
bus_unregister(&greybus_bus_type); bus_unregister(&greybus_bus_type);
gb_debugfs_cleanup(); gb_debugfs_cleanup();
tracepoint_synchronize_unregister();
} }
module_exit(gb_exit); module_exit(gb_exit);
MODULE_LICENSE("GPL v2"); MODULE_LICENSE("GPL v2");
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
#include <linux/workqueue.h> #include <linux/workqueue.h>
#include "greybus.h" #include "greybus.h"
#include "greybus_trace.h"
static struct kmem_cache *gb_operation_cache; static struct kmem_cache *gb_operation_cache;
static struct kmem_cache *gb_message_cache; static struct kmem_cache *gb_message_cache;
...@@ -197,6 +198,7 @@ static int gb_message_send(struct gb_message *message, gfp_t gfp) ...@@ -197,6 +198,7 @@ static int gb_message_send(struct gb_message *message, gfp_t gfp)
{ {
struct gb_connection *connection = message->operation->connection; struct gb_connection *connection = message->operation->connection;
trace_gb_message_send(message);
return connection->hd->driver->message_send(connection->hd, return connection->hd->driver->message_send(connection->hd,
connection->hd_cport_id, connection->hd_cport_id,
message, message,
...@@ -834,6 +836,7 @@ static void gb_connection_recv_request(struct gb_connection *connection, ...@@ -834,6 +836,7 @@ static void gb_connection_recv_request(struct gb_connection *connection,
gb_operation_put(operation); gb_operation_put(operation);
return; return;
} }
trace_gb_message_recv_request(operation->request);
/* /*
* The initial reference to the operation will be dropped when the * The initial reference to the operation will be dropped when the
...@@ -872,6 +875,7 @@ static void gb_connection_recv_response(struct gb_connection *connection, ...@@ -872,6 +875,7 @@ static void gb_connection_recv_response(struct gb_connection *connection,
message->header->type, size, message_size); message->header->type, size, message_size);
errno = -EMSGSIZE; errno = -EMSGSIZE;
} }
trace_gb_message_recv_response(operation->response);
/* We must ignore the payload if a bad status is returned */ /* We must ignore the payload if a bad status is returned */
if (errno) if (errno)
...@@ -942,6 +946,7 @@ void gb_operation_cancel(struct gb_operation *operation, int errno) ...@@ -942,6 +946,7 @@ void gb_operation_cancel(struct gb_operation *operation, int errno)
gb_message_cancel(operation->request); gb_message_cancel(operation->request);
queue_work(gb_operation_completion_wq, &operation->work); queue_work(gb_operation_completion_wq, &operation->work);
} }
trace_gb_message_cancel_outgoing(operation->request);
atomic_inc(&operation->waiters); atomic_inc(&operation->waiters);
wait_event(gb_operation_cancellation_queue, wait_event(gb_operation_cancellation_queue,
...@@ -968,6 +973,7 @@ void gb_operation_cancel_incoming(struct gb_operation *operation, int errno) ...@@ -968,6 +973,7 @@ void gb_operation_cancel_incoming(struct gb_operation *operation, int errno)
if (!gb_operation_result_set(operation, errno)) if (!gb_operation_result_set(operation, errno))
gb_message_cancel(operation->response); gb_message_cancel(operation->response);
} }
trace_gb_message_cancel_incoming(operation->response);
atomic_inc(&operation->waiters); atomic_inc(&operation->waiters);
wait_event(gb_operation_cancellation_queue, wait_event(gb_operation_cancellation_queue,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment