From 23c1c6557af76d506a28bcb3e864d3500e6dc565 Mon Sep 17 00:00:00 2001 From: David Smith Date: Tue, 24 Feb 2009 11:54:16 -0600 Subject: Major hacking to minimal config. 2009-02-24 David Smith * print.h: New file. * print.c: Includes new print.h file. * print_new.c (stp_print_flush): Commented out some code that needs replacing. * sym.c: Includes sym.h. * transport/debugfs.c: Includes transport.h. * transport/relayfs.c: Updated _stp_get_root_dir() call. * transport/transport.c: Ifdef'ed out most setup. * transport/transport.h: Ifdef'ed out all but basics. * transport/utt.c (utt_create_tree): Updated _stp_get_root_dir() call. * transport/utt.h: Commented out 'rchan' in struct utt_trace. (utt_reserve): Ifdef'ed out guts. --- runtime/print_new.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'runtime/print_new.c') diff --git a/runtime/print_new.c b/runtime/print_new.c index fa7b4727..43e37822 100644 --- a/runtime/print_new.c +++ b/runtime/print_new.c @@ -28,8 +28,9 @@ void EXPORT_FN(stp_print_flush) (_stp_pbuf *pb) pb->len = 0; - if (unlikely(!_stp_utt || _stp_utt->trace_state != Utt_trace_running)) - return; +//DRS FIXME: this digs down too deep in internals +// if (unlikely(!_stp_utt || _stp_utt->trace_state != Utt_trace_running)) +// return; #ifdef STP_BULKMODE { -- cgit From 64c962fed5f50a7f82f8b570e000cdcff757862b Mon Sep 17 00:00:00 2001 From: David Smith Date: Wed, 25 Feb 2009 09:04:19 -0600 Subject: More cleanup. 2009-02-25 David Smith * debug.h: Removed unused variable '_stp_transport_state'. * print_new.c (stp_print_flush): Ifdef'ed out call to utt_reserve(). * runtime.h: Added _stp_warn() prototype. * transport/control.c: Includes control.h, mempool.c, and symbols.c. Renamed '_stp_attached' to '_stp_ctl_attached'. * transport/control.h: Removed _stp_pool_q declaration. * transport/debugfs.c (_stp_register_ctl_channel_fs): Uses _stp_get_module_dir(). * transport/transport.c: Cleanup. * transport/transport.h: Ditto. --- runtime/print_new.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'runtime/print_new.c') diff --git a/runtime/print_new.c b/runtime/print_new.c index 43e37822..bebaa19c 100644 --- a/runtime/print_new.c +++ b/runtime/print_new.c @@ -57,7 +57,11 @@ void EXPORT_FN(stp_print_flush) (_stp_pbuf *pb) void *buf; unsigned long flags; spin_lock_irqsave(&_stp_print_lock, flags); +#if 0 buf = utt_reserve(_stp_utt, len); +#else + buf = NULL; +#endif if (likely(buf)) memcpy(buf, pb->buf, len); else -- cgit From eb3101a40fe446cffab677a7d117f028bae9afba Mon Sep 17 00:00:00 2001 From: David Smith Date: Mon, 9 Mar 2009 10:06:20 -0500 Subject: First working version that actually produces output. 2009-03-09 David Smith * print_new.c (stp_print_flush): Calls _stp_data_write_reserve() and _stp_data_write_commit(). * transport/ring_buffer.c (__stp_alloc_ring_buffer): Sets up a default buffer size of STP_BUFFER_SIZE; (trace_seq_reset): New function. (peek_next_entry): New function. (__find_next_entry): New function. (find_next_entry_inc): New function. (_stp_data_read_trace): Uses find_next_entry_inc() to get the next entry, then calls _stp_entry_to_user() to copy it to the user's buffer, then calls ring_buffer_consume() to consume it. (_stp_data_write_reserve): New function. (_stp_data_write_commit): New function. * transport/transport.c (_stp_transport_close): Calls functions that were ifdef'ed out. * transport/transport.h (struct _stp_entry): Added _stp_entry definition and _stp_data_write_reserve()/_stp_data_write_commit() prototypes. --- runtime/print_new.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'runtime/print_new.c') diff --git a/runtime/print_new.c b/runtime/print_new.c index bebaa19c..2759ebcf 100644 --- a/runtime/print_new.c +++ b/runtime/print_new.c @@ -23,6 +23,7 @@ void EXPORT_FN(stp_print_flush) (_stp_pbuf *pb) uint32_t len = pb->len; /* check to see if there is anything in the buffer */ + dbug_trans(1, "len = %ud\n", len); if (likely (len == 0)) return; @@ -54,16 +55,16 @@ void EXPORT_FN(stp_print_flush) (_stp_pbuf *pb) } #else { - void *buf; + struct _stp_entry *entry; unsigned long flags; + + dbug_trans(1, "calling _stp_data_write...\n"); spin_lock_irqsave(&_stp_print_lock, flags); -#if 0 - buf = utt_reserve(_stp_utt, len); -#else - buf = NULL; -#endif - if (likely(buf)) - memcpy(buf, pb->buf, len); + entry = _stp_data_write_reserve(len); + if (likely(entry)) { + memcpy(entry->buf, pb->buf, len); + _stp_data_write_commit(entry); + } else atomic_inc (&_stp_transport_failures); spin_unlock_irqrestore(&_stp_print_lock, flags); -- cgit From 49f34ab20c2afd95b6a34a904563d456d6deb1d1 Mon Sep 17 00:00:00 2001 From: David Smith Date: Wed, 11 Mar 2009 12:54:19 -0500 Subject: Handles polling and breaks down large buffers. 2009-03-11 David Smith * print_new.c (stp_print_flush): Breaks up the buffer into smaller pieces (since the ring_buffer likes lots of small events, not one large one). * transport/ring_buffer.c (__stp_alloc_ring_buffer): Reserves space for struct _stp_entry. (_stp_data_poll_trace): New function. (_stp_data_write_commit): Wakes up any tasks waiting on data. --- runtime/print_new.c | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) (limited to 'runtime/print_new.c') diff --git a/runtime/print_new.c b/runtime/print_new.c index 2759ebcf..4e579c37 100644 --- a/runtime/print_new.c +++ b/runtime/print_new.c @@ -60,13 +60,41 @@ void EXPORT_FN(stp_print_flush) (_stp_pbuf *pb) dbug_trans(1, "calling _stp_data_write...\n"); spin_lock_irqsave(&_stp_print_lock, flags); +#if 0 entry = _stp_data_write_reserve(len); if (likely(entry)) { memcpy(entry->buf, pb->buf, len); _stp_data_write_commit(entry); } else - atomic_inc (&_stp_transport_failures); +#endif + { + uint32_t cnt; + char *bufp = pb->buf; + +#define MAX_RESERVE_SIZE (4080 /*BUF_PAGE_SIZE*/ - sizeof(struct _stp_entry) - 8) + while (len > 0) { + if (len > MAX_RESERVE_SIZE) { + len -= MAX_RESERVE_SIZE; + cnt = MAX_RESERVE_SIZE; + } + else { + cnt = len; + len = 0; + } + + entry = _stp_data_write_reserve(cnt); + if (likely(entry)) { + memcpy(entry->buf, bufp, cnt); + _stp_data_write_commit(entry); + bufp += cnt; + } + else { + atomic_inc (&_stp_transport_failures); + break; + } + } + } spin_unlock_irqrestore(&_stp_print_lock, flags); } #endif /* STP_BULKMODE */ -- cgit From 12659e2d5eea60a6c1021effa7776bc8e58bb508 Mon Sep 17 00:00:00 2001 From: David Smith Date: Wed, 11 Mar 2009 16:10:14 -0500 Subject: Small update. 2009-03-11 David Smith * print_new.c (stp_print_flush): Updated MAX_RESERVE_SIZE. * transport/ring_buffer.c (__stp_alloc_ring_buffer): Reserves more space. --- runtime/print_new.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'runtime/print_new.c') diff --git a/runtime/print_new.c b/runtime/print_new.c index 4e579c37..4857b301 100644 --- a/runtime/print_new.c +++ b/runtime/print_new.c @@ -72,7 +72,7 @@ void EXPORT_FN(stp_print_flush) (_stp_pbuf *pb) uint32_t cnt; char *bufp = pb->buf; -#define MAX_RESERVE_SIZE (4080 /*BUF_PAGE_SIZE*/ - sizeof(struct _stp_entry) - 8) +#define MAX_RESERVE_SIZE (4080 /*BUF_PAGE_SIZE*/ - sizeof(struct _stp_entry) - 10) while (len > 0) { if (len > MAX_RESERVE_SIZE) { len -= MAX_RESERVE_SIZE; -- cgit From 7d573b8d318836ef75d1f2888a50da230b7d83cc Mon Sep 17 00:00:00 2001 From: David Smith Date: Fri, 13 Mar 2009 16:48:58 -0500 Subject: Working bulkmode support. 2009-03-13 David Smith * print_new.c (stp_print_flush): Added bulkmode support for new transport. * transport/ring_buffer.c (__stp_find_next_entry): Fixed syntax error in bulkmode code. (_stp_transport_data_fs_init): Changed 'for_each_possible_cpu()' to 'for_each_online_cpu()' so that non-online cpu's won't have a trace file created. --- runtime/print_new.c | 97 +++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 91 insertions(+), 6 deletions(-) (limited to 'runtime/print_new.c') diff --git a/runtime/print_new.c b/runtime/print_new.c index 4857b301..f8749842 100644 --- a/runtime/print_new.c +++ b/runtime/print_new.c @@ -33,15 +33,95 @@ void EXPORT_FN(stp_print_flush) (_stp_pbuf *pb) // if (unlikely(!_stp_utt || _stp_utt->trace_state != Utt_trace_running)) // return; +#define MAX_RESERVE_SIZE (4080 /*BUF_PAGE_SIZE*/ - sizeof(struct _stp_entry) - 10) #ifdef STP_BULKMODE { + struct _stp_entry *entry; #ifdef NO_PERCPU_HEADERS - void *buf = utt_reserve(_stp_utt, len); - if (likely(buf)) - memcpy(buf, pb->buf, len); - else - atomic_inc (&_stp_transport_failures); + { + uint32_t cnt; + char *bufp = pb->buf; + + printk(KERN_ERR "%s:%d - flushing %d(%d) bytes\n", + __FUNCTION__, __LINE__, pb->len, len); + while (len > 0) { + if (len > MAX_RESERVE_SIZE) { + len -= MAX_RESERVE_SIZE; + cnt = MAX_RESERVE_SIZE; + } + else { + cnt = len; + len = 0; + } + + printk(KERN_ERR "%s:%d - reserving %d bytes\n", + __FUNCTION__, __LINE__, cnt); + entry = _stp_data_write_reserve(cnt); + if (likely(entry)) { + memcpy(entry->buf, bufp, cnt); + _stp_data_write_commit(entry); + bufp += cnt; + } + else { + atomic_inc (&_stp_transport_failures); + break; + } + } + } #else + +#undef MAX_RESERVE_SIZE +#define MAX_RESERVE_SIZE (4080 /*BUF_PAGE_SIZE*/ - sizeof(struct _stp_entry) - 10 - sizeof(struct _stp_trace)) + { + uint32_t cnt; + char *bufp = pb->buf; + struct _stp_trace t = { .sequence = _stp_seq_inc(), + .pdu_len = len}; + + printk(KERN_ERR "%s:%d - flushing %d(%d) bytes\n", + __FUNCTION__, __LINE__, pb->len, len); + + entry = _stp_data_write_reserve(sizeof(struct _stp_trace)); + if (likely(entry)) { + /* prevent unaligned access by using + * memcpy() */ + memcpy(entry->buf, &t, sizeof(t)); + _stp_data_write_commit(entry); + } + else { + atomic_inc (&_stp_transport_failures); + return; + } + + while (len > 0) { + if (len > MAX_RESERVE_SIZE) { + len -= MAX_RESERVE_SIZE; + cnt = MAX_RESERVE_SIZE; + } + else { + cnt = len; + len = 0; + } + + printk(KERN_ERR "%s:%d - reserving %d bytes\n", + __FUNCTION__, __LINE__, cnt); + entry = _stp_data_write_reserve(cnt); + if (likely(entry)) { + memcpy(entry->buf, bufp, cnt); + _stp_data_write_commit(entry); + bufp += cnt; + } + else { + atomic_inc (&_stp_transport_failures); + break; + } + } + } + + + + +#if 0 void *buf = utt_reserve(_stp_utt, sizeof(struct _stp_trace) + len); if (likely(buf)) { @@ -51,6 +131,7 @@ void EXPORT_FN(stp_print_flush) (_stp_pbuf *pb) memcpy(buf + sizeof(t), pb->buf, len); } else atomic_inc (&_stp_transport_failures); +#endif #endif } #else @@ -72,7 +153,9 @@ void EXPORT_FN(stp_print_flush) (_stp_pbuf *pb) uint32_t cnt; char *bufp = pb->buf; -#define MAX_RESERVE_SIZE (4080 /*BUF_PAGE_SIZE*/ - sizeof(struct _stp_entry) - 10) +//#define MAX_RESERVE_SIZE (4080 /*BUF_PAGE_SIZE*/ - sizeof(struct _stp_entry) - 10) + printk(KERN_ERR "%s:%d - flushing %d(%d) bytes\n", + __FUNCTION__, __LINE__, pb->len, len); while (len > 0) { if (len > MAX_RESERVE_SIZE) { len -= MAX_RESERVE_SIZE; @@ -83,6 +166,8 @@ void EXPORT_FN(stp_print_flush) (_stp_pbuf *pb) len = 0; } + printk(KERN_ERR "%s:%d - reserving %d bytes\n", + __FUNCTION__, __LINE__, cnt); entry = _stp_data_write_reserve(cnt); if (likely(entry)) { memcpy(entry->buf, bufp, cnt); -- cgit From 8f47173deb9aa146b388542116d2638ed04fb03a Mon Sep 17 00:00:00 2001 From: David Smith Date: Mon, 30 Mar 2009 15:12:27 -0500 Subject: 2009-03-30 David Smith * print_new.c: Whitespace/indent changes only. --- runtime/print_new.c | 168 ++++++++++++++++++++++++---------------------------- 1 file changed, 79 insertions(+), 89 deletions(-) (limited to 'runtime/print_new.c') diff --git a/runtime/print_new.c b/runtime/print_new.c index f8749842..01bbe809 100644 --- a/runtime/print_new.c +++ b/runtime/print_new.c @@ -21,6 +21,7 @@ static DEFINE_SPINLOCK(_stp_print_lock); void EXPORT_FN(stp_print_flush) (_stp_pbuf *pb) { uint32_t len = pb->len; + struct _stp_entry *entry; /* check to see if there is anything in the buffer */ dbug_trans(1, "len = %ud\n", len); @@ -35,125 +36,114 @@ void EXPORT_FN(stp_print_flush) (_stp_pbuf *pb) #define MAX_RESERVE_SIZE (4080 /*BUF_PAGE_SIZE*/ - sizeof(struct _stp_entry) - 10) #ifdef STP_BULKMODE - { - struct _stp_entry *entry; #ifdef NO_PERCPU_HEADERS - { - uint32_t cnt; - char *bufp = pb->buf; - - printk(KERN_ERR "%s:%d - flushing %d(%d) bytes\n", - __FUNCTION__, __LINE__, pb->len, len); - while (len > 0) { - if (len > MAX_RESERVE_SIZE) { - len -= MAX_RESERVE_SIZE; - cnt = MAX_RESERVE_SIZE; - } - else { - cnt = len; - len = 0; - } + { + uint32_t cnt; + char *bufp = pb->buf; + + printk(KERN_ERR "%s:%d - flushing %d(%d) bytes\n", + __FUNCTION__, __LINE__, pb->len, len); + while (len > 0) { + if (len > MAX_RESERVE_SIZE) { + len -= MAX_RESERVE_SIZE; + cnt = MAX_RESERVE_SIZE; + } + else { + cnt = len; + len = 0; + } - printk(KERN_ERR "%s:%d - reserving %d bytes\n", - __FUNCTION__, __LINE__, cnt); - entry = _stp_data_write_reserve(cnt); - if (likely(entry)) { - memcpy(entry->buf, bufp, cnt); - _stp_data_write_commit(entry); - bufp += cnt; - } - else { - atomic_inc (&_stp_transport_failures); - break; - } + printk(KERN_ERR "%s:%d - reserving %d bytes\n", + __FUNCTION__, __LINE__, cnt); + entry = _stp_data_write_reserve(cnt); + if (likely(entry)) { + memcpy(entry->buf, bufp, cnt); + _stp_data_write_commit(entry); + bufp += cnt; + } + else { + atomic_inc (&_stp_transport_failures); + break; } } -#else + } + +#else /* !NO_PERCPU_HEADERS */ #undef MAX_RESERVE_SIZE #define MAX_RESERVE_SIZE (4080 /*BUF_PAGE_SIZE*/ - sizeof(struct _stp_entry) - 10 - sizeof(struct _stp_trace)) - { - uint32_t cnt; - char *bufp = pb->buf; - struct _stp_trace t = { .sequence = _stp_seq_inc(), - .pdu_len = len}; + { + uint32_t cnt; + char *bufp = pb->buf; + struct _stp_trace t = { .sequence = _stp_seq_inc(), + .pdu_len = len}; - printk(KERN_ERR "%s:%d - flushing %d(%d) bytes\n", - __FUNCTION__, __LINE__, pb->len, len); + printk(KERN_ERR "%s:%d - flushing %d(%d) bytes\n", + __FUNCTION__, __LINE__, pb->len, len); + + entry = _stp_data_write_reserve(sizeof(struct _stp_trace)); + if (likely(entry)) { + /* prevent unaligned access by using memcpy() */ + memcpy(entry->buf, &t, sizeof(t)); + _stp_data_write_commit(entry); + } + else { + atomic_inc (&_stp_transport_failures); + return; + } + + while (len > 0) { + if (len > MAX_RESERVE_SIZE) { + len -= MAX_RESERVE_SIZE; + cnt = MAX_RESERVE_SIZE; + } + else { + cnt = len; + len = 0; + } - entry = _stp_data_write_reserve(sizeof(struct _stp_trace)); + printk(KERN_ERR "%s:%d - reserving %d bytes\n", + __FUNCTION__, __LINE__, cnt); + entry = _stp_data_write_reserve(cnt); if (likely(entry)) { - /* prevent unaligned access by using - * memcpy() */ - memcpy(entry->buf, &t, sizeof(t)); + memcpy(entry->buf, bufp, cnt); _stp_data_write_commit(entry); + bufp += cnt; } else { atomic_inc (&_stp_transport_failures); - return; - } - - while (len > 0) { - if (len > MAX_RESERVE_SIZE) { - len -= MAX_RESERVE_SIZE; - cnt = MAX_RESERVE_SIZE; - } - else { - cnt = len; - len = 0; - } - - printk(KERN_ERR "%s:%d - reserving %d bytes\n", - __FUNCTION__, __LINE__, cnt); - entry = _stp_data_write_reserve(cnt); - if (likely(entry)) { - memcpy(entry->buf, bufp, cnt); - _stp_data_write_commit(entry); - bufp += cnt; - } - else { - atomic_inc (&_stp_transport_failures); - break; - } + break; } } + } #if 0 - void *buf = utt_reserve(_stp_utt, - sizeof(struct _stp_trace) + len); - if (likely(buf)) { - struct _stp_trace t = { .sequence = _stp_seq_inc(), - .pdu_len = len}; - memcpy(buf, &t, sizeof(t)); // prevent unaligned access - memcpy(buf + sizeof(t), pb->buf, len); - } else - atomic_inc (&_stp_transport_failures); -#endif + /* original code */ + void *buf = utt_reserve(_stp_utt, + sizeof(struct _stp_trace) + len); + if (likely(buf)) { + struct _stp_trace t = { .sequence = _stp_seq_inc(), + .pdu_len = len}; + memcpy(buf, &t, sizeof(t)); // prevent unaligned access + memcpy(buf + sizeof(t), pb->buf, len); + } else + atomic_inc (&_stp_transport_failures); #endif - } -#else + +#endif /* !NO_PERCPU_HEADERS */ +#else /* !STP_BULKMODE */ { - struct _stp_entry *entry; unsigned long flags; dbug_trans(1, "calling _stp_data_write...\n"); spin_lock_irqsave(&_stp_print_lock, flags); -#if 0 - entry = _stp_data_write_reserve(len); - if (likely(entry)) { - memcpy(entry->buf, pb->buf, len); - _stp_data_write_commit(entry); - } - else -#endif { uint32_t cnt; char *bufp = pb->buf; -//#define MAX_RESERVE_SIZE (4080 /*BUF_PAGE_SIZE*/ - sizeof(struct _stp_entry) - 10) printk(KERN_ERR "%s:%d - flushing %d(%d) bytes\n", __FUNCTION__, __LINE__, pb->len, len); while (len > 0) { @@ -182,5 +172,5 @@ void EXPORT_FN(stp_print_flush) (_stp_pbuf *pb) } spin_unlock_irqrestore(&_stp_print_lock, flags); } -#endif /* STP_BULKMODE */ +#endif /* !STP_BULKMODE */ } -- cgit From 2e07d704dc5d7304d6a9e666553a1a8ac4382730 Mon Sep 17 00:00:00 2001 From: David Smith Date: Tue, 31 Mar 2009 12:02:25 -0500 Subject: 2009-03-31 David Smith * print_new.c (stp_print_flush): Pushed MAX_RESERVE logic down to _stp_data_write_reserve(). Now just keeps calling _stp_data_write_reserve() until it has written the entire print buffer. * transport/ring_buffer.c (_stp_data_write_reserve): Breaks large reserve requests down into smaller ones for better buffer use. Returns the number of bytes reserved. * transport/transport.h: Updated _stp_data_write_reserve() prototype. --- runtime/print_new.c | 132 +++++++++++++++------------------------------------- 1 file changed, 37 insertions(+), 95 deletions(-) (limited to 'runtime/print_new.c') diff --git a/runtime/print_new.c b/runtime/print_new.c index 01bbe809..86c44ea7 100644 --- a/runtime/print_new.c +++ b/runtime/print_new.c @@ -18,14 +18,14 @@ static DEFINE_SPINLOCK(_stp_print_lock); -void EXPORT_FN(stp_print_flush) (_stp_pbuf *pb) +void EXPORT_FN(stp_print_flush)(_stp_pbuf *pb) { - uint32_t len = pb->len; - struct _stp_entry *entry; + size_t len = pb->len; + struct _stp_entry *entry = NULL; /* check to see if there is anything in the buffer */ - dbug_trans(1, "len = %ud\n", len); - if (likely (len == 0)) + dbug_trans(1, "len = %zu\n", len); + if (likely(len == 0)) return; pb->len = 0; @@ -34,35 +34,23 @@ void EXPORT_FN(stp_print_flush) (_stp_pbuf *pb) // if (unlikely(!_stp_utt || _stp_utt->trace_state != Utt_trace_running)) // return; -#define MAX_RESERVE_SIZE (4080 /*BUF_PAGE_SIZE*/ - sizeof(struct _stp_entry) - 10) #ifdef STP_BULKMODE #ifdef NO_PERCPU_HEADERS { - uint32_t cnt; char *bufp = pb->buf; - printk(KERN_ERR "%s:%d - flushing %d(%d) bytes\n", - __FUNCTION__, __LINE__, pb->len, len); while (len > 0) { - if (len > MAX_RESERVE_SIZE) { - len -= MAX_RESERVE_SIZE; - cnt = MAX_RESERVE_SIZE; - } - else { - cnt = len; - len = 0; - } + size_t bytes_reserved; - printk(KERN_ERR "%s:%d - reserving %d bytes\n", - __FUNCTION__, __LINE__, cnt); - entry = _stp_data_write_reserve(cnt); - if (likely(entry)) { - memcpy(entry->buf, bufp, cnt); + bytes_reserved = _stp_data_write_reserve(len, &entry); + if (likely(entry && bytes_reserved > 0)) { + memcpy(entry->buf, bufp, bytes_reserved); _stp_data_write_commit(entry); - bufp += cnt; + bufp += bytes_reserved; + len -= bytes_reserved; } else { - atomic_inc (&_stp_transport_failures); + atomic_inc(&_stp_transport_failures); break; } } @@ -70,104 +58,58 @@ void EXPORT_FN(stp_print_flush) (_stp_pbuf *pb) #else /* !NO_PERCPU_HEADERS */ -#undef MAX_RESERVE_SIZE -#define MAX_RESERVE_SIZE (4080 /*BUF_PAGE_SIZE*/ - sizeof(struct _stp_entry) - 10 - sizeof(struct _stp_trace)) { - uint32_t cnt; char *bufp = pb->buf; struct _stp_trace t = { .sequence = _stp_seq_inc(), .pdu_len = len}; + size_t bytes_reserved; - printk(KERN_ERR "%s:%d - flushing %d(%d) bytes\n", - __FUNCTION__, __LINE__, pb->len, len); - - entry = _stp_data_write_reserve(sizeof(struct _stp_trace)); - if (likely(entry)) { + bytes_reserved = _stp_data_write_reserve(sizeof(struct _stp_trace), &entry); + if (likely(entry && bytes_reserved > 0)) { /* prevent unaligned access by using memcpy() */ memcpy(entry->buf, &t, sizeof(t)); _stp_data_write_commit(entry); } else { - atomic_inc (&_stp_transport_failures); + atomic_inc(&_stp_transport_failures); return; } while (len > 0) { - if (len > MAX_RESERVE_SIZE) { - len -= MAX_RESERVE_SIZE; - cnt = MAX_RESERVE_SIZE; - } - else { - cnt = len; - len = 0; - } - - printk(KERN_ERR "%s:%d - reserving %d bytes\n", - __FUNCTION__, __LINE__, cnt); - entry = _stp_data_write_reserve(cnt); - if (likely(entry)) { - memcpy(entry->buf, bufp, cnt); + bytes_reserved = _stp_data_write_reserve(len, &entry); + if (likely(entry && bytes_reserved > 0)) { + memcpy(entry->buf, bufp, bytes_reserved); _stp_data_write_commit(entry); - bufp += cnt; + bufp += bytes_reserved; + len -= bytes_reserved; } else { - atomic_inc (&_stp_transport_failures); + atomic_inc(&_stp_transport_failures); break; } } } - - - - -#if 0 - /* original code */ - void *buf = utt_reserve(_stp_utt, - sizeof(struct _stp_trace) + len); - if (likely(buf)) { - struct _stp_trace t = { .sequence = _stp_seq_inc(), - .pdu_len = len}; - memcpy(buf, &t, sizeof(t)); // prevent unaligned access - memcpy(buf + sizeof(t), pb->buf, len); - } else - atomic_inc (&_stp_transport_failures); -#endif - -#endif /* !NO_PERCPU_HEADERS */ -#else /* !STP_BULKMODE */ +#endif /* !NO_PERCPU_HEADERS */ +#else /* !STP_BULKMODE */ { unsigned long flags; + char *bufp = pb->buf; dbug_trans(1, "calling _stp_data_write...\n"); spin_lock_irqsave(&_stp_print_lock, flags); - { - uint32_t cnt; - char *bufp = pb->buf; - - printk(KERN_ERR "%s:%d - flushing %d(%d) bytes\n", - __FUNCTION__, __LINE__, pb->len, len); - while (len > 0) { - if (len > MAX_RESERVE_SIZE) { - len -= MAX_RESERVE_SIZE; - cnt = MAX_RESERVE_SIZE; - } - else { - cnt = len; - len = 0; - } + while (len > 0) { + size_t bytes_reserved; - printk(KERN_ERR "%s:%d - reserving %d bytes\n", - __FUNCTION__, __LINE__, cnt); - entry = _stp_data_write_reserve(cnt); - if (likely(entry)) { - memcpy(entry->buf, bufp, cnt); - _stp_data_write_commit(entry); - bufp += cnt; - } - else { - atomic_inc (&_stp_transport_failures); - break; - } + bytes_reserved = _stp_data_write_reserve(len, &entry); + if (likely(entry && bytes_reserved > 0)) { + memcpy(entry->buf, bufp, bytes_reserved); + _stp_data_write_commit(entry); + bufp += bytes_reserved; + len -= bytes_reserved; + } + else { + atomic_inc(&_stp_transport_failures); + break; } } spin_unlock_irqrestore(&_stp_print_lock, flags); -- cgit From 6edf848ad0053423dd3b06851ab8d62a260a56e8 Mon Sep 17 00:00:00 2001 From: David Smith Date: Thu, 7 May 2009 15:02:05 -0500 Subject: Hid details of internal ring_buffer.c structure. * runtime/print_new.c (stp_print_flush): Calls _stp_data_entry_data() to get data pointer. * runtime/transport/transport.h: Removed _stp_entry definition. Added _stp_data_entry_data() declaration. * runtime/transport/ring_buffer.c: Uses new _stp_data_entry structure. (_stp_data_entry_data): Added. --- runtime/print_new.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'runtime/print_new.c') diff --git a/runtime/print_new.c b/runtime/print_new.c index 86c44ea7..b6187978 100644 --- a/runtime/print_new.c +++ b/runtime/print_new.c @@ -21,7 +21,7 @@ static DEFINE_SPINLOCK(_stp_print_lock); void EXPORT_FN(stp_print_flush)(_stp_pbuf *pb) { size_t len = pb->len; - struct _stp_entry *entry = NULL; + void *entry = NULL; /* check to see if there is anything in the buffer */ dbug_trans(1, "len = %zu\n", len); @@ -44,7 +44,8 @@ void EXPORT_FN(stp_print_flush)(_stp_pbuf *pb) bytes_reserved = _stp_data_write_reserve(len, &entry); if (likely(entry && bytes_reserved > 0)) { - memcpy(entry->buf, bufp, bytes_reserved); + memcpy(_stp_data_entry_data(entry), bufp, + bytes_reserved); _stp_data_write_commit(entry); bufp += bytes_reserved; len -= bytes_reserved; @@ -67,7 +68,7 @@ void EXPORT_FN(stp_print_flush)(_stp_pbuf *pb) bytes_reserved = _stp_data_write_reserve(sizeof(struct _stp_trace), &entry); if (likely(entry && bytes_reserved > 0)) { /* prevent unaligned access by using memcpy() */ - memcpy(entry->buf, &t, sizeof(t)); + memcpy(_stp_data_entry_data(entry), &t, sizeof(t)); _stp_data_write_commit(entry); } else { @@ -78,7 +79,8 @@ void EXPORT_FN(stp_print_flush)(_stp_pbuf *pb) while (len > 0) { bytes_reserved = _stp_data_write_reserve(len, &entry); if (likely(entry && bytes_reserved > 0)) { - memcpy(entry->buf, bufp, bytes_reserved); + memcpy(_stp_data_entry_data(entry), bufp, + bytes_reserved); _stp_data_write_commit(entry); bufp += bytes_reserved; len -= bytes_reserved; @@ -102,7 +104,8 @@ void EXPORT_FN(stp_print_flush)(_stp_pbuf *pb) bytes_reserved = _stp_data_write_reserve(len, &entry); if (likely(entry && bytes_reserved > 0)) { - memcpy(entry->buf, bufp, bytes_reserved); + memcpy(_stp_data_entry_data(entry), bufp, + bytes_reserved); _stp_data_write_commit(entry); bufp += bytes_reserved; len -= bytes_reserved; -- cgit From dd9a3bcbef65bde65491d959e9458bc641924811 Mon Sep 17 00:00:00 2001 From: David Smith Date: Tue, 12 May 2009 13:38:48 -0500 Subject: Start at supporting the original transport (STP_TRANSPORT_VERSION=1). * runtime/print.c: Only use print_new.c. * runtime/print_new.c (stp_print_flush): Add STP_TRANSPORT_VERSION 1 support. * runtime/transport/transport.c: Removed inclusion of procfs.c. * runtime/transport/procfs.c (_stp_proc_read): Adapt to new interface. (_stp_proc_write): Ditto. * runtime/transport/relayfs.c: Ditto. --- runtime/print_new.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'runtime/print_new.c') diff --git a/runtime/print_new.c b/runtime/print_new.c index b6187978..2d5a6e10 100644 --- a/runtime/print_new.c +++ b/runtime/print_new.c @@ -92,7 +92,15 @@ void EXPORT_FN(stp_print_flush)(_stp_pbuf *pb) } } #endif /* !NO_PERCPU_HEADERS */ + #else /* !STP_BULKMODE */ + +#if STP_TRANSPORT_VERSION == 1 + + if (unlikely(_stp_ctl_write(STP_REALTIME_DATA, pb->buf, len) <= 0)) + atomic_inc (&_stp_transport_failures); + +#else /* STP_TRANSPORT_VERSION != 1 */ { unsigned long flags; char *bufp = pb->buf; @@ -117,5 +125,6 @@ void EXPORT_FN(stp_print_flush)(_stp_pbuf *pb) } spin_unlock_irqrestore(&_stp_print_lock, flags); } +#endif /* STP_TRANSPORT_VERSION != 1 */ #endif /* !STP_BULKMODE */ } -- cgit From 7b1be319b40ec791c4fdbe77065204a4c3ed439b Mon Sep 17 00:00:00 2001 From: David Smith Date: Thu, 18 Jun 2009 16:42:35 -0500 Subject: Transports now export their state. * runtime/transport/transport.h: Added prototype for _stp_transport_get_state(). * runtime/transport/relay_v2.c (_stp_transport_get_state): New function. * runtime/transport/relayfs.c (_stp_transport_get_state): Ditto. * runtime/transport/ring_buffer.c (_stp_transport_data_fs_init): Sets state. (_stp_transport_data_fs_start): Ditto. (_stp_transport_data_fs_stop): Ditto. (_stp_transport_get_state): Returns state. * runtime/print_new.c (stp_print_flush): Checks transport state before trying to flush. --- runtime/print_new.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'runtime/print_new.c') diff --git a/runtime/print_new.c b/runtime/print_new.c index 2d5a6e10..52017426 100644 --- a/runtime/print_new.c +++ b/runtime/print_new.c @@ -30,9 +30,8 @@ void EXPORT_FN(stp_print_flush)(_stp_pbuf *pb) pb->len = 0; -//DRS FIXME: this digs down too deep in internals -// if (unlikely(!_stp_utt || _stp_utt->trace_state != Utt_trace_running)) -// return; + if (unlikely(_stp_transport_get_state() != STP_TRANSPORT_RUNNING)) + return; #ifdef STP_BULKMODE #ifdef NO_PERCPU_HEADERS -- cgit From ac4f1eca71edee2feb2cbdad1a044549f30da023 Mon Sep 17 00:00:00 2001 From: David Smith Date: Thu, 18 Jun 2009 16:49:59 -0500 Subject: Cleanup. * runtime/print_old.c: Removed unneeded file. * runtime/print_flush.c: Renamed from print_new.c * runtime/print.c: Includes print_flush.c (instead of print_new.c). --- runtime/print_new.c | 129 ---------------------------------------------------- 1 file changed, 129 deletions(-) delete mode 100644 runtime/print_new.c (limited to 'runtime/print_new.c') diff --git a/runtime/print_new.c b/runtime/print_new.c deleted file mode 100644 index 52017426..00000000 --- a/runtime/print_new.c +++ /dev/null @@ -1,129 +0,0 @@ -/* -*- linux-c -*- - * Print Flush Function - * Copyright (C) 2007-2008 Red Hat Inc. - * - * This file is part of systemtap, and is free software. You can - * redistribute it and/or modify it under the terms of the GNU General - * Public License (GPL); either version 2, or (at your option) any - * later version. - */ - -/** Send the print buffer to the transport now. - * Output accumulates in the print buffer until it - * is filled, or this is called. This MUST be called before returning - * from a probe or accumulated output in the print buffer will be lost. - * - * @note Preemption must be disabled to use this. - */ - -static DEFINE_SPINLOCK(_stp_print_lock); - -void EXPORT_FN(stp_print_flush)(_stp_pbuf *pb) -{ - size_t len = pb->len; - void *entry = NULL; - - /* check to see if there is anything in the buffer */ - dbug_trans(1, "len = %zu\n", len); - if (likely(len == 0)) - return; - - pb->len = 0; - - if (unlikely(_stp_transport_get_state() != STP_TRANSPORT_RUNNING)) - return; - -#ifdef STP_BULKMODE -#ifdef NO_PERCPU_HEADERS - { - char *bufp = pb->buf; - - while (len > 0) { - size_t bytes_reserved; - - bytes_reserved = _stp_data_write_reserve(len, &entry); - if (likely(entry && bytes_reserved > 0)) { - memcpy(_stp_data_entry_data(entry), bufp, - bytes_reserved); - _stp_data_write_commit(entry); - bufp += bytes_reserved; - len -= bytes_reserved; - } - else { - atomic_inc(&_stp_transport_failures); - break; - } - } - } - -#else /* !NO_PERCPU_HEADERS */ - - { - char *bufp = pb->buf; - struct _stp_trace t = { .sequence = _stp_seq_inc(), - .pdu_len = len}; - size_t bytes_reserved; - - bytes_reserved = _stp_data_write_reserve(sizeof(struct _stp_trace), &entry); - if (likely(entry && bytes_reserved > 0)) { - /* prevent unaligned access by using memcpy() */ - memcpy(_stp_data_entry_data(entry), &t, sizeof(t)); - _stp_data_write_commit(entry); - } - else { - atomic_inc(&_stp_transport_failures); - return; - } - - while (len > 0) { - bytes_reserved = _stp_data_write_reserve(len, &entry); - if (likely(entry && bytes_reserved > 0)) { - memcpy(_stp_data_entry_data(entry), bufp, - bytes_reserved); - _stp_data_write_commit(entry); - bufp += bytes_reserved; - len -= bytes_reserved; - } - else { - atomic_inc(&_stp_transport_failures); - break; - } - } - } -#endif /* !NO_PERCPU_HEADERS */ - -#else /* !STP_BULKMODE */ - -#if STP_TRANSPORT_VERSION == 1 - - if (unlikely(_stp_ctl_write(STP_REALTIME_DATA, pb->buf, len) <= 0)) - atomic_inc (&_stp_transport_failures); - -#else /* STP_TRANSPORT_VERSION != 1 */ - { - unsigned long flags; - char *bufp = pb->buf; - - dbug_trans(1, "calling _stp_data_write...\n"); - spin_lock_irqsave(&_stp_print_lock, flags); - while (len > 0) { - size_t bytes_reserved; - - bytes_reserved = _stp_data_write_reserve(len, &entry); - if (likely(entry && bytes_reserved > 0)) { - memcpy(_stp_data_entry_data(entry), bufp, - bytes_reserved); - _stp_data_write_commit(entry); - bufp += bytes_reserved; - len -= bytes_reserved; - } - else { - atomic_inc(&_stp_transport_failures); - break; - } - } - spin_unlock_irqrestore(&_stp_print_lock, flags); - } -#endif /* STP_TRANSPORT_VERSION != 1 */ -#endif /* !STP_BULKMODE */ -} -- cgit