lttng-dev.lists.lttng.org archive mirror
 help / color / mirror / Atom feed
From: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
To: lttng-dev@lists.lttng.org
Cc: jgalar@efficios.com
Subject: [PATCH lttng-tools 3/3] Support LTTNG_KERNEL_SESSION_SET_CREATION_DATETIME of lttng-modules
Date: Tue, 13 Aug 2019 14:26:51 -0400	[thread overview]
Message-ID: <20190813182651.15629-3-jonathan.rajotte-julien__24344.2795168207$1565720910$gmane$org@efficios.com> (raw)
In-Reply-To: <20190813182651.15629-1-jonathan.rajotte-julien@efficios.com>

Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
---

This should also be backported to 2.11 allowing Babeltrace 2 to merge
traces from archived data (rotation) and output a trace with a similar
lttng tree hierarchy.

See [1] for the series to be applied to lttng-modules.

[1] https://lists.lttng.org/pipermail/lttng-dev/2019-August/029191.html
---
 src/bin/lttng-sessiond/kernel.c      |  6 ++++++
 src/common/kernel-ctl/kernel-ctl.c   | 15 +++++++++++++++
 src/common/kernel-ctl/kernel-ctl.h   |  1 +
 src/common/kernel-ctl/kernel-ioctl.h |  2 ++
 src/common/lttng-kernel.h            |  8 ++++++++
 5 files changed, 32 insertions(+)

diff --git a/src/bin/lttng-sessiond/kernel.c b/src/bin/lttng-sessiond/kernel.c
index 7793ba6bc..cedb9346c 100644
--- a/src/bin/lttng-sessiond/kernel.c
+++ b/src/bin/lttng-sessiond/kernel.c
@@ -139,6 +139,12 @@ int kernel_create_session(struct ltt_session *session, int tracer_fd)
 			session->id, session->name);
 	}
 
+	ret = kernctl_session_set_creation_time(lks->fd, session->creation_time);
+	if (ret) {
+		WARN("Could not set kernel session creation time for session %" PRIu64 " name: %s",
+			session->id, session->name);
+	}
+
 	return 0;
 
 error:
diff --git a/src/common/kernel-ctl/kernel-ctl.c b/src/common/kernel-ctl/kernel-ctl.c
index 6a37015ae..8c0025c93 100644
--- a/src/common/kernel-ctl/kernel-ctl.c
+++ b/src/common/kernel-ctl/kernel-ctl.c
@@ -25,6 +25,7 @@
 #include <errno.h>
 #include <stdarg.h>
 #include <assert.h>
+#include <common/time.h>
 
 #include "kernel-ctl.h"
 #include "kernel-ioctl.h"
@@ -248,6 +249,20 @@ int kernctl_session_set_name(int fd, const char *name)
 			&session_name);
 }
 
+int kernctl_session_set_creation_time(int fd, time_t time)
+{
+	int ret;
+	struct lttng_kernel_session_creation_time creation_time;
+
+	ret = time_t_to_ISO8601(creation_time.iso8601, sizeof(creation_time.iso8601), time);
+	if (ret) {
+		return -1;
+	}
+
+	return LTTNG_IOCTL_CHECK(fd, LTTNG_KERNEL_SESSION_SET_CREATION_TIME,
+			&creation_time);
+}
+
 int kernctl_create_stream(int fd)
 {
 	return compat_ioctl_no_arg(fd, LTTNG_KERNEL_OLD_STREAM,
diff --git a/src/common/kernel-ctl/kernel-ctl.h b/src/common/kernel-ctl/kernel-ctl.h
index 884929ac1..053e7df63 100644
--- a/src/common/kernel-ctl/kernel-ctl.h
+++ b/src/common/kernel-ctl/kernel-ctl.h
@@ -68,6 +68,7 @@ int kernctl_list_tracker_pids(int fd);
 int kernctl_session_regenerate_metadata(int fd);
 int kernctl_session_regenerate_statedump(int fd);
 int kernctl_session_set_name(int fd, const char *name);
+int kernctl_session_set_creation_time(int fd, time_t time);
 
 /* Buffer operations */
 
diff --git a/src/common/kernel-ctl/kernel-ioctl.h b/src/common/kernel-ctl/kernel-ioctl.h
index ce910e96f..8d39abbe3 100644
--- a/src/common/kernel-ctl/kernel-ioctl.h
+++ b/src/common/kernel-ctl/kernel-ioctl.h
@@ -147,6 +147,8 @@
 #define LTTNG_KERNEL_SESSION_STATEDUMP		_IO(0xF6, 0x5C)
 #define LTTNG_KERNEL_SESSION_SET_NAME		\
 	_IOR(0xF6, 0x5D, struct lttng_kernel_session_name)
+#define LTTNG_KERNEL_SESSION_SET_CREATION_TIME		\
+	_IOR(0xF6, 0x5E, struct lttng_kernel_session_creation_time)
 
 /* Channel FD ioctl */
 #define LTTNG_KERNEL_STREAM			_IO(0xF6, 0x62)
diff --git a/src/common/lttng-kernel.h b/src/common/lttng-kernel.h
index 001a16e2d..2fd14dc1e 100644
--- a/src/common/lttng-kernel.h
+++ b/src/common/lttng-kernel.h
@@ -28,6 +28,7 @@
 #define LTTNG_KERNEL_SYM_NAME_LEN  256
 #define LTTNG_KERNEL_MAX_UPROBE_NUM  32
 #define LTTNG_KERNEL_SESSION_NAME_LEN	256
+#define LTTNG_KERNEL_SESSION_CREATION_TIME_ISO8601_LEN	26
 
 /*
  * LTTng DebugFS ABI structures.
@@ -186,4 +187,11 @@ struct lttng_kernel_session_name {
 	char name[LTTNG_KERNEL_SESSION_NAME_LEN];
 } LTTNG_PACKED;
 
+/*
+ * kernel session creation datetime
+ */
+struct lttng_kernel_session_creation_time {
+	char iso8601[LTTNG_KERNEL_SESSION_CREATION_TIME_ISO8601_LEN];
+} LTTNG_PACKED;
+
 #endif /* _LTTNG_KERNEL_H */
-- 
2.17.1

  parent reply	other threads:[~2019-08-13 18:27 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20190813182651.15629-1-jonathan.rajotte-julien@efficios.com>
2019-08-13 18:26 ` [PATCH lttng-tools 2/3] Support LTTNG_KERNEL_SESSION_SET_NAME of lttng-modules Jonathan Rajotte
2019-08-13 18:26 ` Jonathan Rajotte [this message]
2019-08-13 20:20 ` [PATCH lttng-tools 1/3] Metadata: add env fields to ease lttng path hierarchy creation for viewer Mathieu Desnoyers

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='20190813182651.15629-3-jonathan.rajotte-julien__24344.2795168207$1565720910$gmane$org@efficios.com' \
    --to=jonathan.rajotte-julien@efficios.com \
    --cc=jgalar@efficios.com \
    --cc=lttng-dev@lists.lttng.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).