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 \
#include <ust/kcompat/disable.h>
-#include <ust/kcompat/kref.h>
-
#endif /* KCOMPAT_H */
+++ /dev/null
-#ifndef _KCOMPAT_KREF_H
-#define _KCOMPAT_KREF_H
-
-/*
- * Kernel sourcecode compatible reference counting implementation
- *
- * Copyright (C) 2009 Novell Inc.
- *
- * Author: Jan Blunck <jblunck@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 */
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);
}
//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);
}
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)
*/
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)
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++) {
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;
}
}
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);
}
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);
}
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);
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);
}
{
int result;
- kref_init(<t_chan->kref);
+ urcu_ref_init(<t_chan->urcu_ref);
ltt_chan->trace = trace;
ltt_chan->overwrite = overwrite;
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);
}
/*
struct ust_channel *chan;
- struct kref kref;
+ struct urcu_ref urcu_ref;
void *buf_data;
size_t buf_size;
int shmid;
* 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;
*
* 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);
*
* 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);
}
/**
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;
}
}
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;
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;
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;
}
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;
}
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;
}
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) {
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;
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();
}
#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
*/
/* 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;
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 */
* 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);
* 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);
}
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();
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);
//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)
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;
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);