net: skb ftracer - Add actual ftrace code to kernel (v3)

skb allocation / consumption correlator

Add ftracer module to kernel to print out a list that correlates a process id,
an skb it read, and the numa nodes on wich the process was running when it was
read along with the numa node the skbuff was allocated on.

Signed-off-by: Neil Horman <nhorman@tuxdriver.com>

 Makefile            |    1
 trace.h             |   19 ++++++
 trace_skb_sources.c |  154 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 174 insertions(+)
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
Neil Horman
2009-08-13 05:23:56 +00:00
committed by David S. Miller
parent 5a165657be
commit 9ec04da748
3 changed files with 174 additions and 0 deletions

View File

@@ -11,6 +11,7 @@
#include <trace/boot.h>
#include <linux/kmemtrace.h>
#include <trace/power.h>
#include <trace/events/skb.h>
#include <linux/trace_seq.h>
#include <linux/ftrace_event.h>
@@ -40,6 +41,7 @@ enum trace_type {
TRACE_KMEM_FREE,
TRACE_POWER,
TRACE_BLK,
TRACE_SKB_SOURCE,
__TRACE_LAST_TYPE,
};
@@ -171,6 +173,21 @@ struct trace_power {
struct power_trace state_data;
};
struct skb_record {
pid_t pid; /* pid of the copying process */
int anid; /* node where skb was allocated */
int cnid; /* node to which skb was copied in userspace */
char ifname[IFNAMSIZ]; /* Name of the receiving interface */
int rx_queue; /* The rx queue the skb was received on */
int ccpu; /* Cpu the application got this frame from */
int len; /* length of the data copied */
};
struct trace_skb_event {
struct trace_entry ent;
struct skb_record event_data;
};
enum kmemtrace_type_id {
KMEMTRACE_TYPE_KMALLOC = 0, /* kmalloc() or kfree(). */
KMEMTRACE_TYPE_CACHE, /* kmem_cache_*(). */
@@ -323,6 +340,8 @@ extern void __ftrace_bad_type(void);
TRACE_SYSCALL_ENTER); \
IF_ASSIGN(var, ent, struct syscall_trace_exit, \
TRACE_SYSCALL_EXIT); \
IF_ASSIGN(var, ent, struct trace_skb_event, \
TRACE_SKB_SOURCE); \
__ftrace_bad_type(); \
} while (0)