Skip to contentSkip to conversation

in-kernel timer benchmark -v3

PATCH In review Jan Kiszka 2 participants 4 messages Jan 2, 2006 – Jan 3, 2006

lore
Share & tools
lore

Jan Kiszka

author
#0 lore raw

PATCH 1/1 in-kernel timer benchmark -v3

Happy New Year everyone!

Hope you all survived the turn of the year without complications. ;)

I would like to start with a new patch round. The first one is a revised and extended version of the earlier posted in-kernel timer benchmark based on a RTDM device. Changes since the first version:

* revised command line argument to set the test mode
* display test mode during startup
* display hint on missing benchmark device
* support of trace freeze on latency above specified threshold
* extended benchmark device to provide ipipe-tracing functions to userspace
* further minor fixes

I think the patch should be ready to merge now. This would also be helpful to provide a base on which Gilles can build his timer-scaling tests. BTW, we still need some RTDM abstraction for timers, but this is a different topic that will be addressed later.

Jan

rtdm/rtbenchmark.h +131 -0
Index: include/rtdm/rtbenchmark.h
===================================================================
@@ -0,0 +1,131 @@
+/**
+ * @file
+ * Real-Time Driver Model for Xenomai, benchmark device profile header
+ *
+ * @note Copyright (C) 2005 Jan Kiszka <[email protected]>
+ *
+ * Xenomai is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * Xenomai is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Xenomai; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * @ingroup rtbenchmark
+ */
+
+/*!
+ * @ingroup profiles
+ * @defgroup rtbenchmark Benchmark Devices
+ *
+ * This group of devices is intended to provide in-kernel benchmark results.
+ * Feel free to comment on this profile via the Xenomai mailing list
+ * ([email protected]) or directly to the author ([email protected]). @n
+ * @n
+ *
+ * @par Device Characteristics
+ * @ref rtdm_device.device_flags "Device Flags": @c RTDM_NAMED_DEVICE, @c RTDM_EXCLUSIVE @n
+ * @n
+ * @ref rtdm_device.device_name "Device Name": @c "rtbenchmark<N>", N >= 0 @n
+ * @n
+ * @ref rtdm_device.device_class "Device Class": @c RTDM_CLASS_BENCHMARK @n
+ * @n
+ *
+ * @par Supported Operations
+ * @b Open @n
+ * Environments: non-RT (RT optional)@n
+ * Specific return values: none @n
+ * @n
+ * @b Close @n
+ * Environments: non-RT (RT optional)@n
+ * Specific return values: none @n
+ * @n
+ * @b IOCTL @n
+ * Mandatory Environments: see @ref IOCTLs "below" @n
+ * Specific return values: see @ref IOCTLs "below" @n
+ *
+ * @{
+ */
+
+#ifndef _RTBENCHMARK_H
+#define _RTBENCHMARK_H
+
+#include <asm/types.h>
+#include <xenomai/rtdm/rtdm.h>
+
+#define RTBNCH_TIMER_TASK       0
+#define RTBNCH_TIMER_HANDLER    1
+
+typedef struct rtbnch_result {
+    long                    avg;
+    long                    min;
+    long                    max;
+    long                    overruns;
+    long                    test_loops;
+} rtbnch_result_t;
+
+typedef struct rtbnch_timerconfig {
+    int                     mode;
+    uint64_t                period;
+    int                     warmup_loops;
+    int                     histogram_size;
+    int                     histogram_bucketsize;
+    long                    freeze_threshold;
+} rtbnch_timerconfig_t;
+
+typedef struct rtbnch_interm_result {
+    struct rtbnch_result    last;
+    struct rtbnch_result    overall;
+} rtbnch_interm_result_t;
+
+typedef struct rtbnch_overall_result {
+    struct rtbnch_result    result;
+    long                    *histogram_avg;
+    long                    *histogram_min;
+    long                    *histogram_max;
+} rtbnch_overall_result_t;
+
+
+#define RTIOC_TYPE_BENCHMARK        RTDM_CLASS_BENCHMARK
+
+
+/*!
+ * @name Sub-Classes of RTDM_CLASS_BENCHMARK
+ * @{ */
+#define RTDM_SUBCLASS_TIMER         0
+/** @} */
+
+
+/*!
+ * @anchor IOCTLs @name IOCTLs
+ * Benchmark device IOCTLs
+ * @{ */
+
+#define RTBNCH_RTIOC_INTERM_RESULT      \
+    _IOWR(RTIOC_TYPE_BENCHMARK, 0x00, struct rtbnch_interm_result)
+
+#define RTBNCH_RTIOC_START_TMTEST       \
+    _IOW(RTIOC_TYPE_BENCHMARK, 0x10, struct rtbnch_timerconfig)
+
+#define RTBNCH_RTIOC_STOP_TMTEST        \
+    _IOWR(RTIOC_TYPE_BENCHMARK, 0x11, struct rtbnch_overall_result)
+
+#define RTBNCH_RTIOC_BEGIN_TRACE        \
+    _IOW(RTIOC_TYPE_BENCHMARK, 0x20, long)
+
+#define RTBNCH_RTIOC_END_TRACE          \
+    _IOW(RTIOC_TYPE_BENCHMARK, 0x21, long)
+
+#define RTBNCH_RTIOC_FREEZE_TRACE       \
+    _IOW(RTIOC_TYPE_BENCHMARK, 0x22, int)
+
+/** @} */
+
+#endif /* _RTBENCHMARK_H */
rtdm/rtdm.h +1 -0
Index: include/rtdm/rtdm.h
===================================================================
@@ -68,6 +68,7 @@
 #define RTDM_CLASS_CAN              3
 #define RTDM_CLASS_NETWORK          4
 #define RTDM_CLASS_RTMAC            5
