projects
/
lttng-tools.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Add Python agent support
[lttng-tools.git]
/
src
/
bin
/
lttng-sessiond
/
buffer-registry.c
diff --git
a/src/bin/lttng-sessiond/buffer-registry.c
b/src/bin/lttng-sessiond/buffer-registry.c
index 5751b8d587f8a1a12a64a1b2fc207aaba22b0534..bab1f309f54560d12f56a8be8675d0532d8772bd 100644
(file)
--- a/
src/bin/lttng-sessiond/buffer-registry.c
+++ b/
src/bin/lttng-sessiond/buffer-registry.c
@@
-25,6
+25,7
@@
#include "fd-limit.h"
#include "ust-consumer.h"
#include "ust-ctl.h"
#include "fd-limit.h"
#include "ust-consumer.h"
#include "ust-ctl.h"
+#include "utils.h"
/*
* Set in main.c during initialization process of the daemon. This contains
/*
* Set in main.c during initialization process of the daemon. This contains
@@
-103,7
+104,7
@@
void buffer_reg_init_uid_registry(void)
*
* Return 0 on success else a negative value and regp is untouched.
*/
*
* Return 0 on success else a negative value and regp is untouched.
*/
-int buffer_reg_uid_create(
in
t 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;
enum lttng_domain_type domain, struct buffer_reg_uid **regp)
{
int ret = 0;
@@
-119,7
+120,7
@@
int buffer_reg_uid_create(int session_id, uint32_t bits_per_long, uid_t uid,
}
reg->registry = zmalloc(sizeof(struct buffer_reg_session));
}
reg->registry = zmalloc(sizeof(struct buffer_reg_session));
- if (!reg) {
+ if (!reg
->registry
) {
PERROR("zmalloc buffer registry uid session");
ret = -ENOMEM;
goto error;
PERROR("zmalloc buffer registry uid session");
ret = -ENOMEM;
goto error;
@@
-139,7
+140,7
@@
int buffer_reg_uid_create(int session_id, uint32_t bits_per_long, uid_t uid,
cds_lfht_node_init(®->node.node);
*regp = reg;
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;
session_id, bits_per_long, uid, domain);
return 0;
@@
-161,7
+162,7
@@
void buffer_reg_uid_add(struct buffer_reg_uid *reg)
assert(reg);
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();
reg->session_id);
rcu_read_lock();
@@
-177,7
+178,7
@@
void buffer_reg_uid_add(struct buffer_reg_uid *reg)
*
* Return the object pointer or NULL on error.
*/
*
* Return the object pointer or NULL on error.
*/
-struct buffer_reg_uid *buffer_reg_uid_find(
in
t 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;
uint32_t bits_per_long, uid_t uid)
{
struct lttng_ht_node_u64 *node;
@@
-190,7
+191,7
@@
struct buffer_reg_uid *buffer_reg_uid_find(int session_id,
key.bits_per_long = bits_per_long;
key.uid = uid;
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. */
session_id, bits_per_long, uid);
/* Custom lookup function since it's a different key. */
@@
-213,7
+214,7
@@
void buffer_reg_init_pid_registry(void)
{
/* Should be called once. */
assert(!buffer_registry_pid);
{
/* Should be called once. */
assert(!buffer_registry_pid);
- buffer_registry_pid = lttng_ht_new(0, LTTNG_HT_TYPE_U
LONG
);
+ buffer_registry_pid = lttng_ht_new(0, LTTNG_HT_TYPE_U
64
);
assert(buffer_registry_pid);
DBG3("Global buffer per PID registry initialized");
assert(buffer_registry_pid);
DBG3("Global buffer per PID registry initialized");
@@
-224,7
+225,7
@@
void buffer_reg_init_pid_registry(void)
*
* Return 0 on success else a negative value and regp is untouched.
*/
*
* Return 0 on success else a negative value and regp is untouched.
*/
-int buffer_reg_pid_create(
in
t 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;
{
int ret = 0;
struct buffer_reg_pid *reg = NULL;
@@
-239,7
+240,7
@@
int buffer_reg_pid_create(int session_id, struct buffer_reg_pid **regp)
}
reg->registry = zmalloc(sizeof(struct buffer_reg_session));
}
reg->registry = zmalloc(sizeof(struct buffer_reg_session));
- if (!reg) {
+ if (!reg
->registry
) {
PERROR("zmalloc buffer registry pid session");
ret = -ENOMEM;
goto error;
PERROR("zmalloc buffer registry pid session");
ret = -ENOMEM;
goto error;
@@
-254,10
+255,11
@@
int buffer_reg_pid_create(int session_id, struct buffer_reg_pid **regp)
goto error_session;
}
goto error_session;
}
- lttng_ht_node_init_u
long
(®->node, reg->session_id);
+ lttng_ht_node_init_u
64
(®->node, reg->session_id);
*regp = reg;
*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;
return 0;
@@
-275,11
+277,11
@@
void buffer_reg_pid_add(struct buffer_reg_pid *reg)
{
assert(reg);
{
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();
reg->session_id);
rcu_read_lock();
- lttng_ht_add_unique_u
long
(buffer_registry_pid, ®->node);
+ lttng_ht_add_unique_u
64
(buffer_registry_pid, ®->node);
rcu_read_unlock();
}
rcu_read_unlock();
}
@@
-289,17
+291,17
@@
void buffer_reg_pid_add(struct buffer_reg_pid *reg)
*
* Return the object pointer or NULL on error.
*/
*
* Return the object pointer or NULL on error.
*/
-struct buffer_reg_pid *buffer_reg_pid_find(
in
t session_id)
+struct buffer_reg_pid *buffer_reg_pid_find(
uint64_
t session_id)
{
{
- struct lttng_ht_node_u
long
*node;
+ struct lttng_ht_node_u
64
*node;
struct lttng_ht_iter iter;
struct buffer_reg_pid *reg = NULL;
struct lttng_ht *ht = buffer_registry_pid;
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_u
long
(&iter);
+ lttng_ht_lookup(ht,
&session_id
, &iter);
+ node = lttng_ht_iter_get_node_u
64
(&iter);
if (!node) {
goto end;
}
if (!node) {
goto end;
}
@@
-375,6
+377,7
@@
void buffer_reg_stream_add(struct buffer_reg_stream *stream,
pthread_mutex_lock(&channel->stream_list_lock);
cds_list_add_tail(&stream->lnode, &channel->streams);
pthread_mutex_lock(&channel->stream_list_lock);
cds_list_add_tail(&stream->lnode, &channel->streams);
+ channel->stream_count++;
pthread_mutex_unlock(&channel->stream_list_lock);
}
pthread_mutex_unlock(&channel->stream_list_lock);
}
@@
-492,8
+495,7
@@
void buffer_reg_channel_destroy(struct buffer_reg_channel *regp,
return;
}
return;
}
- DBG3("Buffer registry channel destroy with key %" PRIu32 " and handle %d",
- regp->key, regp->obj.ust->handle);
+ DBG3("Buffer registry channel destroy with key %" PRIu32, regp->key);
switch (domain) {
case LTTNG_DOMAIN_UST:
switch (domain) {
case LTTNG_DOMAIN_UST:
@@
-503,6
+505,7
@@
void buffer_reg_channel_destroy(struct buffer_reg_channel *regp,
/* Wipe stream */
cds_list_for_each_entry_safe(sreg, stmp, ®p->streams, lnode) {
cds_list_del(&sreg->lnode);
/* Wipe stream */
cds_list_for_each_entry_safe(sreg, stmp, ®p->streams, lnode) {
cds_list_del(&sreg->lnode);
+ regp->stream_count--;
buffer_reg_stream_destroy(sreg, domain);
}
buffer_reg_stream_destroy(sreg, domain);
}
@@
-527,8
+530,10
@@
void buffer_reg_channel_destroy(struct buffer_reg_channel *regp,
/*
* Destroy a buffer registry session with the given domain.
/*
* Destroy a buffer registry session with the given domain.
+ *
+ * Should *NOT* be called with RCU read-side lock held.
*/
*/
-void buffer_reg_session_destroy(struct buffer_reg_session *regp,
+
static
void buffer_reg_session_destroy(struct buffer_reg_session *regp,
enum lttng_domain_type domain)
{
int ret;
enum lttng_domain_type domain)
{
int ret;
@@
-545,9
+550,10
@@
void buffer_reg_session_destroy(struct buffer_reg_session *regp,
assert(!ret);
buffer_reg_channel_destroy(reg_chan, domain);
}
assert(!ret);
buffer_reg_channel_destroy(reg_chan, domain);
}
- lttng_ht_destroy(regp->channels);
rcu_read_unlock();
rcu_read_unlock();
+ ht_cleanup_push(regp->channels);
+
switch (domain) {
case LTTNG_DOMAIN_UST:
ust_registry_session_destroy(regp->reg.ust);
switch (domain) {
case LTTNG_DOMAIN_UST:
ust_registry_session_destroy(regp->reg.ust);
@@
-562,8
+568,7
@@
void buffer_reg_session_destroy(struct buffer_reg_session *regp,
}
/*
}
/*
- * Remove buffer registry UID object from the global hash table. RCU read side
- * lock MUST be acquired before calling this.
+ * Remove buffer registry UID object from the global hash table.
*/
void buffer_reg_uid_remove(struct buffer_reg_uid *regp)
{
*/
void buffer_reg_uid_remove(struct buffer_reg_uid *regp)
{
@@
-572,9
+577,11
@@
void buffer_reg_uid_remove(struct buffer_reg_uid *regp)
assert(regp);
assert(regp);
+ rcu_read_lock();
iter.iter.node = ®p->node.node;
ret = lttng_ht_del(buffer_registry_uid, &iter);
assert(!ret);
iter.iter.node = ®p->node.node;
ret = lttng_ht_del(buffer_registry_uid, &iter);
assert(!ret);
+ rcu_read_unlock();
}
static void rcu_free_buffer_reg_uid(struct rcu_head *head)
}
static void rcu_free_buffer_reg_uid(struct rcu_head *head)
@@
-590,8
+597,8
@@
static void rcu_free_buffer_reg_uid(struct rcu_head *head)
static void rcu_free_buffer_reg_pid(struct rcu_head *head)
{
static void rcu_free_buffer_reg_pid(struct rcu_head *head)
{
- struct lttng_ht_node_u
long
*node =
- caa_container_of(head, struct lttng_ht_node_u
long
, head);
+ struct lttng_ht_node_u
64
*node =
+ caa_container_of(head, struct lttng_ht_node_u
64
, head);
struct buffer_reg_pid *reg =
caa_container_of(node, struct buffer_reg_pid, node);
struct buffer_reg_pid *reg =
caa_container_of(node, struct buffer_reg_pid, node);
@@
-613,18
+620,19
@@
void buffer_reg_uid_destroy(struct buffer_reg_uid *regp,
return;
}
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) {
goto destroy;
}
regp->session_id, regp->bits_per_long, regp->uid);
if (!consumer) {
goto destroy;
}
+ rcu_read_lock();
/* Get the right socket from the consumer object. */
socket = consumer_find_socket_by_bitness(regp->bits_per_long,
consumer);
if (!socket) {
/* Get the right socket from the consumer object. */
socket = consumer_find_socket_by_bitness(regp->bits_per_long,
consumer);
if (!socket) {
- goto
destroy
;
+ goto
unlock
;
}
switch (regp->domain) {
}
switch (regp->domain) {
@@
-637,9
+645,12
@@
void buffer_reg_uid_destroy(struct buffer_reg_uid *regp,
break;
default:
assert(0);
break;
default:
assert(0);
+ rcu_read_unlock();
return;
}
return;
}
+unlock:
+ rcu_read_unlock();
destroy:
call_rcu(®p->node.head, rcu_free_buffer_reg_uid);
}
destroy:
call_rcu(®p->node.head, rcu_free_buffer_reg_uid);
}
@@
-671,7
+682,8
@@
void buffer_reg_pid_destroy(struct buffer_reg_pid *regp)
return;
}
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);
/* This registry is only used by UST. */
call_rcu(®p->node.head, rcu_free_buffer_reg_pid);
@@
-679,10
+691,12
@@
void buffer_reg_pid_destroy(struct buffer_reg_pid *regp)
/*
* Destroy per PID and UID registry hash table.
/*
* Destroy per PID and UID registry hash table.
+ *
+ * Should *NOT* be called with RCU read-side lock held.
*/
void buffer_reg_destroy_registries(void)
{
DBG3("Buffer registry destroy all registry");
*/
void buffer_reg_destroy_registries(void)
{
DBG3("Buffer registry destroy all registry");
-
lttng_ht_destroy
(buffer_registry_uid);
-
lttng_ht_destroy
(buffer_registry_pid);
+
ht_cleanup_push
(buffer_registry_uid);
+
ht_cleanup_push
(buffer_registry_pid);
}
}
This page took
0.030795 seconds
and
5
git commands to generate.