Add DTrace support to xenstored
PATCH 1/1 Add DTrace support to xenstored
# HG changeset patch
# User [email protected]
# Date 1201715263 28800
# Node ID 60778396cfaebd9b2ca651333033b9a6dbbf2566 # Parent 95f312d690357bc6aa2fc476572dd1919f3b5624 Add DTrace support to xenstored
Add USDT probes for significant xenstore operations to allow dynamic tracing.
Signed-off-by John Levon <[email protected]>
tools/xenstore/Makefile +14 -2
@@ -24,7 +24,7 @@ XENSTORED_OBJS = xenstored_core.o xensto XENSTORED_OBJS = xenstored_core.o xenstored_watch.o xenstored_domain.o xenstored_transaction.o xs_lib.o talloc.o utils.o tdb.o hashtable.o XENSTORED_OBJS_$(CONFIG_Linux) = xenstored_linux.o -XENSTORED_OBJS_$(CONFIG_SunOS) = xenstored_solaris.o +XENSTORED_OBJS_$(CONFIG_SunOS) = xenstored_solaris.o xenstored_probes.o XENSTORED_OBJS_$(CONFIG_NetBSD) = xenstored_netbsd.o XENSTORED_OBJS += $(XENSTORED_OBJS_y)
@@ -32,6 +32,18 @@ XENSTORED_OBJS += $(XENSTORED_OBJS_y) .PHONY: all all: libxenstore.so libxenstore.a xenstored $(CLIENTS) xs_tdb_dump xenstore-control xenstore-ls +ifeq ($(CONFIG_SunOS),y) +xenstored_probes.h: xenstored_probes.d + dtrace -C -h -s xenstored_probes.d + +xenstored_solaris.o: xenstored_probes.h + +xenstored_probes.o: xenstored_solaris.o + dtrace -C -G -s xenstored_probes.d xenstored_solaris.o + +CFLAGS += -DHAVE_DTRACE=1 +endif + xenstored: $(XENSTORED_OBJS) $(CC) $(CFLAGS) $(LDFLAGS) $^ $(LOADLIBES) $(LDLIBS) $(LDFLAGS_libxenctrl) $(SOCKET_LIBS) -o $@
@@ -63,7 +75,7 @@ libxenstore.a: xs.o xs_lib.o .PHONY: clean clean: - rm -f *.a *.o *.opic *.so* + rm -f *.a *.o *.opic *.so* xenstored_probes.h rm -f xenstored xs_random xs_stress xs_crashme rm -f xs_tdb_dump xenstore-control xenstore-ls rm -f $(CLIENTS)
tools/xenstore/xenstored_core.c +10 -5
@@ -154,12 +154,16 @@ void trace(const char *fmt, ...) }static void trace_io (const struct connection *conn, -const char *prefix, -const struct buffered_data *data) +const struct buffered_data *data, +int out) {unsigned int i;time_t now;struct tm *tm; + +#ifdef HAVE_DTRACE +dtrace_io (conn, data, out); +#endif if (tracefd <0 )return ;
@@ -167,7 +171,8 @@ static void trace_io(const struct connec now =time (NULL ); tm =localtime (&now); -trace ("%s %p %04d%02d%02d %02d:%02d:%02d %s (" , prefix, conn, +trace ("%s %p %04d%02d%02d %02d:%02d:%02d %s (" , + out ?"OUT" :"IN" , conn, tm->tm_year +1900 , tm->tm_mon +1 , tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec,sockmsg_string (data->hdr.msg.type));
@@ -257,7 +262,7 @@ static bool write_messages(struct connecif (out->used != out->hdr.msg.len)return true; -trace_io (conn,"OUT" , out); +trace_io (conn, out,1 );list_del (&out->list);talloc_free (out);
@@ -1316,7 +1321,7 @@ static void handle_input(struct connectiif (in->used != in->hdr.msg.len)return ; -trace_io (conn,"IN " , in); +trace_io (conn, in,0 );consider_message (conn);return ;
tools/xenstore/xenstored_core.h +1 -1
@@ -160,12 +160,12 @@ struct connection *new_connection(connwr/* Is this a valid node name? */ bool is_valid_nodename (const char *node); -/* Tracing infrastructure. */ void trace_create (const void *data,const char *type);void trace_destroy (const void *data,const char *type);void trace_watch_timeout (const struct connection *conn,const char *node,const char *token);void trace (const char *fmt, ...); +void dtrace_io (const struct connection *conn,const struct buffered_data *data,int out);extern int event_fd;
tools/xenstore/xenstored_probes.d new file +28 -0
@@ -0,0 +1,28 @@ +/* + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 2 of the License. + */ + +#include <sys/types.h> + +provider xenstore { + /* tx id, dom id, pid, type, msg */ + probe msg(uint32_t, unsigned int, pid_t, int, const char *); + /* tx id, dom id, pid, type, reply */ + probe reply(uint32_t, unsigned int, pid_t, int, const char *); + /* tx id, dom id, pid, reply */ + probe error(uint32_t, unsigned int, pid_t, const char *); + /* dom id, pid, watch details */ + probe watch_event(unsigned int, pid_t, const char *); +}; + +#pragma D attributes Evolving/Evolving/Common provider xenstore provider +#pragma D attributes Private/Private/Unknown provider xenstore module +#pragma D attributes Private/Private/Unknown provider xenstore function +#pragma D attributes Evolving/Evolving/Common provider xenstore name +#pragma D attributes Evolving/Evolving/Common provider xenstore args +
tools/xenstore/xenstored_solaris.c +101 -0
113 lines not on this page · raw message