+#define RTDM_CLASS_BENCHMARK        6
 /*
 #define RTDM_CLASS_USB              ?
 #define RTDM_CLASS_FIREWIRE         ?
testsuite/latency/latency.c +175 -46

335 lines not on this page · raw message

testsuite/latency/runinfo +1 -1
Index: src/testsuite/latency/runinfo
===================================================================
@@ -1 +1 @@
-latency:native:!./latency;popall:control_c
+latency:native+rtdm+timerbench:!./latency;popall:control_c
testsuite/latency/Makefile.am +1 -0
Index: src/testsuite/latency/Makefile.am
===================================================================
@@ -10,6 +10,7 @@
 
 latency_LDADD = \
 	../../skins/native/libnative.la \
+	../../skins/rtdm/librtdm.la \
 	-lpthread -lm
 
 install-data-local:
drivers/Kconfig +1 -0
Index: ksrc/drivers/Kconfig
===================================================================
@@ -1 +1,2 @@
 source "drivers/xenomai/16550A/Kconfig"
+source "drivers/xenomai/benchmark/Kconfig"
drivers/Config.in +1 -0
Index: ksrc/drivers/Config.in
===================================================================
@@ -8,5 +8,6 @@
 mainmenu_option next_comment
 comment 'Real-time drivers'
 	source drivers/xenomai/16550A/Config.in
+	source drivers/xenomai/benchmark/Config.in
 endmenu
 fi
drivers/benchmark/Kconfig +7 -0
Index: ksrc/drivers/benchmark/Kconfig
===================================================================
@@ -0,0 +1,7 @@
+config XENO_DRIVERS_TIMERBENCH
+	depends on XENO_SKIN_RTDM
+	tristate "Timer benchmark driver"
+	default n
+	help
+	Kernel-based benchmark driver for timer latency evaluation.
+	See testsuite/latency for a possible front-end.
drivers/benchmark/timerbench.c +538 -0

538 lines not on this page · raw message

drivers/benchmark/Config.in +5 -0
Index: ksrc/drivers/benchmark/Config.in
===================================================================
@@ -0,0 +1,5 @@
+#
+# Xenomai configuration for Linux v2.4
+#
+
+dep_tristate 'Timer benchmark driver' CONFIG_XENO_DRIVERS_TIMERBENCH $CONFIG_XENO_SKIN_RTDM
drivers/benchmark/Makefile +30 -0
Index: ksrc/drivers/benchmark/Makefile
===================================================================
@@ -0,0 +1,30 @@
+ifeq ($(PATCHLEVEL),6)
+
+# Makefile frag for Linux v2.6
+
+obj-$(CONFIG_XENO_DRIVERS_TIMERBENCH) += xeno_timerbench.o
+
+xeno_timerbench-y := timerbench.o
+
+else
+
+# Makefile frag for Linux v2.4
+
+O_TARGET := built-in.o
+
+obj-$(CONFIG_XENO_DRIVERS_TIMERBENCH) := xeno_timerbench.o
+
+list-multi := xeno_timerbench.o
+
+xeno_timerbench-objs := timerbench.o
+
+export-objs := $(xeno_timerbench-objs)
+
+EXTRA_CFLAGS += -I$(TOPDIR)/include/xenomai/compat
+
+include $(TOPDIR)/Rules.make
+
+xeno_timerbench.o: $(xeno_timerbench-objs)
+	$(LD) -r -o $@ $(xeno_timerbench-objs)
+
+endif
drivers/Makefile +3 -1
Index: ksrc/drivers/Makefile
===================================================================
@@ -2,7 +2,7 @@
 
 # Makefile frag for Linux v2.6
 
-obj-$(CONFIG_XENOMAI) += 16550A/
+obj-$(CONFIG_XENOMAI) += 16550A/ benchmark/
 
 else
 
@@ -10,6 +10,8 @@
 
 subdir-$(CONFIG_XENO_DRIVERS_16550A) += 16550A
 
+subdir-$(CONFIG_XENO_DRIVERS_TIMERBENCH) += benchmark
+
 include $(TOPDIR)/Rules.make
 
 endif
#1 lore raw
Quoted 4 lines · Jan Kiszka

Happy New Year everyone!

Hope you all survived the turn of the year without complications. ;)

Nearly buried alive in patches, but this is hardly a complication.

Quoted 4 lines

I would like to start with a new patch round. The first one is a revised and extended version of the earlier posted in-kernel timer benchmark based on a RTDM device. Changes since the first version:

Quoted 8 lines

* revised command line argument to set the test mode
* display test mode during startup
* display hint on missing benchmark device
* support of trace freeze on latency above specified threshold
* extended benchmark device to provide ipipe-tracing functions to userspace
* further minor fixes

Ok, merged.

Quoted 5 lines

I think the patch should be ready to merge now. This would also be helpful to provide a base on which Gilles can build his timer-scaling tests. BTW, we still need some RTDM abstraction for timers, but this is a different topic that will be addressed later.

Btw, since -rc1 is out, I've deprecated the Adeos oldgen support for all archs (ia64 is now I-pipe based too), so that I can merge Dmitry's work later on, exclusively into the newgen codebase. So if anyone still keeps any venerable pre-Ipipe patch in some hideout of his hdd, just let it go now; I know it's heartbreaking, but Xenomai is thankless.

Signature · 1 line
Philippe.
author
#2 lore raw

...as a follow-up, here is a patch to fix some bugs in the new trace triggering and to improve (from my POV) the output of this tool in some regards.

Jan

testsuite/latency/latency.c +25 -15
Index: src/testsuite/latency/latency.c
===================================================================
@@ -39,6 +39,11 @@
 #define TIMER_HANDLER   2
 
 int test_mode = USER_TASK;
+const char *test_mode_names[] = {
+    "periodic user-mode task",
+    "in-kernel periodic task",
+    "in-kernel timer handler"
+};
 
 time_t test_start, test_end;    /* report test duration */
 int test_loops = 0;             /* outer loop count */
