* [ltt-dev] [UST PATCH 1/3] Remove hlist from kcompat's headers and code
@ 2010-11-26 19:28 David Goulet
2010-11-26 19:28 ` [ltt-dev] [UST PATCH 2/3] Remove kref " David Goulet
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: David Goulet @ 2010-11-26 19:28 UTC (permalink / raw)
The hlist structure is no longer needed since it's the exact
same implementation in liburcu.
Signed-off-by: David Goulet <david.goulet at polymtl.ca>
---
include/Makefile.am | 1 -
include/ust/kcompat/hlist.h | 73 -----------------------------------------
include/ust/kcompat/kcompat.h | 2 -
libust/marker.c | 57 ++++++++++++++++----------------
libust/tracepoint.c | 21 ++++++------
5 files changed, 40 insertions(+), 114 deletions(-)
delete mode 100644 include/ust/kcompat/hlist.h
diff --git a/include/Makefile.am b/include/Makefile.am
index b89de20..dd000ba 100644
--- a/include/Makefile.am
+++ b/include/Makefile.am
@@ -14,7 +14,6 @@ nobase_include_HEADERS = \
ust/kcompat/kcompat.h \
ust/kcompat/compiler.h \
ust/kcompat/disable.h \
- ust/kcompat/hlist.h \
ust/kcompat/jhash.h \
ust/kcompat/kref.h \
ust/kcompat/simple.h \
diff --git a/include/ust/kcompat/hlist.h b/include/ust/kcompat/hlist.h
deleted file mode 100644
index 1bec11a..0000000
--- a/include/ust/kcompat/hlist.h
+++ /dev/null
@@ -1,73 +0,0 @@
-#ifndef _KCOMPAT_HLIST_H
-#define _KCOMPAT_HLIST_H
-
-/*
- * Kernel sourcecode compatible lightweight single pointer list head useful
- * for implementing hash tables
- *
- * Copyright (C) 2009 Novell Inc.
- *
- * Author: Jan Blunck <jblunck at suse.de>
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License version 2.1 as
- * published by the Free Software Foundation.
- */
-
-struct hlist_head
-{
- struct hlist_node *next;
-};
-
-struct hlist_node
-{
- struct hlist_node *next;
- struct hlist_node *prev;
-};
-
-/* Initialize a new list head. */
-static inline void INIT_HLIST_HEAD(struct hlist_head *ptr)
-{
- ptr->next = NULL;
-}
-
-/* Get typed element from list at a given position. */
-#define hlist_entry(ptr, type, member) \
- ((type *) ((char *) (ptr) - (unsigned long) (&((type *) 0)->member)))
-
-/* Add new element at the head of the list. */
-static inline void hlist_add_head (struct hlist_node *newp,
- struct hlist_head *head)
-{
- if (head->next)
- head->next->prev = newp;
-
- newp->next = head->next;
- newp->prev = (struct hlist_node *)head;
- head->next = newp;
-}
-
-/* Remove element from list. */
-static inline void hlist_del (struct hlist_node *elem)
-{
- if (elem->next)
- elem->next->prev = elem->prev;
-
- elem->prev->next = elem->next;
-}
-
-#define hlist_for_each_entry(entry, pos, head, member) \
- for (pos = (head)->next, \
- entry = hlist_entry(pos, typeof(*entry), member); \
- pos != NULL; \
- pos = pos->next, \
- entry = hlist_entry(pos, typeof(*entry), member))
-
-#define hlist_for_each_entry_safe(entry, pos, p, head, member) \
- for (pos = (head)->next, \
- entry = hlist_entry(pos, typeof(*entry), member); \
- (pos != NULL) && ({ p = pos->next; 1;}); \
- pos = p, \
- entry = hlist_entry(pos, typeof(*entry), member))
-
-#endif /* _KCOMPAT_HLIST_H */
diff --git a/include/ust/kcompat/kcompat.h b/include/ust/kcompat/kcompat.h
index 4aea4cc..b506afa 100644
--- a/include/ust/kcompat/kcompat.h
+++ b/include/ust/kcompat/kcompat.h
@@ -59,8 +59,6 @@
#include <ust/kcompat/simple.h>
#include <ust/kcompat/compiler.h>
#include <ust/kcompat/types.h>
-#include <ust/kcompat/hlist.h>
-
#include <ust/kcompat/jhash.h>
#include <ust/kcompat/disable.h>
diff --git a/libust/marker.c b/libust/marker.c
index 39e12bb..2618b1a 100644
--- a/libust/marker.c
+++ b/libust/marker.c
@@ -21,6 +21,7 @@
#define _LGPL_SOURCE
#include <urcu-bp.h>
#include <urcu/rculist.h>
+#include <urcu/hlist.h>
#include <ust/core.h>
#include <ust/marker.h>
@@ -64,7 +65,7 @@ void unlock_markers(void)
*/
#define MARKER_HASH_BITS 6
#define MARKER_TABLE_SIZE (1 << MARKER_HASH_BITS)
-static struct hlist_head marker_table[MARKER_TABLE_SIZE];
+static struct cds_hlist_head marker_table[MARKER_TABLE_SIZE];
/*
* Note about RCU :
@@ -75,7 +76,7 @@ static struct hlist_head marker_table[MARKER_TABLE_SIZE];
* marker entries modifications are protected by the markers_mutex.
*/
struct marker_entry {
- struct hlist_node hlist;
+ struct cds_hlist_node hlist;
char *format;
char *name;
/* Probe wrapper */
@@ -386,8 +387,8 @@ marker_entry_remove_probe(struct marker_entry *entry,
*/
static struct marker_entry *get_marker(const char *channel, const char *name)
{
- struct hlist_head *head;
- struct hlist_node *node;
+ struct cds_hlist_head *head;
+ struct cds_hlist_node *node;
struct marker_entry *e;
size_t channel_len = strlen(channel) + 1;
size_t name_len = strlen(name) + 1;
@@ -395,7 +396,7 @@ static struct marker_entry *get_marker(const char *channel, const char *name)
hash = jhash(channel, channel_len-1, 0) ^ jhash(name, name_len-1, 0);
head = &marker_table[hash & ((1 << MARKER_HASH_BITS)-1)];
- hlist_for_each_entry(e, node, head, hlist) {
+ cds_hlist_for_each_entry(e, node, head, hlist) {
if (!strcmp(channel, e->channel) && !strcmp(name, e->name))
return e;
}
@@ -409,8 +410,8 @@ static struct marker_entry *get_marker(const char *channel, const char *name)
static struct marker_entry *add_marker(const char *channel, const char *name,
const char *format)
{
- struct hlist_head *head;
- struct hlist_node *node;
+ struct cds_hlist_head *head;
+ struct cds_hlist_node *node;
struct marker_entry *e;
size_t channel_len = strlen(channel) + 1;
size_t name_len = strlen(name) + 1;
@@ -421,7 +422,7 @@ static struct marker_entry *add_marker(const char *channel, const char *name,
if (format)
format_len = strlen(format) + 1;
head = &marker_table[hash & ((1 << MARKER_HASH_BITS)-1)];
- hlist_for_each_entry(e, node, head, hlist) {
+ cds_hlist_for_each_entry(e, node, head, hlist) {
if (!strcmp(channel, e->channel) && !strcmp(name, e->name)) {
DBG("Marker %s.%s busy", channel, name);
return ERR_PTR(-EBUSY); /* Already there */
@@ -459,7 +460,7 @@ static struct marker_entry *add_marker(const char *channel, const char *name,
e->format_allocated = 0;
e->refcount = 0;
e->rcu_pending = 0;
- hlist_add_head(&e->hlist, head);
+ cds_hlist_add_head(&e->hlist, head);
return e;
}
@@ -469,8 +470,8 @@ static struct marker_entry *add_marker(const char *channel, const char *name,
*/
static int remove_marker(const char *channel, const char *name)
{
- struct hlist_head *head;
- struct hlist_node *node;
+ struct cds_hlist_head *head;
+ struct cds_hlist_node *node;
struct marker_entry *e;
int found = 0;
size_t channel_len = strlen(channel) + 1;
@@ -480,7 +481,7 @@ static int remove_marker(const char *channel, const char *name)
hash = jhash(channel, channel_len-1, 0) ^ jhash(name, name_len-1, 0);
head = &marker_table[hash & ((1 << MARKER_HASH_BITS)-1)];
- hlist_for_each_entry(e, node, head, hlist) {
+ cds_hlist_for_each_entry(e, node, head, hlist) {
if (!strcmp(channel, e->channel) && !strcmp(name, e->name)) {
found = 1;
break;
@@ -490,7 +491,7 @@ static int remove_marker(const char *channel, const char *name)
return -ENOENT;
if (e->single.func != __mark_empty_function)
return -EBUSY;
- hlist_del(&e->hlist);
+ cds_hlist_del(&e->hlist);
if (e->format_allocated)
free(e->format);
ret = ltt_channels_unregister(e->channel);
@@ -912,12 +913,12 @@ get_marker_from_private_data(marker_probe_func *probe, void *probe_private)
{
struct marker_entry *entry;
unsigned int i;
- struct hlist_head *head;
- struct hlist_node *node;
+ struct cds_hlist_head *head;
+ struct cds_hlist_node *node;
for (i = 0; i < MARKER_TABLE_SIZE; i++) {
head = &marker_table[i];
- hlist_for_each_entry(entry, node, head, hlist) {
+ cds_hlist_for_each_entry(entry, node, head, hlist) {
if (!entry->ptype) {
if (entry->single.func == probe
&& entry->single.probe_private
@@ -1013,8 +1014,8 @@ end:
void *marker_get_private_data(const char *channel, const char *name,
marker_probe_func *probe, int num)
{
- struct hlist_head *head;
- struct hlist_node *node;
+ struct cds_hlist_head *head;
+ struct cds_hlist_node *node;
struct marker_entry *e;
size_t channel_len = strlen(channel) + 1;
size_t name_len = strlen(name) + 1;
@@ -1023,7 +1024,7 @@ void *marker_get_private_data(const char *channel, const char *name,
hash = jhash(channel, channel_len-1, 0) ^ jhash(name, name_len-1, 0);
head = &marker_table[hash & ((1 << MARKER_HASH_BITS)-1)];
- hlist_for_each_entry(e, node, head, hlist) {
+ cds_hlist_for_each_entry(e, node, head, hlist) {
if (!strcmp(channel, e->channel) && !strcmp(name, e->name)) {
if (!e->ptype) {
if (num == 0 && e->single.func == probe)
@@ -1178,14 +1179,14 @@ void marker_iter_reset(struct marker_iter *iter)
/*
* must be called with current->user_markers_mutex held
*/
-static void free_user_marker(char __user *state, struct hlist_head *head)
+static void free_user_marker(char __user *state, struct cds_hlist_head *head)
{
struct user_marker *umark;
- struct hlist_node *pos, *n;
+ struct cds_hlist_node *pos, *n;
- hlist_for_each_entry_safe(umark, pos, n, head, hlist) {
+ cds_hlist_for_each_entry_safe(umark, pos, n, head, hlist) {
if (umark->state == state) {
- hlist_del(&umark->hlist);
+ cds_hlist_del(&umark->hlist);
free(umark);
}
}
@@ -1243,12 +1244,12 @@ static void free_user_marker(char __user *state, struct hlist_head *head)
void exit_user_markers(struct task_struct *p)
{
struct user_marker *umark;
- struct hlist_node *pos, *n;
+ struct cds_hlist_node *pos, *n;
if (thread_group_leader(p)) {
pthread_mutex_lock(&markers_mutex);
pthread_mutex_lock(&p->user_markers_mutex);
- hlist_for_each_entry_safe(umark, pos, n, &p->user_markers,
+ cds_hlist_for_each_entry_safe(umark, pos, n, &p->user_markers,
hlist)
free(umark);
INIT_HLIST_HEAD(&p->user_markers);
@@ -1306,8 +1307,8 @@ void ltt_dump_marker_state(struct ust_trace *trace)
{
struct marker_entry *entry;
struct ltt_probe_private_data call_data;
- struct hlist_head *head;
- struct hlist_node *node;
+ struct cds_hlist_head *head;
+ struct cds_hlist_node *node;
unsigned int i;
pthread_mutex_lock(&markers_mutex);
@@ -1316,7 +1317,7 @@ void ltt_dump_marker_state(struct ust_trace *trace)
for (i = 0; i < MARKER_TABLE_SIZE; i++) {
head = &marker_table[i];
- hlist_for_each_entry(entry, node, head, hlist) {
+ cds_hlist_for_each_entry(entry, node, head, hlist) {
__trace_mark(0, metadata, core_marker_id,
&call_data,
"channel %s name %s event_id %hu "
diff --git a/libust/tracepoint.c b/libust/tracepoint.c
index dbaca6f..47d3785 100644
--- a/libust/tracepoint.c
+++ b/libust/tracepoint.c
@@ -27,6 +27,7 @@
#define _LGPL_SOURCE
#include <urcu-bp.h>
+#include <urcu/hlist.h>
//extern struct tracepoint __start___tracepoints[] __attribute__((visibility("hidden")));
//extern struct tracepoint __stop___tracepoints[] __attribute__((visibility("hidden")));
@@ -49,7 +50,7 @@ static DEFINE_MUTEX(tracepoints_mutex);
*/
#define TRACEPOINT_HASH_BITS 6
#define TRACEPOINT_TABLE_SIZE (1 << TRACEPOINT_HASH_BITS)
-static struct hlist_head tracepoint_table[TRACEPOINT_TABLE_SIZE];
+static struct cds_hlist_head tracepoint_table[TRACEPOINT_TABLE_SIZE];
/*
* Note about RCU :
@@ -58,7 +59,7 @@ static struct hlist_head tracepoint_table[TRACEPOINT_TABLE_SIZE];
* Tracepoint entries modifications are protected by the tracepoints_mutex.
*/
struct tracepoint_entry {
- struct hlist_node hlist;
+ struct cds_hlist_node hlist;
struct probe *probes;
int refcount; /* Number of times armed. 0 if disarmed. */
char name[0];
@@ -192,13 +193,13 @@ tracepoint_entry_remove_probe(struct tracepoint_entry *entry, void *probe,
*/
static struct tracepoint_entry *get_tracepoint(const char *name)
{
- struct hlist_head *head;
- struct hlist_node *node;
+ struct cds_hlist_head *head;
+ struct cds_hlist_node *node;
struct tracepoint_entry *e;
u32 hash = jhash(name, strlen(name), 0);
head = &tracepoint_table[hash & (TRACEPOINT_TABLE_SIZE - 1)];
- hlist_for_each_entry(e, node, head, hlist) {
+ cds_hlist_for_each_entry(e, node, head, hlist) {
if (!strcmp(name, e->name))
return e;
}
@@ -211,14 +212,14 @@ static struct tracepoint_entry *get_tracepoint(const char *name)
*/
static struct tracepoint_entry *add_tracepoint(const char *name)
{
- struct hlist_head *head;
- struct hlist_node *node;
+ struct cds_hlist_head *head;
+ struct cds_hlist_node *node;
struct tracepoint_entry *e;
size_t name_len = strlen(name) + 1;
u32 hash = jhash(name, name_len-1, 0);
head = &tracepoint_table[hash & (TRACEPOINT_TABLE_SIZE - 1)];
- hlist_for_each_entry(e, node, head, hlist) {
+ cds_hlist_for_each_entry(e, node, head, hlist) {
if (!strcmp(name, e->name)) {
DBG("tracepoint %s busy", name);
return ERR_PTR(-EEXIST); /* Already there */
@@ -234,7 +235,7 @@ static struct tracepoint_entry *add_tracepoint(const char *name)
memcpy(&e->name[0], name, name_len);
e->probes = NULL;
e->refcount = 0;
- hlist_add_head(&e->hlist, head);
+ cds_hlist_add_head(&e->hlist, head);
return e;
}
@@ -244,7 +245,7 @@ static struct tracepoint_entry *add_tracepoint(const char *name)
*/
static inline void remove_tracepoint(struct tracepoint_entry *e)
{
- hlist_del(&e->hlist);
+ cds_hlist_del(&e->hlist);
free(e);
}
--
1.7.3.2
^ permalink raw reply [flat|nested] 6+ messages in thread* [ltt-dev] [UST PATCH 2/3] Remove kref from kcompat's headers and code
2010-11-26 19:28 [ltt-dev] [UST PATCH 1/3] Remove hlist from kcompat's headers and code David Goulet
@ 2010-11-26 19:28 ` David Goulet
2010-11-27 19:08 ` Mathieu Desnoyers
2010-11-26 19:28 ` [ltt-dev] [UST PATCH 3/3] Remove unuse header disable.h David Goulet
2010-11-27 19:05 ` [ltt-dev] [UST PATCH 1/3] Remove hlist from kcompat's headers and code Mathieu Desnoyers
2 siblings, 1 reply; 6+ messages in thread
From: David Goulet @ 2010-11-26 19:28 UTC (permalink / raw)
It contains the exact same code of urcu_ref.h. The kref
struct and methods are replaced by those from liburcu.
Signed-off-by: David Goulet <david.goulet at polymtl.ca>
---
include/Makefile.am | 1 -
include/ust/kcompat/kcompat.h | 2 -
include/ust/kcompat/kref.h | 46 ---------------------------------------
libust/buffers.c | 46 +++++++++++++++++++-------------------
libust/buffers.h | 2 +-
libust/channels.c | 48 ++++++++++++++++++++--------------------
libust/channels.h | 9 +++++--
libust/tracer.c | 18 +++++++-------
libust/tracer.h | 8 +++---
9 files changed, 67 insertions(+), 113 deletions(-)
delete mode 100644 include/ust/kcompat/kref.h
diff --git a/include/Makefile.am b/include/Makefile.am
index dd000ba..5697e43 100644
--- a/include/Makefile.am
+++ b/include/Makefile.am
@@ -15,7 +15,6 @@ nobase_include_HEADERS = \
ust/kcompat/compiler.h \
ust/kcompat/disable.h \
ust/kcompat/jhash.h \
- ust/kcompat/kref.h \
ust/kcompat/simple.h \
ust/kcompat/types.h \
ust/kcompat/stringify.h \
diff --git a/include/ust/kcompat/kcompat.h b/include/ust/kcompat/kcompat.h
index b506afa..895144b 100644
--- a/include/ust/kcompat/kcompat.h
+++ b/include/ust/kcompat/kcompat.h
@@ -63,6 +63,4 @@
#include <ust/kcompat/disable.h>
-#include <ust/kcompat/kref.h>
-
#endif /* KCOMPAT_H */
diff --git a/include/ust/kcompat/kref.h b/include/ust/kcompat/kref.h
deleted file mode 100644
index f0604ef..0000000
--- a/include/ust/kcompat/kref.h
+++ /dev/null
@@ -1,46 +0,0 @@
-#ifndef _KCOMPAT_KREF_H
-#define _KCOMPAT_KREF_H
-
-/*
- * Kernel sourcecode compatible reference counting implementation
- *
- * Copyright (C) 2009 Novell Inc.
- *
- * Author: Jan Blunck <jblunck at suse.de>
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License version 2.1 as
- * published by the Free Software Foundation.
- */
-
-#include <assert.h>
-#include <urcu/uatomic_arch.h>
-
-struct kref {
- long refcount; /* ATOMIC */
-};
-
-static inline void kref_set(struct kref *ref, int val)
-{
- uatomic_set(&ref->refcount, val);
-}
-
-static inline void kref_init(struct kref *ref)
-{
- kref_set(ref, 1);
-}
-
-static inline void kref_get(struct kref *ref)
-{
- long result = uatomic_add_return(&ref->refcount, 1);
- assert(result != 0);
-}
-
-static inline void kref_put(struct kref *ref, void (*release)(struct kref *))
-{
- long res = uatomic_sub_return(&ref->refcount, 1);
- if (res == 0)
- release(ref);
-}
-
-#endif /* _KCOMPAT_KREF_H */
diff --git a/libust/buffers.c b/libust/buffers.c
index 2e4bb66..3c8b943 100644
--- a/libust/buffers.c
+++ b/libust/buffers.c
@@ -197,13 +197,13 @@ int ust_buffers_create_buf(struct ust_channel *channel, int cpu)
return -1;
buf->chan = channel;
- kref_get(&channel->kref);
+ urcu_ref_get(&channel->urcu_ref);
return 0;
}
-static void ust_buffers_destroy_channel(struct kref *kref)
+static void ust_buffers_destroy_channel(struct urcu_ref *urcu_ref)
{
- struct ust_channel *chan = _ust_container_of(kref, struct ust_channel, kref);
+ struct ust_channel *chan = _ust_container_of(urcu_ref, struct ust_channel, urcu_ref);
free(chan);
}
@@ -219,13 +219,13 @@ static void ust_buffers_destroy_buf(struct ust_buffer *buf)
//ust// chan->buf[buf->cpu] = NULL;
free(buf);
- kref_put(&chan->kref, ust_buffers_destroy_channel);
+ urcu_ref_put(&chan->urcu_ref, ust_buffers_destroy_channel);
}
-/* called from kref_put */
-static void ust_buffers_remove_buf(struct kref *kref)
+/* called from urcu_ref_put */
+static void ust_buffers_remove_buf(struct urcu_ref *urcu_ref)
{
- struct ust_buffer *buf = _ust_container_of(kref, struct ust_buffer, kref);
+ struct ust_buffer *buf = _ust_container_of(urcu_ref, struct ust_buffer, urcu_ref);
ust_buffers_destroy_buf(buf);
}
@@ -237,7 +237,7 @@ int ust_buffers_open_buf(struct ust_channel *chan, int cpu)
if (result == -1)
return -1;
- kref_init(&chan->buf[cpu]->kref);
+ urcu_ref_init(&chan->buf[cpu]->urcu_ref);
result = ust_buffers_init_buffer(chan->trace, chan, chan->buf[cpu], chan->subbuf_cnt);
if(result == -1)
@@ -254,7 +254,7 @@ int ust_buffers_open_buf(struct ust_channel *chan, int cpu)
*/
static void ust_buffers_close_buf(struct ust_buffer *buf)
{
- kref_put(&buf->kref, ust_buffers_remove_buf);
+ urcu_ref_put(&buf->urcu_ref, ust_buffers_remove_buf);
}
int ust_buffers_channel_open(struct ust_channel *chan, size_t subbuf_size, size_t subbuf_cnt)
@@ -280,7 +280,7 @@ int ust_buffers_channel_open(struct ust_channel *chan, size_t subbuf_size, size_
chan->subbuf_size_order = get_count_order(subbuf_size);
chan->alloc_size = subbuf_size * subbuf_cnt;
- kref_init(&chan->kref);
+ urcu_ref_init(&chan->urcu_ref);
pthread_mutex_lock(&ust_buffers_channels_mutex);
for(i=0; i<chan->n_cpus; i++) {
@@ -301,7 +301,7 @@ error:
do {} while(0);
}
- kref_put(&chan->kref, ust_buffers_destroy_channel);
+ urcu_ref_put(&chan->urcu_ref, ust_buffers_destroy_channel);
pthread_mutex_unlock(&ust_buffers_channels_mutex);
return -1;
}
@@ -321,7 +321,7 @@ void ust_buffers_channel_close(struct ust_channel *chan)
}
cds_list_del(&chan->list);
- kref_put(&chan->kref, ust_buffers_destroy_channel);
+ urcu_ref_put(&chan->urcu_ref, ust_buffers_destroy_channel);
pthread_mutex_unlock(&ust_buffers_channels_mutex);
}
@@ -590,10 +590,10 @@ static void ltt_relay_print_buffer_errors(struct ust_channel *channel, int cpu)
ltt_relay_print_errors(trace, channel, cpu);
}
-static void ltt_relay_release_channel(struct kref *kref)
+static void ltt_relay_release_channel(struct urcu_ref *urcu_ref)
{
- struct ust_channel *ltt_chan = _ust_container_of(kref,
- struct ust_channel, kref);
+ struct ust_channel *ltt_chan = _ust_container_of(urcu_ref,
+ struct ust_channel, urcu_ref);
free(ltt_chan->buf);
}
@@ -648,9 +648,9 @@ static int ust_buffers_init_buffer(struct ust_trace *trace,
zmalloc(sizeof(*buf->commit_count) * n_subbufs);
if (!buf->commit_count)
return -ENOMEM;
- kref_get(&trace->kref);
- kref_get(&trace->ltt_transport_kref);
- kref_get(<t_chan->kref);
+ urcu_ref_get(&trace->urcu_ref);
+ urcu_ref_get(&trace->ltt_transport_urcu_ref);
+ urcu_ref_get(<t_chan->urcu_ref);
uatomic_set(&buf->offset, ltt_subbuffer_header_size());
uatomic_set(&buf->consumed, 0);
uatomic_set(&buf->active_readers, 0);
@@ -694,14 +694,14 @@ static void ust_buffers_destroy_buffer(struct ust_channel *ltt_chan, int cpu)
struct ust_trace *trace = ltt_chan->trace;
struct ust_buffer *ltt_buf = ltt_chan->buf[cpu];
- kref_put(<t_chan->trace->ltt_transport_kref,
+ urcu_ref_put(<t_chan->trace->ltt_transport_urcu_ref,
ltt_release_transport);
ltt_relay_print_buffer_errors(ltt_chan, cpu);
//ust// free(ltt_buf->commit_seq);
free(ltt_buf->commit_count);
ltt_buf->commit_count = NULL;
- kref_put(<t_chan->kref, ltt_relay_release_channel);
- kref_put(&trace->kref, ltt_release_trace);
+ urcu_ref_put(<t_chan->urcu_ref, ltt_relay_release_channel);
+ urcu_ref_put(&trace->urcu_ref, ltt_release_trace);
//ust// wake_up_interruptible(&trace->kref_wq);
}
@@ -769,7 +769,7 @@ static int ust_buffers_create_channel(const char *trace_name, struct ust_trace *
{
int result;
- kref_init(<t_chan->kref);
+ urcu_ref_init(<t_chan->urcu_ref);
ltt_chan->trace = trace;
ltt_chan->overwrite = overwrite;
@@ -859,7 +859,7 @@ static void ltt_relay_finish_channel(struct ust_channel *channel)
static void ltt_relay_remove_channel(struct ust_channel *channel)
{
ust_buffers_channel_close(channel);
- kref_put(&channel->kref, ltt_relay_release_channel);
+ urcu_ref_put(&channel->urcu_ref, ltt_relay_release_channel);
}
/*
diff --git a/libust/buffers.h b/libust/buffers.h
index e7630bb..eb75c8b 100644
--- a/libust/buffers.h
+++ b/libust/buffers.h
@@ -94,7 +94,7 @@ struct ust_buffer {
struct ust_channel *chan;
- struct kref kref;
+ struct urcu_ref urcu_ref;
void *buf_data;
size_t buf_size;
int shmid;
diff --git a/libust/channels.c b/libust/channels.c
index 6716b5d..8930705 100644
--- a/libust/channels.c
+++ b/libust/channels.c
@@ -38,11 +38,11 @@ static CDS_LIST_HEAD(ltt_channels);
* Index of next channel in array. Makes sure that as long as a trace channel is
* allocated, no array index will be re-used when a channel is freed and then
* another channel is allocated. This index is cleared and the array indexeds
- * get reassigned when the index_kref goes back to 0, which indicates that no
+ * get reassigned when the index_urcu_ref goes back to 0, which indicates that no
* more trace channels are allocated.
*/
static unsigned int free_index;
-static struct kref index_kref; /* Keeps track of allocated trace channels */
+static struct urcu_ref index_urcu_ref; /* Keeps track of allocated trace channels */
int ust_channels_overwrite_by_default = 0;
int ust_channels_request_collection_by_default = 1;
@@ -64,14 +64,14 @@ static struct ltt_channel_setting *lookup_channel(const char *name)
*
* Called with lock_markers() and channels mutex held.
*/
-static void release_channel_setting(struct kref *kref)
+static void release_channel_setting(struct urcu_ref *urcu_ref)
{
- struct ltt_channel_setting *setting = _ust_container_of(kref,
- struct ltt_channel_setting, kref);
+ struct ltt_channel_setting *setting = _ust_container_of(urcu_ref,
+ struct ltt_channel_setting, urcu_ref);
struct ltt_channel_setting *iter;
- if (uatomic_read(&index_kref.refcount) == 0
- && uatomic_read(&setting->kref.refcount) == 0) {
+ if (uatomic_read(&index_urcu_ref.refcount) == 0
+ && uatomic_read(&setting->urcu_ref.refcount) == 0) {
cds_list_del(&setting->list);
free(setting);
@@ -90,12 +90,12 @@ static void release_channel_setting(struct kref *kref)
*
* Called with lock_markers() and channels mutex held.
*/
-static void release_trace_channel(struct kref *kref)
+static void release_trace_channel(struct urcu_ref *urcu_ref)
{
struct ltt_channel_setting *iter, *n;
cds_list_for_each_entry_safe(iter, n, <t_channels, list)
- release_channel_setting(&iter->kref);
+ release_channel_setting(&iter->urcu_ref);
}
/**
@@ -112,10 +112,10 @@ int ltt_channels_register(const char *name)
pthread_mutex_lock(<t_channel_mutex);
setting = lookup_channel(name);
if (setting) {
- if (uatomic_read(&setting->kref.refcount) == 0)
- goto init_kref;
+ if (uatomic_read(&setting->urcu_ref.refcount) == 0)
+ goto init_urcu_ref;
else {
- kref_get(&setting->kref);
+ urcu_ref_get(&setting->urcu_ref);
goto end;
}
}
@@ -127,8 +127,8 @@ int ltt_channels_register(const char *name)
cds_list_add(&setting->list, <t_channels);
strncpy(setting->name, name, PATH_MAX-1);
setting->index = free_index++;
-init_kref:
- kref_init(&setting->kref);
+init_urcu_ref:
+ urcu_ref_init(&setting->urcu_ref);
end:
pthread_mutex_unlock(<t_channel_mutex);
return ret;
@@ -148,11 +148,11 @@ int ltt_channels_unregister(const char *name)
pthread_mutex_lock(<t_channel_mutex);
setting = lookup_channel(name);
- if (!setting || uatomic_read(&setting->kref.refcount) == 0) {
+ if (!setting || uatomic_read(&setting->urcu_ref.refcount) == 0) {
ret = -ENOENT;
goto end;
}
- kref_put(&setting->kref, release_channel_setting);
+ urcu_ref_put(&setting->urcu_ref, release_channel_setting);
end:
pthread_mutex_unlock(<t_channel_mutex);
return ret;
@@ -174,7 +174,7 @@ int ltt_channels_set_default(const char *name,
pthread_mutex_lock(<t_channel_mutex);
setting = lookup_channel(name);
- if (!setting || uatomic_read(&setting->kref.refcount) == 0) {
+ if (!setting || uatomic_read(&setting->urcu_ref.refcount) == 0) {
ret = -ENOENT;
goto end;
}
@@ -198,7 +198,7 @@ const char *ltt_channels_get_name_from_index(unsigned int index)
struct ltt_channel_setting *iter;
cds_list_for_each_entry(iter, <t_channels, list)
- if (iter->index == index && uatomic_read(&iter->kref.refcount))
+ if (iter->index == index && uatomic_read(&iter->urcu_ref.refcount))
return iter->name;
return NULL;
}
@@ -211,7 +211,7 @@ ltt_channels_get_setting_from_name(const char *name)
cds_list_for_each_entry(iter, <t_channels, list)
if (!strcmp(iter->name, name)
- && uatomic_read(&iter->kref.refcount))
+ && uatomic_read(&iter->urcu_ref.refcount))
return iter;
return NULL;
}
@@ -259,10 +259,10 @@ struct ust_channel *ltt_channels_trace_alloc(unsigned int *nr_channels,
WARN("ltt_channels_trace_alloc: no free_index; are there any probes connected?");
goto end;
}
- if (!uatomic_read(&index_kref.refcount))
- kref_init(&index_kref);
+ if (!uatomic_read(&index_urcu_ref.refcount))
+ urcu_ref_init(&index_urcu_ref);
else
- kref_get(&index_kref);
+ urcu_ref_get(&index_urcu_ref);
*nr_channels = free_index;
channel = zmalloc(sizeof(struct ust_channel) * free_index);
if (!channel) {
@@ -270,7 +270,7 @@ struct ust_channel *ltt_channels_trace_alloc(unsigned int *nr_channels,
goto end;
}
cds_list_for_each_entry(iter, <t_channels, list) {
- if (!uatomic_read(&iter->kref.refcount))
+ if (!uatomic_read(&iter->urcu_ref.refcount))
continue;
channel[iter->index].subbuf_size = iter->subbuf_size;
channel[iter->index].subbuf_cnt = iter->subbuf_cnt;
@@ -297,7 +297,7 @@ void ltt_channels_trace_free(struct ust_channel *channels)
lock_markers();
pthread_mutex_lock(<t_channel_mutex);
free(channels);
- kref_put(&index_kref, release_trace_channel);
+ urcu_ref_put(&index_urcu_ref, release_trace_channel);
pthread_mutex_unlock(<t_channel_mutex);
unlock_markers();
}
diff --git a/libust/channels.h b/libust/channels.h
index 6db8e63..e7bc59f 100644
--- a/libust/channels.h
+++ b/libust/channels.h
@@ -24,9 +24,12 @@
#include <linux/limits.h>
#include <errno.h>
#include <ust/kcompat/kcompat.h>
-#include <urcu/list.h>
#include <ust/core.h>
+#define _LGPL_SOURCE
+#include <urcu/list.h>
+#include <urcu/urcu_ref.h>
+
#define EVENTS_PER_CHANNEL 65536
#define MAX_CPUS 32
@@ -52,7 +55,7 @@ struct ust_channel {
*/
/* End of first 32 bytes cacheline */
- struct kref kref; /* Channel transport reference count */
+ struct urcu_ref urcu_ref; /* Channel transport reference count */
size_t subbuf_size;
int subbuf_size_order;
unsigned int subbuf_cnt;
@@ -67,7 +70,7 @@ struct ust_channel {
struct ltt_channel_setting {
unsigned int subbuf_size;
unsigned int subbuf_cnt;
- struct kref kref; /* Number of references to structure content */
+ struct urcu_ref urcu_ref; /* Number of references to structure content */
struct cds_list_head list;
unsigned int index; /* index of channel in trace channel array */
u16 free_event_id; /* Next event ID to allocate */
diff --git a/libust/tracer.c b/libust/tracer.c
index ecf403a..eb44f54 100644
--- a/libust/tracer.c
+++ b/libust/tracer.c
@@ -324,7 +324,7 @@ struct ust_trace *_ltt_trace_find_setup(const char *trace_name)
* ltt_release_transport - Release an LTT transport
* @kref : reference count on the transport
*/
-void ltt_release_transport(struct kref *kref)
+void ltt_release_transport(struct urcu_ref *urcu_ref)
{
//ust// struct ust_trace *trace = container_of(kref,
//ust// struct ust_trace, ltt_transport_kref);
@@ -335,10 +335,10 @@ void ltt_release_transport(struct kref *kref)
* ltt_release_trace - Release a LTT trace
* @kref : reference count on the trace
*/
-void ltt_release_trace(struct kref *kref)
+void ltt_release_trace(struct urcu_ref *urcu_ref)
{
- struct ust_trace *trace = _ust_container_of(kref,
- struct ust_trace, kref);
+ struct ust_trace *trace = _ust_container_of(urcu_ref,
+ struct ust_trace, urcu_ref);
ltt_channels_trace_free(trace->channels);
free(trace);
}
@@ -640,9 +640,9 @@ int ltt_trace_alloc(const char *trace_name)
goto traces_error;
}
- kref_init(&trace->kref);
- kref_init(&trace->ltt_transport_kref);
-//ust// init_waitqueue_head(&trace->kref_wq);
+ urcu_ref_init(&trace->urcu_ref);
+ urcu_ref_init(&trace->ltt_transport_urcu_ref);
+//ust// init_waitqueue_head(&trace->urcu_ref_wq);
trace->active = 0;
//ust// get_trace_clock();
trace->freq_scale = trace_clock_freq_scale();
@@ -811,7 +811,7 @@ static void __ltt_trace_destroy(struct ust_trace *trace, int drop)
trace->ops->remove_channel(chan);
}
- kref_put(&trace->ltt_transport_kref, ltt_release_transport);
+ urcu_ref_put(&trace->ltt_transport_urcu_ref, ltt_release_transport);
//ust// module_put(trace->transport->owner);
@@ -824,7 +824,7 @@ static void __ltt_trace_destroy(struct ust_trace *trace, int drop)
//ust// __wait_event_interruptible(trace->kref_wq,
//ust// (atomic_read(&trace->kref.refcount) == 1), ret);
//ust// }
- kref_put(&trace->kref, ltt_release_trace);
+ urcu_ref_put(&trace->urcu_ref, ltt_release_trace);
}
int ltt_trace_destroy(const char *trace_name, int drop)
diff --git a/libust/tracer.h b/libust/tracer.h
index c316c9a..64996b2 100644
--- a/libust/tracer.h
+++ b/libust/tracer.h
@@ -185,9 +185,9 @@ struct ust_trace {
struct {
struct dentry *trace_root;
} dentry;
- struct kref kref; /* Each channel has a kref of the trace struct */
+ struct urcu_ref urcu_ref; /* Each channel has a urcu_ref of the trace struct */
struct ltt_transport *transport;
- struct kref ltt_transport_kref;
+ struct urcu_ref ltt_transport_urcu_ref;
char trace_name[NAME_MAX];
} ____cacheline_aligned;
@@ -427,8 +427,8 @@ extern void ltt_core_register(int (*function)(u8, void *));
extern void ltt_core_unregister(void);
-extern void ltt_release_trace(struct kref *kref);
-extern void ltt_release_transport(struct kref *kref);
+extern void ltt_release_trace(struct urcu_ref *urcu_ref);
+extern void ltt_release_transport(struct urcu_ref *urcu_ref);
extern void ltt_dump_marker_state(struct ust_trace *trace);
--
1.7.3.2
^ permalink raw reply [flat|nested] 6+ messages in thread* [ltt-dev] [UST PATCH 2/3] Remove kref from kcompat's headers and code
2010-11-26 19:28 ` [ltt-dev] [UST PATCH 2/3] Remove kref " David Goulet
@ 2010-11-27 19:08 ` Mathieu Desnoyers
0 siblings, 0 replies; 6+ messages in thread
From: Mathieu Desnoyers @ 2010-11-27 19:08 UTC (permalink / raw)
* David Goulet (david.goulet at polymtl.ca) wrote:
> It contains the exact same code of urcu_ref.h. The kref
> struct and methods are replaced by those from liburcu.
Merged, thanks!
>
> Signed-off-by: David Goulet <david.goulet at polymtl.ca>
> ---
> include/Makefile.am | 1 -
> include/ust/kcompat/kcompat.h | 2 -
> include/ust/kcompat/kref.h | 46 ---------------------------------------
> libust/buffers.c | 46 +++++++++++++++++++-------------------
> libust/buffers.h | 2 +-
> libust/channels.c | 48 ++++++++++++++++++++--------------------
> libust/channels.h | 9 +++++--
> libust/tracer.c | 18 +++++++-------
> libust/tracer.h | 8 +++---
> 9 files changed, 67 insertions(+), 113 deletions(-)
> delete mode 100644 include/ust/kcompat/kref.h
>
> diff --git a/include/Makefile.am b/include/Makefile.am
> index dd000ba..5697e43 100644
> --- a/include/Makefile.am
> +++ b/include/Makefile.am
> @@ -15,7 +15,6 @@ nobase_include_HEADERS = \
> ust/kcompat/compiler.h \
> ust/kcompat/disable.h \
> ust/kcompat/jhash.h \
> - ust/kcompat/kref.h \
> ust/kcompat/simple.h \
> ust/kcompat/types.h \
> ust/kcompat/stringify.h \
> diff --git a/include/ust/kcompat/kcompat.h b/include/ust/kcompat/kcompat.h
> index b506afa..895144b 100644
> --- a/include/ust/kcompat/kcompat.h
> +++ b/include/ust/kcompat/kcompat.h
> @@ -63,6 +63,4 @@
>
> #include <ust/kcompat/disable.h>
>
> -#include <ust/kcompat/kref.h>
> -
> #endif /* KCOMPAT_H */
> diff --git a/include/ust/kcompat/kref.h b/include/ust/kcompat/kref.h
> deleted file mode 100644
> index f0604ef..0000000
> --- a/include/ust/kcompat/kref.h
> +++ /dev/null
> @@ -1,46 +0,0 @@
> -#ifndef _KCOMPAT_KREF_H
> -#define _KCOMPAT_KREF_H
> -
> -/*
> - * Kernel sourcecode compatible reference counting implementation
> - *
> - * Copyright (C) 2009 Novell Inc.
> - *
> - * Author: Jan Blunck <jblunck at suse.de>
> - *
> - * This program is free software; you can redistribute it and/or modify it
> - * under the terms of the GNU Lesser General Public License version 2.1 as
> - * published by the Free Software Foundation.
> - */
> -
> -#include <assert.h>
> -#include <urcu/uatomic_arch.h>
> -
> -struct kref {
> - long refcount; /* ATOMIC */
> -};
> -
> -static inline void kref_set(struct kref *ref, int val)
> -{
> - uatomic_set(&ref->refcount, val);
> -}
> -
> -static inline void kref_init(struct kref *ref)
> -{
> - kref_set(ref, 1);
> -}
> -
> -static inline void kref_get(struct kref *ref)
> -{
> - long result = uatomic_add_return(&ref->refcount, 1);
> - assert(result != 0);
> -}
> -
> -static inline void kref_put(struct kref *ref, void (*release)(struct kref *))
> -{
> - long res = uatomic_sub_return(&ref->refcount, 1);
> - if (res == 0)
> - release(ref);
> -}
> -
> -#endif /* _KCOMPAT_KREF_H */
> diff --git a/libust/buffers.c b/libust/buffers.c
> index 2e4bb66..3c8b943 100644
> --- a/libust/buffers.c
> +++ b/libust/buffers.c
> @@ -197,13 +197,13 @@ int ust_buffers_create_buf(struct ust_channel *channel, int cpu)
> return -1;
>
> buf->chan = channel;
> - kref_get(&channel->kref);
> + urcu_ref_get(&channel->urcu_ref);
> return 0;
> }
>
> -static void ust_buffers_destroy_channel(struct kref *kref)
> +static void ust_buffers_destroy_channel(struct urcu_ref *urcu_ref)
> {
> - struct ust_channel *chan = _ust_container_of(kref, struct ust_channel, kref);
> + struct ust_channel *chan = _ust_container_of(urcu_ref, struct ust_channel, urcu_ref);
> free(chan);
> }
>
> @@ -219,13 +219,13 @@ static void ust_buffers_destroy_buf(struct ust_buffer *buf)
>
> //ust// chan->buf[buf->cpu] = NULL;
> free(buf);
> - kref_put(&chan->kref, ust_buffers_destroy_channel);
> + urcu_ref_put(&chan->urcu_ref, ust_buffers_destroy_channel);
> }
>
> -/* called from kref_put */
> -static void ust_buffers_remove_buf(struct kref *kref)
> +/* called from urcu_ref_put */
> +static void ust_buffers_remove_buf(struct urcu_ref *urcu_ref)
> {
> - struct ust_buffer *buf = _ust_container_of(kref, struct ust_buffer, kref);
> + struct ust_buffer *buf = _ust_container_of(urcu_ref, struct ust_buffer, urcu_ref);
> ust_buffers_destroy_buf(buf);
> }
>
> @@ -237,7 +237,7 @@ int ust_buffers_open_buf(struct ust_channel *chan, int cpu)
> if (result == -1)
> return -1;
>
> - kref_init(&chan->buf[cpu]->kref);
> + urcu_ref_init(&chan->buf[cpu]->urcu_ref);
>
> result = ust_buffers_init_buffer(chan->trace, chan, chan->buf[cpu], chan->subbuf_cnt);
> if(result == -1)
> @@ -254,7 +254,7 @@ int ust_buffers_open_buf(struct ust_channel *chan, int cpu)
> */
> static void ust_buffers_close_buf(struct ust_buffer *buf)
> {
> - kref_put(&buf->kref, ust_buffers_remove_buf);
> + urcu_ref_put(&buf->urcu_ref, ust_buffers_remove_buf);
> }
>
> int ust_buffers_channel_open(struct ust_channel *chan, size_t subbuf_size, size_t subbuf_cnt)
> @@ -280,7 +280,7 @@ int ust_buffers_channel_open(struct ust_channel *chan, size_t subbuf_size, size_
> chan->subbuf_size_order = get_count_order(subbuf_size);
> chan->alloc_size = subbuf_size * subbuf_cnt;
>
> - kref_init(&chan->kref);
> + urcu_ref_init(&chan->urcu_ref);
>
> pthread_mutex_lock(&ust_buffers_channels_mutex);
> for(i=0; i<chan->n_cpus; i++) {
> @@ -301,7 +301,7 @@ error:
> do {} while(0);
> }
>
> - kref_put(&chan->kref, ust_buffers_destroy_channel);
> + urcu_ref_put(&chan->urcu_ref, ust_buffers_destroy_channel);
> pthread_mutex_unlock(&ust_buffers_channels_mutex);
> return -1;
> }
> @@ -321,7 +321,7 @@ void ust_buffers_channel_close(struct ust_channel *chan)
> }
>
> cds_list_del(&chan->list);
> - kref_put(&chan->kref, ust_buffers_destroy_channel);
> + urcu_ref_put(&chan->urcu_ref, ust_buffers_destroy_channel);
> pthread_mutex_unlock(&ust_buffers_channels_mutex);
> }
>
> @@ -590,10 +590,10 @@ static void ltt_relay_print_buffer_errors(struct ust_channel *channel, int cpu)
> ltt_relay_print_errors(trace, channel, cpu);
> }
>
> -static void ltt_relay_release_channel(struct kref *kref)
> +static void ltt_relay_release_channel(struct urcu_ref *urcu_ref)
> {
> - struct ust_channel *ltt_chan = _ust_container_of(kref,
> - struct ust_channel, kref);
> + struct ust_channel *ltt_chan = _ust_container_of(urcu_ref,
> + struct ust_channel, urcu_ref);
> free(ltt_chan->buf);
> }
>
> @@ -648,9 +648,9 @@ static int ust_buffers_init_buffer(struct ust_trace *trace,
> zmalloc(sizeof(*buf->commit_count) * n_subbufs);
> if (!buf->commit_count)
> return -ENOMEM;
> - kref_get(&trace->kref);
> - kref_get(&trace->ltt_transport_kref);
> - kref_get(<t_chan->kref);
> + urcu_ref_get(&trace->urcu_ref);
> + urcu_ref_get(&trace->ltt_transport_urcu_ref);
> + urcu_ref_get(<t_chan->urcu_ref);
> uatomic_set(&buf->offset, ltt_subbuffer_header_size());
> uatomic_set(&buf->consumed, 0);
> uatomic_set(&buf->active_readers, 0);
> @@ -694,14 +694,14 @@ static void ust_buffers_destroy_buffer(struct ust_channel *ltt_chan, int cpu)
> struct ust_trace *trace = ltt_chan->trace;
> struct ust_buffer *ltt_buf = ltt_chan->buf[cpu];
>
> - kref_put(<t_chan->trace->ltt_transport_kref,
> + urcu_ref_put(<t_chan->trace->ltt_transport_urcu_ref,
> ltt_release_transport);
> ltt_relay_print_buffer_errors(ltt_chan, cpu);
> //ust// free(ltt_buf->commit_seq);
> free(ltt_buf->commit_count);
> ltt_buf->commit_count = NULL;
> - kref_put(<t_chan->kref, ltt_relay_release_channel);
> - kref_put(&trace->kref, ltt_release_trace);
> + urcu_ref_put(<t_chan->urcu_ref, ltt_relay_release_channel);
> + urcu_ref_put(&trace->urcu_ref, ltt_release_trace);
> //ust// wake_up_interruptible(&trace->kref_wq);
> }
>
> @@ -769,7 +769,7 @@ static int ust_buffers_create_channel(const char *trace_name, struct ust_trace *
> {
> int result;
>
> - kref_init(<t_chan->kref);
> + urcu_ref_init(<t_chan->urcu_ref);
>
> ltt_chan->trace = trace;
> ltt_chan->overwrite = overwrite;
> @@ -859,7 +859,7 @@ static void ltt_relay_finish_channel(struct ust_channel *channel)
> static void ltt_relay_remove_channel(struct ust_channel *channel)
> {
> ust_buffers_channel_close(channel);
> - kref_put(&channel->kref, ltt_relay_release_channel);
> + urcu_ref_put(&channel->urcu_ref, ltt_relay_release_channel);
> }
>
> /*
> diff --git a/libust/buffers.h b/libust/buffers.h
> index e7630bb..eb75c8b 100644
> --- a/libust/buffers.h
> +++ b/libust/buffers.h
> @@ -94,7 +94,7 @@ struct ust_buffer {
>
> struct ust_channel *chan;
>
> - struct kref kref;
> + struct urcu_ref urcu_ref;
> void *buf_data;
> size_t buf_size;
> int shmid;
> diff --git a/libust/channels.c b/libust/channels.c
> index 6716b5d..8930705 100644
> --- a/libust/channels.c
> +++ b/libust/channels.c
> @@ -38,11 +38,11 @@ static CDS_LIST_HEAD(ltt_channels);
> * Index of next channel in array. Makes sure that as long as a trace channel is
> * allocated, no array index will be re-used when a channel is freed and then
> * another channel is allocated. This index is cleared and the array indexeds
> - * get reassigned when the index_kref goes back to 0, which indicates that no
> + * get reassigned when the index_urcu_ref goes back to 0, which indicates that no
> * more trace channels are allocated.
> */
> static unsigned int free_index;
> -static struct kref index_kref; /* Keeps track of allocated trace channels */
> +static struct urcu_ref index_urcu_ref; /* Keeps track of allocated trace channels */
>
> int ust_channels_overwrite_by_default = 0;
> int ust_channels_request_collection_by_default = 1;
> @@ -64,14 +64,14 @@ static struct ltt_channel_setting *lookup_channel(const char *name)
> *
> * Called with lock_markers() and channels mutex held.
> */
> -static void release_channel_setting(struct kref *kref)
> +static void release_channel_setting(struct urcu_ref *urcu_ref)
> {
> - struct ltt_channel_setting *setting = _ust_container_of(kref,
> - struct ltt_channel_setting, kref);
> + struct ltt_channel_setting *setting = _ust_container_of(urcu_ref,
> + struct ltt_channel_setting, urcu_ref);
> struct ltt_channel_setting *iter;
>
> - if (uatomic_read(&index_kref.refcount) == 0
> - && uatomic_read(&setting->kref.refcount) == 0) {
> + if (uatomic_read(&index_urcu_ref.refcount) == 0
> + && uatomic_read(&setting->urcu_ref.refcount) == 0) {
> cds_list_del(&setting->list);
> free(setting);
>
> @@ -90,12 +90,12 @@ static void release_channel_setting(struct kref *kref)
> *
> * Called with lock_markers() and channels mutex held.
> */
> -static void release_trace_channel(struct kref *kref)
> +static void release_trace_channel(struct urcu_ref *urcu_ref)
> {
> struct ltt_channel_setting *iter, *n;
>
> cds_list_for_each_entry_safe(iter, n, <t_channels, list)
> - release_channel_setting(&iter->kref);
> + release_channel_setting(&iter->urcu_ref);
> }
>
> /**
> @@ -112,10 +112,10 @@ int ltt_channels_register(const char *name)
> pthread_mutex_lock(<t_channel_mutex);
> setting = lookup_channel(name);
> if (setting) {
> - if (uatomic_read(&setting->kref.refcount) == 0)
> - goto init_kref;
> + if (uatomic_read(&setting->urcu_ref.refcount) == 0)
> + goto init_urcu_ref;
> else {
> - kref_get(&setting->kref);
> + urcu_ref_get(&setting->urcu_ref);
> goto end;
> }
> }
> @@ -127,8 +127,8 @@ int ltt_channels_register(const char *name)
> cds_list_add(&setting->list, <t_channels);
> strncpy(setting->name, name, PATH_MAX-1);
> setting->index = free_index++;
> -init_kref:
> - kref_init(&setting->kref);
> +init_urcu_ref:
> + urcu_ref_init(&setting->urcu_ref);
> end:
> pthread_mutex_unlock(<t_channel_mutex);
> return ret;
> @@ -148,11 +148,11 @@ int ltt_channels_unregister(const char *name)
>
> pthread_mutex_lock(<t_channel_mutex);
> setting = lookup_channel(name);
> - if (!setting || uatomic_read(&setting->kref.refcount) == 0) {
> + if (!setting || uatomic_read(&setting->urcu_ref.refcount) == 0) {
> ret = -ENOENT;
> goto end;
> }
> - kref_put(&setting->kref, release_channel_setting);
> + urcu_ref_put(&setting->urcu_ref, release_channel_setting);
> end:
> pthread_mutex_unlock(<t_channel_mutex);
> return ret;
> @@ -174,7 +174,7 @@ int ltt_channels_set_default(const char *name,
>
> pthread_mutex_lock(<t_channel_mutex);
> setting = lookup_channel(name);
> - if (!setting || uatomic_read(&setting->kref.refcount) == 0) {
> + if (!setting || uatomic_read(&setting->urcu_ref.refcount) == 0) {
> ret = -ENOENT;
> goto end;
> }
> @@ -198,7 +198,7 @@ const char *ltt_channels_get_name_from_index(unsigned int index)
> struct ltt_channel_setting *iter;
>
> cds_list_for_each_entry(iter, <t_channels, list)
> - if (iter->index == index && uatomic_read(&iter->kref.refcount))
> + if (iter->index == index && uatomic_read(&iter->urcu_ref.refcount))
> return iter->name;
> return NULL;
> }
> @@ -211,7 +211,7 @@ ltt_channels_get_setting_from_name(const char *name)
>
> cds_list_for_each_entry(iter, <t_channels, list)
> if (!strcmp(iter->name, name)
> - && uatomic_read(&iter->kref.refcount))
> + && uatomic_read(&iter->urcu_ref.refcount))
> return iter;
> return NULL;
> }
> @@ -259,10 +259,10 @@ struct ust_channel *ltt_channels_trace_alloc(unsigned int *nr_channels,
> WARN("ltt_channels_trace_alloc: no free_index; are there any probes connected?");
> goto end;
> }
> - if (!uatomic_read(&index_kref.refcount))
> - kref_init(&index_kref);
> + if (!uatomic_read(&index_urcu_ref.refcount))
> + urcu_ref_init(&index_urcu_ref);
> else
> - kref_get(&index_kref);
> + urcu_ref_get(&index_urcu_ref);
> *nr_channels = free_index;
> channel = zmalloc(sizeof(struct ust_channel) * free_index);
> if (!channel) {
> @@ -270,7 +270,7 @@ struct ust_channel *ltt_channels_trace_alloc(unsigned int *nr_channels,
> goto end;
> }
> cds_list_for_each_entry(iter, <t_channels, list) {
> - if (!uatomic_read(&iter->kref.refcount))
> + if (!uatomic_read(&iter->urcu_ref.refcount))
> continue;
> channel[iter->index].subbuf_size = iter->subbuf_size;
> channel[iter->index].subbuf_cnt = iter->subbuf_cnt;
> @@ -297,7 +297,7 @@ void ltt_channels_trace_free(struct ust_channel *channels)
> lock_markers();
> pthread_mutex_lock(<t_channel_mutex);
> free(channels);
> - kref_put(&index_kref, release_trace_channel);
> + urcu_ref_put(&index_urcu_ref, release_trace_channel);
> pthread_mutex_unlock(<t_channel_mutex);
> unlock_markers();
> }
> diff --git a/libust/channels.h b/libust/channels.h
> index 6db8e63..e7bc59f 100644
> --- a/libust/channels.h
> +++ b/libust/channels.h
> @@ -24,9 +24,12 @@
> #include <linux/limits.h>
> #include <errno.h>
> #include <ust/kcompat/kcompat.h>
> -#include <urcu/list.h>
> #include <ust/core.h>
>
> +#define _LGPL_SOURCE
> +#include <urcu/list.h>
> +#include <urcu/urcu_ref.h>
> +
> #define EVENTS_PER_CHANNEL 65536
> #define MAX_CPUS 32
>
> @@ -52,7 +55,7 @@ struct ust_channel {
> */
> /* End of first 32 bytes cacheline */
>
> - struct kref kref; /* Channel transport reference count */
> + struct urcu_ref urcu_ref; /* Channel transport reference count */
> size_t subbuf_size;
> int subbuf_size_order;
> unsigned int subbuf_cnt;
> @@ -67,7 +70,7 @@ struct ust_channel {
> struct ltt_channel_setting {
> unsigned int subbuf_size;
> unsigned int subbuf_cnt;
> - struct kref kref; /* Number of references to structure content */
> + struct urcu_ref urcu_ref; /* Number of references to structure content */
> struct cds_list_head list;
> unsigned int index; /* index of channel in trace channel array */
> u16 free_event_id; /* Next event ID to allocate */
> diff --git a/libust/tracer.c b/libust/tracer.c
> index ecf403a..eb44f54 100644
> --- a/libust/tracer.c
> +++ b/libust/tracer.c
> @@ -324,7 +324,7 @@ struct ust_trace *_ltt_trace_find_setup(const char *trace_name)
> * ltt_release_transport - Release an LTT transport
> * @kref : reference count on the transport
> */
> -void ltt_release_transport(struct kref *kref)
> +void ltt_release_transport(struct urcu_ref *urcu_ref)
> {
> //ust// struct ust_trace *trace = container_of(kref,
> //ust// struct ust_trace, ltt_transport_kref);
> @@ -335,10 +335,10 @@ void ltt_release_transport(struct kref *kref)
> * ltt_release_trace - Release a LTT trace
> * @kref : reference count on the trace
> */
> -void ltt_release_trace(struct kref *kref)
> +void ltt_release_trace(struct urcu_ref *urcu_ref)
> {
> - struct ust_trace *trace = _ust_container_of(kref,
> - struct ust_trace, kref);
> + struct ust_trace *trace = _ust_container_of(urcu_ref,
> + struct ust_trace, urcu_ref);
> ltt_channels_trace_free(trace->channels);
> free(trace);
> }
> @@ -640,9 +640,9 @@ int ltt_trace_alloc(const char *trace_name)
> goto traces_error;
> }
>
> - kref_init(&trace->kref);
> - kref_init(&trace->ltt_transport_kref);
> -//ust// init_waitqueue_head(&trace->kref_wq);
> + urcu_ref_init(&trace->urcu_ref);
> + urcu_ref_init(&trace->ltt_transport_urcu_ref);
> +//ust// init_waitqueue_head(&trace->urcu_ref_wq);
> trace->active = 0;
> //ust// get_trace_clock();
> trace->freq_scale = trace_clock_freq_scale();
> @@ -811,7 +811,7 @@ static void __ltt_trace_destroy(struct ust_trace *trace, int drop)
> trace->ops->remove_channel(chan);
> }
>
> - kref_put(&trace->ltt_transport_kref, ltt_release_transport);
> + urcu_ref_put(&trace->ltt_transport_urcu_ref, ltt_release_transport);
>
> //ust// module_put(trace->transport->owner);
>
> @@ -824,7 +824,7 @@ static void __ltt_trace_destroy(struct ust_trace *trace, int drop)
> //ust// __wait_event_interruptible(trace->kref_wq,
> //ust// (atomic_read(&trace->kref.refcount) == 1), ret);
> //ust// }
> - kref_put(&trace->kref, ltt_release_trace);
> + urcu_ref_put(&trace->urcu_ref, ltt_release_trace);
> }
>
> int ltt_trace_destroy(const char *trace_name, int drop)
> diff --git a/libust/tracer.h b/libust/tracer.h
> index c316c9a..64996b2 100644
> --- a/libust/tracer.h
> +++ b/libust/tracer.h
> @@ -185,9 +185,9 @@ struct ust_trace {
> struct {
> struct dentry *trace_root;
> } dentry;
> - struct kref kref; /* Each channel has a kref of the trace struct */
> + struct urcu_ref urcu_ref; /* Each channel has a urcu_ref of the trace struct */
> struct ltt_transport *transport;
> - struct kref ltt_transport_kref;
> + struct urcu_ref ltt_transport_urcu_ref;
> char trace_name[NAME_MAX];
> } ____cacheline_aligned;
>
> @@ -427,8 +427,8 @@ extern void ltt_core_register(int (*function)(u8, void *));
>
> extern void ltt_core_unregister(void);
>
> -extern void ltt_release_trace(struct kref *kref);
> -extern void ltt_release_transport(struct kref *kref);
> +extern void ltt_release_trace(struct urcu_ref *urcu_ref);
> +extern void ltt_release_transport(struct urcu_ref *urcu_ref);
>
> extern void ltt_dump_marker_state(struct ust_trace *trace);
>
> --
> 1.7.3.2
>
--
Mathieu Desnoyers
Operating System Efficiency R&D Consultant
EfficiOS Inc.
http://www.efficios.com
^ permalink raw reply [flat|nested] 6+ messages in thread
* [ltt-dev] [UST PATCH 3/3] Remove unuse header disable.h
2010-11-26 19:28 [ltt-dev] [UST PATCH 1/3] Remove hlist from kcompat's headers and code David Goulet
2010-11-26 19:28 ` [ltt-dev] [UST PATCH 2/3] Remove kref " David Goulet
@ 2010-11-26 19:28 ` David Goulet
2010-11-27 19:08 ` Mathieu Desnoyers
2010-11-27 19:05 ` [ltt-dev] [UST PATCH 1/3] Remove hlist from kcompat's headers and code Mathieu Desnoyers
2 siblings, 1 reply; 6+ messages in thread
From: David Goulet @ 2010-11-26 19:28 UTC (permalink / raw)
Signed-off-by: David Goulet <david.goulet at polymtl.ca>
---
include/Makefile.am | 1 -
include/ust/kcompat/disable.h | 21 ---------------------
include/ust/kcompat/kcompat.h | 2 --
3 files changed, 0 insertions(+), 24 deletions(-)
delete mode 100644 include/ust/kcompat/disable.h
diff --git a/include/Makefile.am b/include/Makefile.am
index 5697e43..0ace775 100644
--- a/include/Makefile.am
+++ b/include/Makefile.am
@@ -13,7 +13,6 @@ nobase_include_HEADERS = \
ust/type-serializer.h \
ust/kcompat/kcompat.h \
ust/kcompat/compiler.h \
- ust/kcompat/disable.h \
ust/kcompat/jhash.h \
ust/kcompat/simple.h \
ust/kcompat/types.h \
diff --git a/include/ust/kcompat/disable.h b/include/ust/kcompat/disable.h
deleted file mode 100644
index 36d36f5..0000000
--- a/include/ust/kcompat/disable.h
+++ /dev/null
@@ -1,21 +0,0 @@
-/*
- * disable.h
- *
- * Copyright (C) 2009 - Pierre-Marc Fournier (pierre-marc dot fournier at polymtl dot ca)
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#define prefetch(a) ({ do {} while(0); })
diff --git a/include/ust/kcompat/kcompat.h b/include/ust/kcompat/kcompat.h
index 895144b..7903650 100644
--- a/include/ust/kcompat/kcompat.h
+++ b/include/ust/kcompat/kcompat.h
@@ -61,6 +61,4 @@
#include <ust/kcompat/types.h>
#include <ust/kcompat/jhash.h>
-#include <ust/kcompat/disable.h>
-
#endif /* KCOMPAT_H */
--
1.7.3.2
^ permalink raw reply [flat|nested] 6+ messages in thread* [ltt-dev] [UST PATCH 3/3] Remove unuse header disable.h
2010-11-26 19:28 ` [ltt-dev] [UST PATCH 3/3] Remove unuse header disable.h David Goulet
@ 2010-11-27 19:08 ` Mathieu Desnoyers
0 siblings, 0 replies; 6+ messages in thread
From: Mathieu Desnoyers @ 2010-11-27 19:08 UTC (permalink / raw)
* David Goulet (david.goulet at polymtl.ca) wrote:
> Signed-off-by: David Goulet <david.goulet at polymtl.ca>
Merged, thanks!
Mathieu
> ---
> include/Makefile.am | 1 -
> include/ust/kcompat/disable.h | 21 ---------------------
> include/ust/kcompat/kcompat.h | 2 --
> 3 files changed, 0 insertions(+), 24 deletions(-)
> delete mode 100644 include/ust/kcompat/disable.h
>
> diff --git a/include/Makefile.am b/include/Makefile.am
> index 5697e43..0ace775 100644
> --- a/include/Makefile.am
> +++ b/include/Makefile.am
> @@ -13,7 +13,6 @@ nobase_include_HEADERS = \
> ust/type-serializer.h \
> ust/kcompat/kcompat.h \
> ust/kcompat/compiler.h \
> - ust/kcompat/disable.h \
> ust/kcompat/jhash.h \
> ust/kcompat/simple.h \
> ust/kcompat/types.h \
> diff --git a/include/ust/kcompat/disable.h b/include/ust/kcompat/disable.h
> deleted file mode 100644
> index 36d36f5..0000000
> --- a/include/ust/kcompat/disable.h
> +++ /dev/null
> @@ -1,21 +0,0 @@
> -/*
> - * disable.h
> - *
> - * Copyright (C) 2009 - Pierre-Marc Fournier (pierre-marc dot fournier at polymtl dot ca)
> - *
> - * This library is free software; you can redistribute it and/or
> - * modify it under the terms of the GNU Lesser General Public
> - * License as published by the Free Software Foundation; either
> - * version 2.1 of the License, or (at your option) any later version.
> - *
> - * This library is distributed in the hope that it will be useful,
> - * but WITHOUT ANY WARRANTY; without even the implied warranty of
> - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
> - * Lesser General Public License for more details.
> - *
> - * You should have received a copy of the GNU Lesser General Public
> - * License along with this library; if not, write to the Free Software
> - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
> - */
> -
> -#define prefetch(a) ({ do {} while(0); })
> diff --git a/include/ust/kcompat/kcompat.h b/include/ust/kcompat/kcompat.h
> index 895144b..7903650 100644
> --- a/include/ust/kcompat/kcompat.h
> +++ b/include/ust/kcompat/kcompat.h
> @@ -61,6 +61,4 @@
> #include <ust/kcompat/types.h>
> #include <ust/kcompat/jhash.h>
>
> -#include <ust/kcompat/disable.h>
> -
> #endif /* KCOMPAT_H */
> --
> 1.7.3.2
>
--
Mathieu Desnoyers
Operating System Efficiency R&D Consultant
EfficiOS Inc.
http://www.efficios.com
^ permalink raw reply [flat|nested] 6+ messages in thread
* [ltt-dev] [UST PATCH 1/3] Remove hlist from kcompat's headers and code
2010-11-26 19:28 [ltt-dev] [UST PATCH 1/3] Remove hlist from kcompat's headers and code David Goulet
2010-11-26 19:28 ` [ltt-dev] [UST PATCH 2/3] Remove kref " David Goulet
2010-11-26 19:28 ` [ltt-dev] [UST PATCH 3/3] Remove unuse header disable.h David Goulet
@ 2010-11-27 19:05 ` Mathieu Desnoyers
2 siblings, 0 replies; 6+ messages in thread
From: Mathieu Desnoyers @ 2010-11-27 19:05 UTC (permalink / raw)
* David Goulet (david.goulet at polymtl.ca) wrote:
> The hlist structure is no longer needed since it's the exact
> same implementation in liburcu.
>
> Signed-off-by: David Goulet <david.goulet at polymtl.ca>
Committed and pushed, thanks!
Mathieu
> ---
> include/Makefile.am | 1 -
> include/ust/kcompat/hlist.h | 73 -----------------------------------------
> include/ust/kcompat/kcompat.h | 2 -
> libust/marker.c | 57 ++++++++++++++++----------------
> libust/tracepoint.c | 21 ++++++------
> 5 files changed, 40 insertions(+), 114 deletions(-)
> delete mode 100644 include/ust/kcompat/hlist.h
>
> diff --git a/include/Makefile.am b/include/Makefile.am
> index b89de20..dd000ba 100644
> --- a/include/Makefile.am
> +++ b/include/Makefile.am
> @@ -14,7 +14,6 @@ nobase_include_HEADERS = \
> ust/kcompat/kcompat.h \
> ust/kcompat/compiler.h \
> ust/kcompat/disable.h \
> - ust/kcompat/hlist.h \
> ust/kcompat/jhash.h \
> ust/kcompat/kref.h \
> ust/kcompat/simple.h \
> diff --git a/include/ust/kcompat/hlist.h b/include/ust/kcompat/hlist.h
> deleted file mode 100644
> index 1bec11a..0000000
> --- a/include/ust/kcompat/hlist.h
> +++ /dev/null
> @@ -1,73 +0,0 @@
> -#ifndef _KCOMPAT_HLIST_H
> -#define _KCOMPAT_HLIST_H
> -
> -/*
> - * Kernel sourcecode compatible lightweight single pointer list head useful
> - * for implementing hash tables
> - *
> - * Copyright (C) 2009 Novell Inc.
> - *
> - * Author: Jan Blunck <jblunck at suse.de>
> - *
> - * This program is free software; you can redistribute it and/or modify it
> - * under the terms of the GNU Lesser General Public License version 2.1 as
> - * published by the Free Software Foundation.
> - */
> -
> -struct hlist_head
> -{
> - struct hlist_node *next;
> -};
> -
> -struct hlist_node
> -{
> - struct hlist_node *next;
> - struct hlist_node *prev;
> -};
> -
> -/* Initialize a new list head. */
> -static inline void INIT_HLIST_HEAD(struct hlist_head *ptr)
> -{
> - ptr->next = NULL;
> -}
> -
> -/* Get typed element from list at a given position. */
> -#define hlist_entry(ptr, type, member) \
> - ((type *) ((char *) (ptr) - (unsigned long) (&((type *) 0)->member)))
> -
> -/* Add new element at the head of the list. */
> -static inline void hlist_add_head (struct hlist_node *newp,
> - struct hlist_head *head)
> -{
> - if (head->next)
> - head->next->prev = newp;
> -
> - newp->next = head->next;
> - newp->prev = (struct hlist_node *)head;
> - head->next = newp;
> -}
> -
> -/* Remove element from list. */
> -static inline void hlist_del (struct hlist_node *elem)
> -{
> - if (elem->next)
> - elem->next->prev = elem->prev;
> -
> - elem->prev->next = elem->next;
> -}
> -
> -#define hlist_for_each_entry(entry, pos, head, member) \
> - for (pos = (head)->next, \
> - entry = hlist_entry(pos, typeof(*entry), member); \
> - pos != NULL; \
> - pos = pos->next, \
> - entry = hlist_entry(pos, typeof(*entry), member))
> -
> -#define hlist_for_each_entry_safe(entry, pos, p, head, member) \
> - for (pos = (head)->next, \
> - entry = hlist_entry(pos, typeof(*entry), member); \
> - (pos != NULL) && ({ p = pos->next; 1;}); \
> - pos = p, \
> - entry = hlist_entry(pos, typeof(*entry), member))
> -
> -#endif /* _KCOMPAT_HLIST_H */
> diff --git a/include/ust/kcompat/kcompat.h b/include/ust/kcompat/kcompat.h
> index 4aea4cc..b506afa 100644
> --- a/include/ust/kcompat/kcompat.h
> +++ b/include/ust/kcompat/kcompat.h
> @@ -59,8 +59,6 @@
> #include <ust/kcompat/simple.h>
> #include <ust/kcompat/compiler.h>
> #include <ust/kcompat/types.h>
> -#include <ust/kcompat/hlist.h>
> -
> #include <ust/kcompat/jhash.h>
>
> #include <ust/kcompat/disable.h>
> diff --git a/libust/marker.c b/libust/marker.c
> index 39e12bb..2618b1a 100644
> --- a/libust/marker.c
> +++ b/libust/marker.c
> @@ -21,6 +21,7 @@
> #define _LGPL_SOURCE
> #include <urcu-bp.h>
> #include <urcu/rculist.h>
> +#include <urcu/hlist.h>
>
> #include <ust/core.h>
> #include <ust/marker.h>
> @@ -64,7 +65,7 @@ void unlock_markers(void)
> */
> #define MARKER_HASH_BITS 6
> #define MARKER_TABLE_SIZE (1 << MARKER_HASH_BITS)
> -static struct hlist_head marker_table[MARKER_TABLE_SIZE];
> +static struct cds_hlist_head marker_table[MARKER_TABLE_SIZE];
>
> /*
> * Note about RCU :
> @@ -75,7 +76,7 @@ static struct hlist_head marker_table[MARKER_TABLE_SIZE];
> * marker entries modifications are protected by the markers_mutex.
> */
> struct marker_entry {
> - struct hlist_node hlist;
> + struct cds_hlist_node hlist;
> char *format;
> char *name;
> /* Probe wrapper */
> @@ -386,8 +387,8 @@ marker_entry_remove_probe(struct marker_entry *entry,
> */
> static struct marker_entry *get_marker(const char *channel, const char *name)
> {
> - struct hlist_head *head;
> - struct hlist_node *node;
> + struct cds_hlist_head *head;
> + struct cds_hlist_node *node;
> struct marker_entry *e;
> size_t channel_len = strlen(channel) + 1;
> size_t name_len = strlen(name) + 1;
> @@ -395,7 +396,7 @@ static struct marker_entry *get_marker(const char *channel, const char *name)
>
> hash = jhash(channel, channel_len-1, 0) ^ jhash(name, name_len-1, 0);
> head = &marker_table[hash & ((1 << MARKER_HASH_BITS)-1)];
> - hlist_for_each_entry(e, node, head, hlist) {
> + cds_hlist_for_each_entry(e, node, head, hlist) {
> if (!strcmp(channel, e->channel) && !strcmp(name, e->name))
> return e;
> }
> @@ -409,8 +410,8 @@ static struct marker_entry *get_marker(const char *channel, const char *name)
> static struct marker_entry *add_marker(const char *channel, const char *name,
> const char *format)
> {
> - struct hlist_head *head;
> - struct hlist_node *node;
> + struct cds_hlist_head *head;
> + struct cds_hlist_node *node;
> struct marker_entry *e;
> size_t channel_len = strlen(channel) + 1;
> size_t name_len = strlen(name) + 1;
> @@ -421,7 +422,7 @@ static struct marker_entry *add_marker(const char *channel, const char *name,
> if (format)
> format_len = strlen(format) + 1;
> head = &marker_table[hash & ((1 << MARKER_HASH_BITS)-1)];
> - hlist_for_each_entry(e, node, head, hlist) {
> + cds_hlist_for_each_entry(e, node, head, hlist) {
> if (!strcmp(channel, e->channel) && !strcmp(name, e->name)) {
> DBG("Marker %s.%s busy", channel, name);
> return ERR_PTR(-EBUSY); /* Already there */
> @@ -459,7 +460,7 @@ static struct marker_entry *add_marker(const char *channel, const char *name,
> e->format_allocated = 0;
> e->refcount = 0;
> e->rcu_pending = 0;
> - hlist_add_head(&e->hlist, head);
> + cds_hlist_add_head(&e->hlist, head);
> return e;
> }
>
> @@ -469,8 +470,8 @@ static struct marker_entry *add_marker(const char *channel, const char *name,
> */
> static int remove_marker(const char *channel, const char *name)
> {
> - struct hlist_head *head;
> - struct hlist_node *node;
> + struct cds_hlist_head *head;
> + struct cds_hlist_node *node;
> struct marker_entry *e;
> int found = 0;
> size_t channel_len = strlen(channel) + 1;
> @@ -480,7 +481,7 @@ static int remove_marker(const char *channel, const char *name)
>
> hash = jhash(channel, channel_len-1, 0) ^ jhash(name, name_len-1, 0);
> head = &marker_table[hash & ((1 << MARKER_HASH_BITS)-1)];
> - hlist_for_each_entry(e, node, head, hlist) {
> + cds_hlist_for_each_entry(e, node, head, hlist) {
> if (!strcmp(channel, e->channel) && !strcmp(name, e->name)) {
> found = 1;
> break;
> @@ -490,7 +491,7 @@ static int remove_marker(const char *channel, const char *name)
> return -ENOENT;
> if (e->single.func != __mark_empty_function)
> return -EBUSY;
> - hlist_del(&e->hlist);
> + cds_hlist_del(&e->hlist);
> if (e->format_allocated)
> free(e->format);
> ret = ltt_channels_unregister(e->channel);
> @@ -912,12 +913,12 @@ get_marker_from_private_data(marker_probe_func *probe, void *probe_private)
> {
> struct marker_entry *entry;
> unsigned int i;
> - struct hlist_head *head;
> - struct hlist_node *node;
> + struct cds_hlist_head *head;
> + struct cds_hlist_node *node;
>
> for (i = 0; i < MARKER_TABLE_SIZE; i++) {
> head = &marker_table[i];
> - hlist_for_each_entry(entry, node, head, hlist) {
> + cds_hlist_for_each_entry(entry, node, head, hlist) {
> if (!entry->ptype) {
> if (entry->single.func == probe
> && entry->single.probe_private
> @@ -1013,8 +1014,8 @@ end:
> void *marker_get_private_data(const char *channel, const char *name,
> marker_probe_func *probe, int num)
> {
> - struct hlist_head *head;
> - struct hlist_node *node;
> + struct cds_hlist_head *head;
> + struct cds_hlist_node *node;
> struct marker_entry *e;
> size_t channel_len = strlen(channel) + 1;
> size_t name_len = strlen(name) + 1;
> @@ -1023,7 +1024,7 @@ void *marker_get_private_data(const char *channel, const char *name,
>
> hash = jhash(channel, channel_len-1, 0) ^ jhash(name, name_len-1, 0);
> head = &marker_table[hash & ((1 << MARKER_HASH_BITS)-1)];
> - hlist_for_each_entry(e, node, head, hlist) {
> + cds_hlist_for_each_entry(e, node, head, hlist) {
> if (!strcmp(channel, e->channel) && !strcmp(name, e->name)) {
> if (!e->ptype) {
> if (num == 0 && e->single.func == probe)
> @@ -1178,14 +1179,14 @@ void marker_iter_reset(struct marker_iter *iter)
> /*
> * must be called with current->user_markers_mutex held
> */
> -static void free_user_marker(char __user *state, struct hlist_head *head)
> +static void free_user_marker(char __user *state, struct cds_hlist_head *head)
> {
> struct user_marker *umark;
> - struct hlist_node *pos, *n;
> + struct cds_hlist_node *pos, *n;
>
> - hlist_for_each_entry_safe(umark, pos, n, head, hlist) {
> + cds_hlist_for_each_entry_safe(umark, pos, n, head, hlist) {
> if (umark->state == state) {
> - hlist_del(&umark->hlist);
> + cds_hlist_del(&umark->hlist);
> free(umark);
> }
> }
> @@ -1243,12 +1244,12 @@ static void free_user_marker(char __user *state, struct hlist_head *head)
> void exit_user_markers(struct task_struct *p)
> {
> struct user_marker *umark;
> - struct hlist_node *pos, *n;
> + struct cds_hlist_node *pos, *n;
>
> if (thread_group_leader(p)) {
> pthread_mutex_lock(&markers_mutex);
> pthread_mutex_lock(&p->user_markers_mutex);
> - hlist_for_each_entry_safe(umark, pos, n, &p->user_markers,
> + cds_hlist_for_each_entry_safe(umark, pos, n, &p->user_markers,
> hlist)
> free(umark);
> INIT_HLIST_HEAD(&p->user_markers);
> @@ -1306,8 +1307,8 @@ void ltt_dump_marker_state(struct ust_trace *trace)
> {
> struct marker_entry *entry;
> struct ltt_probe_private_data call_data;
> - struct hlist_head *head;
> - struct hlist_node *node;
> + struct cds_hlist_head *head;
> + struct cds_hlist_node *node;
> unsigned int i;
>
> pthread_mutex_lock(&markers_mutex);
> @@ -1316,7 +1317,7 @@ void ltt_dump_marker_state(struct ust_trace *trace)
>
> for (i = 0; i < MARKER_TABLE_SIZE; i++) {
> head = &marker_table[i];
> - hlist_for_each_entry(entry, node, head, hlist) {
> + cds_hlist_for_each_entry(entry, node, head, hlist) {
> __trace_mark(0, metadata, core_marker_id,
> &call_data,
> "channel %s name %s event_id %hu "
> diff --git a/libust/tracepoint.c b/libust/tracepoint.c
> index dbaca6f..47d3785 100644
> --- a/libust/tracepoint.c
> +++ b/libust/tracepoint.c
> @@ -27,6 +27,7 @@
>
> #define _LGPL_SOURCE
> #include <urcu-bp.h>
> +#include <urcu/hlist.h>
>
> //extern struct tracepoint __start___tracepoints[] __attribute__((visibility("hidden")));
> //extern struct tracepoint __stop___tracepoints[] __attribute__((visibility("hidden")));
> @@ -49,7 +50,7 @@ static DEFINE_MUTEX(tracepoints_mutex);
> */
> #define TRACEPOINT_HASH_BITS 6
> #define TRACEPOINT_TABLE_SIZE (1 << TRACEPOINT_HASH_BITS)
> -static struct hlist_head tracepoint_table[TRACEPOINT_TABLE_SIZE];
> +static struct cds_hlist_head tracepoint_table[TRACEPOINT_TABLE_SIZE];
>
> /*
> * Note about RCU :
> @@ -58,7 +59,7 @@ static struct hlist_head tracepoint_table[TRACEPOINT_TABLE_SIZE];
> * Tracepoint entries modifications are protected by the tracepoints_mutex.
> */
> struct tracepoint_entry {
> - struct hlist_node hlist;
> + struct cds_hlist_node hlist;
> struct probe *probes;
> int refcount; /* Number of times armed. 0 if disarmed. */
> char name[0];
> @@ -192,13 +193,13 @@ tracepoint_entry_remove_probe(struct tracepoint_entry *entry, void *probe,
> */
> static struct tracepoint_entry *get_tracepoint(const char *name)
> {
> - struct hlist_head *head;
> - struct hlist_node *node;
> + struct cds_hlist_head *head;
> + struct cds_hlist_node *node;
> struct tracepoint_entry *e;
> u32 hash = jhash(name, strlen(name), 0);
>
> head = &tracepoint_table[hash & (TRACEPOINT_TABLE_SIZE - 1)];
> - hlist_for_each_entry(e, node, head, hlist) {
> + cds_hlist_for_each_entry(e, node, head, hlist) {
> if (!strcmp(name, e->name))
> return e;
> }
> @@ -211,14 +212,14 @@ static struct tracepoint_entry *get_tracepoint(const char *name)
> */
> static struct tracepoint_entry *add_tracepoint(const char *name)
> {
> - struct hlist_head *head;
> - struct hlist_node *node;
> + struct cds_hlist_head *head;
> + struct cds_hlist_node *node;
> struct tracepoint_entry *e;
> size_t name_len = strlen(name) + 1;
> u32 hash = jhash(name, name_len-1, 0);
>
> head = &tracepoint_table[hash & (TRACEPOINT_TABLE_SIZE - 1)];
> - hlist_for_each_entry(e, node, head, hlist) {
> + cds_hlist_for_each_entry(e, node, head, hlist) {
> if (!strcmp(name, e->name)) {
> DBG("tracepoint %s busy", name);
> return ERR_PTR(-EEXIST); /* Already there */
> @@ -234,7 +235,7 @@ static struct tracepoint_entry *add_tracepoint(const char *name)
> memcpy(&e->name[0], name, name_len);
> e->probes = NULL;
> e->refcount = 0;
> - hlist_add_head(&e->hlist, head);
> + cds_hlist_add_head(&e->hlist, head);
> return e;
> }
>
> @@ -244,7 +245,7 @@ static struct tracepoint_entry *add_tracepoint(const char *name)
> */
> static inline void remove_tracepoint(struct tracepoint_entry *e)
> {
> - hlist_del(&e->hlist);
> + cds_hlist_del(&e->hlist);
> free(e);
> }
>
> --
> 1.7.3.2
>
--
Mathieu Desnoyers
Operating System Efficiency R&D Consultant
EfficiOS Inc.
http://www.efficios.com
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2010-11-27 19:08 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-11-26 19:28 [ltt-dev] [UST PATCH 1/3] Remove hlist from kcompat's headers and code David Goulet
2010-11-26 19:28 ` [ltt-dev] [UST PATCH 2/3] Remove kref " David Goulet
2010-11-27 19:08 ` Mathieu Desnoyers
2010-11-26 19:28 ` [ltt-dev] [UST PATCH 3/3] Remove unuse header disable.h David Goulet
2010-11-27 19:08 ` Mathieu Desnoyers
2010-11-27 19:05 ` [ltt-dev] [UST PATCH 1/3] Remove hlist from kcompat's headers and code Mathieu Desnoyers
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox