Uninline tsc/ns conversions
RFC PATCH 2/2 Uninline tsc/ns conversions
Another pending patch from my repos (don't think I already posted this, did I?). This one uninlines xnarch_tsc_to_ns() and xnarch_ns_to_tsc(). Both functions are fairly heavy right now, and uninlining can save a few kilobyte code. Some stats on my Pentium M box:
[Before]
text data bss dec hex filename
15714 844 28 16586 40ca drivers/xenomai/can/xeno_can.ko
6625 824 4 7453 1d1d drivers/xenomai/testing/xeno_timerbench.ko
12736 984 260 13980 369c drivers/xenomai/serial/xeno_16550A.ko
10304 664 1196 12164 2f84 kernel/xenomai/skins/rtai/xeno_rtai.ko
19809 936 564 21309 533d kernel/xenomai/skins/rtdm/xeno_rtdm.ko
27172 1376 1184 29732 7424 kernel/xenomai/skins/vrtx/xeno_vrtx.ko
58869 1312 42624 102805 19195 kernel/xenomai/skins/posix/xeno_posix.ko
27791 1144 136 29071 718f kernel/xenomai/skins/psos+/xeno_psos.ko
47891 1696 160 49747 c253 kernel/xenomai/skins/native/xeno_native.ko
24465 1136 132 25733 6485 kernel/xenomai/skins/vxworks/xeno_vxworks.ko
73963 1536 50140 125639 1eac7 kernel/xenomai/nucleus/xeno_nucleus.ko
------
434219[After]
text data bss dec hex filename
15518 844 28 16390 4006 drivers/xenomai/can/xeno_can.ko
5445 824 4 6273 1881 drivers/xenomai/testing/xeno_timerbench.ko
12552 984 260 13796 35e4 drivers/xenomai/serial/xeno_16550A.ko
9696 664 1196 11556 2d24 kernel/xenomai/skins/rtai/xeno_rtai.ko
19561 936 564 21061 5245 kernel/xenomai/skins/rtdm/xeno_rtdm.ko
26604 1376 1184 29164 71ec kernel/xenomai/skins/vrtx/xeno_vrtx.ko
54741 1312 42624 98677 18175 kernel/xenomai/skins/posix/xeno_posix.ko
27191 1144 136 28471 6f37 kernel/xenomai/skins/psos+/xeno_psos.ko
46615 1696 160 48471 bd57 kernel/xenomai/skins/native/xeno_native.ko
24277 1136 132 25545 63c9 kernel/xenomai/skins/vxworks/xeno_vxworks.ko
71663 1536 50140 123339 1e1cb kernel/xenomai/nucleus/xeno_nucleus.ko
------
422743Means a win of 11k. Does anyone expect noticeable latency regressions?
We may reconsider this uninlining for xnarch_tsc_to_ns() when we switch to scaled math for that function. But my feeling is that even then the function size will still demand a dedicated function.
Jan
--- include/asm-arm/bits/timer.h | 2 + include/asm-blackfin/bits/timer.h | 2 + include/asm-generic/bits/timer.h | 41 ++++++++++++++++++++++++++++++++++++++ include/asm-generic/system.h | 11 +--------- include/asm-i386/bits/timer.h | 2 + include/asm-ia64/bits/timer.h | 2 + include/asm-powerpc/bits/timer.h | 2 + include/asm-sim/bits/timer.h | 2 + include/asm-x86_64/bits/timer.h | 2 + 9 files changed, 57 insertions(+), 9 deletions(-)
include/asm-generic/system.h +2 -9
@@ -180,15 +180,8 @@ typedef struct xnarch_heapcb {extern "C" {#endif -static inline long long xnarch_tsc_to_ns (long long ts) -{ -return xnarch_llimd (ts,1000000000 ,RTHAL_CPU_FREQ ); -} - -static inline long long xnarch_ns_to_tsc (long long ns) -{ -return xnarch_llimd (ns,RTHAL_CPU_FREQ ,1000000000 ); -} +long long xnarch_tsc_to_ns (long long ts); +long long xnarch_ns_to_tsc (long long ns);static inline unsigned long long xnarch_get_cpu_time (void ) {
include/asm-arm/bits/timer.h +2 -0
@@ -27,6 +27,8 @@#error "Pure kernel header included from user-space!"#endif +#include <asm-generic/xenomai/bits/timer.h> +static inline void xnarch_program_timer_shot (unsigned long delay) { rthal_timer_program_shot(rthal_imuldiv
include/asm-blackfin/bits/timer.h +2 -0
@@ -24,6 +24,8 @@#error "Pure kernel header included from user-space!"#endif +#include <asm-generic/xenomai/bits/timer.h> +static inline void xnarch_program_timer_shot (unsigned long delay) {/* The core timer runs at the core clock rate -- therefore no
include/asm-generic/bits/timer.h new file +1 -0
@@ -0,0 +1,41 @@ +/*
+ * Copyright (C) 2001-2007 Philippe Gerum <[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.
+ */
+
+#ifndef _XENO_ASM_GENERIC_BITS_TIMER_H
+#define _XENO_ASM_GENERIC_BITS_TIMER_H
+
+#ifndef __KERNEL__
+#error "Pure kernel header included from user-space!"
+#endif
+
+long long xnarch_tsc_to_ns(long long ts)
+{
+ return xnarch_llimd(ts,1000000000,RTHAL_CPU_FREQ);
+}
+
+EXPORT_SYMBOL(xnarch_tsc_to_ns);
+
+long long xnarch_ns_to_tsc(long long ns)
+{
+ return xnarch_llimd(ns,RTHAL_CPU_FREQ,1000000000);
+}
+
+EXPORT_SYMBOL(xnarch_ns_to_tsc);
+
+#endif /* !_XENO_ASM_GENERIC_BITS_TIMER_H */
include/asm-i386/bits/timer.h +2 -0
@@ -24,6 +24,8 @@#error "Pure kernel header included from user-space!"#endif +#include <asm-generic/xenomai/bits/timer.h> +static inline void xnarch_program_timer_shot (unsigned long delay) {/* Even though some architectures may use a 64 bits delay here, we
include/asm-ia64/bits/timer.h +2 -0
@@ -24,6 +24,8 @@#error "Pure kernel header included from user-space!"#endif +#include <asm-generic/xenomai/bits/timer.h> +static inline void xnarch_program_timer_shot (unsigned long delay) {rthal_timer_program_shot (delay);
include/asm-powerpc/bits/timer.h +2 -0
@@ -27,6 +27,8 @@#error "Pure kernel header included from user-space!"#endif +#include <asm-generic/xenomai/bits/timer.h> +static inline void xnarch_program_timer_shot (unsigned long delay) {/* Even though some architectures may use a 64 bits delay here, we
include/asm-sim/bits/timer.h +2 -0
@@ -19,6 +19,8 @@#ifndef _XENO_ASM_SIM_BITS_TIMER_H#define _XENO_ASM_SIM_BITS_TIMER_H +#include <asm-generic/xenomai/bits/timer.h> +static inline void xnarch_program_timer_shot (unsigned long delay) {/* 1 tsc unit of the virtual CPU == 1 ns. */
include/asm-x86_64/bits/timer.h +2 -0
@@ -24,6 +24,8 @@#error "Pure kernel header included from user-space!"#endif +#include <asm-generic/xenomai/bits/timer.h> +static inline void xnarch_program_timer_shot (unsigned long delay) { rthal_timer_program_shot(rthal_imuldiv