@@ -78,8 +83,7 @@
         return;
         }
 
-    if (freeze_threshold > 0)
-        freeze_threshold = rt_timer_ns2tsc(freeze_threshold*1000);
+    freeze_threshold = rt_timer_ns2tsc(freeze_threshold);
 
     nsamples = ONE_BILLION / period_ns;
     period_tsc = rt_timer_ns2tsc(period_ns);
@@ -122,11 +126,15 @@
             if (dt < minj) minj = dt;
             sumj += dt;
 
-            if ((freeze_threshold > 0) && (dt > freeze_threshold))
-                rt_dev_ioctl(benchdev, RTBNCH_RTIOC_FREEZE_TRACE, freeze_threshold);
+            if (!(finished || warmup))
+                {
+                if ((freeze_threshold > 0) && (dt > freeze_threshold))
+                    rt_dev_ioctl(benchdev, RTBNCH_RTIOC_FREEZE_TRACE,
+                                 freeze_threshold);
 
-            if (!(finished || warmup) && (do_histogram || do_stats))
-                add_histogram(histogram_avg, dt);
+                if (do_histogram || do_stats)
+                    add_histogram(histogram_avg, dt);
+                }
             }
 
         if(!warmup)
@@ -173,8 +181,6 @@
             return;
             }
 
-        printf("== Test mode: periodic userspace task\n");
-
     } else {
         struct rtbnch_timerconfig   config;
 
@@ -196,13 +202,13 @@
             fprintf(stderr,"latency: failed to start in-kernel timer benchmark, code %d\n",err);
             return;
             }
-
-        printf("== Test mode: in-kernel %s\n",
-               (test_mode == TIMER_HANDLER) ? "timer handler" : "periodic task");
     }
 
     time(&start);
 
+    if (WARMUP_TIME)
+        printf("warming up...\n");
+
     if (quiet)
         fprintf(stderr, "running quietly for %d seconds\n", test_duration);
 
@@ -256,8 +262,9 @@
                 time_t now, dt;
                 time(&now);
                 dt = now - start - WARMUP_TIME;
-                printf("RTT|  %.2ld:%.2ld:%.2ld\n",
-                       dt / 3600,(dt / 60) % 60,dt % 60);
+                printf("RTT|  %.2ld:%.2ld:%.2ld  (%s, %Ld us period)\n",
+                       dt / 3600,(dt / 60) % 60,dt % 60,
+                       test_mode_names[test_mode],period_ns / 1000);
                 printf("RTH|%12s|%12s|%12s|%8s|%12s|%12s\n",
                        "-----lat min","-----lat avg","-----lat max","-overrun",
                        "----lat best","---lat worst");
@@ -469,7 +476,7 @@
 
             case 'f':
 
-                freeze_threshold = atoi(optarg);
+                freeze_threshold = atoi(optarg)*1000;
                 break;
 
             default:
@@ -520,7 +527,10 @@
 
     setlinebuf(stdout);
 
-    printf("== Sampling period: %Ld us\n",period_ns / 1000);
+    printf("== Sampling period: %Ld us\n"
+           "== Test mode: %s\n",
+           period_ns / 1000,
+           test_mode_names[test_mode]);
 
     mlockall(MCL_CURRENT|MCL_FUTURE);
 
author
#3 lore raw
Quoted 3 lines · Jan Kiszka

...as a follow-up, here is a patch to fix some bugs in the new trace triggering and to improve (from my POV) the output of this tool in some regards.

Applied on my own.

Jan