*
* Return 0 on success else a negative value and regp is untouched.
*/
-int buffer_reg_uid_create(int session_id, uint32_t bits_per_long, uid_t uid,
+int buffer_reg_uid_create(uint64_t session_id, uint32_t bits_per_long, uid_t uid,
enum lttng_domain_type domain, struct buffer_reg_uid **regp)
{
int ret = 0;
cds_lfht_node_init(®->node.node);
*regp = reg;
- DBG3("Buffer registry per UID created id: %d, ABI: %u, uid: %d, domain: %d",
+ DBG3("Buffer registry per UID created id: %" PRIu64 ", ABI: %u, uid: %d, domain: %d",
session_id, bits_per_long, uid, domain);
return 0;
assert(reg);
- DBG3("Buffer registry per UID adding to global registry with id: %d",
+ DBG3("Buffer registry per UID adding to global registry with id: %" PRIu64 ,
reg->session_id);
rcu_read_lock();
*
* Return the object pointer or NULL on error.
*/
-struct buffer_reg_uid *buffer_reg_uid_find(int session_id,
+struct buffer_reg_uid *buffer_reg_uid_find(uint64_t session_id,
uint32_t bits_per_long, uid_t uid)
{
struct lttng_ht_node_u64 *node;
key.bits_per_long = bits_per_long;
key.uid = uid;
- DBG3("Buffer registry per UID find id: %d, ABI: %u, uid: %d",
+ DBG3("Buffer registry per UID find id: %" PRIu64 ", ABI: %u, uid: %d",
session_id, bits_per_long, uid);
/* Custom lookup function since it's a different key. */
{
/* Should be called once. */
assert(!buffer_registry_pid);
- buffer_registry_pid = lttng_ht_new(0, LTTNG_HT_TYPE_ULONG);
+ buffer_registry_pid = lttng_ht_new(0, LTTNG_HT_TYPE_U64);
assert(buffer_registry_pid);
DBG3("Global buffer per PID registry initialized");
*
* Return 0 on success else a negative value and regp is untouched.
*/
-int buffer_reg_pid_create(int session_id, struct buffer_reg_pid **regp)
+int buffer_reg_pid_create(uint64_t session_id, struct buffer_reg_pid **regp)
{
int ret = 0;
struct buffer_reg_pid *reg = NULL;
goto error_session;
}
- lttng_ht_node_init_ulong(®->node, reg->session_id);
+ lttng_ht_node_init_u64(®->node, reg->session_id);
*regp = reg;
- DBG3("Buffer registry per PID created with session id: %d", session_id);
+ DBG3("Buffer registry per PID created with session id: %" PRIu64,
+ session_id);
return 0;
{
assert(reg);
- DBG3("Buffer registry per PID adding to global registry with id: %d",
+ DBG3("Buffer registry per PID adding to global registry with id: %" PRIu64,
reg->session_id);
rcu_read_lock();
- lttng_ht_add_unique_ulong(buffer_registry_pid, ®->node);
+ lttng_ht_add_unique_u64(buffer_registry_pid, ®->node);
rcu_read_unlock();
}
*
* Return the object pointer or NULL on error.
*/
-struct buffer_reg_pid *buffer_reg_pid_find(int session_id)
+struct buffer_reg_pid *buffer_reg_pid_find(uint64_t session_id)
{
- struct lttng_ht_node_ulong *node;
+ struct lttng_ht_node_u64 *node;
struct lttng_ht_iter iter;
struct buffer_reg_pid *reg = NULL;
struct lttng_ht *ht = buffer_registry_pid;
- DBG3("Buffer registry per PID find id: %d", session_id);
+ DBG3("Buffer registry per PID find id: %" PRIu64, session_id);
- lttng_ht_lookup(ht, (void *)((unsigned long) session_id), &iter);
- node = lttng_ht_iter_get_node_ulong(&iter);
+ lttng_ht_lookup(ht, &session_id, &iter);
+ node = lttng_ht_iter_get_node_u64(&iter);
if (!node) {
goto end;
}
static void rcu_free_buffer_reg_pid(struct rcu_head *head)
{
- struct lttng_ht_node_ulong *node =
- caa_container_of(head, struct lttng_ht_node_ulong, head);
+ struct lttng_ht_node_u64 *node =
+ caa_container_of(head, struct lttng_ht_node_u64, head);
struct buffer_reg_pid *reg =
caa_container_of(node, struct buffer_reg_pid, node);
return;
}
- DBG3("Buffer registry per UID destroy with id: %d, ABI: %u, uid: %d",
+ DBG3("Buffer registry per UID destroy with id: %" PRIu64 ", ABI: %u, uid: %d",
regp->session_id, regp->bits_per_long, regp->uid);
if (!consumer) {
return;
}
- DBG3("Buffer registry per PID destroy with id: %d", regp->session_id);
+ DBG3("Buffer registry per PID destroy with id: %" PRIu64,
+ regp->session_id);
/* This registry is only used by UST. */
call_rcu(®p->node.head, rcu_free_buffer_reg_pid);
* Keys to match this object in a hash table. The following three variables
* identify a unique per UID buffer registry.
*/
- int session_id; /* Unique tracing session id. */
+ uint64_t session_id; /* Unique tracing session id. */
int bits_per_long; /* ABI */
uid_t uid; /* Owner. */
* Registry object for per PID buffers.
*/
struct buffer_reg_pid {
- int session_id;
+ uint64_t session_id;
struct buffer_reg_session *registry;
/* Indexed by session id. */
- struct lttng_ht_node_ulong node;
+ struct lttng_ht_node_u64 node;
};
/* Buffer registry per UID. */
void buffer_reg_init_uid_registry(void);
-int buffer_reg_uid_create(int session_id, uint32_t bits_per_long, uid_t uid,
+int buffer_reg_uid_create(uint64_t session_id, uint32_t bits_per_long, uid_t uid,
enum lttng_domain_type domain, struct buffer_reg_uid **regp);
void buffer_reg_uid_add(struct buffer_reg_uid *reg);
-struct buffer_reg_uid *buffer_reg_uid_find(int session_id,
+struct buffer_reg_uid *buffer_reg_uid_find(uint64_t session_id,
uint32_t bits_per_long, uid_t uid);
void buffer_reg_uid_remove(struct buffer_reg_uid *regp);
void buffer_reg_uid_destroy(struct buffer_reg_uid *regp,
/* Buffer registry per PID. */
void buffer_reg_init_pid_registry(void);
-int buffer_reg_pid_create(int session_id, struct buffer_reg_pid **regp);
+int buffer_reg_pid_create(uint64_t session_id, struct buffer_reg_pid **regp);
void buffer_reg_pid_add(struct buffer_reg_pid *reg);
-struct buffer_reg_pid *buffer_reg_pid_find(int session_id);
+struct buffer_reg_pid *buffer_reg_pid_find(uint64_t session_id);
void buffer_reg_pid_remove(struct buffer_reg_pid *regp);
void buffer_reg_pid_destroy(struct buffer_reg_pid *regp);
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
+#include <inttypes.h>
#include <common/common.h>
#include <common/defaults.h>
*
* Return pointer to structure or NULL.
*/
-struct ltt_ust_session *trace_ust_create_session(unsigned int session_id)
+struct ltt_ust_session *trace_ust_create_session(uint64_t session_id)
{
struct ltt_ust_session *lus;
assert(session);
- DBG2("Trace UST destroy session %u", session->id);
+ DBG2("Trace UST destroy session %" PRIu64, session->id);
/* Cleaning up UST domain */
destroy_domain_global(&session->domain_global);
/* UST session */
struct ltt_ust_session {
- int id; /* Unique identifier of session */
+ uint64_t id; /* Unique identifier of session */
int start_trace;
struct ltt_ust_domain_global domain_global;
/* UID/GID of the user owning the session */
/*
* Create functions malloc() the data structure.
*/
-struct ltt_ust_session *trace_ust_create_session(unsigned int session_id);
+struct ltt_ust_session *trace_ust_create_session(uint64_t session_id);
struct ltt_ust_channel *trace_ust_create_channel(struct lttng_channel *attr);
struct ltt_ust_event *trace_ust_create_event(struct lttng_event *ev,
struct lttng_filter_bytecode *filter);
#include "ust-ctl.h"
#include "utils.h"
-/* Next available channel key. */
-static unsigned long next_channel_key;
-static unsigned long next_session_id;
+/* Next available channel key. Access under next_channel_key_lock. */
+static uint64_t _next_channel_key;
+static pthread_mutex_t next_channel_key_lock = PTHREAD_MUTEX_INITIALIZER;
+
+/* Next available session ID. Access under next_session_id_lock. */
+static uint64_t _next_session_id;
+static pthread_mutex_t next_session_id_lock = PTHREAD_MUTEX_INITIALIZER;
/*
- * Return the atomically incremented value of next_channel_key.
+ * Return the incremented value of next_channel_key.
*/
-static inline unsigned long get_next_channel_key(void)
+static uint64_t get_next_channel_key(void)
{
- return uatomic_add_return(&next_channel_key, 1);
+ uint64_t ret;
+
+ pthread_mutex_lock(&next_channel_key_lock);
+ ret = ++_next_channel_key;
+ pthread_mutex_unlock(&next_channel_key_lock);
+ return ret;
}
/*
* Return the atomically incremented value of next_session_id.
*/
-static inline unsigned long get_next_session_id(void)
+static uint64_t get_next_session_id(void)
{
- return uatomic_add_return(&next_session_id, 1);
+ uint64_t ret;
+
+ pthread_mutex_lock(&next_session_id_lock);
+ ret = ++_next_session_id;
+ pthread_mutex_unlock(&next_session_id_lock);
+ return ret;
}
static void copy_channel_attr_to_ustctl(
struct ust_app *app, struct lttng_ht_iter *iter)
{
/* Get right UST app session from app */
- lttng_ht_lookup(app->sessions, (void *)((unsigned long) usess->id), iter);
+ lttng_ht_lookup(app->sessions, &usess->id, iter);
}
/*
struct ltt_ust_session *usess, struct ust_app *app)
{
struct lttng_ht_iter iter;
- struct lttng_ht_node_ulong *node;
+ struct lttng_ht_node_u64 *node;
__lookup_session_by_app(usess, app, &iter);
- node = lttng_ht_iter_get_node_ulong(&iter);
+ node = lttng_ht_iter_get_node_u64(&iter);
if (node == NULL) {
goto error;
}
ua_sess = lookup_session_by_app(usess, app);
if (ua_sess == NULL) {
- DBG2("UST app pid: %d session id %d not found, creating it",
+ DBG2("UST app pid: %d session id %" PRIu64 " not found, creating it",
app->pid, usess->id);
ua_sess = alloc_ust_app_session(app);
if (ua_sess == NULL) {
ua_sess->handle = ret;
/* Add ust app session to app's HT */
- lttng_ht_node_init_ulong(&ua_sess->node,
- (unsigned long) ua_sess->tracing_id);
- lttng_ht_add_unique_ulong(app->sessions, &ua_sess->node);
+ lttng_ht_node_init_u64(&ua_sess->node,
+ ua_sess->tracing_id);
+ lttng_ht_add_unique_u64(app->sessions, &ua_sess->node);
DBG2("UST app session created successfully with handle %d", ret);
}
lttng_ht_lookup(ua_sess->channels, (void *)uchan->name, &iter);
ua_chan_node = lttng_ht_iter_get_node_str(&iter);
if (ua_chan_node == NULL) {
- DBG2("Unable to find channel %s in ust session id %u",
+ DBG2("Unable to find channel %s in ust session id %" PRIu64,
uchan->name, ua_sess->tracing_id);
goto error;
}
lta->v_major = msg->major;
lta->v_minor = msg->minor;
- lta->sessions = lttng_ht_new(0, LTTNG_HT_TYPE_ULONG);
+ lta->sessions = lttng_ht_new(0, LTTNG_HT_TYPE_U64);
lta->ust_objd = lttng_ht_new(0, LTTNG_HT_TYPE_ULONG);
lta->notify_sock = -1;
goto error;
}
- DBG2("UST app disabling channel %s from global domain for session id %d",
+ DBG2("UST app disabling channel %s from global domain for session id %" PRIu64,
uchan->name, usess->id);
rcu_read_lock();
goto error;
}
- DBG2("UST app enabling channel %s to global domain for session id %d",
+ DBG2("UST app enabling channel %s to global domain for session id %" PRIu64,
uchan->name, usess->id);
rcu_read_lock();
struct ust_app_event *ua_event;
DBG("UST app disabling event %s for all apps in channel "
- "%s for session id %d", uevent->attr.name, uchan->name, usess->id);
+ "%s for session id %" PRIu64,
+ uevent->attr.name, uchan->name, usess->id);
rcu_read_lock();
lttng_ht_lookup(ua_sess->channels, (void *)uchan->name, &uiter);
ua_chan_node = lttng_ht_iter_get_node_str(&uiter);
if (ua_chan_node == NULL) {
- DBG2("Channel %s not found in session id %d for app pid %d."
+ DBG2("Channel %s not found in session id %" PRIu64 " for app pid %d."
"Skipping", uchan->name, usess->id, app->pid);
continue;
}
struct ust_app_event *ua_event;
DBG("UST app disabling all event for all apps in channel "
- "%s for session id %d", uchan->name, usess->id);
+ "%s for session id %" PRIu64, uchan->name, usess->id);
rcu_read_lock();
assert(usess);
assert(uchan);
- DBG2("UST app adding channel %s to UST domain for session id %d",
+ DBG2("UST app adding channel %s to UST domain for session id %" PRIu64,
uchan->name, usess->id);
rcu_read_lock();
struct ust_app_channel *ua_chan;
struct ust_app_event *ua_event;
- DBG("UST app enabling event %s for all apps for session id %d",
+ DBG("UST app enabling event %s for all apps for session id %" PRIu64,
uevent->attr.name, usess->id);
/*
struct ust_app_session *ua_sess;
struct ust_app_channel *ua_chan;
- DBG("UST app creating event %s for all apps for session id %d",
+ DBG("UST app creating event %s for all apps for session id %" PRIu64,
uevent->attr.name, usess->id);
rcu_read_lock();
int ret;
struct ust_app_session *ua_sess;
struct lttng_ht_iter iter;
- struct lttng_ht_node_ulong *node;
+ struct lttng_ht_node_u64 *node;
DBG("Destroy tracing for ust app pid %d", app->pid);
}
__lookup_session_by_app(usess, app, &iter);
- node = lttng_ht_iter_get_node_ulong(&iter);
+ node = lttng_ht_iter_get_node_u64(&iter);
if (node == NULL) {
/* Session is being or is deleted. */
goto end;
assert(usess);
assert(sock >= 0);
- DBG2("UST app global update for app sock %d for session id %d", sock,
+ DBG2("UST app global update for app sock %d for session id %" PRIu64, sock,
usess->id);
rcu_read_lock();
* Tracing session ID. Multiple ust app session can have the same tracing
* session id making this value NOT unique to the object.
*/
- int tracing_id;
+ uint64_t tracing_id;
uint64_t id; /* Unique session identifier */
struct lttng_ht *channels; /* Registered channels */
- struct lttng_ht_node_ulong node;
+ struct lttng_ht_node_u64 node;
char path[PATH_MAX];
/* UID/GID of the application owning the session */
uid_t uid;