[ltt-dev] [PATCH 09/13] enable accessing struct ltt_channel_buf_struct
Lai Jiangshan
laijs at cn.fujitsu.com
Tue Jan 13 04:09:26 EST 2009
struct ltt_channel_buf_struct in ltt-relay.c and ltt-relay-locked.c
are different to each other, we implement access-ops for access them.
Signed-off-by: Lai Jiangshan <laijs at cn.fujitsu.com>
---
b/ltt/ltt-relay-locked.c | 18 ++++++++++++++++++
b/ltt/ltt-relay.c | 18 ++++++++++++++++++
include/linux/ltt-channels.h | 7 +++++++
3 files changed, 43 insertions(+)
diff --git a/include/linux/ltt-channels.h b/include/linux/ltt-channels.h
index 4a3924b..db513cb 100644
--- a/include/linux/ltt-channels.h
+++ b/include/linux/ltt-channels.h
@@ -45,11 +48,18 @@ struct ltt_channel_struct {
void (*buffer_end) (struct rchan_buf *buf,
u64 tsc, unsigned int offset, unsigned int subbuf_idx);
struct kref kref; /* Channel transport reference count */
+ struct ltt_channel_buf_access_ops *buf_access_ops;
unsigned int subbuf_size;
unsigned int subbuf_cnt;
const char *channel_name;
} ____cacheline_aligned;
+/* ops for accessing struct ltt_channel_struct.buf's data */
+struct ltt_channel_buf_access_ops {
+ unsigned long (*get_offset)(void *buf, int cpu);
+ unsigned long (*get_consumed)(void *buf, int cpu);
+};
+
struct ltt_channel_setting {
unsigned int subbuf_size;
unsigned int subbuf_cnt;
diff --git a/ltt/ltt-relay.c b/ltt/ltt-relay.c
index 6d222c6..806558f
--- a/ltt/ltt-relay.c
+++ b/ltt/ltt-relay.c
@@ -90,6 +90,24 @@ struct ltt_channel_buf_struct {
atomic_t wakeup_readers; /* Boolean : wakeup readers waiting ? */
} ____cacheline_aligned;
+static unsigned long get_offset(void *buf, int cpu)
+{
+ struct ltt_channel_buf_struct *ltt_buf = percpu_ptr(buf, cpu);
+ return local_read(<t_buf->offset);
+}
+
+static unsigned long get_consumed(void *buf, int cpu)
+{
+ struct ltt_channel_buf_struct *ltt_buf = percpu_ptr(buf, cpu);
+ return atomic_long_read(<t_buf->consumed);
+}
+
+static struct ltt_channel_buf_access_ops ltt_channel_buf_accesser =
+{
+ .get_offset = get_offset,
+ .get_consumed = get_consumed,
+};
+
/*
* Last TSC comparison functions. Check if the current TSC overflows
* LTT_TSC_BITS bits from the last TSC read. Reads and writes last_tsc
diff --git a/ltt/ltt-relay-locked.c b/ltt/ltt-relay-locked.c
index ef5f47c..a3c5bb9
--- a/ltt/ltt-relay-locked.c
+++ b/ltt/ltt-relay-locked.c
@@ -81,6 +81,24 @@ struct ltt_channel_buf_struct {
int wakeup_readers; /* Boolean : wakeup readers waiting ? */
} ____cacheline_aligned;
+static unsigned long get_offset(void *buf, int cpu)
+{
+ struct ltt_channel_buf_struct *ltt_buf = percpu_ptr(buf, cpu);
+ return ltt_buf->offset;
+}
+
+static unsigned long get_consumed(void *buf, int cpu)
+{
+ struct ltt_channel_buf_struct *ltt_buf = percpu_ptr(buf, cpu);
+ return ltt_buf->consumed;
+}
+
+static struct ltt_channel_buf_access_ops ltt_channel_buf_accesser =
+{
+ .get_offset = get_offset,
+ .get_consumed = get_consumed,
+};
+
/*
* Last TSC comparison functions. Check if the current TSC overflows
* LTT_TSC_BITS bits from the last TSC read. Reads and writes last_tsc
More information about the lttng-dev
mailing list