[sheepdog] [PATCH 5/6] lib: add tracepoints related to sockfd management
Hitoshi Mitake
mitake.hitoshi at lab.ntt.co.jp
Fri Jan 9 08:37:18 CET 2015
Cc: Gu Ping <guping610 at qq.com>
Signed-off-by: Hitoshi Mitake <mitake.hitoshi at lab.ntt.co.jp>
---
lib/Makefile.am | 4 +--
lib/sockfd_cache.c | 16 +++++++++
lib/tracepoint/sockfd_cache_tp.c | 13 ++++++++
lib/tracepoint/sockfd_cache_tp.h | 70 ++++++++++++++++++++++++++++++++++++++++
4 files changed, 101 insertions(+), 2 deletions(-)
create mode 100644 lib/tracepoint/sockfd_cache_tp.c
create mode 100644 lib/tracepoint/sockfd_cache_tp.h
diff --git a/lib/Makefile.am b/lib/Makefile.am
index bb68430..64ac309 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -37,10 +37,10 @@ endif
# for LTTng ust tracepoints
AM_CPPFLAGS = -I$(top_srcdir)/lib/tracepoint
-noinst_HEADERS = tracepoint/work_tp.h
+noinst_HEADERS = tracepoint/work_tp.h tracepoint/sockfd_cache_tp.h
if BUILD_LTTNG_UST
-libsheepdog_a_SOURCES += tracepoint/work_tp.c
+libsheepdog_a_SOURCES += tracepoint/work_tp.c tracepoint/sockfd_cache_tp.c
endif
# support for GNU Flymake
diff --git a/lib/sockfd_cache.c b/lib/sockfd_cache.c
index a8b86b8..7c8dd93 100644
--- a/lib/sockfd_cache.c
+++ b/lib/sockfd_cache.c
@@ -35,6 +35,9 @@
#include "util.h"
#include "sheep.h"
+#define TRACEPOINT_DEFINE
+#include "sockfd_cache_tp.h"
+
struct sockfd_cache {
struct rb_root root;
struct sd_rw_lock lock;
@@ -202,6 +205,8 @@ static void sockfd_cache_add_nolock(const struct node_id *nid)
return;
}
sockfd_cache.count++;
+
+ tracepoint(sockfd_cache, new_sockfd_entry, new, fds_count);
}
/* Add group of nodes to the cache */
@@ -237,6 +242,8 @@ void sockfd_cache_add(const struct node_id *nid)
sd_rw_unlock(&sockfd_cache.lock);
n = uatomic_add_return(&sockfd_cache.count, 1);
sd_debug("%s, count %d", addr_to_str(nid->addr, nid->port), n);
+
+ tracepoint(sockfd_cache, new_sockfd_entry, new, fds_count);
}
static uatomic_bool fds_in_grow;
@@ -265,6 +272,8 @@ static void do_grow_fds(struct work *work)
fds_count *= 2;
fds_high_watermark = FDS_WATERMARK(fds_count);
sd_rw_unlock(&sockfd_cache.lock);
+
+ tracepoint(sockfd_cache, grow_fd_count, new_fds_count);
}
static void grow_fds_done(struct work *work)
@@ -359,6 +368,9 @@ out:
sfd = xmalloc(sizeof(*sfd));
sfd->fd = entry->fds[idx].fd;
sfd->idx = idx;
+
+ tracepoint(sockfd_cache, cache_get, 0);
+
return sfd;
}
@@ -456,11 +468,15 @@ void sockfd_cache_put(const struct node_id *nid, struct sockfd *sfd)
sd_debug("%d", sfd->fd);
close(sfd->fd);
free(sfd);
+
+ tracepoint(sockfd_cache, cache_put, 0);
return;
}
sockfd_cache_put_long(nid, sfd->idx);
free(sfd);
+
+ tracepoint(sockfd_cache, cache_put, 1);
}
/* Delete all sockfd connected to the node, when node is crashed. */
diff --git a/lib/tracepoint/sockfd_cache_tp.c b/lib/tracepoint/sockfd_cache_tp.c
new file mode 100644
index 0000000..c810f5f
--- /dev/null
+++ b/lib/tracepoint/sockfd_cache_tp.c
@@ -0,0 +1,13 @@
+/*
+ * Copyright (C) 2015 Nippon Telegraph and Telephone Corporation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License version
+ * 2 as published by the Free Software Foundation.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#define TRACEPOINT_CREATE_PROBES
+#include "sockfd_cache_tp.h"
diff --git a/lib/tracepoint/sockfd_cache_tp.h b/lib/tracepoint/sockfd_cache_tp.h
new file mode 100644
index 0000000..483cb7f
--- /dev/null
+++ b/lib/tracepoint/sockfd_cache_tp.h
@@ -0,0 +1,70 @@
+/*
+ * Copyright (C) 2015 Nippon Telegraph and Telephone Corporation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License version
+ * 2 as published by the Free Software Foundation.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifdef ENABLE_LTTNG_UST
+
+#undef TRACEPOINT_PROVIDER
+#define TRACEPOINT_PROVIDER sockfd_cache
+
+#undef TRACEPOINT_INCLUDE
+#define TRACEPOINT_INCLUDE "./sockfd_cache_tp.h"
+
+#if !defined(SOCKFD_CACHE_TRACEPOINT_H) || defined(TRACEPOINT_HEADER_MULTI_READ)
+#define SOCKFD_CACHE_TRACEPOINT_H
+
+#include <lttng/tracepoint.h>
+
+TRACEPOINT_EVENT(
+ sockfd_cache,
+ new_sockfd_entry,
+ TP_ARGS(void *, _new_entry, int, _fd_count),
+ TP_FIELDS(
+ ctf_integer_hex(void *, new_entry, _new_entry)
+ ctf_integer(void *, fd_count, _fd_count)
+ )
+ )
+
+TRACEPOINT_EVENT(
+ sockfd_cache,
+ grow_fd_count,
+ TP_ARGS(int, _new_fd_count),
+ TP_FIELDS(
+ ctf_integer(int, new_fd_count, _new_fd_count)
+ )
+ )
+
+TRACEPOINT_EVENT(
+ sockfd_cache,
+ cache_get,
+ TP_ARGS(int, _is_long_cache),
+ TP_FIELDS(
+ ctf_integer(int, is_long_cache, _is_long_cache)
+ )
+ )
+
+TRACEPOINT_EVENT(
+ sockfd_cache,
+ cache_put,
+ TP_ARGS(int, _is_long_cache),
+ TP_FIELDS(
+ ctf_integer(int, is_long_cache, _is_long_cache)
+ )
+ )
+
+#endif /* WORK_TRACEPOINT_H */
+
+#include <lttng/tracepoint-event.h>
+
+#else /* ENABLE_LTTNG_UST */
+
+#include "lttng_disable.h"
+
+#endif
--
1.9.1
More information about the sheepdog
mailing list