From d4c8882bf01716b2f0ef75292c0c8f888fde9712 Mon Sep 17 00:00:00 2001 From: compudj Date: Thu, 9 Nov 2006 17:37:02 +0000 Subject: [PATCH] irq test git-svn-id: http://ltt.polymtl.ca/svn@2247 04897980-b3bd-0310-b5e0-8ef037075253 --- tests/kernel/Makefile | 9 +- tests/kernel/ltt-facility-id-tests.h | 4 +- tests/kernel/ltt-facility-loader-tests.c | 2 +- tests/kernel/ltt-facility-loader-tests.h | 12 +- tests/kernel/ltt-facility-tests.h | 495 ++--------------------- tests/kernel/test-cmpxchg-nolock.c | 4 +- 6 files changed, 41 insertions(+), 485 deletions(-) diff --git a/tests/kernel/Makefile b/tests/kernel/Makefile index b928b684..3cba56ad 100644 --- a/tests/kernel/Makefile +++ b/tests/kernel/Makefile @@ -1,15 +1,15 @@ ifneq ($(KERNELRELEASE),) ifneq ($(CONFIG_LTT),) -# obj-m += ltt-facility-loader-tests.o + obj-m += ltt-facility-loader-tests.o # obj-m += test-time-probe.o -# obj-m += test-time-probe2.o + obj-m += test-time-probe2.o # obj-m += test-instrument-size-small.o # obj-m += test-instrument-size-med.o # obj-m += test-instrument-size-big.o # obj-m += test-printk-effect.o endif -# obj-m += test-cmpxchg.o -# obj-m += test-cmpxchg-nolock.o + obj-m += test-cmpxchg.o + obj-m += test-cmpxchg-nolock.o # obj-m += test-spinlock.o # obj-m += test-inc.o # obj-m += test-inc-nolock.o @@ -21,6 +21,7 @@ endif #obj-m += test-debugfs.o obj-m += test-mark.o obj-m += probe.o + obj-m += test-irqloop.o #obj-m += marker-loader.o #obj-m += test-linuxtrace.o diff --git a/tests/kernel/ltt-facility-id-tests.h b/tests/kernel/ltt-facility-id-tests.h index ba107442..651b06c4 100644 --- a/tests/kernel/ltt-facility-id-tests.h +++ b/tests/kernel/ltt-facility-id-tests.h @@ -6,7 +6,7 @@ /**** facility handle ****/ -extern ltt_facility_t ltt_facility_tests_2F06D8DB; +extern ltt_facility_t ltt_facility_tests_CA7F1536; extern ltt_facility_t ltt_facility_tests; @@ -14,8 +14,6 @@ extern ltt_facility_t ltt_facility_tests; enum tests_event { event_tests_write_4bytes, - event_tests_write_string, - event_tests_write_struct, facility_tests_num_events }; diff --git a/tests/kernel/ltt-facility-loader-tests.c b/tests/kernel/ltt-facility-loader-tests.c index 3a232c7f..218d623a 100644 --- a/tests/kernel/ltt-facility-loader-tests.c +++ b/tests/kernel/ltt-facility-loader-tests.c @@ -51,7 +51,7 @@ static void __exit facility_exit(void) int err; err = ltt_facility_unregister(LTT_FACILITY_SYMBOL); - if(err != 0) + if (err != 0) printk(KERN_ERR "LTT : Error in unregistering facility.\n"); } diff --git a/tests/kernel/ltt-facility-loader-tests.h b/tests/kernel/ltt-facility-loader-tests.h index bf161480..a70e7c3d 100644 --- a/tests/kernel/ltt-facility-loader-tests.h +++ b/tests/kernel/ltt-facility-loader-tests.h @@ -7,13 +7,13 @@ #include "ltt-facility-id-tests.h" ltt_facility_t ltt_facility_tests; -ltt_facility_t ltt_facility_tests_2F06D8DB; +ltt_facility_t ltt_facility_tests_CA7F1536; -#define LTT_FACILITY_SYMBOL ltt_facility_tests -#define LTT_FACILITY_CHECKSUM_SYMBOL ltt_facility_tests_2F06D8DB -#define LTT_FACILITY_CHECKSUM 0x2F06D8DB -#define LTT_FACILITY_NAME "tests" -#define LTT_FACILITY_NUM_EVENTS facility_tests_num_events +#define LTT_FACILITY_SYMBOL ltt_facility_tests +#define LTT_FACILITY_CHECKSUM_SYMBOL ltt_facility_tests_CA7F1536 +#define LTT_FACILITY_CHECKSUM 0xCA7F1536 +#define LTT_FACILITY_NAME "tests" +#define LTT_FACILITY_NUM_EVENTS facility_tests_num_events #endif //CONFIG_LTT diff --git a/tests/kernel/ltt-facility-tests.h b/tests/kernel/ltt-facility-tests.h index a0aa42e1..f28b4238 100644 --- a/tests/kernel/ltt-facility-tests.h +++ b/tests/kernel/ltt-facility-tests.h @@ -1,9 +1,12 @@ #ifndef _LTT_FACILITY_TESTS_H_ #define _LTT_FACILITY_TESTS_H_ + #include #include "ltt-facility-id-tests.h" -#include +#include + +#define ltt_get_index_from_facility_tests ltt_get_index_from_facility /* Named types */ @@ -11,17 +14,13 @@ /* Event write_4bytes logging function */ static inline void trace_tests_write_4bytes( - int lttng_param_data) -#if (!defined(CONFIG_LTT) || !defined(CONFIG_LTT_FACILITY_TESTS)) -{ -} -#else + unsigned int lttng_param_value) { unsigned int index; struct ltt_channel_struct *channel; struct ltt_trace_struct *trace; - struct rchan_buf *relayfs_buf; - void *buffer = NULL; + void *transport_data; + char *buffer = NULL; size_t real_to_base = 0; /* The buffer is allocated on arch_size alignment */ size_t *to_base = &real_to_base; size_t real_to = 0; @@ -31,329 +30,23 @@ static inline void trace_tests_write_4bytes( size_t reserve_size; size_t slot_size; size_t align; - const void *real_from; - const void **from = &real_from; - u64 tsc; - size_t before_hdr_pad, after_hdr_pad, header_size; - - if(ltt_traces.num_active_traces == 0) return; - - /* For each field, calculate the field size. */ - /* size = *to_base + *to + *len */ - /* Assume that the padding for alignment starts at a - * sizeof(void *) address. */ - - *from = <tng_param_data; - align = sizeof(int); - - if(*len == 0) { - *to += ltt_align(*to, align); /* align output */ - } else { - *len += ltt_align(*to+*len, align); /* alignment, ok to do a memcpy of it */ - } - - *len += sizeof(int); - - reserve_size = *to_base + *to + *len; - preempt_disable(); - ltt_nesting[smp_processor_id()]++; - index = ltt_get_index_from_facility(ltt_facility_tests_2F06D8DB, - event_tests_write_4bytes); - - list_for_each_entry_rcu(trace, <t_traces.head, list) { - if(!trace->active) continue; - - channel = ltt_get_channel_from_index(trace, index); - relayfs_buf = channel->rchan->buf[smp_processor_id()]; - - slot_size = 0; - buffer = ltt_reserve_slot(trace, relayfs_buf, - reserve_size, &slot_size, &tsc, - &before_hdr_pad, &after_hdr_pad, &header_size); - if(!buffer) continue; /* buffer full */ - - *to_base = *to = *len = 0; - - ltt_write_event_header(trace, channel, buffer, - ltt_facility_tests_2F06D8DB, event_tests_write_4bytes, - reserve_size, before_hdr_pad, tsc); - *to_base += before_hdr_pad + after_hdr_pad + header_size; - - *from = <tng_param_data; - align = sizeof(int); - - if(*len == 0) { - *to += ltt_align(*to, align); /* align output */ - } else { - *len += ltt_align(*to+*len, align); /* alignment, ok to do a memcpy of it */ - } - - *len += sizeof(int); - - /* Flush pending memcpy */ - if(*len != 0) { - memcpy(buffer+*to_base+*to, *from, *len); - *to += *len; - *len = 0; - } - - ltt_commit_slot(relayfs_buf, buffer, slot_size); - - } - - ltt_nesting[smp_processor_id()]--; - preempt_enable_no_resched(); -} -#endif //(!defined(CONFIG_LTT) || !defined(CONFIG_LTT_FACILITY_TESTS)) - - -/* Event write_string structures */ -static inline void lttng_write_string_tests_write_string_data( - void *buffer, - size_t *to_base, - size_t *to, - const void **from, - size_t *len, - const char * obj) -{ - size_t size; - size_t align; - - /* Flush pending memcpy */ - if(*len != 0) { - if(buffer != NULL) - memcpy(buffer+*to_base+*to, *from, *len); - } - *to += *len; - *len = 0; - - align = sizeof(char); - - if(*len == 0) { - *to += ltt_align(*to, align); /* align output */ - } else { - *len += ltt_align(*to+*len, align); /* alignment, ok to do a memcpy of it */ - } - - /* Contains variable sized fields : must explode the structure */ - - size = strlen(obj) + 1; /* Include final NULL char. */ - if(buffer != NULL) - memcpy(buffer+*to_base+*to, obj, size); - *to += size; - - /* Realign the *to_base on arch size, set *to to 0 */ - *to += ltt_align(*to, sizeof(void *)); - *to_base = *to_base+*to; - *to = 0; - - /* Put source *from just after the C string */ - *from += size; -} - - -/* Event write_string logging function */ -static inline void trace_tests_write_string( - const char * lttng_param_data) -#if (!defined(CONFIG_LTT) || !defined(CONFIG_LTT_FACILITY_TESTS)) -{ -} -#else -{ - unsigned int index; - struct ltt_channel_struct *channel; - struct ltt_trace_struct *trace; - struct rchan_buf *relayfs_buf; - void *buffer = NULL; - size_t real_to_base = 0; /* The buffer is allocated on arch_size alignment */ - size_t *to_base = &real_to_base; - size_t real_to = 0; - size_t *to = &real_to; - size_t real_len = 0; - size_t *len = &real_len; - size_t reserve_size; - size_t slot_size; - const void *real_from; - const void **from = &real_from; + const char *real_from; + const char **from = &real_from; u64 tsc; size_t before_hdr_pad, after_hdr_pad, header_size; - if(ltt_traces.num_active_traces == 0) return; + if (ltt_traces.num_active_traces == 0) + return; /* For each field, calculate the field size. */ /* size = *to_base + *to + *len */ /* Assume that the padding for alignment starts at a * sizeof(void *) address. */ - *from = lttng_param_data; - lttng_write_string_tests_write_string_data(buffer, to_base, to, from, len, lttng_param_data); - - reserve_size = *to_base + *to + *len; - preempt_disable(); - ltt_nesting[smp_processor_id()]++; - index = ltt_get_index_from_facility(ltt_facility_tests_2F06D8DB, - event_tests_write_string); - - list_for_each_entry_rcu(trace, <t_traces.head, list) { - if(!trace->active) continue; - - channel = ltt_get_channel_from_index(trace, index); - relayfs_buf = channel->rchan->buf[smp_processor_id()]; - - slot_size = 0; - buffer = ltt_reserve_slot(trace, relayfs_buf, - reserve_size, &slot_size, &tsc, - &before_hdr_pad, &after_hdr_pad, &header_size); - if(!buffer) continue; /* buffer full */ - - *to_base = *to = *len = 0; - - ltt_write_event_header(trace, channel, buffer, - ltt_facility_tests_2F06D8DB, event_tests_write_string, - reserve_size, before_hdr_pad, tsc); - *to_base += before_hdr_pad + after_hdr_pad + header_size; - - *from = lttng_param_data; - lttng_write_string_tests_write_string_data(buffer, to_base, to, from, len, lttng_param_data); - - /* Flush pending memcpy */ - if(*len != 0) { - memcpy(buffer+*to_base+*to, *from, *len); - *to += *len; - *len = 0; - } - - ltt_commit_slot(relayfs_buf, buffer, slot_size); - - } - - ltt_nesting[smp_processor_id()]--; - preempt_enable_no_resched(); -} -#endif //(!defined(CONFIG_LTT) || !defined(CONFIG_LTT_FACILITY_TESTS)) - - -/* Event write_struct structures */ -typedef struct lttng_sequence_tests_write_struct_data2_data5 lttng_sequence_tests_write_struct_data2_data5; -struct lttng_sequence_tests_write_struct_data2_data5 { - unsigned int len; - const int64_t *array; -}; - -struct lttng_tests_write_struct_data2 { - const char * data3; - int data4; - lttng_sequence_tests_write_struct_data2_data5 data5; - int data6; -} LTT_ALIGN; - -static inline size_t lttng_get_alignment_sequence_tests_write_struct_data2_data5( - lttng_sequence_tests_write_struct_data2_data5 *obj) -{ - size_t align=0, localign; - localign = sizeof(unsigned int); - align = max(align, localign); - - localign = sizeof(int64_t); - align = max(align, localign); - - return align; -} - -static inline size_t lttng_get_alignment_struct_tests_write_struct_data2( - struct lttng_tests_write_struct_data2 *obj) -{ - size_t align=0, localign; - localign = sizeof(char); - align = max(align, localign); - - localign = sizeof(int); - align = max(align, localign); - - localign = lttng_get_alignment_sequence_tests_write_struct_data2_data5(&obj->data5); - align = max(align, localign); - - localign = sizeof(int); - align = max(align, localign); - - return align; -} - -static inline void lttng_write_string_tests_write_struct_data2_data3( - void *buffer, - size_t *to_base, - size_t *to, - const void **from, - size_t *len, - const char * obj) -{ - size_t size; - size_t align; - - /* Flush pending memcpy */ - if(*len != 0) { - if(buffer != NULL) - memcpy(buffer+*to_base+*to, *from, *len); - } - *to += *len; - *len = 0; - - align = sizeof(char); - - if(*len == 0) { - *to += ltt_align(*to, align); /* align output */ - } else { - *len += ltt_align(*to+*len, align); /* alignment, ok to do a memcpy of it */ - } - - /* Contains variable sized fields : must explode the structure */ - - size = strlen(obj) + 1; /* Include final NULL char. */ - if(buffer != NULL) - memcpy(buffer+*to_base+*to, obj, size); - *to += size; - - /* Realign the *to_base on arch size, set *to to 0 */ - *to += ltt_align(*to, sizeof(void *)); - *to_base = *to_base+*to; - *to = 0; - - /* Put source *from just after the C string */ - *from += size; -} - -static inline void lttng_write_sequence_tests_write_struct_data2_data5( - void *buffer, - size_t *to_base, - size_t *to, - const void **from, - size_t *len, - lttng_sequence_tests_write_struct_data2_data5 *obj) -{ - size_t align; - - /* Flush pending memcpy */ - if(*len != 0) { - if(buffer != NULL) - memcpy(buffer+*to_base+*to, *from, *len); - } - *to += *len; - *len = 0; - - align = lttng_get_alignment_sequence_tests_write_struct_data2_data5(obj); - - if(*len == 0) { - *to += ltt_align(*to, align); /* align output */ - } else { - *len += ltt_align(*to+*len, align); /* alignment, ok to do a memcpy of it */ - } - - /* Contains variable sized fields : must explode the structure */ - - /* Copy members */ + *from = (const char*)<tng_param_value; align = sizeof(unsigned int); - if(*len == 0) { + if (*len == 0) { *to += ltt_align(*to, align); /* align output */ } else { *len += ltt_align(*to+*len, align); /* alignment, ok to do a memcpy of it */ @@ -361,191 +54,55 @@ static inline void lttng_write_sequence_tests_write_struct_data2_data5( *len += sizeof(unsigned int); - if(buffer != NULL) - memcpy(buffer+*to_base+*to, &obj->len, *len); - *to += *len; - *len = 0; - - align = sizeof(int64_t); - - if(*len == 0) { - *to += ltt_align(*to, align); /* align output */ - } else { - *len += ltt_align(*to+*len, align); /* alignment, ok to do a memcpy of it */ - } - - *len += sizeof(int64_t); - - *len = obj->len * (*len); - if(buffer != NULL) - memcpy(buffer+*to_base+*to, obj->array, *len); - *to += *len; - *len = 0; - - - /* Realign the *to_base on arch size, set *to to 0 */ - *to += ltt_align(*to, sizeof(void *)); - *to_base = *to_base+*to; - *to = 0; - - /* Put source *from just after the C sequence */ - *from = obj+1; -} - -static inline void lttng_write_struct_tests_write_struct_data2( - void *buffer, - size_t *to_base, - size_t *to, - const void **from, - size_t *len, - struct lttng_tests_write_struct_data2 *obj) -{ - size_t align; - - align = lttng_get_alignment_struct_tests_write_struct_data2(obj); - - if(*len == 0) { - *to += ltt_align(*to, align); /* align output */ - } else { - *len += ltt_align(*to+*len, align); /* alignment, ok to do a memcpy of it */ - } - - /* Contains variable sized fields : must explode the structure */ - - lttng_write_string_tests_write_struct_data2_data3(buffer, to_base, to, from, len, obj->data3); - - align = sizeof(int); - - if(*len == 0) { - *to += ltt_align(*to, align); /* align output */ - } else { - *len += ltt_align(*to+*len, align); /* alignment, ok to do a memcpy of it */ - } - - *len += sizeof(int); - - lttng_write_sequence_tests_write_struct_data2_data5(buffer, to_base, to, from, len, &obj->data5); - align = sizeof(int); - - if(*len == 0) { - *to += ltt_align(*to, align); /* align output */ - } else { - *len += ltt_align(*to+*len, align); /* alignment, ok to do a memcpy of it */ - } - - *len += sizeof(int); - -} - - -/* Event write_struct logging function */ -static inline void trace_tests_write_struct( - int lttng_param_data1, - struct lttng_tests_write_struct_data2 * lttng_param_data2) -#if (!defined(CONFIG_LTT) || !defined(CONFIG_LTT_FACILITY_TESTS)) -{ -} -#else -{ - unsigned int index; - struct ltt_channel_struct *channel; - struct ltt_trace_struct *trace; - struct rchan_buf *relayfs_buf; - void *buffer = NULL; - size_t real_to_base = 0; /* The buffer is allocated on arch_size alignment */ - size_t *to_base = &real_to_base; - size_t real_to = 0; - size_t *to = &real_to; - size_t real_len = 0; - size_t *len = &real_len; - size_t reserve_size; - size_t slot_size; - size_t align; - const void *real_from; - const void **from = &real_from; - u64 tsc; - size_t before_hdr_pad, after_hdr_pad, header_size; - - if(ltt_traces.num_active_traces == 0) return; - - /* For each field, calculate the field size. */ - /* size = *to_base + *to + *len */ - /* Assume that the padding for alignment starts at a - * sizeof(void *) address. */ - - *from = <tng_param_data1; - align = sizeof(int); - - if(*len == 0) { - *to += ltt_align(*to, align); /* align output */ - } else { - *len += ltt_align(*to+*len, align); /* alignment, ok to do a memcpy of it */ - } - - *len += sizeof(int); - - *from = lttng_param_data2; - lttng_write_struct_tests_write_struct_data2(buffer, to_base, to, from, len, lttng_param_data2); reserve_size = *to_base + *to + *len; preempt_disable(); ltt_nesting[smp_processor_id()]++; - index = ltt_get_index_from_facility(ltt_facility_tests_2F06D8DB, - event_tests_write_struct); + index = ltt_get_index_from_facility_tests( event_tests_write_4bytes); list_for_each_entry_rcu(trace, <t_traces.head, list) { - if(!trace->active) continue; + if (!trace->active) + continue; channel = ltt_get_channel_from_index(trace, index); - relayfs_buf = channel->rchan->buf[smp_processor_id()]; slot_size = 0; - buffer = ltt_reserve_slot(trace, relayfs_buf, + buffer = ltt_reserve_slot(trace, channel, &transport_data, reserve_size, &slot_size, &tsc, &before_hdr_pad, &after_hdr_pad, &header_size); - if(!buffer) continue; /* buffer full */ + if (!buffer) + continue; /* buffer full */ *to_base = *to = *len = 0; ltt_write_event_header(trace, channel, buffer, - ltt_facility_tests_2F06D8DB, event_tests_write_struct, + ltt_facility_tests_CA7F1536, event_tests_write_4bytes, reserve_size, before_hdr_pad, tsc); *to_base += before_hdr_pad + after_hdr_pad + header_size; - *from = <tng_param_data1; - align = sizeof(int); + *from = (const char*)<tng_param_value; + align = sizeof(unsigned int); - if(*len == 0) { + if (*len == 0) { *to += ltt_align(*to, align); /* align output */ } else { *len += ltt_align(*to+*len, align); /* alignment, ok to do a memcpy of it */ } - *len += sizeof(int); + *len += sizeof(unsigned int); /* Flush pending memcpy */ - if(*len != 0) { + if (*len != 0) { memcpy(buffer+*to_base+*to, *from, *len); *to += *len; *len = 0; } - *from = lttng_param_data2; - lttng_write_struct_tests_write_struct_data2(buffer, to_base, to, from, len, lttng_param_data2); - /* Flush pending memcpy */ - if(*len != 0) { - memcpy(buffer+*to_base+*to, *from, *len); - *to += *len; - *len = 0; - } - - ltt_commit_slot(relayfs_buf, buffer, slot_size); + ltt_commit_slot(channel, &transport_data, buffer, slot_size); } ltt_nesting[smp_processor_id()]--; preempt_enable_no_resched(); } -#endif //(!defined(CONFIG_LTT) || !defined(CONFIG_LTT_FACILITY_TESTS)) - #endif //_LTT_FACILITY_TESTS_H_ diff --git a/tests/kernel/test-cmpxchg-nolock.c b/tests/kernel/test-cmpxchg-nolock.c index 5f3d7981..16711e5f 100644 --- a/tests/kernel/test-cmpxchg-nolock.c +++ b/tests/kernel/test-cmpxchg-nolock.c @@ -10,7 +10,7 @@ #include #include - +#if 0 #define cmpxchg_up(ptr,o,n)\ ((__typeof__(*(ptr)))__cmpxchg_up((ptr),(unsigned long)(o),\ (unsigned long)(n),sizeof(*(ptr)))) @@ -40,7 +40,7 @@ static inline unsigned long __cmpxchg_up(volatile void *ptr, unsigned long old, } return old; } - +#endif //0 #define NR_LOOPS 20000 -- 2.34.1