ust: continue work
[ust.git] / libtracing / relay.c
CommitLineData
bb07823d
PMF
1/*
2 * Public API and common code for kernel->userspace relay file support.
3 *
4 * Copyright (C) 2002-2005 - Tom Zanussi (zanussi@us.ibm.com), IBM Corp
5 * Copyright (C) 1999-2005 - Karim Yaghmour (karim@opersys.com)
6 * Copyright (C) 2008 - Mathieu Desnoyers (mathieu.desnoyers@polymtl.ca)
7 *
8 * Moved to kernel/relay.c by Paul Mundt, 2006.
9 * November 2006 - CPU hotplug support by Mathieu Desnoyers
10 * (mathieu.desnoyers@polymtl.ca)
11 *
12 * This file is released under the GPL.
13 */
14//ust// #include <linux/errno.h>
15//ust// #include <linux/stddef.h>
16//ust// #include <linux/slab.h>
17//ust// #include <linux/module.h>
18//ust// #include <linux/string.h>
19//ust// #include <linux/ltt-relay.h>
20//ust// #include <linux/vmalloc.h>
21//ust// #include <linux/mm.h>
22//ust// #include <linux/cpu.h>
23//ust// #include <linux/splice.h>
24//ust// #include <linux/bitops.h>
25#include <sys/mman.h>
26#include "kernelcompat.h"
27#include "list.h"
28#include "relay.h"
29#include "channels.h"
30#include "kref.h"
31#include "tracer.h"
32#include "tracercore.h"
33#include "usterr.h"
34
35/* list of open channels, for cpu hotplug */
36static DEFINE_MUTEX(relay_channels_mutex);
37static LIST_HEAD(relay_channels);
38
39/**
40 * relay_alloc_buf - allocate a channel buffer
41 * @buf: the buffer struct
42 * @size: total size of the buffer
43 */
44//ust// static int relay_alloc_buf(struct rchan_buf *buf, size_t *size)
45//ust//{
46//ust// unsigned int i, n_pages;
47//ust// struct buf_page *buf_page, *n;
48//ust//
49//ust// *size = PAGE_ALIGN(*size);
50//ust// n_pages = *size >> PAGE_SHIFT;
51//ust//
52//ust// INIT_LIST_HEAD(&buf->pages);
53//ust//
54//ust// for (i = 0; i < n_pages; i++) {
55//ust// buf_page = kmalloc_node(sizeof(*buf_page), GFP_KERNEL,
56//ust// cpu_to_node(buf->cpu));
57//ust// if (unlikely(!buf_page))
58//ust// goto depopulate;
59//ust// buf_page->page = alloc_pages_node(cpu_to_node(buf->cpu),
60//ust// GFP_KERNEL | __GFP_ZERO, 0);
61//ust// if (unlikely(!buf_page->page)) {
62//ust// kfree(buf_page);
63//ust// goto depopulate;
64//ust// }
65//ust// list_add_tail(&buf_page->list, &buf->pages);
66//ust// buf_page->offset = (size_t)i << PAGE_SHIFT;
67//ust// buf_page->buf = buf;
68//ust// set_page_private(buf_page->page, (unsigned long)buf_page);
69//ust// if (i == 0) {
70//ust// buf->wpage = buf_page;
71//ust// buf->hpage[0] = buf_page;
72//ust// buf->hpage[1] = buf_page;
73//ust// buf->rpage = buf_page;
74//ust// }
75//ust// }
76//ust// buf->page_count = n_pages;
77//ust// return 0;
78//ust//
79//ust//depopulate:
80//ust// list_for_each_entry_safe(buf_page, n, &buf->pages, list) {
81//ust// list_del_init(&buf_page->list);
82//ust// __free_page(buf_page->page);
83//ust// kfree(buf_page);
84//ust// }
85//ust// return -ENOMEM;
86//ust//}
87
88static int relay_alloc_buf(struct rchan_buf *buf, size_t *size)
89{
90 unsigned int n_pages;
91 struct buf_page *buf_page, *n;
92
93 void *result;
94
95 *size = PAGE_ALIGN(*size);
96
97 /* Maybe do read-ahead */
8d938dbd 98 result = mmap(NULL, *size, PROT_READ | PROT_WRITE, MAP_ANONYMOUS | MAP_PRIVATE, -1, 0);
bb07823d
PMF
99 if(result == MAP_FAILED) {
100 PERROR("mmap");
101 return -1;
102 }
103
104 buf->buf_data = result;
105 buf->buf_size = *size;
106
107 return 0;
108}
109
110/**
111 * relay_create_buf - allocate and initialize a channel buffer
112 * @chan: the relay channel
113 * @cpu: cpu the buffer belongs to
114 *
115 * Returns channel buffer if successful, %NULL otherwise.
116 */
117static struct rchan_buf *relay_create_buf(struct rchan *chan)
118{
119 int ret;
120 struct rchan_buf *buf = kzalloc(sizeof(struct rchan_buf), GFP_KERNEL);
121 if (!buf)
122 return NULL;
123
124// buf->cpu = cpu;
125 ret = relay_alloc_buf(buf, &chan->alloc_size);
126 if (ret)
127 goto free_buf;
128
129 buf->chan = chan;
130 kref_get(&buf->chan->kref);
131 return buf;
132
133free_buf:
134 kfree(buf);
135 return NULL;
136}
137
138/**
139 * relay_destroy_channel - free the channel struct
140 * @kref: target kernel reference that contains the relay channel
141 *
142 * Should only be called from kref_put().
143 */
144static void relay_destroy_channel(struct kref *kref)
145{
146 struct rchan *chan = container_of(kref, struct rchan, kref);
147 kfree(chan);
148}
149
150/**
151 * relay_destroy_buf - destroy an rchan_buf struct and associated buffer
152 * @buf: the buffer struct
153 */
154static void relay_destroy_buf(struct rchan_buf *buf)
155{
156 struct rchan *chan = buf->chan;
157 struct buf_page *buf_page, *n;
158 int result;
159
160 result = munmap(buf->buf_data, buf->buf_size);
161 if(result == -1) {
162 PERROR("munmap");
163 }
164
165//ust// chan->buf[buf->cpu] = NULL;
166 kfree(buf);
167 kref_put(&chan->kref, relay_destroy_channel);
168}
169
170/**
171 * relay_remove_buf - remove a channel buffer
172 * @kref: target kernel reference that contains the relay buffer
173 *
174 * Removes the file from the fileystem, which also frees the
175 * rchan_buf_struct and the channel buffer. Should only be called from
176 * kref_put().
177 */
178static void relay_remove_buf(struct kref *kref)
179{
180 struct rchan_buf *buf = container_of(kref, struct rchan_buf, kref);
181 buf->chan->cb->remove_buf_file(buf);
182 relay_destroy_buf(buf);
183}
184
185/*
186 * High-level relay kernel API and associated functions.
187 */
188
189/*
190 * rchan_callback implementations defining default channel behavior. Used
191 * in place of corresponding NULL values in client callback struct.
192 */
193
194/*
195 * create_buf_file_create() default callback. Does nothing.
196 */
197static struct dentry *create_buf_file_default_callback(const char *filename,
198 struct dentry *parent,
199 int mode,
200 struct rchan_buf *buf)
201{
202 return NULL;
203}
204
205/*
206 * remove_buf_file() default callback. Does nothing.
207 */
208static int remove_buf_file_default_callback(struct dentry *dentry)
209{
210 return -EINVAL;
211}
212
213/**
214 * wakeup_readers - wake up readers waiting on a channel
215 * @data: contains the channel buffer
216 *
217 * This is the timer function used to defer reader waking.
218 */
219//ust// static void wakeup_readers(unsigned long data)
220//ust// {
221//ust// struct rchan_buf *buf = (struct rchan_buf *)data;
222//ust// wake_up_interruptible(&buf->read_wait);
223//ust// }
224
225/**
226 * __relay_reset - reset a channel buffer
227 * @buf: the channel buffer
228 * @init: 1 if this is a first-time initialization
229 *
230 * See relay_reset() for description of effect.
231 */
232static void __relay_reset(struct rchan_buf *buf, unsigned int init)
233{
234 if (init) {
235//ust// init_waitqueue_head(&buf->read_wait);
236 kref_init(&buf->kref);
237//ust// setup_timer(&buf->timer, wakeup_readers, (unsigned long)buf);
238 } else
239//ust// del_timer_sync(&buf->timer);
240
241 buf->finalized = 0;
242}
243
244/*
245 * relay_open_buf - create a new relay channel buffer
246 *
247 * used by relay_open() and CPU hotplug.
248 */
249static struct rchan_buf *relay_open_buf(struct rchan *chan)
250{
251 struct rchan_buf *buf = NULL;
252 struct dentry *dentry;
253//ust// char *tmpname;
254
255//ust// tmpname = kzalloc(NAME_MAX + 1, GFP_KERNEL);
256//ust// if (!tmpname)
257//ust// goto end;
258//ust// snprintf(tmpname, NAME_MAX, "%s%d", chan->base_filename, cpu);
259
260 buf = relay_create_buf(chan);
261 if (!buf)
262 goto free_name;
263
264 __relay_reset(buf, 1);
265
266 /* Create file in fs */
267//ust// dentry = chan->cb->create_buf_file(tmpname, chan->parent, S_IRUSR,
268//ust// buf);
269//ust// if (!dentry)
270//ust// goto free_buf;
271//ust//
272//ust// buf->dentry = dentry;
273
274 goto free_name;
275
276free_buf:
277 relay_destroy_buf(buf);
278 buf = NULL;
279free_name:
280//ust// kfree(tmpname);
281end:
282 return buf;
283}
284
285/**
286 * relay_close_buf - close a channel buffer
287 * @buf: channel buffer
288 *
289 * Marks the buffer finalized and restores the default callbacks.
290 * The channel buffer and channel buffer data structure are then freed
291 * automatically when the last reference is given up.
292 */
293static void relay_close_buf(struct rchan_buf *buf)
294{
295//ust// del_timer_sync(&buf->timer);
296 kref_put(&buf->kref, relay_remove_buf);
297}
298
299//ust// static void setup_callbacks(struct rchan *chan,
300//ust// struct rchan_callbacks *cb)
301//ust// {
302//ust// if (!cb) {
303//ust// chan->cb = &default_channel_callbacks;
304//ust// return;
305//ust// }
306//ust//
307//ust// if (!cb->create_buf_file)
308//ust// cb->create_buf_file = create_buf_file_default_callback;
309//ust// if (!cb->remove_buf_file)
310//ust// cb->remove_buf_file = remove_buf_file_default_callback;
311//ust// chan->cb = cb;
312//ust// }
313
314/**
315 * relay_hotcpu_callback - CPU hotplug callback
316 * @nb: notifier block
317 * @action: hotplug action to take
318 * @hcpu: CPU number
319 *
320 * Returns the success/failure of the operation. (%NOTIFY_OK, %NOTIFY_BAD)
321 */
322//ust// static int __cpuinit relay_hotcpu_callback(struct notifier_block *nb,
323//ust// unsigned long action,
324//ust// void *hcpu)
325//ust// {
326//ust// unsigned int hotcpu = (unsigned long)hcpu;
327//ust// struct rchan *chan;
328//ust//
329//ust// switch (action) {
330//ust// case CPU_UP_PREPARE:
331//ust// case CPU_UP_PREPARE_FROZEN:
332//ust// mutex_lock(&relay_channels_mutex);
333//ust// list_for_each_entry(chan, &relay_channels, list) {
334//ust// if (chan->buf[hotcpu])
335//ust// continue;
336//ust// chan->buf[hotcpu] = relay_open_buf(chan, hotcpu);
337//ust// if (!chan->buf[hotcpu]) {
338//ust// printk(KERN_ERR
339//ust// "relay_hotcpu_callback: cpu %d buffer "
340//ust// "creation failed\n", hotcpu);
341//ust// mutex_unlock(&relay_channels_mutex);
342//ust// return NOTIFY_BAD;
343//ust// }
344//ust// }
345//ust// mutex_unlock(&relay_channels_mutex);
346//ust// break;
347//ust// case CPU_DEAD:
348//ust// case CPU_DEAD_FROZEN:
349//ust// /* No need to flush the cpu : will be flushed upon
350//ust// * final relay_flush() call. */
351//ust// break;
352//ust// }
353//ust// return NOTIFY_OK;
354//ust// }
355
356/**
357 * ltt_relay_open - create a new relay channel
358 * @base_filename: base name of files to create
359 * @parent: dentry of parent directory, %NULL for root directory
360 * @subbuf_size: size of sub-buffers
361 * @n_subbufs: number of sub-buffers
362 * @cb: client callback functions
363 * @private_data: user-defined data
364 *
365 * Returns channel pointer if successful, %NULL otherwise.
366 *
367 * Creates a channel buffer for each cpu using the sizes and
368 * attributes specified. The created channel buffer files
369 * will be named base_filename0...base_filenameN-1. File
370 * permissions will be %S_IRUSR.
371 */
372struct rchan *ltt_relay_open(const char *base_filename,
373 struct dentry *parent,
374 size_t subbuf_size,
375 size_t n_subbufs,
376 void *private_data)
377{
378 unsigned int i;
379 struct rchan *chan;
380//ust// if (!base_filename)
381//ust// return NULL;
382
383 if (!(subbuf_size && n_subbufs))
384 return NULL;
385
386 chan = kzalloc(sizeof(struct rchan), GFP_KERNEL);
387 if (!chan)
388 return NULL;
389
390 chan->version = LTT_RELAY_CHANNEL_VERSION;
391 chan->n_subbufs = n_subbufs;
392 chan->subbuf_size = subbuf_size;
393 chan->subbuf_size_order = get_count_order(subbuf_size);
394 chan->alloc_size = FIX_SIZE(subbuf_size * n_subbufs);
395 chan->parent = parent;
396 chan->private_data = private_data;
397//ust// strlcpy(chan->base_filename, base_filename, NAME_MAX);
398//ust// setup_callbacks(chan, cb);
399 kref_init(&chan->kref);
400
401 mutex_lock(&relay_channels_mutex);
402//ust// for_each_online_cpu(i) {
403 chan->buf = relay_open_buf(chan);
404 if (!chan->buf)
405 goto error;
406//ust// }
407 list_add(&chan->list, &relay_channels);
408 mutex_unlock(&relay_channels_mutex);
409
410 return chan;
411
412//ust//free_bufs:
413//ust// for_each_possible_cpu(i) {
414//ust// if (!chan->buf[i])
415//ust// break;
416//ust// relay_close_buf(chan->buf[i]);
417//ust// }
418
419 error:
420 kref_put(&chan->kref, relay_destroy_channel);
421 mutex_unlock(&relay_channels_mutex);
422 return NULL;
423}
424//ust// EXPORT_SYMBOL_GPL(ltt_relay_open);
425
426/**
427 * ltt_relay_close - close the channel
428 * @chan: the channel
429 *
430 * Closes all channel buffers and frees the channel.
431 */
432void ltt_relay_close(struct rchan *chan)
433{
434 unsigned int i;
435
436 if (!chan)
437 return;
438
439 mutex_lock(&relay_channels_mutex);
440//ust// for_each_possible_cpu(i)
441 if (chan->buf)
442 relay_close_buf(chan->buf);
443
444 list_del(&chan->list);
445 kref_put(&chan->kref, relay_destroy_channel);
446 mutex_unlock(&relay_channels_mutex);
447}
448//ust// EXPORT_SYMBOL_GPL(ltt_relay_close);
449
450/*
451 * Start iteration at the previous element. Skip the real list head.
452 */
453//ust// struct buf_page *ltt_relay_find_prev_page(struct rchan_buf *buf,
454//ust// struct buf_page *page, size_t offset, ssize_t diff_offset)
455//ust// {
456//ust// struct buf_page *iter;
457//ust// size_t orig_iter_off;
458//ust// unsigned int i = 0;
459//ust//
460//ust// orig_iter_off = page->offset;
461//ust// list_for_each_entry_reverse(iter, &page->list, list) {
462//ust// /*
463//ust// * Skip the real list head.
464//ust// */
465//ust// if (&iter->list == &buf->pages)
466//ust// continue;
467//ust// i++;
468//ust// if (offset >= iter->offset
469//ust// && offset < iter->offset + PAGE_SIZE) {
470//ust// #ifdef CONFIG_LTT_RELAY_CHECK_RANDOM_ACCESS
471//ust// if (i > 1) {
472//ust// printk(KERN_WARNING
473//ust// "Backward random access detected in "
474//ust// "ltt_relay. Iterations %u, "
475//ust// "offset %zu, orig iter->off %zu, "
476//ust// "iter->off %zu diff_offset %zd.\n", i,
477//ust// offset, orig_iter_off, iter->offset,
478//ust// diff_offset);
479//ust// WARN_ON(1);
480//ust// }
481//ust// #endif
482//ust// return iter;
483//ust// }
484//ust// }
485//ust// WARN_ON(1);
486//ust// return NULL;
487//ust// }
488//ust// EXPORT_SYMBOL_GPL(ltt_relay_find_prev_page);
489
490/*
491 * Start iteration at the next element. Skip the real list head.
492 */
493//ust// struct buf_page *ltt_relay_find_next_page(struct rchan_buf *buf,
494//ust// struct buf_page *page, size_t offset, ssize_t diff_offset)
495//ust// {
496//ust// struct buf_page *iter;
497//ust// unsigned int i = 0;
498//ust// size_t orig_iter_off;
499//ust//
500//ust// orig_iter_off = page->offset;
501//ust// list_for_each_entry(iter, &page->list, list) {
502//ust// /*
503//ust// * Skip the real list head.
504//ust// */
505//ust// if (&iter->list == &buf->pages)
506//ust// continue;
507//ust// i++;
508//ust// if (offset >= iter->offset
509//ust// && offset < iter->offset + PAGE_SIZE) {
510//ust// #ifdef CONFIG_LTT_RELAY_CHECK_RANDOM_ACCESS
511//ust// if (i > 1) {
512//ust// printk(KERN_WARNING
513//ust// "Forward random access detected in "
514//ust// "ltt_relay. Iterations %u, "
515//ust// "offset %zu, orig iter->off %zu, "
516//ust// "iter->off %zu diff_offset %zd.\n", i,
517//ust// offset, orig_iter_off, iter->offset,
518//ust// diff_offset);
519//ust// WARN_ON(1);
520//ust// }
521//ust// #endif
522//ust// return iter;
523//ust// }
524//ust// }
525//ust// WARN_ON(1);
526//ust// return NULL;
527//ust// }
528//ust// EXPORT_SYMBOL_GPL(ltt_relay_find_next_page);
529
530/**
531 * ltt_relay_write - write data to a ltt_relay buffer.
532 * @buf : buffer
533 * @offset : offset within the buffer
534 * @src : source address
535 * @len : length to write
536 * @page : cached buffer page
537 * @pagecpy : page size copied so far
538 */
539void _ltt_relay_write(struct rchan_buf *buf, size_t offset,
540 const void *src, size_t len, ssize_t cpy)
541{
542 do {
543 len -= cpy;
544 src += cpy;
545 offset += cpy;
546 /*
547 * Underlying layer should never ask for writes across
548 * subbuffers.
549 */
550 WARN_ON(offset >= buf->buf_size);
551
552 cpy = min_t(size_t, len, buf->buf_size - offset);
553 ltt_relay_do_copy(buf->buf_data + offset, src, cpy);
554 } while (unlikely(len != cpy));
555}
556//ust// EXPORT_SYMBOL_GPL(_ltt_relay_write);
557
558/**
559 * ltt_relay_read - read data from ltt_relay_buffer.
560 * @buf : buffer
561 * @offset : offset within the buffer
562 * @dest : destination address
563 * @len : length to write
564 */
565//ust// int ltt_relay_read(struct rchan_buf *buf, size_t offset,
566//ust// void *dest, size_t len)
567//ust// {
568//ust// struct buf_page *page;
569//ust// ssize_t pagecpy, orig_len;
570//ust//
571//ust// orig_len = len;
572//ust// offset &= buf->chan->alloc_size - 1;
573//ust// page = buf->rpage;
574//ust// if (unlikely(!len))
575//ust// return 0;
576//ust// for (;;) {
577//ust// page = ltt_relay_cache_page(buf, &buf->rpage, page, offset);
578//ust// pagecpy = min_t(size_t, len, PAGE_SIZE - (offset & ~PAGE_MASK));
579//ust// memcpy(dest, page_address(page->page) + (offset & ~PAGE_MASK),
580//ust// pagecpy);
581//ust// len -= pagecpy;
582//ust// if (likely(!len))
583//ust// break;
584//ust// dest += pagecpy;
585//ust// offset += pagecpy;
586//ust// /*
587//ust// * Underlying layer should never ask for reads across
588//ust// * subbuffers.
589//ust// */
590//ust// WARN_ON(offset >= buf->chan->alloc_size);
591//ust// }
592//ust// return orig_len;
593//ust// }
594//ust// EXPORT_SYMBOL_GPL(ltt_relay_read);
595
596/**
597 * ltt_relay_read_get_page - Get a whole page to read from
598 * @buf : buffer
599 * @offset : offset within the buffer
600 */
601//ust// struct buf_page *ltt_relay_read_get_page(struct rchan_buf *buf, size_t offset)
602//ust// {
603//ust// struct buf_page *page;
604
605//ust// offset &= buf->chan->alloc_size - 1;
606//ust// page = buf->rpage;
607//ust// page = ltt_relay_cache_page(buf, &buf->rpage, page, offset);
608//ust// return page;
609//ust// }
610//ust// EXPORT_SYMBOL_GPL(ltt_relay_read_get_page);
611
612/**
613 * ltt_relay_offset_address - get address of a location within the buffer
614 * @buf : buffer
615 * @offset : offset within the buffer.
616 *
617 * Return the address where a given offset is located.
618 * Should be used to get the current subbuffer header pointer. Given we know
619 * it's never on a page boundary, it's safe to write directly to this address,
620 * as long as the write is never bigger than a page size.
621 */
622void *ltt_relay_offset_address(struct rchan_buf *buf, size_t offset)
623{
624//ust// struct buf_page *page;
625//ust// unsigned int odd;
626//ust//
627//ust// offset &= buf->chan->alloc_size - 1;
628//ust// odd = !!(offset & buf->chan->subbuf_size);
629//ust// page = buf->hpage[odd];
630//ust// if (offset < page->offset || offset >= page->offset + PAGE_SIZE)
631//ust// buf->hpage[odd] = page = buf->wpage;
632//ust// page = ltt_relay_cache_page(buf, &buf->hpage[odd], page, offset);
633//ust// return page_address(page->page) + (offset & ~PAGE_MASK);
634 return NULL;
635}
636//ust// EXPORT_SYMBOL_GPL(ltt_relay_offset_address);
637
638/**
639 * relay_file_open - open file op for relay files
640 * @inode: the inode
641 * @filp: the file
642 *
643 * Increments the channel buffer refcount.
644 */
645//ust// static int relay_file_open(struct inode *inode, struct file *filp)
646//ust// {
647//ust// struct rchan_buf *buf = inode->i_private;
648//ust// kref_get(&buf->kref);
649//ust// filp->private_data = buf;
650//ust//
651//ust// return nonseekable_open(inode, filp);
652//ust// }
653
654/**
655 * relay_file_release - release file op for relay files
656 * @inode: the inode
657 * @filp: the file
658 *
659 * Decrements the channel refcount, as the filesystem is
660 * no longer using it.
661 */
662//ust// static int relay_file_release(struct inode *inode, struct file *filp)
663//ust// {
664//ust// struct rchan_buf *buf = filp->private_data;
665//ust// kref_put(&buf->kref, relay_remove_buf);
666//ust//
667//ust// return 0;
668//ust// }
669
670//ust// const struct file_operations ltt_relay_file_operations = {
671//ust// .open = relay_file_open,
672//ust// .release = relay_file_release,
673//ust// };
674//ust// EXPORT_SYMBOL_GPL(ltt_relay_file_operations);
675
676//ust// static __init int relay_init(void)
677//ust// {
678//ust// hotcpu_notifier(relay_hotcpu_callback, 5);
679//ust// return 0;
680//ust// }
681
682//ust// module_init(relay_init);
e1152c37
PMF
683/*
684 * ltt/ltt-relay.c
685 *
686 * (C) Copyright 2005-2008 - Mathieu Desnoyers (mathieu.desnoyers@polymtl.ca)
687 *
688 * LTTng lockless buffer space management (reader/writer).
689 *
690 * Author:
691 * Mathieu Desnoyers (mathieu.desnoyers@polymtl.ca)
692 *
693 * Inspired from LTT :
694 * Karim Yaghmour (karim@opersys.com)
695 * Tom Zanussi (zanussi@us.ibm.com)
696 * Bob Wisniewski (bob@watson.ibm.com)
697 * And from K42 :
698 * Bob Wisniewski (bob@watson.ibm.com)
699 *
700 * Changelog:
701 * 08/10/08, Cleanup.
702 * 19/10/05, Complete lockless mechanism.
703 * 27/05/05, Modular redesign and rewrite.
704 *
705 * Userspace reader semantic :
706 * while (poll fd != POLLHUP) {
707 * - ioctl RELAY_GET_SUBBUF_SIZE
708 * while (1) {
709 * - ioctl GET_SUBBUF
710 * - splice 1 subbuffer worth of data to a pipe
711 * - splice the data from pipe to disk/network
712 * - ioctl PUT_SUBBUF, check error value
713 * if err val < 0, previous subbuffer was corrupted.
714 * }
715 * }
716 */
717
bb07823d
PMF
718//ust// #include <linux/time.h>
719//ust// #include <linux/ltt-tracer.h>
720//ust// #include <linux/ltt-relay.h>
721//ust// #include <linux/module.h>
722//ust// #include <linux/string.h>
723//ust// #include <linux/slab.h>
724//ust// #include <linux/init.h>
725//ust// #include <linux/rcupdate.h>
726//ust// #include <linux/sched.h>
727//ust// #include <linux/bitops.h>
728//ust// #include <linux/fs.h>
729//ust// #include <linux/smp_lock.h>
730//ust// #include <linux/debugfs.h>
731//ust// #include <linux/stat.h>
732//ust// #include <linux/cpu.h>
733//ust// #include <linux/pipe_fs_i.h>
734//ust// #include <linux/splice.h>
735//ust// #include <asm/atomic.h>
736//ust// #include <asm/local.h>
e1152c37
PMF
737
738#if 0
739#define printk_dbg(fmt, args...) printk(fmt, args)
740#else
741#define printk_dbg(fmt, args...)
742#endif
743
744/* LTTng lockless logging buffer info */
745struct ltt_channel_buf_struct {
746 /* First 32 bytes cache-hot cacheline */
747 local_t offset; /* Current offset in the buffer */
748 local_t *commit_count; /* Commit count per sub-buffer */
749 atomic_long_t consumed; /*
750 * Current offset in the buffer
751 * standard atomic access (shared)
752 */
753 unsigned long last_tsc; /*
754 * Last timestamp written in the buffer.
755 */
756 /* End of first 32 bytes cacheline */
757 atomic_long_t active_readers; /*
758 * Active readers count
759 * standard atomic access (shared)
760 */
761 local_t events_lost;
762 local_t corrupted_subbuffers;
763 spinlock_t full_lock; /*
764 * buffer full condition spinlock, only
765 * for userspace tracing blocking mode
766 * synchronization with reader.
767 */
bb07823d
PMF
768//ust// wait_queue_head_t write_wait; /*
769//ust// * Wait queue for blocking user space
770//ust// * writers
771//ust// */
e1152c37
PMF
772 atomic_t wakeup_readers; /* Boolean : wakeup readers waiting ? */
773} ____cacheline_aligned;
774
775/*
776 * Last TSC comparison functions. Check if the current TSC overflows
777 * LTT_TSC_BITS bits from the last TSC read. Reads and writes last_tsc
778 * atomically.
779 */
780
781#if (BITS_PER_LONG == 32)
782static inline void save_last_tsc(struct ltt_channel_buf_struct *ltt_buf,
783 u64 tsc)
784{
785 ltt_buf->last_tsc = (unsigned long)(tsc >> LTT_TSC_BITS);
786}
787
788static inline int last_tsc_overflow(struct ltt_channel_buf_struct *ltt_buf,
789 u64 tsc)
790{
791 unsigned long tsc_shifted = (unsigned long)(tsc >> LTT_TSC_BITS);
792
793 if (unlikely((tsc_shifted - ltt_buf->last_tsc)))
794 return 1;
795 else
796 return 0;
797}
798#else
799static inline void save_last_tsc(struct ltt_channel_buf_struct *ltt_buf,
800 u64 tsc)
801{
802 ltt_buf->last_tsc = (unsigned long)tsc;
803}
804
805static inline int last_tsc_overflow(struct ltt_channel_buf_struct *ltt_buf,
806 u64 tsc)
807{
808 if (unlikely((tsc - ltt_buf->last_tsc) >> LTT_TSC_BITS))
809 return 1;
810 else
811 return 0;
812}
813#endif
814
5f54827b 815//ust// static struct file_operations ltt_file_operations;
e1152c37
PMF
816
817/*
818 * A switch is done during tracing or as a final flush after tracing (so it
819 * won't write in the new sub-buffer).
820 */
821enum force_switch_mode { FORCE_ACTIVE, FORCE_FLUSH };
822
823static int ltt_relay_create_buffer(struct ltt_trace_struct *trace,
824 struct ltt_channel_struct *ltt_chan,
825 struct rchan_buf *buf,
e1152c37
PMF
826 unsigned int n_subbufs);
827
bb07823d 828static void ltt_relay_destroy_buffer(struct ltt_channel_struct *ltt_chan);
e1152c37
PMF
829
830static void ltt_force_switch(struct rchan_buf *buf,
831 enum force_switch_mode mode);
832
833/*
834 * Trace callbacks
835 */
836static void ltt_buffer_begin_callback(struct rchan_buf *buf,
837 u64 tsc, unsigned int subbuf_idx)
838{
839 struct ltt_channel_struct *channel =
840 (struct ltt_channel_struct *)buf->chan->private_data;
841 struct ltt_subbuffer_header *header =
842 (struct ltt_subbuffer_header *)
843 ltt_relay_offset_address(buf,
844 subbuf_idx * buf->chan->subbuf_size);
845
846 header->cycle_count_begin = tsc;
847 header->lost_size = 0xFFFFFFFF; /* for debugging */
848 header->buf_size = buf->chan->subbuf_size;
849 ltt_write_trace_header(channel->trace, header);
850}
851
852/*
853 * offset is assumed to never be 0 here : never deliver a completely empty
854 * subbuffer. The lost size is between 0 and subbuf_size-1.
855 */
856static notrace void ltt_buffer_end_callback(struct rchan_buf *buf,
857 u64 tsc, unsigned int offset, unsigned int subbuf_idx)
858{
859 struct ltt_channel_struct *channel =
860 (struct ltt_channel_struct *)buf->chan->private_data;
bb07823d 861 struct ltt_channel_buf_struct *ltt_buf = channel->buf;
e1152c37
PMF
862 struct ltt_subbuffer_header *header =
863 (struct ltt_subbuffer_header *)
864 ltt_relay_offset_address(buf,
865 subbuf_idx * buf->chan->subbuf_size);
866
867 header->lost_size = SUBBUF_OFFSET((buf->chan->subbuf_size - offset),
868 buf->chan);
869 header->cycle_count_end = tsc;
bb07823d
PMF
870 header->events_lost = ltt_buf->events_lost;
871 header->subbuf_corrupt = ltt_buf->corrupted_subbuffers;
e1152c37
PMF
872}
873
874static notrace void ltt_deliver(struct rchan_buf *buf, unsigned int subbuf_idx,
875 void *subbuf)
876{
877 struct ltt_channel_struct *channel =
878 (struct ltt_channel_struct *)buf->chan->private_data;
bb07823d 879 struct ltt_channel_buf_struct *ltt_buf = channel->buf;
e1152c37
PMF
880
881 atomic_set(&ltt_buf->wakeup_readers, 1);
882}
883
884static struct dentry *ltt_create_buf_file_callback(const char *filename,
885 struct dentry *parent, int mode,
886 struct rchan_buf *buf)
887{
888 struct ltt_channel_struct *ltt_chan;
889 int err;
5f54827b 890//ust// struct dentry *dentry;
e1152c37
PMF
891
892 ltt_chan = buf->chan->private_data;
bb07823d 893 err = ltt_relay_create_buffer(ltt_chan->trace, ltt_chan, buf, buf->chan->n_subbufs);
e1152c37
PMF
894 if (err)
895 return ERR_PTR(err);
896
5f54827b
PMF
897//ust// dentry = debugfs_create_file(filename, mode, parent, buf,
898//ust// &ltt_file_operations);
899//ust// if (!dentry)
900//ust// goto error;
901//ust// return dentry;
902//ust//error:
bb07823d 903 ltt_relay_destroy_buffer(ltt_chan);
e1152c37
PMF
904 return NULL;
905}
906
bb07823d 907static int ltt_remove_buf_file_callback(struct rchan_buf *buf)
e1152c37 908{
bb07823d 909//ust// struct rchan_buf *buf = dentry->d_inode->i_private;
e1152c37
PMF
910 struct ltt_channel_struct *ltt_chan = buf->chan->private_data;
911
5f54827b 912//ust// debugfs_remove(dentry);
bb07823d 913 ltt_relay_destroy_buffer(ltt_chan);
e1152c37
PMF
914
915 return 0;
916}
917
918/*
919 * Wake writers :
920 *
921 * This must be done after the trace is removed from the RCU list so that there
922 * are no stalled writers.
923 */
bb07823d
PMF
924//ust// static void ltt_relay_wake_writers(struct ltt_channel_buf_struct *ltt_buf)
925//ust// {
926//ust//
927//ust// if (waitqueue_active(&ltt_buf->write_wait))
928//ust// wake_up_interruptible(&ltt_buf->write_wait);
929//ust// }
e1152c37
PMF
930
931/*
932 * This function should not be called from NMI interrupt context
933 */
934static notrace void ltt_buf_unfull(struct rchan_buf *buf,
935 unsigned int subbuf_idx,
936 long offset)
937{
bb07823d
PMF
938//ust// struct ltt_channel_struct *ltt_channel =
939//ust// (struct ltt_channel_struct *)buf->chan->private_data;
940//ust// struct ltt_channel_buf_struct *ltt_buf = ltt_channel->buf;
941//ust//
942//ust// ltt_relay_wake_writers(ltt_buf);
e1152c37
PMF
943}
944
945/**
946 * ltt_open - open file op for ltt files
947 * @inode: opened inode
948 * @file: opened file
949 *
950 * Open implementation. Makes sure only one open instance of a buffer is
951 * done at a given moment.
952 */
bb07823d
PMF
953//ust// static int ltt_open(struct inode *inode, struct file *file)
954//ust// {
955//ust// struct rchan_buf *buf = inode->i_private;
956//ust// struct ltt_channel_struct *ltt_channel =
957//ust// (struct ltt_channel_struct *)buf->chan->private_data;
958//ust// struct ltt_channel_buf_struct *ltt_buf =
959//ust// percpu_ptr(ltt_channel->buf, buf->cpu);
960//ust//
961//ust// if (!atomic_long_add_unless(&ltt_buf->active_readers, 1, 1))
962//ust// return -EBUSY;
963//ust// return ltt_relay_file_operations.open(inode, file);
964//ust// }
e1152c37
PMF
965
966/**
967 * ltt_release - release file op for ltt files
968 * @inode: opened inode
969 * @file: opened file
970 *
971 * Release implementation.
972 */
bb07823d
PMF
973//ust// static int ltt_release(struct inode *inode, struct file *file)
974//ust// {
975//ust// struct rchan_buf *buf = inode->i_private;
976//ust// struct ltt_channel_struct *ltt_channel =
977//ust// (struct ltt_channel_struct *)buf->chan->private_data;
978//ust// struct ltt_channel_buf_struct *ltt_buf =
979//ust// percpu_ptr(ltt_channel->buf, buf->cpu);
980//ust// int ret;
981//ust//
982//ust// WARN_ON(atomic_long_read(&ltt_buf->active_readers) != 1);
983//ust// atomic_long_dec(&ltt_buf->active_readers);
984//ust// ret = ltt_relay_file_operations.release(inode, file);
985//ust// WARN_ON(ret);
986//ust// return ret;
987//ust// }
e1152c37
PMF
988
989/**
990 * ltt_poll - file op for ltt files
991 * @filp: the file
992 * @wait: poll table
993 *
994 * Poll implementation.
995 */
bb07823d
PMF
996//ust// static unsigned int ltt_poll(struct file *filp, poll_table *wait)
997//ust// {
998//ust// unsigned int mask = 0;
999//ust// struct inode *inode = filp->f_dentry->d_inode;
1000//ust// struct rchan_buf *buf = inode->i_private;
1001//ust// struct ltt_channel_struct *ltt_channel =
1002//ust// (struct ltt_channel_struct *)buf->chan->private_data;
1003//ust// struct ltt_channel_buf_struct *ltt_buf =
1004//ust// percpu_ptr(ltt_channel->buf, buf->cpu);
1005//ust//
1006//ust// if (filp->f_mode & FMODE_READ) {
1007//ust// poll_wait_set_exclusive(wait);
1008//ust// poll_wait(filp, &buf->read_wait, wait);
1009//ust//
1010//ust// WARN_ON(atomic_long_read(&ltt_buf->active_readers) != 1);
1011//ust// if (SUBBUF_TRUNC(local_read(&ltt_buf->offset),
1012//ust// buf->chan)
1013//ust// - SUBBUF_TRUNC(atomic_long_read(&ltt_buf->consumed),
1014//ust// buf->chan)
1015//ust// == 0) {
1016//ust// if (buf->finalized)
1017//ust// return POLLHUP;
1018//ust// else
1019//ust// return 0;
1020//ust// } else {
1021//ust// struct rchan *rchan =
1022//ust// ltt_channel->trans_channel_data;
1023//ust// if (SUBBUF_TRUNC(local_read(&ltt_buf->offset),
1024//ust// buf->chan)
1025//ust// - SUBBUF_TRUNC(atomic_long_read(
1026//ust// &ltt_buf->consumed),
1027//ust// buf->chan)
1028//ust// >= rchan->alloc_size)
1029//ust// return POLLPRI | POLLRDBAND;
1030//ust// else
1031//ust// return POLLIN | POLLRDNORM;
1032//ust// }
1033//ust// }
1034//ust// return mask;
1035//ust// }
e1152c37
PMF
1036
1037static int ltt_do_get_subbuf(struct rchan_buf *buf, struct ltt_channel_buf_struct *ltt_buf, long *pconsumed_old)
1038{
bb07823d 1039 struct ltt_channel_struct *ltt_channel = (struct ltt_channel_struct *)buf->chan->private_data;
e1152c37
PMF
1040 long consumed_old, consumed_idx, commit_count, write_offset;
1041 consumed_old = atomic_long_read(&ltt_buf->consumed);
1042 consumed_idx = SUBBUF_INDEX(consumed_old, buf->chan);
1043 commit_count = local_read(&ltt_buf->commit_count[consumed_idx]);
1044 /*
1045 * Make sure we read the commit count before reading the buffer
1046 * data and the write offset. Correct consumed offset ordering
1047 * wrt commit count is insured by the use of cmpxchg to update
1048 * the consumed offset.
1049 */
1050 smp_rmb();
1051 write_offset = local_read(&ltt_buf->offset);
1052 /*
1053 * Check that the subbuffer we are trying to consume has been
1054 * already fully committed.
1055 */
1056 if (((commit_count - buf->chan->subbuf_size)
1057 & ltt_channel->commit_count_mask)
1058 - (BUFFER_TRUNC(consumed_old, buf->chan)
1059 >> ltt_channel->n_subbufs_order)
1060 != 0) {
1061 return -EAGAIN;
1062 }
1063 /*
1064 * Check that we are not about to read the same subbuffer in
1065 * which the writer head is.
1066 */
1067 if ((SUBBUF_TRUNC(write_offset, buf->chan)
1068 - SUBBUF_TRUNC(consumed_old, buf->chan))
1069 == 0) {
1070 return -EAGAIN;
1071 }
1072
1073 *pconsumed_old = consumed_old;
1074 return 0;
1075}
1076
1077static int ltt_do_put_subbuf(struct rchan_buf *buf, struct ltt_channel_buf_struct *ltt_buf, u32 uconsumed_old)
1078{
1079 long consumed_new, consumed_old;
1080
1081 consumed_old = atomic_long_read(&ltt_buf->consumed);
1082 consumed_old = consumed_old & (~0xFFFFFFFFL);
1083 consumed_old = consumed_old | uconsumed_old;
1084 consumed_new = SUBBUF_ALIGN(consumed_old, buf->chan);
1085
1086 spin_lock(&ltt_buf->full_lock);
1087 if (atomic_long_cmpxchg(&ltt_buf->consumed, consumed_old,
1088 consumed_new)
1089 != consumed_old) {
1090 /* We have been pushed by the writer : the last
1091 * buffer read _is_ corrupted! It can also
1092 * happen if this is a buffer we never got. */
1093 spin_unlock(&ltt_buf->full_lock);
1094 return -EIO;
1095 } else {
1096 /* tell the client that buffer is now unfull */
1097 int index;
1098 long data;
1099 index = SUBBUF_INDEX(consumed_old, buf->chan);
1100 data = BUFFER_OFFSET(consumed_old, buf->chan);
1101 ltt_buf_unfull(buf, index, data);
1102 spin_unlock(&ltt_buf->full_lock);
1103 }
1104 return 0;
1105}
1106
1107/**
1108 * ltt_ioctl - control on the debugfs file
1109 *
1110 * @inode: the inode
1111 * @filp: the file
1112 * @cmd: the command
1113 * @arg: command arg
1114 *
1115 * This ioctl implements three commands necessary for a minimal
1116 * producer/consumer implementation :
1117 * RELAY_GET_SUBBUF
1118 * Get the next sub buffer that can be read. It never blocks.
1119 * RELAY_PUT_SUBBUF
1120 * Release the currently read sub-buffer. Parameter is the last
1121 * put subbuffer (returned by GET_SUBBUF).
1122 * RELAY_GET_N_BUBBUFS
1123 * returns the number of sub buffers in the per cpu channel.
1124 * RELAY_GET_SUBBUF_SIZE
1125 * returns the size of the sub buffers.
1126 */
5f54827b
PMF
1127//ust// static int ltt_ioctl(struct inode *inode, struct file *filp,
1128//ust// unsigned int cmd, unsigned long arg)
1129//ust// {
1130//ust// struct rchan_buf *buf = inode->i_private;
1131//ust// struct ltt_channel_struct *ltt_channel =
1132//ust// (struct ltt_channel_struct *)buf->chan->private_data;
1133//ust// struct ltt_channel_buf_struct *ltt_buf =
1134//ust// percpu_ptr(ltt_channel->buf, buf->cpu);
1135//ust// u32 __user *argp = (u32 __user *)arg;
1136//ust//
1137//ust// WARN_ON(atomic_long_read(&ltt_buf->active_readers) != 1);
1138//ust// switch (cmd) {
1139//ust// case RELAY_GET_SUBBUF:
1140//ust// {
1141//ust// int ret;
1142//ust// ret = ltt_do_get_subbuf(buf, ltt_buf, &consumed_old);
1143//ust// if(ret < 0)
1144//ust// return ret;
1145//ust// return put_user((u32)consumed_old, argp);
1146//ust// }
1147//ust// case RELAY_PUT_SUBBUF:
1148//ust// {
1149//ust// int ret;
1150//ust// u32 uconsumed_old;
1151//ust// ret = get_user(uconsumed_old, argp);
1152//ust// if (ret)
1153//ust// return ret; /* will return -EFAULT */
1154//ust// return ltt_do_put_subbuf(buf, ltt_buf, uconsumed_old);
1155//ust// }
1156//ust// case RELAY_GET_N_SUBBUFS:
1157//ust// return put_user((u32)buf->chan->n_subbufs, argp);
1158//ust// break;
1159//ust// case RELAY_GET_SUBBUF_SIZE:
1160//ust// return put_user((u32)buf->chan->subbuf_size, argp);
1161//ust// break;
1162//ust// default:
1163//ust// return -ENOIOCTLCMD;
1164//ust// }
1165//ust// return 0;
1166//ust// }
1167
1168//ust// #ifdef CONFIG_COMPAT
1169//ust// static long ltt_compat_ioctl(struct file *file, unsigned int cmd,
1170//ust// unsigned long arg)
1171//ust// {
1172//ust// long ret = -ENOIOCTLCMD;
1173//ust//
1174//ust// lock_kernel();
1175//ust// ret = ltt_ioctl(file->f_dentry->d_inode, file, cmd, arg);
1176//ust// unlock_kernel();
1177//ust//
1178//ust// return ret;
1179//ust// }
1180//ust// #endif
1181
1182//ust// static void ltt_relay_pipe_buf_release(struct pipe_inode_info *pipe,
1183//ust// struct pipe_buffer *pbuf)
1184//ust// {
1185//ust// }
1186//ust//
1187//ust// static struct pipe_buf_operations ltt_relay_pipe_buf_ops = {
1188//ust// .can_merge = 0,
1189//ust// .map = generic_pipe_buf_map,
1190//ust// .unmap = generic_pipe_buf_unmap,
1191//ust// .confirm = generic_pipe_buf_confirm,
1192//ust// .release = ltt_relay_pipe_buf_release,
1193//ust// .steal = generic_pipe_buf_steal,
1194//ust// .get = generic_pipe_buf_get,
1195//ust// };
1196
1197//ust// static void ltt_relay_page_release(struct splice_pipe_desc *spd, unsigned int i)
1198//ust// {
1199//ust// }
e1152c37
PMF
1200
1201/*
1202 * subbuf_splice_actor - splice up to one subbuf's worth of data
1203 */
bb07823d
PMF
1204//ust// static int subbuf_splice_actor(struct file *in,
1205//ust// loff_t *ppos,
1206//ust// struct pipe_inode_info *pipe,
1207//ust// size_t len,
1208//ust// unsigned int flags)
1209//ust// {
1210//ust// struct rchan_buf *buf = in->private_data;
1211//ust// struct ltt_channel_struct *ltt_channel =
1212//ust// (struct ltt_channel_struct *)buf->chan->private_data;
1213//ust// struct ltt_channel_buf_struct *ltt_buf =
1214//ust// percpu_ptr(ltt_channel->buf, buf->cpu);
1215//ust// unsigned int poff, subbuf_pages, nr_pages;
1216//ust// struct page *pages[PIPE_BUFFERS];
1217//ust// struct partial_page partial[PIPE_BUFFERS];
1218//ust// struct splice_pipe_desc spd = {
1219//ust// .pages = pages,
1220//ust// .nr_pages = 0,
1221//ust// .partial = partial,
1222//ust// .flags = flags,
1223//ust// .ops = &ltt_relay_pipe_buf_ops,
1224//ust// .spd_release = ltt_relay_page_release,
1225//ust// };
1226//ust// long consumed_old, consumed_idx, roffset;
1227//ust// unsigned long bytes_avail;
1228//ust//
1229//ust// /*
1230//ust// * Check that a GET_SUBBUF ioctl has been done before.
1231//ust// */
1232//ust// WARN_ON(atomic_long_read(&ltt_buf->active_readers) != 1);
1233//ust// consumed_old = atomic_long_read(&ltt_buf->consumed);
1234//ust// consumed_old += *ppos;
1235//ust// consumed_idx = SUBBUF_INDEX(consumed_old, buf->chan);
1236//ust//
1237//ust// /*
1238//ust// * Adjust read len, if longer than what is available
1239//ust// */
1240//ust// bytes_avail = SUBBUF_TRUNC(local_read(&ltt_buf->offset), buf->chan)
1241//ust// - consumed_old;
1242//ust// WARN_ON(bytes_avail > buf->chan->alloc_size);
1243//ust// len = min_t(size_t, len, bytes_avail);
1244//ust// subbuf_pages = bytes_avail >> PAGE_SHIFT;
1245//ust// nr_pages = min_t(unsigned int, subbuf_pages, PIPE_BUFFERS);
1246//ust// roffset = consumed_old & PAGE_MASK;
1247//ust// poff = consumed_old & ~PAGE_MASK;
1248//ust// printk_dbg(KERN_DEBUG "SPLICE actor len %zu pos %zd write_pos %ld\n",
1249//ust// len, (ssize_t)*ppos, local_read(&ltt_buf->offset));
1250//ust//
1251//ust// for (; spd.nr_pages < nr_pages; spd.nr_pages++) {
1252//ust// unsigned int this_len;
1253//ust// struct buf_page *page;
1254//ust//
1255//ust// if (!len)
1256//ust// break;
1257//ust// printk_dbg(KERN_DEBUG "SPLICE actor loop len %zu roffset %ld\n",
1258//ust// len, roffset);
1259//ust//
1260//ust// this_len = PAGE_SIZE - poff;
1261//ust// page = ltt_relay_read_get_page(buf, roffset);
1262//ust// spd.pages[spd.nr_pages] = page->page;
1263//ust// spd.partial[spd.nr_pages].offset = poff;
1264//ust// spd.partial[spd.nr_pages].len = this_len;
1265//ust//
1266//ust// poff = 0;
1267//ust// roffset += PAGE_SIZE;
1268//ust// len -= this_len;
1269//ust// }
1270//ust//
1271//ust// if (!spd.nr_pages)
1272//ust// return 0;
1273//ust//
1274//ust// return splice_to_pipe(pipe, &spd);
1275//ust// }
e1152c37 1276
bb07823d
PMF
1277//ust// static ssize_t ltt_relay_file_splice_read(struct file *in,
1278//ust// loff_t *ppos,
1279//ust// struct pipe_inode_info *pipe,
1280//ust// size_t len,
1281//ust// unsigned int flags)
1282//ust// {
1283//ust// ssize_t spliced;
1284//ust// int ret;
1285//ust//
1286//ust// ret = 0;
1287//ust// spliced = 0;
1288//ust//
1289//ust// printk_dbg(KERN_DEBUG "SPLICE read len %zu pos %zd\n",
1290//ust// len, (ssize_t)*ppos);
1291//ust// while (len && !spliced) {
1292//ust// ret = subbuf_splice_actor(in, ppos, pipe, len, flags);
1293//ust// printk_dbg(KERN_DEBUG "SPLICE read loop ret %d\n", ret);
1294//ust// if (ret < 0)
1295//ust// break;
1296//ust// else if (!ret) {
1297//ust// if (flags & SPLICE_F_NONBLOCK)
1298//ust// ret = -EAGAIN;
1299//ust// break;
1300//ust// }
1301//ust//
1302//ust// *ppos += ret;
1303//ust// if (ret > len)
1304//ust// len = 0;
1305//ust// else
1306//ust// len -= ret;
1307//ust// spliced += ret;
1308//ust// }
1309//ust//
1310//ust// if (spliced)
1311//ust// return spliced;
1312//ust//
1313//ust// return ret;
1314//ust// }
e1152c37
PMF
1315
1316static void ltt_relay_print_subbuffer_errors(
1317 struct ltt_channel_struct *ltt_chan,
bb07823d 1318 long cons_off)
e1152c37
PMF
1319{
1320 struct rchan *rchan = ltt_chan->trans_channel_data;
bb07823d 1321 struct ltt_channel_buf_struct *ltt_buf = ltt_chan->buf;
e1152c37
PMF
1322 long cons_idx, commit_count, write_offset;
1323
1324 cons_idx = SUBBUF_INDEX(cons_off, rchan);
1325 commit_count = local_read(&ltt_buf->commit_count[cons_idx]);
1326 /*
1327 * No need to order commit_count and write_offset reads because we
1328 * execute after trace is stopped when there are no readers left.
1329 */
1330 write_offset = local_read(&ltt_buf->offset);
1331 printk(KERN_WARNING
1332 "LTT : unread channel %s offset is %ld "
bb07823d
PMF
1333 "and cons_off : %ld\n",
1334 ltt_chan->channel_name, write_offset, cons_off);
e1152c37
PMF
1335 /* Check each sub-buffer for non filled commit count */
1336 if (((commit_count - rchan->subbuf_size) & ltt_chan->commit_count_mask)
1337 - (BUFFER_TRUNC(cons_off, rchan) >> ltt_chan->n_subbufs_order)
1338 != 0)
1339 printk(KERN_ALERT
1340 "LTT : %s : subbuffer %lu has non filled "
1341 "commit count %lu.\n",
1342 ltt_chan->channel_name, cons_idx, commit_count);
1343 printk(KERN_ALERT "LTT : %s : commit count : %lu, subbuf size %zd\n",
1344 ltt_chan->channel_name, commit_count,
1345 rchan->subbuf_size);
1346}
1347
1348static void ltt_relay_print_errors(struct ltt_trace_struct *trace,
bb07823d 1349 struct ltt_channel_struct *ltt_chan)
e1152c37
PMF
1350{
1351 struct rchan *rchan = ltt_chan->trans_channel_data;
bb07823d 1352 struct ltt_channel_buf_struct *ltt_buf = ltt_chan->buf;
e1152c37
PMF
1353 long cons_off;
1354
1355 for (cons_off = atomic_long_read(&ltt_buf->consumed);
1356 (SUBBUF_TRUNC(local_read(&ltt_buf->offset),
1357 rchan)
1358 - cons_off) > 0;
1359 cons_off = SUBBUF_ALIGN(cons_off, rchan))
bb07823d 1360 ltt_relay_print_subbuffer_errors(ltt_chan, cons_off);
e1152c37
PMF
1361}
1362
bb07823d 1363static void ltt_relay_print_buffer_errors(struct ltt_channel_struct *ltt_chan)
e1152c37
PMF
1364{
1365 struct ltt_trace_struct *trace = ltt_chan->trace;
bb07823d 1366 struct ltt_channel_buf_struct *ltt_buf = ltt_chan->buf;
e1152c37
PMF
1367
1368 if (local_read(&ltt_buf->events_lost))
1369 printk(KERN_ALERT
1370 "LTT : %s : %ld events lost "
bb07823d 1371 "in %s channel.\n",
e1152c37
PMF
1372 ltt_chan->channel_name,
1373 local_read(&ltt_buf->events_lost),
bb07823d 1374 ltt_chan->channel_name);
e1152c37
PMF
1375 if (local_read(&ltt_buf->corrupted_subbuffers))
1376 printk(KERN_ALERT
1377 "LTT : %s : %ld corrupted subbuffers "
bb07823d 1378 "in %s channel.\n",
e1152c37
PMF
1379 ltt_chan->channel_name,
1380 local_read(&ltt_buf->corrupted_subbuffers),
bb07823d 1381 ltt_chan->channel_name);
e1152c37 1382
bb07823d 1383 ltt_relay_print_errors(trace, ltt_chan);
e1152c37
PMF
1384}
1385
bb07823d
PMF
1386static void ltt_relay_remove_dirs(struct ltt_trace_struct *trace)
1387{
5f54827b 1388//ust// debugfs_remove(trace->dentry.trace_root);
bb07823d 1389}
e1152c37
PMF
1390
1391static void ltt_relay_release_channel(struct kref *kref)
1392{
1393 struct ltt_channel_struct *ltt_chan = container_of(kref,
1394 struct ltt_channel_struct, kref);
bb07823d 1395 free(ltt_chan->buf);
e1152c37
PMF
1396}
1397
1398/*
1399 * Create ltt buffer.
1400 */
5f54827b
PMF
1401//ust// static int ltt_relay_create_buffer(struct ltt_trace_struct *trace,
1402//ust// struct ltt_channel_struct *ltt_chan, struct rchan_buf *buf,
1403//ust// unsigned int cpu, unsigned int n_subbufs)
1404//ust// {
1405//ust// struct ltt_channel_buf_struct *ltt_buf =
1406//ust// percpu_ptr(ltt_chan->buf, cpu);
1407//ust// unsigned int j;
1408//ust//
1409//ust// ltt_buf->commit_count =
1410//ust// kzalloc_node(sizeof(ltt_buf->commit_count) * n_subbufs,
1411//ust// GFP_KERNEL, cpu_to_node(cpu));
1412//ust// if (!ltt_buf->commit_count)
1413//ust// return -ENOMEM;
1414//ust// kref_get(&trace->kref);
1415//ust// kref_get(&trace->ltt_transport_kref);
1416//ust// kref_get(&ltt_chan->kref);
1417//ust// local_set(&ltt_buf->offset, ltt_subbuffer_header_size());
1418//ust// atomic_long_set(&ltt_buf->consumed, 0);
1419//ust// atomic_long_set(&ltt_buf->active_readers, 0);
1420//ust// for (j = 0; j < n_subbufs; j++)
1421//ust// local_set(&ltt_buf->commit_count[j], 0);
1422//ust// init_waitqueue_head(&ltt_buf->write_wait);
1423//ust// atomic_set(&ltt_buf->wakeup_readers, 0);
1424//ust// spin_lock_init(&ltt_buf->full_lock);
1425//ust//
1426//ust// ltt_buffer_begin_callback(buf, trace->start_tsc, 0);
1427//ust// /* atomic_add made on local variable on data that belongs to
1428//ust// * various CPUs : ok because tracing not started (for this cpu). */
1429//ust// local_add(ltt_subbuffer_header_size(), &ltt_buf->commit_count[0]);
1430//ust//
1431//ust// local_set(&ltt_buf->events_lost, 0);
1432//ust// local_set(&ltt_buf->corrupted_subbuffers, 0);
1433//ust//
1434//ust// return 0;
1435//ust// }
1436
e1152c37
PMF
1437static int ltt_relay_create_buffer(struct ltt_trace_struct *trace,
1438 struct ltt_channel_struct *ltt_chan, struct rchan_buf *buf,
bb07823d 1439 unsigned int n_subbufs)
e1152c37 1440{
5f54827b 1441 struct ltt_channel_buf_struct *ltt_buf = ltt_chan->buf;
e1152c37
PMF
1442 unsigned int j;
1443
1444 ltt_buf->commit_count =
5f54827b 1445 malloc(sizeof(ltt_buf->commit_count) * n_subbufs);
e1152c37
PMF
1446 if (!ltt_buf->commit_count)
1447 return -ENOMEM;
1448 kref_get(&trace->kref);
1449 kref_get(&trace->ltt_transport_kref);
1450 kref_get(&ltt_chan->kref);
5f54827b 1451 ltt_buf->offset = ltt_subbuffer_header_size();
e1152c37
PMF
1452 atomic_long_set(&ltt_buf->consumed, 0);
1453 atomic_long_set(&ltt_buf->active_readers, 0);
1454 for (j = 0; j < n_subbufs; j++)
1455 local_set(&ltt_buf->commit_count[j], 0);
5f54827b 1456//ust// init_waitqueue_head(&ltt_buf->write_wait);
e1152c37
PMF
1457 atomic_set(&ltt_buf->wakeup_readers, 0);
1458 spin_lock_init(&ltt_buf->full_lock);
1459
1460 ltt_buffer_begin_callback(buf, trace->start_tsc, 0);
e1152c37 1461
5f54827b
PMF
1462 ltt_buf->commit_count[0] += ltt_subbuffer_header_size();
1463
1464 ltt_buf->events_lost = 0;
1465 ltt_buf->corrupted_subbuffers = 0;
e1152c37
PMF
1466
1467 return 0;
1468}
1469
bb07823d 1470static void ltt_relay_destroy_buffer(struct ltt_channel_struct *ltt_chan)
e1152c37
PMF
1471{
1472 struct ltt_trace_struct *trace = ltt_chan->trace;
bb07823d 1473 struct ltt_channel_buf_struct *ltt_buf = ltt_chan->buf;
e1152c37
PMF
1474
1475 kref_put(&ltt_chan->trace->ltt_transport_kref,
1476 ltt_release_transport);
bb07823d 1477 ltt_relay_print_buffer_errors(ltt_chan);
e1152c37
PMF
1478 kfree(ltt_buf->commit_count);
1479 ltt_buf->commit_count = NULL;
1480 kref_put(&ltt_chan->kref, ltt_relay_release_channel);
1481 kref_put(&trace->kref, ltt_release_trace);
bb07823d 1482//ust// wake_up_interruptible(&trace->kref_wq);
e1152c37
PMF
1483}
1484
1485/*
1486 * Create channel.
1487 */
1488static int ltt_relay_create_channel(const char *trace_name,
1489 struct ltt_trace_struct *trace, struct dentry *dir,
1490 const char *channel_name, struct ltt_channel_struct *ltt_chan,
1491 unsigned int subbuf_size, unsigned int n_subbufs,
1492 int overwrite)
1493{
1494 char *tmpname;
1495 unsigned int tmpname_len;
1496 int err = 0;
1497
1498 tmpname = kmalloc(PATH_MAX, GFP_KERNEL);
1499 if (!tmpname)
1500 return EPERM;
1501 if (overwrite) {
1502 strncpy(tmpname, LTT_FLIGHT_PREFIX, PATH_MAX-1);
1503 strncat(tmpname, channel_name,
1504 PATH_MAX-1-sizeof(LTT_FLIGHT_PREFIX));
1505 } else {
1506 strncpy(tmpname, channel_name, PATH_MAX-1);
1507 }
1508 strncat(tmpname, "_", PATH_MAX-1-strlen(tmpname));
1509
1510 kref_init(&ltt_chan->kref);
1511
1512 ltt_chan->trace = trace;
1513 ltt_chan->buffer_begin = ltt_buffer_begin_callback;
1514 ltt_chan->buffer_end = ltt_buffer_end_callback;
1515 ltt_chan->overwrite = overwrite;
1516 ltt_chan->n_subbufs_order = get_count_order(n_subbufs);
1517 ltt_chan->commit_count_mask = (~0UL >> ltt_chan->n_subbufs_order);
bb07823d
PMF
1518//ust// ltt_chan->buf = percpu_alloc_mask(sizeof(struct ltt_channel_buf_struct), GFP_KERNEL, cpu_possible_map);
1519 ltt_chan->buf = malloc(sizeof(struct ltt_channel_buf_struct));
e1152c37 1520 if (!ltt_chan->buf)
bb07823d 1521 goto alloc_error;
e1152c37
PMF
1522 ltt_chan->trans_channel_data = ltt_relay_open(tmpname,
1523 dir,
1524 subbuf_size,
1525 n_subbufs,
e1152c37
PMF
1526 ltt_chan);
1527 tmpname_len = strlen(tmpname);
1528 if (tmpname_len > 0) {
1529 /* Remove final _ for pretty printing */
1530 tmpname[tmpname_len-1] = '\0';
1531 }
1532 if (ltt_chan->trans_channel_data == NULL) {
1533 printk(KERN_ERR "LTT : Can't open %s channel for trace %s\n",
1534 tmpname, trace_name);
1535 goto relay_open_error;
1536 }
1537
1538 err = 0;
1539 goto end;
1540
1541relay_open_error:
bb07823d
PMF
1542//ust// percpu_free(ltt_chan->buf);
1543alloc_error:
e1152c37
PMF
1544 err = EPERM;
1545end:
1546 kfree(tmpname);
1547 return err;
1548}
1549
bb07823d
PMF
1550static int ltt_relay_create_dirs(struct ltt_trace_struct *new_trace)
1551{
1552//ust// new_trace->dentry.trace_root = debugfs_create_dir(new_trace->trace_name,
1553//ust// get_ltt_root());
1554//ust// if (new_trace->dentry.trace_root == NULL) {
1555//ust// printk(KERN_ERR "LTT : Trace directory name %s already taken\n",
1556//ust// new_trace->trace_name);
1557//ust// return EEXIST;
1558//ust// }
1559
1560//ust// new_trace->callbacks.create_buf_file = ltt_create_buf_file_callback;
1561//ust// new_trace->callbacks.remove_buf_file = ltt_remove_buf_file_callback;
1562
1563 return 0;
1564}
e1152c37
PMF
1565
1566/*
1567 * LTTng channel flush function.
1568 *
1569 * Must be called when no tracing is active in the channel, because of
1570 * accesses across CPUs.
1571 */
1572static notrace void ltt_relay_buffer_flush(struct rchan_buf *buf)
1573{
1574 buf->finalized = 1;
1575 ltt_force_switch(buf, FORCE_FLUSH);
1576}
1577
1578static void ltt_relay_async_wakeup_chan(struct ltt_channel_struct *ltt_channel)
1579{
bb07823d
PMF
1580//ust// unsigned int i;
1581//ust// struct rchan *rchan = ltt_channel->trans_channel_data;
1582//ust//
1583//ust// for_each_possible_cpu(i) {
1584//ust// struct ltt_channel_buf_struct *ltt_buf =
1585//ust// percpu_ptr(ltt_channel->buf, i);
1586//ust//
1587//ust// if (atomic_read(&ltt_buf->wakeup_readers) == 1) {
1588//ust// atomic_set(&ltt_buf->wakeup_readers, 0);
1589//ust// wake_up_interruptible(&rchan->buf[i]->read_wait);
1590//ust// }
1591//ust// }
e1152c37
PMF
1592}
1593
bb07823d 1594static void ltt_relay_finish_buffer(struct ltt_channel_struct *ltt_channel)
e1152c37
PMF
1595{
1596 struct rchan *rchan = ltt_channel->trans_channel_data;
1597
bb07823d
PMF
1598 if (rchan->buf) {
1599 struct ltt_channel_buf_struct *ltt_buf = ltt_channel->buf;
1600 ltt_relay_buffer_flush(rchan->buf);
1601//ust// ltt_relay_wake_writers(ltt_buf);
e1152c37
PMF
1602 }
1603}
1604
1605
1606static void ltt_relay_finish_channel(struct ltt_channel_struct *ltt_channel)
1607{
1608 unsigned int i;
1609
bb07823d
PMF
1610//ust// for_each_possible_cpu(i)
1611 ltt_relay_finish_buffer(ltt_channel);
e1152c37
PMF
1612}
1613
1614static void ltt_relay_remove_channel(struct ltt_channel_struct *channel)
1615{
1616 struct rchan *rchan = channel->trans_channel_data;
1617
1618 ltt_relay_close(rchan);
1619 kref_put(&channel->kref, ltt_relay_release_channel);
1620}
1621
1622struct ltt_reserve_switch_offsets {
1623 long begin, end, old;
1624 long begin_switch, end_switch_current, end_switch_old;
1625 long commit_count, reserve_commit_diff;
1626 size_t before_hdr_pad, size;
1627};
1628
1629/*
1630 * Returns :
1631 * 0 if ok
1632 * !0 if execution must be aborted.
1633 */
1634static inline int ltt_relay_try_reserve(
1635 struct ltt_channel_struct *ltt_channel,
1636 struct ltt_channel_buf_struct *ltt_buf, struct rchan *rchan,
1637 struct rchan_buf *buf,
1638 struct ltt_reserve_switch_offsets *offsets, size_t data_size,
1639 u64 *tsc, unsigned int *rflags, int largest_align)
1640{
1641 offsets->begin = local_read(&ltt_buf->offset);
1642 offsets->old = offsets->begin;
1643 offsets->begin_switch = 0;
1644 offsets->end_switch_current = 0;
1645 offsets->end_switch_old = 0;
1646
1647 *tsc = trace_clock_read64();
1648 if (last_tsc_overflow(ltt_buf, *tsc))
1649 *rflags = LTT_RFLAG_ID_SIZE_TSC;
1650
1651 if (SUBBUF_OFFSET(offsets->begin, buf->chan) == 0) {
1652 offsets->begin_switch = 1; /* For offsets->begin */
1653 } else {
1654 offsets->size = ltt_get_header_size(ltt_channel,
1655 offsets->begin, data_size,
1656 &offsets->before_hdr_pad, *rflags);
1657 offsets->size += ltt_align(offsets->begin + offsets->size,
1658 largest_align)
1659 + data_size;
1660 if ((SUBBUF_OFFSET(offsets->begin, buf->chan) + offsets->size)
1661 > buf->chan->subbuf_size) {
1662 offsets->end_switch_old = 1; /* For offsets->old */
1663 offsets->begin_switch = 1; /* For offsets->begin */
1664 }
1665 }
1666 if (offsets->begin_switch) {
1667 long subbuf_index;
1668
1669 if (offsets->end_switch_old)
1670 offsets->begin = SUBBUF_ALIGN(offsets->begin,
1671 buf->chan);
1672 offsets->begin = offsets->begin + ltt_subbuffer_header_size();
1673 /* Test new buffer integrity */
1674 subbuf_index = SUBBUF_INDEX(offsets->begin, buf->chan);
1675 offsets->reserve_commit_diff =
1676 (BUFFER_TRUNC(offsets->begin, buf->chan)
1677 >> ltt_channel->n_subbufs_order)
1678 - (local_read(&ltt_buf->commit_count[subbuf_index])
1679 & ltt_channel->commit_count_mask);
1680 if (offsets->reserve_commit_diff == 0) {
1681 /* Next buffer not corrupted. */
1682 if (!ltt_channel->overwrite &&
1683 (SUBBUF_TRUNC(offsets->begin, buf->chan)
1684 - SUBBUF_TRUNC(atomic_long_read(
1685 &ltt_buf->consumed),
1686 buf->chan))
1687 >= rchan->alloc_size) {
1688 /*
1689 * We do not overwrite non consumed buffers
1690 * and we are full : event is lost.
1691 */
1692 local_inc(&ltt_buf->events_lost);
1693 return -1;
1694 } else {
1695 /*
1696 * next buffer not corrupted, we are either in
1697 * overwrite mode or the buffer is not full.
1698 * It's safe to write in this new subbuffer.
1699 */
1700 }
1701 } else {
1702 /*
1703 * Next subbuffer corrupted. Force pushing reader even
1704 * in normal mode. It's safe to write in this new
1705 * subbuffer.
1706 */
1707 }
1708 offsets->size = ltt_get_header_size(ltt_channel,
1709 offsets->begin, data_size,
1710 &offsets->before_hdr_pad, *rflags);
1711 offsets->size += ltt_align(offsets->begin + offsets->size,
1712 largest_align)
1713 + data_size;
1714 if ((SUBBUF_OFFSET(offsets->begin, buf->chan) + offsets->size)
1715 > buf->chan->subbuf_size) {
1716 /*
1717 * Event too big for subbuffers, report error, don't
1718 * complete the sub-buffer switch.
1719 */
1720 local_inc(&ltt_buf->events_lost);
1721 return -1;
1722 } else {
1723 /*
1724 * We just made a successful buffer switch and the event
1725 * fits in the new subbuffer. Let's write.
1726 */
1727 }
1728 } else {
1729 /*
1730 * Event fits in the current buffer and we are not on a switch
1731 * boundary. It's safe to write.
1732 */
1733 }
1734 offsets->end = offsets->begin + offsets->size;
1735
1736 if ((SUBBUF_OFFSET(offsets->end, buf->chan)) == 0) {
1737 /*
1738 * The offset_end will fall at the very beginning of the next
1739 * subbuffer.
1740 */
1741 offsets->end_switch_current = 1; /* For offsets->begin */
1742 }
1743 return 0;
1744}
1745
1746/*
1747 * Returns :
1748 * 0 if ok
1749 * !0 if execution must be aborted.
1750 */
1751static inline int ltt_relay_try_switch(
1752 enum force_switch_mode mode,
1753 struct ltt_channel_struct *ltt_channel,
1754 struct ltt_channel_buf_struct *ltt_buf, struct rchan *rchan,
1755 struct rchan_buf *buf,
1756 struct ltt_reserve_switch_offsets *offsets,
1757 u64 *tsc)
1758{
1759 long subbuf_index;
1760
1761 offsets->begin = local_read(&ltt_buf->offset);
1762 offsets->old = offsets->begin;
1763 offsets->begin_switch = 0;
1764 offsets->end_switch_old = 0;
1765
1766 *tsc = trace_clock_read64();
1767
1768 if (SUBBUF_OFFSET(offsets->begin, buf->chan) != 0) {
1769 offsets->begin = SUBBUF_ALIGN(offsets->begin, buf->chan);
1770 offsets->end_switch_old = 1;
1771 } else {
1772 /* we do not have to switch : buffer is empty */
1773 return -1;
1774 }
1775 if (mode == FORCE_ACTIVE)
1776 offsets->begin += ltt_subbuffer_header_size();
1777 /*
1778 * Always begin_switch in FORCE_ACTIVE mode.
1779 * Test new buffer integrity
1780 */
1781 subbuf_index = SUBBUF_INDEX(offsets->begin, buf->chan);
1782 offsets->reserve_commit_diff =
1783 (BUFFER_TRUNC(offsets->begin, buf->chan)
1784 >> ltt_channel->n_subbufs_order)
1785 - (local_read(&ltt_buf->commit_count[subbuf_index])
1786 & ltt_channel->commit_count_mask);
1787 if (offsets->reserve_commit_diff == 0) {
1788 /* Next buffer not corrupted. */
1789 if (mode == FORCE_ACTIVE
1790 && !ltt_channel->overwrite
1791 && offsets->begin - atomic_long_read(&ltt_buf->consumed)
1792 >= rchan->alloc_size) {
1793 /*
1794 * We do not overwrite non consumed buffers and we are
1795 * full : ignore switch while tracing is active.
1796 */
1797 return -1;
1798 }
1799 } else {
1800 /*
1801 * Next subbuffer corrupted. Force pushing reader even in normal
1802 * mode
1803 */
1804 }
1805 offsets->end = offsets->begin;
1806 return 0;
1807}
1808
1809static inline void ltt_reserve_push_reader(
1810 struct ltt_channel_struct *ltt_channel,
1811 struct ltt_channel_buf_struct *ltt_buf,
1812 struct rchan *rchan,
1813 struct rchan_buf *buf,
1814 struct ltt_reserve_switch_offsets *offsets)
1815{
1816 long consumed_old, consumed_new;
1817
1818 do {
1819 consumed_old = atomic_long_read(&ltt_buf->consumed);
1820 /*
1821 * If buffer is in overwrite mode, push the reader consumed
1822 * count if the write position has reached it and we are not
1823 * at the first iteration (don't push the reader farther than
1824 * the writer). This operation can be done concurrently by many
1825 * writers in the same buffer, the writer being at the farthest
1826 * write position sub-buffer index in the buffer being the one
1827 * which will win this loop.
1828 * If the buffer is not in overwrite mode, pushing the reader
1829 * only happens if a sub-buffer is corrupted.
1830 */
1831 if ((SUBBUF_TRUNC(offsets->end-1, buf->chan)
1832 - SUBBUF_TRUNC(consumed_old, buf->chan))
1833 >= rchan->alloc_size)
1834 consumed_new = SUBBUF_ALIGN(consumed_old, buf->chan);
1835 else {
1836 consumed_new = consumed_old;
1837 break;
1838 }
1839 } while (atomic_long_cmpxchg(&ltt_buf->consumed, consumed_old,
1840 consumed_new) != consumed_old);
1841
1842 if (consumed_old != consumed_new) {
1843 /*
1844 * Reader pushed : we are the winner of the push, we can
1845 * therefore reequilibrate reserve and commit. Atomic increment
1846 * of the commit count permits other writers to play around
1847 * with this variable before us. We keep track of
1848 * corrupted_subbuffers even in overwrite mode :
1849 * we never want to write over a non completely committed
1850 * sub-buffer : possible causes : the buffer size is too low
1851 * compared to the unordered data input, or there is a writer
1852 * that died between the reserve and the commit.
1853 */
1854 if (offsets->reserve_commit_diff) {
1855 /*
1856 * We have to alter the sub-buffer commit count.
1857 * We do not deliver the previous subbuffer, given it
1858 * was either corrupted or not consumed (overwrite
1859 * mode).
1860 */
1861 local_add(offsets->reserve_commit_diff,
1862 &ltt_buf->commit_count[
1863 SUBBUF_INDEX(offsets->begin,
1864 buf->chan)]);
1865 if (!ltt_channel->overwrite
1866 || offsets->reserve_commit_diff
1867 != rchan->subbuf_size) {
1868 /*
1869 * The reserve commit diff was not subbuf_size :
1870 * it means the subbuffer was partly written to
1871 * and is therefore corrupted. If it is multiple
1872 * of subbuffer size and we are in flight
1873 * recorder mode, we are skipping over a whole
1874 * subbuffer.
1875 */
1876 local_inc(&ltt_buf->corrupted_subbuffers);
1877 }
1878 }
1879 }
1880}
1881
1882
1883/*
1884 * ltt_reserve_switch_old_subbuf: switch old subbuffer
1885 *
1886 * Concurrency safe because we are the last and only thread to alter this
1887 * sub-buffer. As long as it is not delivered and read, no other thread can
1888 * alter the offset, alter the reserve_count or call the
1889 * client_buffer_end_callback on this sub-buffer.
1890 *
1891 * The only remaining threads could be the ones with pending commits. They will
1892 * have to do the deliver themselves. Not concurrency safe in overwrite mode.
1893 * We detect corrupted subbuffers with commit and reserve counts. We keep a
1894 * corrupted sub-buffers count and push the readers across these sub-buffers.
1895 *
1896 * Not concurrency safe if a writer is stalled in a subbuffer and another writer
1897 * switches in, finding out it's corrupted. The result will be than the old
1898 * (uncommited) subbuffer will be declared corrupted, and that the new subbuffer
1899 * will be declared corrupted too because of the commit count adjustment.
1900 *
1901 * Note : offset_old should never be 0 here.
1902 */
1903static inline void ltt_reserve_switch_old_subbuf(
1904 struct ltt_channel_struct *ltt_channel,
1905 struct ltt_channel_buf_struct *ltt_buf, struct rchan *rchan,
1906 struct rchan_buf *buf,
1907 struct ltt_reserve_switch_offsets *offsets, u64 *tsc)
1908{
1909 long oldidx = SUBBUF_INDEX(offsets->old - 1, rchan);
1910
1911 ltt_channel->buffer_end(buf, *tsc, offsets->old, oldidx);
1912 /* Must write buffer end before incrementing commit count */
1913 smp_wmb();
1914 offsets->commit_count =
1915 local_add_return(rchan->subbuf_size
1916 - (SUBBUF_OFFSET(offsets->old - 1, rchan)
1917 + 1),
1918 &ltt_buf->commit_count[oldidx]);
1919 if ((BUFFER_TRUNC(offsets->old - 1, rchan)
1920 >> ltt_channel->n_subbufs_order)
1921 - ((offsets->commit_count - rchan->subbuf_size)
1922 & ltt_channel->commit_count_mask) == 0)
1923 ltt_deliver(buf, oldidx, NULL);
1924}
1925
1926/*
1927 * ltt_reserve_switch_new_subbuf: Populate new subbuffer.
1928 *
1929 * This code can be executed unordered : writers may already have written to the
1930 * sub-buffer before this code gets executed, caution. The commit makes sure
1931 * that this code is executed before the deliver of this sub-buffer.
1932 */
1933static inline void ltt_reserve_switch_new_subbuf(
1934 struct ltt_channel_struct *ltt_channel,
1935 struct ltt_channel_buf_struct *ltt_buf, struct rchan *rchan,
1936 struct rchan_buf *buf,
1937 struct ltt_reserve_switch_offsets *offsets, u64 *tsc)
1938{
1939 long beginidx = SUBBUF_INDEX(offsets->begin, rchan);
1940
1941 ltt_channel->buffer_begin(buf, *tsc, beginidx);
1942 /* Must write buffer end before incrementing commit count */
1943 smp_wmb();
1944 offsets->commit_count = local_add_return(ltt_subbuffer_header_size(),
1945 &ltt_buf->commit_count[beginidx]);
1946 /* Check if the written buffer has to be delivered */
1947 if ((BUFFER_TRUNC(offsets->begin, rchan)
1948 >> ltt_channel->n_subbufs_order)
1949 - ((offsets->commit_count - rchan->subbuf_size)
1950 & ltt_channel->commit_count_mask) == 0)
1951 ltt_deliver(buf, beginidx, NULL);
1952}
1953
1954
1955/*
1956 * ltt_reserve_end_switch_current: finish switching current subbuffer
1957 *
1958 * Concurrency safe because we are the last and only thread to alter this
1959 * sub-buffer. As long as it is not delivered and read, no other thread can
1960 * alter the offset, alter the reserve_count or call the
1961 * client_buffer_end_callback on this sub-buffer.
1962 *
1963 * The only remaining threads could be the ones with pending commits. They will
1964 * have to do the deliver themselves. Not concurrency safe in overwrite mode.
1965 * We detect corrupted subbuffers with commit and reserve counts. We keep a
1966 * corrupted sub-buffers count and push the readers across these sub-buffers.
1967 *
1968 * Not concurrency safe if a writer is stalled in a subbuffer and another writer
1969 * switches in, finding out it's corrupted. The result will be than the old
1970 * (uncommited) subbuffer will be declared corrupted, and that the new subbuffer
1971 * will be declared corrupted too because of the commit count adjustment.
1972 */
1973static inline void ltt_reserve_end_switch_current(
1974 struct ltt_channel_struct *ltt_channel,
1975 struct ltt_channel_buf_struct *ltt_buf, struct rchan *rchan,
1976 struct rchan_buf *buf,
1977 struct ltt_reserve_switch_offsets *offsets, u64 *tsc)
1978{
1979 long endidx = SUBBUF_INDEX(offsets->end - 1, rchan);
1980
1981 ltt_channel->buffer_end(buf, *tsc, offsets->end, endidx);
1982 /* Must write buffer begin before incrementing commit count */
1983 smp_wmb();
1984 offsets->commit_count =
1985 local_add_return(rchan->subbuf_size
1986 - (SUBBUF_OFFSET(offsets->end - 1, rchan)
1987 + 1),
1988 &ltt_buf->commit_count[endidx]);
1989 if ((BUFFER_TRUNC(offsets->end - 1, rchan)
1990 >> ltt_channel->n_subbufs_order)
1991 - ((offsets->commit_count - rchan->subbuf_size)
1992 & ltt_channel->commit_count_mask) == 0)
1993 ltt_deliver(buf, endidx, NULL);
1994}
1995
1996/**
1997 * ltt_relay_reserve_slot - Atomic slot reservation in a LTTng buffer.
1998 * @trace: the trace structure to log to.
1999 * @ltt_channel: channel structure
2000 * @transport_data: data structure specific to ltt relay
2001 * @data_size: size of the variable length data to log.
2002 * @slot_size: pointer to total size of the slot (out)
2003 * @buf_offset : pointer to reserved buffer offset (out)
2004 * @tsc: pointer to the tsc at the slot reservation (out)
2005 * @cpu: cpuid
2006 *
2007 * Return : -ENOSPC if not enough space, else returns 0.
2008 * It will take care of sub-buffer switching.
2009 */
2010static notrace int ltt_relay_reserve_slot(struct ltt_trace_struct *trace,
2011 struct ltt_channel_struct *ltt_channel, void **transport_data,
2012 size_t data_size, size_t *slot_size, long *buf_offset, u64 *tsc,
2013 unsigned int *rflags, int largest_align, int cpu)
2014{
2015 struct rchan *rchan = ltt_channel->trans_channel_data;
bb07823d
PMF
2016 struct rchan_buf *buf = *transport_data = rchan->buf;
2017 struct ltt_channel_buf_struct *ltt_buf = ltt_channel->buf;
e1152c37
PMF
2018 struct ltt_reserve_switch_offsets offsets;
2019
2020 offsets.reserve_commit_diff = 0;
2021 offsets.size = 0;
2022
2023 /*
2024 * Perform retryable operations.
2025 */
bb07823d 2026 if (ltt_nesting > 4) {
e1152c37
PMF
2027 local_inc(&ltt_buf->events_lost);
2028 return -EPERM;
2029 }
2030 do {
2031 if (ltt_relay_try_reserve(ltt_channel, ltt_buf,
2032 rchan, buf, &offsets, data_size, tsc, rflags,
2033 largest_align))
2034 return -ENOSPC;
2035 } while (local_cmpxchg(&ltt_buf->offset, offsets.old,
2036 offsets.end) != offsets.old);
2037
2038 /*
2039 * Atomically update last_tsc. This update races against concurrent
2040 * atomic updates, but the race will always cause supplementary full TSC
2041 * events, never the opposite (missing a full TSC event when it would be
2042 * needed).
2043 */
2044 save_last_tsc(ltt_buf, *tsc);
2045
2046 /*
2047 * Push the reader if necessary
2048 */
2049 ltt_reserve_push_reader(ltt_channel, ltt_buf, rchan, buf, &offsets);
2050
2051 /*
2052 * Switch old subbuffer if needed.
2053 */
2054 if (offsets.end_switch_old)
2055 ltt_reserve_switch_old_subbuf(ltt_channel, ltt_buf, rchan, buf,
2056 &offsets, tsc);
2057
2058 /*
2059 * Populate new subbuffer.
2060 */
2061 if (offsets.begin_switch)
2062 ltt_reserve_switch_new_subbuf(ltt_channel, ltt_buf, rchan,
2063 buf, &offsets, tsc);
2064
2065 if (offsets.end_switch_current)
2066 ltt_reserve_end_switch_current(ltt_channel, ltt_buf, rchan,
2067 buf, &offsets, tsc);
2068
2069 *slot_size = offsets.size;
2070 *buf_offset = offsets.begin + offsets.before_hdr_pad;
2071 return 0;
2072}
2073
2074/*
2075 * Force a sub-buffer switch for a per-cpu buffer. This operation is
2076 * completely reentrant : can be called while tracing is active with
2077 * absolutely no lock held.
2078 *
2079 * Note, however, that as a local_cmpxchg is used for some atomic
2080 * operations, this function must be called from the CPU which owns the buffer
2081 * for a ACTIVE flush.
2082 */
2083static notrace void ltt_force_switch(struct rchan_buf *buf,
2084 enum force_switch_mode mode)
2085{
2086 struct ltt_channel_struct *ltt_channel =
2087 (struct ltt_channel_struct *)buf->chan->private_data;
bb07823d 2088 struct ltt_channel_buf_struct *ltt_buf = ltt_channel->buf;
e1152c37
PMF
2089 struct rchan *rchan = ltt_channel->trans_channel_data;
2090 struct ltt_reserve_switch_offsets offsets;
2091 u64 tsc;
2092
2093 offsets.reserve_commit_diff = 0;
2094 offsets.size = 0;
2095
2096 /*
2097 * Perform retryable operations.
2098 */
2099 do {
2100 if (ltt_relay_try_switch(mode, ltt_channel, ltt_buf,
2101 rchan, buf, &offsets, &tsc))
2102 return;
2103 } while (local_cmpxchg(&ltt_buf->offset, offsets.old,
2104 offsets.end) != offsets.old);
2105
2106 /*
2107 * Atomically update last_tsc. This update races against concurrent
2108 * atomic updates, but the race will always cause supplementary full TSC
2109 * events, never the opposite (missing a full TSC event when it would be
2110 * needed).
2111 */
2112 save_last_tsc(ltt_buf, tsc);
2113
2114 /*
2115 * Push the reader if necessary
2116 */
2117 if (mode == FORCE_ACTIVE)
2118 ltt_reserve_push_reader(ltt_channel, ltt_buf, rchan,
2119 buf, &offsets);
2120
2121 /*
2122 * Switch old subbuffer if needed.
2123 */
2124 if (offsets.end_switch_old)
2125 ltt_reserve_switch_old_subbuf(ltt_channel, ltt_buf, rchan, buf,
2126 &offsets, &tsc);
2127
2128 /*
2129 * Populate new subbuffer.
2130 */
2131 if (mode == FORCE_ACTIVE)
2132 ltt_reserve_switch_new_subbuf(ltt_channel,
2133 ltt_buf, rchan, buf, &offsets, &tsc);
2134}
2135
2136/*
2137 * for flight recording. must be called after relay_commit.
2138 * This function decrements de subbuffer's lost_size each time the commit count
2139 * reaches back the reserve offset (module subbuffer size). It is useful for
2140 * crash dump.
2141 * We use slot_size - 1 to make sure we deal correctly with the case where we
2142 * fill the subbuffer completely (so the subbuf index stays in the previous
2143 * subbuffer).
2144 */
2145#ifdef CONFIG_LTT_VMCORE
2146static inline void ltt_write_commit_counter(struct rchan_buf *buf,
2147 long buf_offset, size_t slot_size)
2148{
2149 struct ltt_channel_struct *ltt_channel =
2150 (struct ltt_channel_struct *)buf->chan->private_data;
2151 struct ltt_channel_buf_struct *ltt_buf =
2152 percpu_ptr(ltt_channel->buf, buf->cpu);
2153 struct ltt_subbuffer_header *header;
2154 long offset, subbuf_idx, commit_count;
2155 uint32_t lost_old, lost_new;
2156
2157 subbuf_idx = SUBBUF_INDEX(buf_offset - 1, buf->chan);
2158 offset = buf_offset + slot_size;
2159 header = (struct ltt_subbuffer_header *)
2160 ltt_relay_offset_address(buf,
2161 subbuf_idx * buf->chan->subbuf_size);
2162 for (;;) {
2163 lost_old = header->lost_size;
2164 commit_count =
2165 local_read(&ltt_buf->commit_count[subbuf_idx]);
2166 /* SUBBUF_OFFSET includes commit_count_mask */
2167 if (!SUBBUF_OFFSET(offset - commit_count, buf->chan)) {
2168 lost_new = (uint32_t)buf->chan->subbuf_size
2169 - SUBBUF_OFFSET(commit_count, buf->chan);
2170 lost_old = cmpxchg_local(&header->lost_size, lost_old,
2171 lost_new);
2172 if (lost_old <= lost_new)
2173 break;
2174 } else {
2175 break;
2176 }
2177 }
2178}
2179#else
2180static inline void ltt_write_commit_counter(struct rchan_buf *buf,
2181 long buf_offset, size_t slot_size)
2182{
2183}
2184#endif
2185
2186/*
2187 * Atomic unordered slot commit. Increments the commit count in the
2188 * specified sub-buffer, and delivers it if necessary.
2189 *
2190 * Parameters:
2191 *
2192 * @ltt_channel : channel structure
2193 * @transport_data: transport-specific data
2194 * @buf_offset : offset following the event header.
2195 * @slot_size : size of the reserved slot.
2196 */
2197static notrace void ltt_relay_commit_slot(
2198 struct ltt_channel_struct *ltt_channel,
2199 void **transport_data, long buf_offset, size_t slot_size)
2200{
2201 struct rchan_buf *buf = *transport_data;
bb07823d 2202 struct ltt_channel_buf_struct *ltt_buf = ltt_channel->buf;
e1152c37
PMF
2203 struct rchan *rchan = buf->chan;
2204 long offset_end = buf_offset;
2205 long endidx = SUBBUF_INDEX(offset_end - 1, rchan);
2206 long commit_count;
2207
2208 /* Must write slot data before incrementing commit count */
2209 smp_wmb();
2210 commit_count = local_add_return(slot_size,
2211 &ltt_buf->commit_count[endidx]);
2212 /* Check if all commits have been done */
2213 if ((BUFFER_TRUNC(offset_end - 1, rchan)
2214 >> ltt_channel->n_subbufs_order)
2215 - ((commit_count - rchan->subbuf_size)
2216 & ltt_channel->commit_count_mask) == 0)
2217 ltt_deliver(buf, endidx, NULL);
2218 /*
2219 * Update lost_size for each commit. It's needed only for extracting
2220 * ltt buffers from vmcore, after crash.
2221 */
2222 ltt_write_commit_counter(buf, buf_offset, slot_size);
2223}
2224
2225/*
2226 * This is called with preemption disabled when user space has requested
2227 * blocking mode. If one of the active traces has free space below a
2228 * specific threshold value, we reenable preemption and block.
2229 */
2230static int ltt_relay_user_blocking(struct ltt_trace_struct *trace,
2231 unsigned int chan_index, size_t data_size,
2232 struct user_dbg_data *dbg)
2233{
bb07823d
PMF
2234//ust// struct rchan *rchan;
2235//ust// struct ltt_channel_buf_struct *ltt_buf;
2236//ust// struct ltt_channel_struct *channel;
2237//ust// struct rchan_buf *relay_buf;
2238//ust// int cpu;
2239//ust// DECLARE_WAITQUEUE(wait, current);
2240//ust//
2241//ust// channel = &trace->channels[chan_index];
2242//ust// rchan = channel->trans_channel_data;
2243//ust// cpu = smp_processor_id();
2244//ust// relay_buf = rchan->buf[cpu];
2245//ust// ltt_buf = percpu_ptr(channel->buf, cpu);
2246//ust//
2247//ust// /*
2248//ust// * Check if data is too big for the channel : do not
2249//ust// * block for it.
2250//ust// */
2251//ust// if (LTT_RESERVE_CRITICAL + data_size > relay_buf->chan->subbuf_size)
2252//ust// return 0;
2253//ust//
2254//ust// /*
2255//ust// * If free space too low, we block. We restart from the
2256//ust// * beginning after we resume (cpu id may have changed
2257//ust// * while preemption is active).
2258//ust// */
2259//ust// spin_lock(&ltt_buf->full_lock);
2260//ust// if (!channel->overwrite) {
2261//ust// dbg->write = local_read(&ltt_buf->offset);
2262//ust// dbg->read = atomic_long_read(&ltt_buf->consumed);
2263//ust// dbg->avail_size = dbg->write + LTT_RESERVE_CRITICAL + data_size
2264//ust// - SUBBUF_TRUNC(dbg->read,
2265//ust// relay_buf->chan);
2266//ust// if (dbg->avail_size > rchan->alloc_size) {
2267//ust// __set_current_state(TASK_INTERRUPTIBLE);
2268//ust// add_wait_queue(&ltt_buf->write_wait, &wait);
2269//ust// spin_unlock(&ltt_buf->full_lock);
2270//ust// preempt_enable();
2271//ust// schedule();
2272//ust// __set_current_state(TASK_RUNNING);
2273//ust// remove_wait_queue(&ltt_buf->write_wait, &wait);
2274//ust// if (signal_pending(current))
2275//ust// return -ERESTARTSYS;
2276//ust// preempt_disable();
2277//ust// return 1;
2278//ust// }
2279//ust// }
2280//ust// spin_unlock(&ltt_buf->full_lock);
e1152c37
PMF
2281 return 0;
2282}
2283
2284static void ltt_relay_print_user_errors(struct ltt_trace_struct *trace,
2285 unsigned int chan_index, size_t data_size,
2286 struct user_dbg_data *dbg, int cpu)
2287{
2288 struct rchan *rchan;
2289 struct ltt_channel_buf_struct *ltt_buf;
2290 struct ltt_channel_struct *channel;
2291 struct rchan_buf *relay_buf;
2292
2293 channel = &trace->channels[chan_index];
2294 rchan = channel->trans_channel_data;
bb07823d
PMF
2295 relay_buf = rchan->buf;
2296 ltt_buf = channel->buf;
e1152c37
PMF
2297
2298 printk(KERN_ERR "Error in LTT usertrace : "
2299 "buffer full : event lost in blocking "
2300 "mode. Increase LTT_RESERVE_CRITICAL.\n");
bb07823d 2301 printk(KERN_ERR "LTT nesting level is %u.\n", ltt_nesting);
e1152c37
PMF
2302 printk(KERN_ERR "LTT avail size %lu.\n",
2303 dbg->avail_size);
2304 printk(KERN_ERR "avai write : %lu, read : %lu\n",
2305 dbg->write, dbg->read);
2306
2307 dbg->write = local_read(&ltt_buf->offset);
2308 dbg->read = atomic_long_read(&ltt_buf->consumed);
2309
2310 printk(KERN_ERR "LTT cur size %lu.\n",
2311 dbg->write + LTT_RESERVE_CRITICAL + data_size
2312 - SUBBUF_TRUNC(dbg->read, relay_buf->chan));
2313 printk(KERN_ERR "cur write : %lu, read : %lu\n",
2314 dbg->write, dbg->read);
2315}
2316
5f54827b
PMF
2317//ust// static struct ltt_transport ltt_relay_transport = {
2318//ust// .name = "relay",
2319//ust// .owner = THIS_MODULE,
2320//ust// .ops = {
2321//ust// .create_dirs = ltt_relay_create_dirs,
2322//ust// .remove_dirs = ltt_relay_remove_dirs,
2323//ust// .create_channel = ltt_relay_create_channel,
2324//ust// .finish_channel = ltt_relay_finish_channel,
2325//ust// .remove_channel = ltt_relay_remove_channel,
2326//ust// .wakeup_channel = ltt_relay_async_wakeup_chan,
2327//ust// .commit_slot = ltt_relay_commit_slot,
2328//ust// .reserve_slot = ltt_relay_reserve_slot,
2329//ust// .user_blocking = ltt_relay_user_blocking,
2330//ust// .user_errors = ltt_relay_print_user_errors,
2331//ust// },
2332//ust// };
2333
2334static struct ltt_transport ust_relay_transport = {
2335 .name = "ustrelay",
bb07823d 2336//ust// .owner = THIS_MODULE,
e1152c37
PMF
2337 .ops = {
2338 .create_dirs = ltt_relay_create_dirs,
2339 .remove_dirs = ltt_relay_remove_dirs,
2340 .create_channel = ltt_relay_create_channel,
2341 .finish_channel = ltt_relay_finish_channel,
2342 .remove_channel = ltt_relay_remove_channel,
2343 .wakeup_channel = ltt_relay_async_wakeup_chan,
2344 .commit_slot = ltt_relay_commit_slot,
2345 .reserve_slot = ltt_relay_reserve_slot,
2346 .user_blocking = ltt_relay_user_blocking,
2347 .user_errors = ltt_relay_print_user_errors,
2348 },
2349};
2350
5f54827b
PMF
2351//ust// static int __init ltt_relay_init(void)
2352//ust// {
2353//ust// printk(KERN_INFO "LTT : ltt-relay init\n");
2354//ust//
2355//ust// ltt_file_operations = ltt_relay_file_operations;
2356//ust// ltt_file_operations.owner = THIS_MODULE;
2357//ust// ltt_file_operations.open = ltt_open;
2358//ust// ltt_file_operations.release = ltt_release;
2359//ust// ltt_file_operations.poll = ltt_poll;
2360//ust// ltt_file_operations.splice_read = ltt_relay_file_splice_read,
2361//ust// ltt_file_operations.ioctl = ltt_ioctl;
2362//ust//#ifdef CONFIG_COMPAT
2363//ust// ltt_file_operations.compat_ioctl = ltt_compat_ioctl;
2364//ust//#endif
2365//ust//
2366//ust// ltt_transport_register(&ltt_relay_transport);
2367//ust//
2368//ust// return 0;
2369//ust// }
2370
2371void init_ustrelay_transport(void)
e1152c37 2372{
5f54827b 2373 ltt_transport_register(&ust_relay_transport);
e1152c37
PMF
2374}
2375
2376static void __exit ltt_relay_exit(void)
2377{
5f54827b 2378//ust// printk(KERN_INFO "LTT : ltt-relay exit\n");
e1152c37 2379
bb07823d 2380 ltt_transport_unregister(&ust_relay_transport);
e1152c37
PMF
2381}
2382
5f54827b
PMF
2383//ust// module_init(ltt_relay_init);
2384//ust// module_exit(ltt_relay_exit);
2385//ust//
2386//ust// MODULE_LICENSE("GPL");
2387//ust// MODULE_AUTHOR("Mathieu Desnoyers");
2388//ust// MODULE_DESCRIPTION("Linux Trace Toolkit Next Generation Lockless Relay");
This page took 0.112637 seconds and 4 git commands to generate.