All of lore.kernel.org
 help / color / mirror / Atom feed
* [LTP] [PATCH] compiling realtime tests for SH.
@ 2009-11-04 15:48 Giuseppe CAVALLARO
  2009-11-09 17:39 ` Subrata Modak
  0 siblings, 1 reply; 7+ messages in thread
From: Giuseppe CAVALLARO @ 2009-11-04 15:48 UTC (permalink / raw)
  To: ltp-list

[-- Attachment #1: Type: text/plain, Size: 52 bytes --]

Hoping somebody will find useful it.

Regards
Peppe

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: ltp-full-20090731-sh_RT.patch --]
[-- Type: text/x-patch; name="ltp-full-20090731-sh_RT.patch", Size: 9144 bytes --]

[PATCH] compiling realtime tests for SH.

This patch adds the atomi_add() define for __sh__;
ltp realtime tests seem to show that it works.

The patch also moves the tsc macros form the librttest.h
to another header file (named libtsc.h).

Without this I got the following error and no tests were built.

 [snip]
 In file included from librttest.c:43:
 ../include/librttest.h:127:2: error: #error 
 ../include/librttest.h:169:2: error: #error 
 In file included from librttest.c:43:
 ../include/librttest.h: In function ���atomic_add���:
 [snip]

The tsc macros header is only included in the following tests
(thus where necessary):

 o async_handler_tsc.c
 o preempt_timing.c
 o rdtsc-latency.c

Note1: instead of touching the make process the patch allows to build
the tests above also for architecture that do not support tsc, yet.
These tests will fail at run-time with ENOTSUP. A warning will
appear while compiling as well.
hmm, I do know if it is the right solution but it's simple and
a good starting point for me.

Note2: I've just started running this part of the ltp on stlinux
targets so I cannot provide results and I don't know which
tests will fail.

Note3: realtime tests continues to build and apparently work on i386.

Signed-off-by: Giuseppe Cavallaro <peppe.cavallaro@st.com>

diff -urN ltp-full-20090731/testcases/realtime.orig/func/async_handler/async_handler_tsc.c ltp-full-20090731/testcases/realtime/func/async_handler/async_handler_tsc.c
--- ltp-full-20090731/testcases/realtime.orig/func/async_handler/async_handler_tsc.c	2009-11-04 15:55:58.000000000 +0100
+++ ltp-full-20090731/testcases/realtime/func/async_handler/async_handler_tsc.c	2009-11-04 15:39:21.000000000 +0100
@@ -45,6 +45,7 @@
 #include <pthread.h>
 #include <librttest.h>
 #include <libstats.h>
+#include <libtsc.h>
 
 #define HANDLER_PRIO 98
 #define SIGNAL_PRIO 99
@@ -190,6 +191,11 @@
 int main(int argc, char *argv[])
 {
 	int signal_id, handler_id;
+
+#ifdef TSC_UNSUPPORTED
+	printf("Error: test cannot be executed on an arch wihout TSC.\n");
+	return ENOTSUP;
+#endif
 	setup();
 
 	rt_init("h", parse_args, argc, argv);
diff -urN ltp-full-20090731/testcases/realtime.orig/func/measurement/preempt_timing.c ltp-full-20090731/testcases/realtime/func/measurement/preempt_timing.c
--- ltp-full-20090731/testcases/realtime.orig/func/measurement/preempt_timing.c	2009-11-04 15:55:58.000000000 +0100
+++ ltp-full-20090731/testcases/realtime/func/measurement/preempt_timing.c	2009-11-04 15:39:26.000000000 +0100
@@ -52,7 +52,7 @@
 #include <sys/mman.h>
 #include <stdint.h>
 #include <librttest.h>
-
+#include <libtsc.h>
 
 #define ITERATIONS 1000000ULL
 #define INTERVALS 10
@@ -86,6 +86,12 @@
 	struct sched_param param;
 	cpu_set_t mask;
 	int err;
+
+#ifdef TSC_UNSUPPORTED
+	printf("Error: test cannot be executed on an arch wihout TSC.\n");
+	return ENOTSUP;
+#endif
+
 	max = avg = 0;
 	min = -1;
 	setup();
diff -urN ltp-full-20090731/testcases/realtime.orig/func/measurement/rdtsc-latency.c ltp-full-20090731/testcases/realtime/func/measurement/rdtsc-latency.c
--- ltp-full-20090731/testcases/realtime.orig/func/measurement/rdtsc-latency.c	2009-11-04 15:55:58.000000000 +0100
+++ ltp-full-20090731/testcases/realtime/func/measurement/rdtsc-latency.c	2009-11-04 15:38:49.000000000 +0100
@@ -44,6 +44,7 @@
 #include <errno.h>
 #include <stdint.h>
 #include <librttest.h>
+#include <libtsc.h>
 
 #define ITERATIONS 1000000
 
@@ -101,6 +102,12 @@
 	unsigned long long deltas[ITERATIONS];
 	unsigned long long max, min, avg, tsc_a, tsc_b, tsc_period;
 	struct sched_param param;
+
+#ifdef TSC_UNSUPPORTED
+	printf("Error: test cannot be executed on an arch wihout TSC.\n");
+	return ENOTSUP;
+#endif
+
 	setup();
 
 	rt_init("h",parse_args,argc,argv);
diff -urN ltp-full-20090731/testcases/realtime.orig/include/librttest.h ltp-full-20090731/testcases/realtime/include/librttest.h
--- ltp-full-20090731/testcases/realtime.orig/include/librttest.h	2009-11-04 15:55:58.000000000 +0100
+++ ltp-full-20090731/testcases/realtime/include/librttest.h	2009-11-04 14:21:22.000000000 +0100
@@ -36,6 +36,7 @@
  *      2006-May-09: improved command line argument handling
  *      2007-Jul-12: Added latency tracing functions -- Josh Triplett
  *      2007-Jul-26: Renamed to librttest.h -- Josh Triplett
+ *      2009-Nov-4: TSC macros within another header -- Giuseppe Cavallaro
  *
  *****************************************************************************/
 
@@ -96,36 +97,7 @@
 #define thread_quit(T) (((T)->flags) & THREAD_QUIT)
 
 #define PRINT_BUFFER_SIZE (1024*1024*4)
-
-/* TSC macros */
 #define ULL_MAX 18446744073709551615ULL // (1 << 64) - 1
-#if defined(__i386__)
-#define rdtscll(val) __asm__ __volatile__("rdtsc" : "=A" (val))
-#elif defined(__x86_64__)
-#define rdtscll(val)					\
-	do {						\
-		uint32_t low, high;			\
-		__asm__ __volatile__ ("rdtsc" : "=a" (low), "=d" (high)); \
-		val = (uint64_t)high << 32 | low;	\
-	} while(0)
-#elif defined(__powerpc__)
-#if defined(__powerpc64__)	/* 64bit version */
-#define rdtscll(val)					\
-	do {								\
-		__asm__ __volatile__ ("mfspr %0, 268" : "=r" (val));	\
-	} while(0)
-#else	/*__powerpc__ 32bit version */
-#define rdtscll(val)							\
-	 do {								\
-		uint32_t tbhi, tblo ;					\
-		__asm__ __volatile__ ("mftbu %0" : "=r" (tbhi));	\
-		__asm__ __volatile__ ("mftbl %0" : "=r" (tblo));	\
-		val = 1000 * ((uint64_t) tbhi << 32) | tblo;		\
-	} while(0)
-#endif
-#else
-#error
-#endif
 
 extern pthread_mutex_t _buffer_mutex;
 extern char * _print_buffer;
@@ -135,7 +107,7 @@
 
 /* function prototypes */
 
-/* atomic_add - add integer to atomic variable
+/* atomic_add - add integer to atomic variable and returns a value.
  * i: integer value to add
  * v: pointer of type atomic_t
  */
@@ -165,6 +137,20 @@
 	: "cc", "memory");
 
 	return t;
+#elif defined(__sh__)
+	unsigned long t;
+
+	__asm__ __volatile__ (
+"1:	 movli.l @%2, %0	 ! atomic_add_return     \n"
+"	 add     %1, %0				  \n"
+"	 movco.l %0, @%2				 \n"
+"	 bf      1b				      \n"
+"       synco					   \n"
+	: "=&z" (t)
+	: "r" (i), "r" (&v->counter)
+	: "t");
+
+	return t;
 #else
 #error
 #endif
@@ -343,7 +329,6 @@
  */
 int ts_to_nsec(struct timespec *ts, nsec_t *ns);
 
-/* return difference in microseconds */
 unsigned long long tsc_minus(unsigned long long tsc_start, unsigned long long tsc_end);
 
 /* rt_nanosleep: sleep for ns nanoseconds using clock_nanosleep
diff -urN ltp-full-20090731/testcases/realtime.orig/include/libtsc.h ltp-full-20090731/testcases/realtime/include/libtsc.h
--- ltp-full-20090731/testcases/realtime.orig/include/libtsc.h	1970-01-01 01:00:00.000000000 +0100
+++ ltp-full-20090731/testcases/realtime/include/libtsc.h	2009-11-04 15:41:03.000000000 +0100
@@ -0,0 +1,72 @@
+/******************************************************************************
+ *
+ *   Copyright �� International Business Machines  Corp., 2006-2008
+ *
+ *   This program 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.
+ *
+ *   This program 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 this program;  if not, write to the Free Software
+ *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * NAME
+ *       libtsc.h
+ *
+ * DESCRIPTION
+ *
+ * USAGE:
+ *       To be included in some testcases.
+ *
+ * AUTHOR
+ *        Darren Hart <dvhltc@us.ibm.com>
+ *        Giuseppe Cavallaro <peppe.cavallarost.com>
+ *
+ * HISTORY
+ *      It directly comes from the librttest.h (see its HISTORY).
+ *
+ *****************************************************************************/
+
+#undef TSC_UNSUPPORTED
+
+/* TSC macros */
+#if defined(__i386__)
+#define rdtscll(val) __asm__ __volatile__("rdtsc" : "=A" (val))
+#elif defined(__x86_64__)
+#define rdtscll(val)					\
+	do {						\
+		uint32_t low, high;			\
+		__asm__ __volatile__ ("rdtsc" : "=a" (low), "=d" (high)); \
+		val = (uint64_t)high << 32 | low;	\
+	} while (0)
+#elif defined(__powerpc__)
+#if defined(__powerpc64__)	/* 64bit version */
+#define rdtscll(val)					\
+	do {								\
+		__asm__ __volatile__ ("mfspr %0, 268" : "=r" (val));	\
+	} while (0)
+#else	/*__powerpc__ 32bit version */
+#define rdtscll(val)							\
+	 do {								\
+		uint32_t tbhi, tblo ;					\
+		__asm__ __volatile__ ("mftbu %0" : "=r" (tbhi));	\
+		__asm__ __volatile__ ("mftbl %0" : "=r" (tblo));	\
+		val = 1000 * ((uint64_t) tbhi << 32) | tblo;		\
+	} while (0)
+#endif
+#else
+#warning TSC UNSUPPORTED
+/* All tests will be compiled also for the
+ * architecture without TSC support (e.g. SH).
+ * At run-time these will fail with ENOTSUP.
+ */
+#define rdtscll(val)	do {  } while (0)
+#define TSC_UNSUPPORTED
+#endif
+

[-- Attachment #3: Type: text/plain, Size: 354 bytes --]

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july

[-- Attachment #4: Type: text/plain, Size: 155 bytes --]

_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [LTP] [PATCH] compiling realtime tests for SH.
  2009-11-04 15:48 [LTP] [PATCH] compiling realtime tests for SH Giuseppe CAVALLARO
@ 2009-11-09 17:39 ` Subrata Modak
  2009-11-12  8:48   ` Sripathi Kodi
  0 siblings, 1 reply; 7+ messages in thread
From: Subrata Modak @ 2009-11-09 17:39 UTC (permalink / raw)
  To: Giuseppe CAVALLARO, Gowrishankar, amrith, Sripathi Kodi; +Cc: ltp-list

Hi Giuseppe,

Thanks for the patch. Meanwhile i did not find the RT guys saying
anything about this patch.

Gowri/Amrith/Sripathi,

Any views on this patch ?

Regards--
Subrata

** Also, this fails to apply:
patching file testcases/realtime/func/async_handler/async_handler_tsc.c
Hunk #1 succeeded at 46 (offset 1 line).
Hunk #2 succeeded at 193 (offset 2 lines).
patching file testcases/realtime/func/measurement/preempt_timing.c
patching file testcases/realtime/func/measurement/rdtsc-latency.c
patching file testcases/realtime/include/librttest.h
Hunk #2 succeeded at 98 (offset 1 line).
Hunk #4 succeeded at 138 (offset 1 line).
Hunk #5 succeeded at 337 (offset 8 lines).
patching file testcases/realtime/include/libtsc.h
---

On Wed, 2009-11-04 at 16:48 +0100, Giuseppe CAVALLARO wrote:
> Hoping somebody will find useful it.
> 
> Regards
> Peppe
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> differences
> between files
> attachment
> (ltp-full-20090731-sh_RT.patch)
> 
> 
> [PATCH] compiling realtime tests for SH.
> 
> This patch adds the atomi_add() define for __sh__;
> ltp realtime tests seem to show that it works.
> 
> The patch also moves the tsc macros form the librttest.h
> to another header file (named libtsc.h).
> 
> Without this I got the following error and no tests were built.
> 
>  [snip]
>  In file included from librttest.c:43:
>  ../include/librttest.h:127:2: error: #error 
>  ../include/librttest.h:169:2: error: #error 
>  In file included from librttest.c:43:
>  ../include/librttest.h: In function ‘atomic_add’:
>  [snip]
> 
> The tsc macros header is only included in the following tests
> (thus where necessary):
> 
>  o async_handler_tsc.c
>  o preempt_timing.c
>  o rdtsc-latency.c
> 
> Note1: instead of touching the make process the patch allows to build
> the tests above also for architecture that do not support tsc, yet.
> These tests will fail at run-time with ENOTSUP. A warning will
> appear while compiling as well.
> hmm, I do know if it is the right solution but it's simple and
> a good starting point for me.
> 
> Note2: I've just started running this part of the ltp on stlinux
> targets so I cannot provide results and I don't know which
> tests will fail.
> 
> Note3: realtime tests continues to build and apparently work on i386.
> 
> Signed-off-by: Giuseppe Cavallaro <peppe.cavallaro@st.com>
> 
> diff -urN
> ltp-full-20090731/testcases/realtime.orig/func/async_handler/async_handler_tsc.c ltp-full-20090731/testcases/realtime/func/async_handler/async_handler_tsc.c
> ---
> ltp-full-20090731/testcases/realtime.orig/func/async_handler/async_handler_tsc.c    2009-11-04 15:55:58.000000000 +0100
> +++
> ltp-full-20090731/testcases/realtime/func/async_handler/async_handler_tsc.c 2009-11-04 15:39:21.000000000 +0100
> @@ -45,6 +45,7 @@
>  #include <pthread.h>
>  #include <librttest.h>
>  #include <libstats.h>
> +#include <libtsc.h>
> 
>  #define HANDLER_PRIO 98
>  #define SIGNAL_PRIO 99
> @@ -190,6 +191,11 @@
>  int main(int argc, char *argv[])
>  {
>         int signal_id, handler_id;
> +
> +#ifdef TSC_UNSUPPORTED
> +       printf("Error: test cannot be executed on an arch wihout
> TSC.\n");
> +       return ENOTSUP;
> +#endif
>         setup();
> 
>         rt_init("h", parse_args, argc, argv);
> diff -urN
> ltp-full-20090731/testcases/realtime.orig/func/measurement/preempt_timing.c ltp-full-20090731/testcases/realtime/func/measurement/preempt_timing.c
> ---
> ltp-full-20090731/testcases/realtime.orig/func/measurement/preempt_timing.c 2009-11-04 15:55:58.000000000 +0100
> +++
> ltp-full-20090731/testcases/realtime/func/measurement/preempt_timing.c      2009-11-04 15:39:26.000000000 +0100
> @@ -52,7 +52,7 @@
>  #include <sys/mman.h>
>  #include <stdint.h>
>  #include <librttest.h>
> -
> +#include <libtsc.h>
> 
>  #define ITERATIONS 1000000ULL
>  #define INTERVALS 10
> @@ -86,6 +86,12 @@
>         struct sched_param param;
>         cpu_set_t mask;
>         int err;
> +
> +#ifdef TSC_UNSUPPORTED
> +       printf("Error: test cannot be executed on an arch wihout
> TSC.\n");
> +       return ENOTSUP;
> +#endif
> +
>         max = avg = 0;
>         min = -1;
>         setup();
> diff -urN
> ltp-full-20090731/testcases/realtime.orig/func/measurement/rdtsc-latency.c ltp-full-20090731/testcases/realtime/func/measurement/rdtsc-latency.c
> ---
> ltp-full-20090731/testcases/realtime.orig/func/measurement/rdtsc-latency.c  2009-11-04 15:55:58.000000000 +0100
> +++
> ltp-full-20090731/testcases/realtime/func/measurement/rdtsc-latency.c       2009-11-04 15:38:49.000000000 +0100
> @@ -44,6 +44,7 @@
>  #include <errno.h>
>  #include <stdint.h>
>  #include <librttest.h>
> +#include <libtsc.h>
> 
>  #define ITERATIONS 1000000
> 
> @@ -101,6 +102,12 @@
>         unsigned long long deltas[ITERATIONS];
>         unsigned long long max, min, avg, tsc_a, tsc_b, tsc_period;
>         struct sched_param param;
> +
> +#ifdef TSC_UNSUPPORTED
> +       printf("Error: test cannot be executed on an arch wihout
> TSC.\n");
> +       return ENOTSUP;
> +#endif
> +
>         setup();
> 
>         rt_init("h",parse_args,argc,argv);
> diff -urN
> ltp-full-20090731/testcases/realtime.orig/include/librttest.h
> ltp-full-20090731/testcases/realtime/include/librttest.h
> ---
> ltp-full-20090731/testcases/realtime.orig/include/librttest.h       2009-11-04 15:55:58.000000000 +0100
> +++
> ltp-full-20090731/testcases/realtime/include/librttest.h    2009-11-04
> 14:21:22.000000000 +0100
> @@ -36,6 +36,7 @@
>   *      2006-May-09: improved command line argument handling
>   *      2007-Jul-12: Added latency tracing functions -- Josh Triplett
>   *      2007-Jul-26: Renamed to librttest.h -- Josh Triplett
> + *      2009-Nov-4: TSC macros within another header -- Giuseppe
> Cavallaro
>   *
> 
> *****************************************************************************/
> 
> @@ -96,36 +97,7 @@
>  #define thread_quit(T) (((T)->flags) & THREAD_QUIT)
> 
>  #define PRINT_BUFFER_SIZE (1024*1024*4)
> -
> -/* TSC macros */
>  #define ULL_MAX 18446744073709551615ULL // (1 << 64) - 1
> -#if defined(__i386__)
> -#define rdtscll(val) __asm__ __volatile__("rdtsc" : "=A" (val))
> -#elif defined(__x86_64__)
> -#define rdtscll(val)                                   \
> -       do {                                            \
> -               uint32_t low, high;                     \
> -               __asm__ __volatile__ ("rdtsc" : "=a" (low),
> "=d" (high)); \
> -               val = (uint64_t)high << 32 | low;       \
> -       } while(0)
> -#elif defined(__powerpc__)
> -#if defined(__powerpc64__)     /* 64bit version */
> -#define rdtscll(val)                                   \
> -       do
> {                                                            \
> -               __asm__ __volatile__ ("mfspr %0, 268" :
> "=r" (val));    \
> -       } while(0)
> -#else  /*__powerpc__ 32bit version */
> -#define
> rdtscll(val)                                                   \
> -        do
> {                                                           \
> -               uint32_t tbhi,
> tblo ;                                   \
> -               __asm__ __volatile__ ("mftbu %0" :
> "=r" (tbhi));        \
> -               __asm__ __volatile__ ("mftbl %0" :
> "=r" (tblo));        \
> -               val = 1000 * ((uint64_t) tbhi << 32) |
> tblo;            \
> -       } while(0)
> -#endif
> -#else
> -#error
> -#endif
> 
>  extern pthread_mutex_t _buffer_mutex;
>  extern char * _print_buffer;
> @@ -135,7 +107,7 @@
> 
>  /* function prototypes */
> 
> -/* atomic_add - add integer to atomic variable
> +/* atomic_add - add integer to atomic variable and returns a value.
>   * i: integer value to add
>   * v: pointer of type atomic_t
>   */
> @@ -165,6 +137,20 @@
>         : "cc", "memory");
> 
>         return t;
> +#elif defined(__sh__)
> +       unsigned long t;
> +
> +       __asm__ __volatile__ (
> +"1:     movli.l @%2, %0         ! atomic_add_return     \n"
> +"       add     %1, %0                           \n"
> +"       movco.l %0, @%2                                 \n"
> +"       bf      1b                                   \n"
> +"       synco                                     \n"
> +       : "=&z" (t)
> +       : "r" (i), "r" (&v->counter)
> +       : "t");
> +
> +       return t;
>  #else
>  #error
>  #endif
> @@ -343,7 +329,6 @@
>   */
>  int ts_to_nsec(struct timespec *ts, nsec_t *ns);
> 
> -/* return difference in microseconds */
>  unsigned long long tsc_minus(unsigned long long tsc_start, unsigned
> long long tsc_end);
> 
>  /* rt_nanosleep: sleep for ns nanoseconds using clock_nanosleep
> diff -urN ltp-full-20090731/testcases/realtime.orig/include/libtsc.h
> ltp-full-20090731/testcases/realtime/include/libtsc.h
> ---
> ltp-full-20090731/testcases/realtime.orig/include/libtsc.h  1970-01-01
> 01:00:00.000000000 +0100
> +++
> ltp-full-20090731/testcases/realtime/include/libtsc.h       2009-11-04
> 15:41:03.000000000 +0100
> @@ -0,0 +1,72 @@
> +/******************************************************************************
> + *
> + *   Copyright © International Business Machines  Corp., 2006-2008
> + *
> + *   This program 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.
> + *
> + *   This program 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 this program;  if not, write to the Free Software
> + *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
> 02111-1307 USA
> + *
> + * NAME
> + *       libtsc.h
> + *
> + * DESCRIPTION
> + *
> + * USAGE:
> + *       To be included in some testcases.
> + *
> + * AUTHOR
> + *        Darren Hart <dvhltc@us.ibm.com>
> + *        Giuseppe Cavallaro <peppe.cavallarost.com>
> + *
> + * HISTORY
> + *      It directly comes from the librttest.h (see its HISTORY).
> + *
> +
> *****************************************************************************/
> +
> +#undef TSC_UNSUPPORTED
> +
> +/* TSC macros */
> +#if defined(__i386__)
> +#define rdtscll(val) __asm__ __volatile__("rdtsc" : "=A" (val))
> +#elif defined(__x86_64__)
> +#define rdtscll(val)                                   \
> +       do {                                            \
> +               uint32_t low, high;                     \
> +               __asm__ __volatile__ ("rdtsc" : "=a" (low),
> "=d" (high)); \
> +               val = (uint64_t)high << 32 | low;       \
> +       } while (0)
> +#elif defined(__powerpc__)
> +#if defined(__powerpc64__)     /* 64bit version */
> +#define rdtscll(val)                                   \
> +       do
> {                                                            \
> +               __asm__ __volatile__ ("mfspr %0, 268" :
> "=r" (val));    \
> +       } while (0)
> +#else  /*__powerpc__ 32bit version */
> +#define
> rdtscll(val)                                                   \
> +        do
> {                                                           \
> +               uint32_t tbhi,
> tblo ;                                   \
> +               __asm__ __volatile__ ("mftbu %0" :
> "=r" (tbhi));        \
> +               __asm__ __volatile__ ("mftbl %0" :
> "=r" (tblo));        \
> +               val = 1000 * ((uint64_t) tbhi << 32) |
> tblo;            \
> +       } while (0)
> +#endif
> +#else
> +#warning TSC UNSUPPORTED
> +/* All tests will be compiled also for the
> + * architecture without TSC support (e.g. SH).
> + * At run-time these will fail with ENOTSUP.
> + */
> +#define rdtscll(val)   do {  } while (0)
> +#define TSC_UNSUPPORTED
> +#endif
> +
> 


------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [LTP] [PATCH] compiling realtime tests for SH.
  2009-11-09 17:39 ` Subrata Modak
@ 2009-11-12  8:48   ` Sripathi Kodi
  2009-11-13  7:40     ` Giuseppe CAVALLARO
  0 siblings, 1 reply; 7+ messages in thread
From: Sripathi Kodi @ 2009-11-12  8:48 UTC (permalink / raw)
  To: subrata; +Cc: ltp-list, amrith, Gowrishankar, Sripathi Kodi

On Mon, 09 Nov 2009 23:09:16 +0530
Subrata Modak <subrata@linux.vnet.ibm.com> wrote:

> Hi Giuseppe,
> 
> Thanks for the patch. Meanwhile i did not find the RT guys saying
> anything about this patch.
> 
> Gowri/Amrith/Sripathi,
> 
> Any views on this patch ?

Hi Subrata,

I think separating out the tests that need TSC from the others is
the right thing to do. In future it may be useful to do something
similar for atomic_* functions as well.

In my opinion this patch would have been better split into 2
parts: one that separates out TSC parts and the other that adds atomic
functions for SH. That would make changelogs easier to search through
in future.

Thanks,
Sripathi.

> 
> Regards--
> Subrata
> 
> ** Also, this fails to apply:
> patching file testcases/realtime/func/async_handler/async_handler_tsc.c
> Hunk #1 succeeded at 46 (offset 1 line).
> Hunk #2 succeeded at 193 (offset 2 lines).
> patching file testcases/realtime/func/measurement/preempt_timing.c
> patching file testcases/realtime/func/measurement/rdtsc-latency.c
> patching file testcases/realtime/include/librttest.h
> Hunk #2 succeeded at 98 (offset 1 line).
> Hunk #4 succeeded at 138 (offset 1 line).
> Hunk #5 succeeded at 337 (offset 8 lines).
> patching file testcases/realtime/include/libtsc.h
> ---
> 
> On Wed, 2009-11-04 at 16:48 +0100, Giuseppe CAVALLARO wrote:
> > Hoping somebody will find useful it.
> > 
> > Regards
> > Peppe
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > differences
> > between files
> > attachment
> > (ltp-full-20090731-sh_RT.patch)
> > 
> > 
> > [PATCH] compiling realtime tests for SH.
> > 
> > This patch adds the atomi_add() define for __sh__;
> > ltp realtime tests seem to show that it works.
> > 
> > The patch also moves the tsc macros form the librttest.h
> > to another header file (named libtsc.h).
> > 
> > Without this I got the following error and no tests were built.
> > 
> >  [snip]
> >  In file included from librttest.c:43:
> >  ../include/librttest.h:127:2: error: #error 
> >  ../include/librttest.h:169:2: error: #error 
> >  In file included from librttest.c:43:
> >  ../include/librttest.h: In function ‘atomic_add’:
> >  [snip]
> > 
> > The tsc macros header is only included in the following tests
> > (thus where necessary):
> > 
> >  o async_handler_tsc.c
> >  o preempt_timing.c
> >  o rdtsc-latency.c
> > 
> > Note1: instead of touching the make process the patch allows to build
> > the tests above also for architecture that do not support tsc, yet.
> > These tests will fail at run-time with ENOTSUP. A warning will
> > appear while compiling as well.
> > hmm, I do know if it is the right solution but it's simple and
> > a good starting point for me.
> > 
> > Note2: I've just started running this part of the ltp on stlinux
> > targets so I cannot provide results and I don't know which
> > tests will fail.
> > 
> > Note3: realtime tests continues to build and apparently work on i386.
> > 
> > Signed-off-by: Giuseppe Cavallaro <peppe.cavallaro@st.com>
> > 
> > diff -urN
> > ltp-full-20090731/testcases/realtime.orig/func/async_handler/async_handler_tsc.c ltp-full-20090731/testcases/realtime/func/async_handler/async_handler_tsc.c
> > ---
> > ltp-full-20090731/testcases/realtime.orig/func/async_handler/async_handler_tsc.c    2009-11-04 15:55:58.000000000 +0100
> > +++
> > ltp-full-20090731/testcases/realtime/func/async_handler/async_handler_tsc.c 2009-11-04 15:39:21.000000000 +0100
> > @@ -45,6 +45,7 @@
> >  #include <pthread.h>
> >  #include <librttest.h>
> >  #include <libstats.h>
> > +#include <libtsc.h>
> > 
> >  #define HANDLER_PRIO 98
> >  #define SIGNAL_PRIO 99
> > @@ -190,6 +191,11 @@
> >  int main(int argc, char *argv[])
> >  {
> >         int signal_id, handler_id;
> > +
> > +#ifdef TSC_UNSUPPORTED
> > +       printf("Error: test cannot be executed on an arch wihout
> > TSC.\n");
> > +       return ENOTSUP;
> > +#endif
> >         setup();
> > 
> >         rt_init("h", parse_args, argc, argv);
> > diff -urN
> > ltp-full-20090731/testcases/realtime.orig/func/measurement/preempt_timing.c ltp-full-20090731/testcases/realtime/func/measurement/preempt_timing.c
> > ---
> > ltp-full-20090731/testcases/realtime.orig/func/measurement/preempt_timing.c 2009-11-04 15:55:58.000000000 +0100
> > +++
> > ltp-full-20090731/testcases/realtime/func/measurement/preempt_timing.c      2009-11-04 15:39:26.000000000 +0100
> > @@ -52,7 +52,7 @@
> >  #include <sys/mman.h>
> >  #include <stdint.h>
> >  #include <librttest.h>
> > -
> > +#include <libtsc.h>
> > 
> >  #define ITERATIONS 1000000ULL
> >  #define INTERVALS 10
> > @@ -86,6 +86,12 @@
> >         struct sched_param param;
> >         cpu_set_t mask;
> >         int err;
> > +
> > +#ifdef TSC_UNSUPPORTED
> > +       printf("Error: test cannot be executed on an arch wihout
> > TSC.\n");
> > +       return ENOTSUP;
> > +#endif
> > +
> >         max = avg = 0;
> >         min = -1;
> >         setup();
> > diff -urN
> > ltp-full-20090731/testcases/realtime.orig/func/measurement/rdtsc-latency.c ltp-full-20090731/testcases/realtime/func/measurement/rdtsc-latency.c
> > ---
> > ltp-full-20090731/testcases/realtime.orig/func/measurement/rdtsc-latency.c  2009-11-04 15:55:58.000000000 +0100
> > +++
> > ltp-full-20090731/testcases/realtime/func/measurement/rdtsc-latency.c       2009-11-04 15:38:49.000000000 +0100
> > @@ -44,6 +44,7 @@
> >  #include <errno.h>
> >  #include <stdint.h>
> >  #include <librttest.h>
> > +#include <libtsc.h>
> > 
> >  #define ITERATIONS 1000000
> > 
> > @@ -101,6 +102,12 @@
> >         unsigned long long deltas[ITERATIONS];
> >         unsigned long long max, min, avg, tsc_a, tsc_b, tsc_period;
> >         struct sched_param param;
> > +
> > +#ifdef TSC_UNSUPPORTED
> > +       printf("Error: test cannot be executed on an arch wihout
> > TSC.\n");
> > +       return ENOTSUP;
> > +#endif
> > +
> >         setup();
> > 
> >         rt_init("h",parse_args,argc,argv);
> > diff -urN
> > ltp-full-20090731/testcases/realtime.orig/include/librttest.h
> > ltp-full-20090731/testcases/realtime/include/librttest.h
> > ---
> > ltp-full-20090731/testcases/realtime.orig/include/librttest.h       2009-11-04 15:55:58.000000000 +0100
> > +++
> > ltp-full-20090731/testcases/realtime/include/librttest.h    2009-11-04
> > 14:21:22.000000000 +0100
> > @@ -36,6 +36,7 @@
> >   *      2006-May-09: improved command line argument handling
> >   *      2007-Jul-12: Added latency tracing functions -- Josh Triplett
> >   *      2007-Jul-26: Renamed to librttest.h -- Josh Triplett
> > + *      2009-Nov-4: TSC macros within another header -- Giuseppe
> > Cavallaro
> >   *
> > 
> > *****************************************************************************/
> > 
> > @@ -96,36 +97,7 @@
> >  #define thread_quit(T) (((T)->flags) & THREAD_QUIT)
> > 
> >  #define PRINT_BUFFER_SIZE (1024*1024*4)
> > -
> > -/* TSC macros */
> >  #define ULL_MAX 18446744073709551615ULL // (1 << 64) - 1
> > -#if defined(__i386__)
> > -#define rdtscll(val) __asm__ __volatile__("rdtsc" : "=A" (val))
> > -#elif defined(__x86_64__)
> > -#define rdtscll(val)                                   \
> > -       do {                                            \
> > -               uint32_t low, high;                     \
> > -               __asm__ __volatile__ ("rdtsc" : "=a" (low),
> > "=d" (high)); \
> > -               val = (uint64_t)high << 32 | low;       \
> > -       } while(0)
> > -#elif defined(__powerpc__)
> > -#if defined(__powerpc64__)     /* 64bit version */
> > -#define rdtscll(val)                                   \
> > -       do
> > {                                                            \
> > -               __asm__ __volatile__ ("mfspr %0, 268" :
> > "=r" (val));    \
> > -       } while(0)
> > -#else  /*__powerpc__ 32bit version */
> > -#define
> > rdtscll(val)                                                   \
> > -        do
> > {                                                           \
> > -               uint32_t tbhi,
> > tblo ;                                   \
> > -               __asm__ __volatile__ ("mftbu %0" :
> > "=r" (tbhi));        \
> > -               __asm__ __volatile__ ("mftbl %0" :
> > "=r" (tblo));        \
> > -               val = 1000 * ((uint64_t) tbhi << 32) |
> > tblo;            \
> > -       } while(0)
> > -#endif
> > -#else
> > -#error
> > -#endif
> > 
> >  extern pthread_mutex_t _buffer_mutex;
> >  extern char * _print_buffer;
> > @@ -135,7 +107,7 @@
> > 
> >  /* function prototypes */
> > 
> > -/* atomic_add - add integer to atomic variable
> > +/* atomic_add - add integer to atomic variable and returns a value.
> >   * i: integer value to add
> >   * v: pointer of type atomic_t
> >   */
> > @@ -165,6 +137,20 @@
> >         : "cc", "memory");
> > 
> >         return t;
> > +#elif defined(__sh__)
> > +       unsigned long t;
> > +
> > +       __asm__ __volatile__ (
> > +"1:     movli.l @%2, %0         ! atomic_add_return     \n"
> > +"       add     %1, %0                           \n"
> > +"       movco.l %0, @%2                                 \n"
> > +"       bf      1b                                   \n"
> > +"       synco                                     \n"
> > +       : "=&z" (t)
> > +       : "r" (i), "r" (&v->counter)
> > +       : "t");
> > +
> > +       return t;
> >  #else
> >  #error
> >  #endif
> > @@ -343,7 +329,6 @@
> >   */
> >  int ts_to_nsec(struct timespec *ts, nsec_t *ns);
> > 
> > -/* return difference in microseconds */
> >  unsigned long long tsc_minus(unsigned long long tsc_start, unsigned
> > long long tsc_end);
> > 
> >  /* rt_nanosleep: sleep for ns nanoseconds using clock_nanosleep
> > diff -urN ltp-full-20090731/testcases/realtime.orig/include/libtsc.h
> > ltp-full-20090731/testcases/realtime/include/libtsc.h
> > ---
> > ltp-full-20090731/testcases/realtime.orig/include/libtsc.h  1970-01-01
> > 01:00:00.000000000 +0100
> > +++
> > ltp-full-20090731/testcases/realtime/include/libtsc.h       2009-11-04
> > 15:41:03.000000000 +0100
> > @@ -0,0 +1,72 @@
> > +/******************************************************************************
> > + *
> > + *   Copyright © International Business Machines  Corp., 2006-2008
> > + *
> > + *   This program 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.
> > + *
> > + *   This program 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 this program;  if not, write to the Free Software
> > + *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
> > 02111-1307 USA
> > + *
> > + * NAME
> > + *       libtsc.h
> > + *
> > + * DESCRIPTION
> > + *
> > + * USAGE:
> > + *       To be included in some testcases.
> > + *
> > + * AUTHOR
> > + *        Darren Hart <dvhltc@us.ibm.com>
> > + *        Giuseppe Cavallaro <peppe.cavallarost.com>
> > + *
> > + * HISTORY
> > + *      It directly comes from the librttest.h (see its HISTORY).
> > + *
> > +
> > *****************************************************************************/
> > +
> > +#undef TSC_UNSUPPORTED
> > +
> > +/* TSC macros */
> > +#if defined(__i386__)
> > +#define rdtscll(val) __asm__ __volatile__("rdtsc" : "=A" (val))
> > +#elif defined(__x86_64__)
> > +#define rdtscll(val)                                   \
> > +       do {                                            \
> > +               uint32_t low, high;                     \
> > +               __asm__ __volatile__ ("rdtsc" : "=a" (low),
> > "=d" (high)); \
> > +               val = (uint64_t)high << 32 | low;       \
> > +       } while (0)
> > +#elif defined(__powerpc__)
> > +#if defined(__powerpc64__)     /* 64bit version */
> > +#define rdtscll(val)                                   \
> > +       do
> > {                                                            \
> > +               __asm__ __volatile__ ("mfspr %0, 268" :
> > "=r" (val));    \
> > +       } while (0)
> > +#else  /*__powerpc__ 32bit version */
> > +#define
> > rdtscll(val)                                                   \
> > +        do
> > {                                                           \
> > +               uint32_t tbhi,
> > tblo ;                                   \
> > +               __asm__ __volatile__ ("mftbu %0" :
> > "=r" (tbhi));        \
> > +               __asm__ __volatile__ ("mftbl %0" :
> > "=r" (tblo));        \
> > +               val = 1000 * ((uint64_t) tbhi << 32) |
> > tblo;            \
> > +       } while (0)
> > +#endif
> > +#else
> > +#warning TSC UNSUPPORTED
> > +/* All tests will be compiled also for the
> > + * architecture without TSC support (e.g. SH).
> > + * At run-time these will fail with ENOTSUP.
> > + */
> > +#define rdtscll(val)   do {  } while (0)
> > +#define TSC_UNSUPPORTED
> > +#endif
> > +
> > 
> 
> 
> ------------------------------------------------------------------------------
> Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
> trial. Simplify your report design, integration and deployment - and focus on 
> what you do best, core application coding. Discover what's new with
> Crystal Reports now.  http://p.sf.net/sfu/bobj-july
> _______________________________________________
> Ltp-list mailing list
> Ltp-list@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/ltp-list

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [LTP] [PATCH] compiling realtime tests for SH.
  2009-11-12  8:48   ` Sripathi Kodi
@ 2009-11-13  7:40     ` Giuseppe CAVALLARO
  2009-11-16  8:13       ` Subrata Modak
  0 siblings, 1 reply; 7+ messages in thread
From: Giuseppe CAVALLARO @ 2009-11-13  7:40 UTC (permalink / raw)
  To: Sripathi Kodi; +Cc: ltp-list, amrith, Gowrishankar, Sripathi Kodi

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Sripathi Kodi wrote:
> On Mon, 09 Nov 2009 23:09:16 +0530
> Subrata Modak <subrata@linux.vnet.ibm.com> wrote:
> 
>> Hi Giuseppe,
>>
>> Thanks for the patch. Meanwhile i did not find the RT guys saying
>> anything about this patch.
>>
>> Gowri/Amrith/Sripathi,
>>
>> Any views on this patch ?
> 
> Hi Subrata,
> 
> I think separating out the tests that need TSC from the others is
> the right thing to do. In future it may be useful to do something
> similar for atomic_* functions as well.
> 
> In my opinion this patch would have been better split into 2
> parts: one that separates out TSC parts and the other that adds atomic
> functions for SH. That would make changelogs easier to search through
> in future.

if you like I can resend the patch splitted into two parts.
Let me know.
Regards,
Peppe

> Thanks,
> Sripathi.
> 
>> Regards--
>> Subrata
>>
>> ** Also, this fails to apply:
>> patching file testcases/realtime/func/async_handler/async_handler_tsc.c
>> Hunk #1 succeeded at 46 (offset 1 line).
>> Hunk #2 succeeded at 193 (offset 2 lines).
>> patching file testcases/realtime/func/measurement/preempt_timing.c
>> patching file testcases/realtime/func/measurement/rdtsc-latency.c
>> patching file testcases/realtime/include/librttest.h
>> Hunk #2 succeeded at 98 (offset 1 line).
>> Hunk #4 succeeded at 138 (offset 1 line).
>> Hunk #5 succeeded at 337 (offset 8 lines).
>> patching file testcases/realtime/include/libtsc.h
>> ---
>>
>> On Wed, 2009-11-04 at 16:48 +0100, Giuseppe CAVALLARO wrote:
>>> Hoping somebody will find useful it.
>>>
>>> Regards
>>> Peppe
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>> differences
>>> between files
>>> attachment
>>> (ltp-full-20090731-sh_RT.patch)
>>>
>>>
>>> [PATCH] compiling realtime tests for SH.
>>>
>>> This patch adds the atomi_add() define for __sh__;
>>> ltp realtime tests seem to show that it works.
>>>
>>> The patch also moves the tsc macros form the librttest.h
>>> to another header file (named libtsc.h).
>>>
>>> Without this I got the following error and no tests were built.
>>>
>>>  [snip]
>>>  In file included from librttest.c:43:
>>>  ../include/librttest.h:127:2: error: #error 
>>>  ../include/librttest.h:169:2: error: #error 
>>>  In file included from librttest.c:43:
>>>  ../include/librttest.h: In function ‘atomic_add’:
>>>  [snip]
>>>
>>> The tsc macros header is only included in the following tests
>>> (thus where necessary):
>>>
>>>  o async_handler_tsc.c
>>>  o preempt_timing.c
>>>  o rdtsc-latency.c
>>>
>>> Note1: instead of touching the make process the patch allows to build
>>> the tests above also for architecture that do not support tsc, yet.
>>> These tests will fail at run-time with ENOTSUP. A warning will
>>> appear while compiling as well.
>>> hmm, I do know if it is the right solution but it's simple and
>>> a good starting point for me.
>>>
>>> Note2: I've just started running this part of the ltp on stlinux
>>> targets so I cannot provide results and I don't know which
>>> tests will fail.
>>>
>>> Note3: realtime tests continues to build and apparently work on i386.
>>>
>>> Signed-off-by: Giuseppe Cavallaro <peppe.cavallaro@st.com>
>>>
>>> diff -urN
>>> ltp-full-20090731/testcases/realtime.orig/func/async_handler/async_handler_tsc.c ltp-full-20090731/testcases/realtime/func/async_handler/async_handler_tsc.c
>>> ---
>>> ltp-full-20090731/testcases/realtime.orig/func/async_handler/async_handler_tsc.c    2009-11-04 15:55:58.000000000 +0100
>>> +++
>>> ltp-full-20090731/testcases/realtime/func/async_handler/async_handler_tsc.c 2009-11-04 15:39:21.000000000 +0100
>>> @@ -45,6 +45,7 @@
>>>  #include <pthread.h>
>>>  #include <librttest.h>
>>>  #include <libstats.h>
>>> +#include <libtsc.h>
>>>
>>>  #define HANDLER_PRIO 98
>>>  #define SIGNAL_PRIO 99
>>> @@ -190,6 +191,11 @@
>>>  int main(int argc, char *argv[])
>>>  {
>>>         int signal_id, handler_id;
>>> +
>>> +#ifdef TSC_UNSUPPORTED
>>> +       printf("Error: test cannot be executed on an arch wihout
>>> TSC.\n");
>>> +       return ENOTSUP;
>>> +#endif
>>>         setup();
>>>
>>>         rt_init("h", parse_args, argc, argv);
>>> diff -urN
>>> ltp-full-20090731/testcases/realtime.orig/func/measurement/preempt_timing.c ltp-full-20090731/testcases/realtime/func/measurement/preempt_timing.c
>>> ---
>>> ltp-full-20090731/testcases/realtime.orig/func/measurement/preempt_timing.c 2009-11-04 15:55:58.000000000 +0100
>>> +++
>>> ltp-full-20090731/testcases/realtime/func/measurement/preempt_timing.c      2009-11-04 15:39:26.000000000 +0100
>>> @@ -52,7 +52,7 @@
>>>  #include <sys/mman.h>
>>>  #include <stdint.h>
>>>  #include <librttest.h>
>>> -
>>> +#include <libtsc.h>
>>>
>>>  #define ITERATIONS 1000000ULL
>>>  #define INTERVALS 10
>>> @@ -86,6 +86,12 @@
>>>         struct sched_param param;
>>>         cpu_set_t mask;
>>>         int err;
>>> +
>>> +#ifdef TSC_UNSUPPORTED
>>> +       printf("Error: test cannot be executed on an arch wihout
>>> TSC.\n");
>>> +       return ENOTSUP;
>>> +#endif
>>> +
>>>         max = avg = 0;
>>>         min = -1;
>>>         setup();
>>> diff -urN
>>> ltp-full-20090731/testcases/realtime.orig/func/measurement/rdtsc-latency.c ltp-full-20090731/testcases/realtime/func/measurement/rdtsc-latency.c
>>> ---
>>> ltp-full-20090731/testcases/realtime.orig/func/measurement/rdtsc-latency.c  2009-11-04 15:55:58.000000000 +0100
>>> +++
>>> ltp-full-20090731/testcases/realtime/func/measurement/rdtsc-latency.c       2009-11-04 15:38:49.000000000 +0100
>>> @@ -44,6 +44,7 @@
>>>  #include <errno.h>
>>>  #include <stdint.h>
>>>  #include <librttest.h>
>>> +#include <libtsc.h>
>>>
>>>  #define ITERATIONS 1000000
>>>
>>> @@ -101,6 +102,12 @@
>>>         unsigned long long deltas[ITERATIONS];
>>>         unsigned long long max, min, avg, tsc_a, tsc_b, tsc_period;
>>>         struct sched_param param;
>>> +
>>> +#ifdef TSC_UNSUPPORTED
>>> +       printf("Error: test cannot be executed on an arch wihout
>>> TSC.\n");
>>> +       return ENOTSUP;
>>> +#endif
>>> +
>>>         setup();
>>>
>>>         rt_init("h",parse_args,argc,argv);
>>> diff -urN
>>> ltp-full-20090731/testcases/realtime.orig/include/librttest.h
>>> ltp-full-20090731/testcases/realtime/include/librttest.h
>>> ---
>>> ltp-full-20090731/testcases/realtime.orig/include/librttest.h       2009-11-04 15:55:58.000000000 +0100
>>> +++
>>> ltp-full-20090731/testcases/realtime/include/librttest.h    2009-11-04
>>> 14:21:22.000000000 +0100
>>> @@ -36,6 +36,7 @@
>>>   *      2006-May-09: improved command line argument handling
>>>   *      2007-Jul-12: Added latency tracing functions -- Josh Triplett
>>>   *      2007-Jul-26: Renamed to librttest.h -- Josh Triplett
>>> + *      2009-Nov-4: TSC macros within another header -- Giuseppe
>>> Cavallaro
>>>   *
>>>
>>> *****************************************************************************/
>>>
>>> @@ -96,36 +97,7 @@
>>>  #define thread_quit(T) (((T)->flags) & THREAD_QUIT)
>>>
>>>  #define PRINT_BUFFER_SIZE (1024*1024*4)
>>> -
>>> -/* TSC macros */
>>>  #define ULL_MAX 18446744073709551615ULL // (1 << 64) - 1
>>> -#if defined(__i386__)
>>> -#define rdtscll(val) __asm__ __volatile__("rdtsc" : "=A" (val))
>>> -#elif defined(__x86_64__)
>>> -#define rdtscll(val)                                   \
>>> -       do {                                            \
>>> -               uint32_t low, high;                     \
>>> -               __asm__ __volatile__ ("rdtsc" : "=a" (low),
>>> "=d" (high)); \
>>> -               val = (uint64_t)high << 32 | low;       \
>>> -       } while(0)
>>> -#elif defined(__powerpc__)
>>> -#if defined(__powerpc64__)     /* 64bit version */
>>> -#define rdtscll(val)                                   \
>>> -       do
>>> {                                                            \
>>> -               __asm__ __volatile__ ("mfspr %0, 268" :
>>> "=r" (val));    \
>>> -       } while(0)
>>> -#else  /*__powerpc__ 32bit version */
>>> -#define
>>> rdtscll(val)                                                   \
>>> -        do
>>> {                                                           \
>>> -               uint32_t tbhi,
>>> tblo ;                                   \
>>> -               __asm__ __volatile__ ("mftbu %0" :
>>> "=r" (tbhi));        \
>>> -               __asm__ __volatile__ ("mftbl %0" :
>>> "=r" (tblo));        \
>>> -               val = 1000 * ((uint64_t) tbhi << 32) |
>>> tblo;            \
>>> -       } while(0)
>>> -#endif
>>> -#else
>>> -#error
>>> -#endif
>>>
>>>  extern pthread_mutex_t _buffer_mutex;
>>>  extern char * _print_buffer;
>>> @@ -135,7 +107,7 @@
>>>
>>>  /* function prototypes */
>>>
>>> -/* atomic_add - add integer to atomic variable
>>> +/* atomic_add - add integer to atomic variable and returns a value.
>>>   * i: integer value to add
>>>   * v: pointer of type atomic_t
>>>   */
>>> @@ -165,6 +137,20 @@
>>>         : "cc", "memory");
>>>
>>>         return t;
>>> +#elif defined(__sh__)
>>> +       unsigned long t;
>>> +
>>> +       __asm__ __volatile__ (
>>> +"1:     movli.l @%2, %0         ! atomic_add_return     \n"
>>> +"       add     %1, %0                           \n"
>>> +"       movco.l %0, @%2                                 \n"
>>> +"       bf      1b                                   \n"
>>> +"       synco                                     \n"
>>> +       : "=&z" (t)
>>> +       : "r" (i), "r" (&v->counter)
>>> +       : "t");
>>> +
>>> +       return t;
>>>  #else
>>>  #error
>>>  #endif
>>> @@ -343,7 +329,6 @@
>>>   */
>>>  int ts_to_nsec(struct timespec *ts, nsec_t *ns);
>>>
>>> -/* return difference in microseconds */
>>>  unsigned long long tsc_minus(unsigned long long tsc_start, unsigned
>>> long long tsc_end);
>>>
>>>  /* rt_nanosleep: sleep for ns nanoseconds using clock_nanosleep
>>> diff -urN ltp-full-20090731/testcases/realtime.orig/include/libtsc.h
>>> ltp-full-20090731/testcases/realtime/include/libtsc.h
>>> ---
>>> ltp-full-20090731/testcases/realtime.orig/include/libtsc.h  1970-01-01
>>> 01:00:00.000000000 +0100
>>> +++
>>> ltp-full-20090731/testcases/realtime/include/libtsc.h       2009-11-04
>>> 15:41:03.000000000 +0100
>>> @@ -0,0 +1,72 @@
>>> +/******************************************************************************
>>> + *
>>> + *   Copyright © International Business Machines  Corp., 2006-2008
>>> + *
>>> + *   This program 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.
>>> + *
>>> + *   This program 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 this program;  if not, write to the Free Software
>>> + *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
>>> 02111-1307 USA
>>> + *
>>> + * NAME
>>> + *       libtsc.h
>>> + *
>>> + * DESCRIPTION
>>> + *
>>> + * USAGE:
>>> + *       To be included in some testcases.
>>> + *
>>> + * AUTHOR
>>> + *        Darren Hart <dvhltc@us.ibm.com>
>>> + *        Giuseppe Cavallaro <peppe.cavallarost.com>
>>> + *
>>> + * HISTORY
>>> + *      It directly comes from the librttest.h (see its HISTORY).
>>> + *
>>> +
>>> *****************************************************************************/
>>> +
>>> +#undef TSC_UNSUPPORTED
>>> +
>>> +/* TSC macros */
>>> +#if defined(__i386__)
>>> +#define rdtscll(val) __asm__ __volatile__("rdtsc" : "=A" (val))
>>> +#elif defined(__x86_64__)
>>> +#define rdtscll(val)                                   \
>>> +       do {                                            \
>>> +               uint32_t low, high;                     \
>>> +               __asm__ __volatile__ ("rdtsc" : "=a" (low),
>>> "=d" (high)); \
>>> +               val = (uint64_t)high << 32 | low;       \
>>> +       } while (0)
>>> +#elif defined(__powerpc__)
>>> +#if defined(__powerpc64__)     /* 64bit version */
>>> +#define rdtscll(val)                                   \
>>> +       do
>>> {                                                            \
>>> +               __asm__ __volatile__ ("mfspr %0, 268" :
>>> "=r" (val));    \
>>> +       } while (0)
>>> +#else  /*__powerpc__ 32bit version */
>>> +#define
>>> rdtscll(val)                                                   \
>>> +        do
>>> {                                                           \
>>> +               uint32_t tbhi,
>>> tblo ;                                   \
>>> +               __asm__ __volatile__ ("mftbu %0" :
>>> "=r" (tbhi));        \
>>> +               __asm__ __volatile__ ("mftbl %0" :
>>> "=r" (tblo));        \
>>> +               val = 1000 * ((uint64_t) tbhi << 32) |
>>> tblo;            \
>>> +       } while (0)
>>> +#endif
>>> +#else
>>> +#warning TSC UNSUPPORTED
>>> +/* All tests will be compiled also for the
>>> + * architecture without TSC support (e.g. SH).
>>> + * At run-time these will fail with ENOTSUP.
>>> + */
>>> +#define rdtscll(val)   do {  } while (0)
>>> +#define TSC_UNSUPPORTED
>>> +#endif
>>> +
>>>
>>
>> ------------------------------------------------------------------------------
>> Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
>> trial. Simplify your report design, integration and deployment - and focus on 
>> what you do best, core application coding. Discover what's new with
>> Crystal Reports now.  http://p.sf.net/sfu/bobj-july
>> _______________________________________________
>> Ltp-list mailing list
>> Ltp-list@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/ltp-list
> 

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkr9DXwACgkQ2Xo3j31MSSKO7wCgsH3KAqveTZfPlZhTeQDMLrMl
+w4An0XRbe7MZQa/Nk5Rs6D58rvIHIZk
=MRBR
-----END PGP SIGNATURE-----

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [LTP] [PATCH] compiling realtime tests for SH.
  2009-11-13  7:40     ` Giuseppe CAVALLARO
@ 2009-11-16  8:13       ` Subrata Modak
  2009-11-16 10:53         ` Giuseppe CAVALLARO
  0 siblings, 1 reply; 7+ messages in thread
From: Subrata Modak @ 2009-11-16  8:13 UTC (permalink / raw)
  To: Giuseppe CAVALLARO; +Cc: ltp-list, amrith, Gowrishankar, Sripathi Kodi

Hi Giuseppe,

On Fri, 2009-11-13 at 08:40 +0100, Giuseppe CAVALLARO wrote: 
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> Sripathi Kodi wrote:
> > On Mon, 09 Nov 2009 23:09:16 +0530
> > Subrata Modak <subrata@linux.vnet.ibm.com> wrote:
> > 
> >> Hi Giuseppe,
> >>
> >> Thanks for the patch. Meanwhile i did not find the RT guys saying
> >> anything about this patch.
> >>
> >> Gowri/Amrith/Sripathi,
> >>
> >> Any views on this patch ?
> > 
> > Hi Subrata,
> > 
> > I think separating out the tests that need TSC from the others is
> > the right thing to do. In future it may be useful to do something
> > similar for atomic_* functions as well.
> > 
> > In my opinion this patch would have been better split into 2
> > parts: one that separates out TSC parts and the other that adds atomic
> > functions for SH. That would make changelogs easier to search through
> > in future.
> 
> if you like I can resend the patch splitted into two parts.
> Let me know.

Yah, Please do so. I will do separate check-ins with separate LOG
messages.

Regards--
Subrata

> Regards,
> Peppe
> 
> > Thanks,
> > Sripathi.
> > 
> >> Regards--
> >> Subrata
> >>
> >> ** Also, this fails to apply:
> >> patching file testcases/realtime/func/async_handler/async_handler_tsc.c
> >> Hunk #1 succeeded at 46 (offset 1 line).
> >> Hunk #2 succeeded at 193 (offset 2 lines).
> >> patching file testcases/realtime/func/measurement/preempt_timing.c
> >> patching file testcases/realtime/func/measurement/rdtsc-latency.c
> >> patching file testcases/realtime/include/librttest.h
> >> Hunk #2 succeeded at 98 (offset 1 line).
> >> Hunk #4 succeeded at 138 (offset 1 line).
> >> Hunk #5 succeeded at 337 (offset 8 lines).
> >> patching file testcases/realtime/include/libtsc.h
> >> ---
> >>
> >> On Wed, 2009-11-04 at 16:48 +0100, Giuseppe CAVALLARO wrote:
> >>> Hoping somebody will find useful it.
> >>>
> >>> Regards
> >>> Peppe
> >>>
> >>>
> >>>
> >>>
> >>>
> >>>
> >>>
> >>>
> >>>
> >>>
> >>>
> >>> differences
> >>> between files
> >>> attachment
> >>> (ltp-full-20090731-sh_RT.patch)
> >>>
> >>>
> >>> [PATCH] compiling realtime tests for SH.
> >>>
> >>> This patch adds the atomi_add() define for __sh__;
> >>> ltp realtime tests seem to show that it works.
> >>>
> >>> The patch also moves the tsc macros form the librttest.h
> >>> to another header file (named libtsc.h).
> >>>
> >>> Without this I got the following error and no tests were built.
> >>>
> >>>  [snip]
> >>>  In file included from librttest.c:43:
> >>>  ../include/librttest.h:127:2: error: #error 
> >>>  ../include/librttest.h:169:2: error: #error 
> >>>  In file included from librttest.c:43:
> >>>  ../include/librttest.h: In function ‘atomic_add’:
> >>>  [snip]
> >>>
> >>> The tsc macros header is only included in the following tests
> >>> (thus where necessary):
> >>>
> >>>  o async_handler_tsc.c
> >>>  o preempt_timing.c
> >>>  o rdtsc-latency.c
> >>>
> >>> Note1: instead of touching the make process the patch allows to build
> >>> the tests above also for architecture that do not support tsc, yet.
> >>> These tests will fail at run-time with ENOTSUP. A warning will
> >>> appear while compiling as well.
> >>> hmm, I do know if it is the right solution but it's simple and
> >>> a good starting point for me.
> >>>
> >>> Note2: I've just started running this part of the ltp on stlinux
> >>> targets so I cannot provide results and I don't know which
> >>> tests will fail.
> >>>
> >>> Note3: realtime tests continues to build and apparently work on i386.
> >>>
> >>> Signed-off-by: Giuseppe Cavallaro <peppe.cavallaro@st.com>
> >>>
> >>> diff -urN
> >>> ltp-full-20090731/testcases/realtime.orig/func/async_handler/async_handler_tsc.c ltp-full-20090731/testcases/realtime/func/async_handler/async_handler_tsc.c
> >>> ---
> >>> ltp-full-20090731/testcases/realtime.orig/func/async_handler/async_handler_tsc.c    2009-11-04 15:55:58.000000000 +0100
> >>> +++
> >>> ltp-full-20090731/testcases/realtime/func/async_handler/async_handler_tsc.c 2009-11-04 15:39:21.000000000 +0100
> >>> @@ -45,6 +45,7 @@
> >>>  #include <pthread.h>
> >>>  #include <librttest.h>
> >>>  #include <libstats.h>
> >>> +#include <libtsc.h>
> >>>
> >>>  #define HANDLER_PRIO 98
> >>>  #define SIGNAL_PRIO 99
> >>> @@ -190,6 +191,11 @@
> >>>  int main(int argc, char *argv[])
> >>>  {
> >>>         int signal_id, handler_id;
> >>> +
> >>> +#ifdef TSC_UNSUPPORTED
> >>> +       printf("Error: test cannot be executed on an arch wihout
> >>> TSC.\n");
> >>> +       return ENOTSUP;
> >>> +#endif
> >>>         setup();
> >>>
> >>>         rt_init("h", parse_args, argc, argv);
> >>> diff -urN
> >>> ltp-full-20090731/testcases/realtime.orig/func/measurement/preempt_timing.c ltp-full-20090731/testcases/realtime/func/measurement/preempt_timing.c
> >>> ---
> >>> ltp-full-20090731/testcases/realtime.orig/func/measurement/preempt_timing.c 2009-11-04 15:55:58.000000000 +0100
> >>> +++
> >>> ltp-full-20090731/testcases/realtime/func/measurement/preempt_timing.c      2009-11-04 15:39:26.000000000 +0100
> >>> @@ -52,7 +52,7 @@
> >>>  #include <sys/mman.h>
> >>>  #include <stdint.h>
> >>>  #include <librttest.h>
> >>> -
> >>> +#include <libtsc.h>
> >>>
> >>>  #define ITERATIONS 1000000ULL
> >>>  #define INTERVALS 10
> >>> @@ -86,6 +86,12 @@
> >>>         struct sched_param param;
> >>>         cpu_set_t mask;
> >>>         int err;
> >>> +
> >>> +#ifdef TSC_UNSUPPORTED
> >>> +       printf("Error: test cannot be executed on an arch wihout
> >>> TSC.\n");
> >>> +       return ENOTSUP;
> >>> +#endif
> >>> +
> >>>         max = avg = 0;
> >>>         min = -1;
> >>>         setup();
> >>> diff -urN
> >>> ltp-full-20090731/testcases/realtime.orig/func/measurement/rdtsc-latency.c ltp-full-20090731/testcases/realtime/func/measurement/rdtsc-latency.c
> >>> ---
> >>> ltp-full-20090731/testcases/realtime.orig/func/measurement/rdtsc-latency.c  2009-11-04 15:55:58.000000000 +0100
> >>> +++
> >>> ltp-full-20090731/testcases/realtime/func/measurement/rdtsc-latency.c       2009-11-04 15:38:49.000000000 +0100
> >>> @@ -44,6 +44,7 @@
> >>>  #include <errno.h>
> >>>  #include <stdint.h>
> >>>  #include <librttest.h>
> >>> +#include <libtsc.h>
> >>>
> >>>  #define ITERATIONS 1000000
> >>>
> >>> @@ -101,6 +102,12 @@
> >>>         unsigned long long deltas[ITERATIONS];
> >>>         unsigned long long max, min, avg, tsc_a, tsc_b, tsc_period;
> >>>         struct sched_param param;
> >>> +
> >>> +#ifdef TSC_UNSUPPORTED
> >>> +       printf("Error: test cannot be executed on an arch wihout
> >>> TSC.\n");
> >>> +       return ENOTSUP;
> >>> +#endif
> >>> +
> >>>         setup();
> >>>
> >>>         rt_init("h",parse_args,argc,argv);
> >>> diff -urN
> >>> ltp-full-20090731/testcases/realtime.orig/include/librttest.h
> >>> ltp-full-20090731/testcases/realtime/include/librttest.h
> >>> ---
> >>> ltp-full-20090731/testcases/realtime.orig/include/librttest.h       2009-11-04 15:55:58.000000000 +0100
> >>> +++
> >>> ltp-full-20090731/testcases/realtime/include/librttest.h    2009-11-04
> >>> 14:21:22.000000000 +0100
> >>> @@ -36,6 +36,7 @@
> >>>   *      2006-May-09: improved command line argument handling
> >>>   *      2007-Jul-12: Added latency tracing functions -- Josh Triplett
> >>>   *      2007-Jul-26: Renamed to librttest.h -- Josh Triplett
> >>> + *      2009-Nov-4: TSC macros within another header -- Giuseppe
> >>> Cavallaro
> >>>   *
> >>>
> >>> *****************************************************************************/
> >>>
> >>> @@ -96,36 +97,7 @@
> >>>  #define thread_quit(T) (((T)->flags) & THREAD_QUIT)
> >>>
> >>>  #define PRINT_BUFFER_SIZE (1024*1024*4)
> >>> -
> >>> -/* TSC macros */
> >>>  #define ULL_MAX 18446744073709551615ULL // (1 << 64) - 1
> >>> -#if defined(__i386__)
> >>> -#define rdtscll(val) __asm__ __volatile__("rdtsc" : "=A" (val))
> >>> -#elif defined(__x86_64__)
> >>> -#define rdtscll(val)                                   \
> >>> -       do {                                            \
> >>> -               uint32_t low, high;                     \
> >>> -               __asm__ __volatile__ ("rdtsc" : "=a" (low),
> >>> "=d" (high)); \
> >>> -               val = (uint64_t)high << 32 | low;       \
> >>> -       } while(0)
> >>> -#elif defined(__powerpc__)
> >>> -#if defined(__powerpc64__)     /* 64bit version */
> >>> -#define rdtscll(val)                                   \
> >>> -       do
> >>> {                                                            \
> >>> -               __asm__ __volatile__ ("mfspr %0, 268" :
> >>> "=r" (val));    \
> >>> -       } while(0)
> >>> -#else  /*__powerpc__ 32bit version */
> >>> -#define
> >>> rdtscll(val)                                                   \
> >>> -        do
> >>> {                                                           \
> >>> -               uint32_t tbhi,
> >>> tblo ;                                   \
> >>> -               __asm__ __volatile__ ("mftbu %0" :
> >>> "=r" (tbhi));        \
> >>> -               __asm__ __volatile__ ("mftbl %0" :
> >>> "=r" (tblo));        \
> >>> -               val = 1000 * ((uint64_t) tbhi << 32) |
> >>> tblo;            \
> >>> -       } while(0)
> >>> -#endif
> >>> -#else
> >>> -#error
> >>> -#endif
> >>>
> >>>  extern pthread_mutex_t _buffer_mutex;
> >>>  extern char * _print_buffer;
> >>> @@ -135,7 +107,7 @@
> >>>
> >>>  /* function prototypes */
> >>>
> >>> -/* atomic_add - add integer to atomic variable
> >>> +/* atomic_add - add integer to atomic variable and returns a value.
> >>>   * i: integer value to add
> >>>   * v: pointer of type atomic_t
> >>>   */
> >>> @@ -165,6 +137,20 @@
> >>>         : "cc", "memory");
> >>>
> >>>         return t;
> >>> +#elif defined(__sh__)
> >>> +       unsigned long t;
> >>> +
> >>> +       __asm__ __volatile__ (
> >>> +"1:     movli.l @%2, %0         ! atomic_add_return     \n"
> >>> +"       add     %1, %0                           \n"
> >>> +"       movco.l %0, @%2                                 \n"
> >>> +"       bf      1b                                   \n"
> >>> +"       synco                                     \n"
> >>> +       : "=&z" (t)
> >>> +       : "r" (i), "r" (&v->counter)
> >>> +       : "t");
> >>> +
> >>> +       return t;
> >>>  #else
> >>>  #error
> >>>  #endif
> >>> @@ -343,7 +329,6 @@
> >>>   */
> >>>  int ts_to_nsec(struct timespec *ts, nsec_t *ns);
> >>>
> >>> -/* return difference in microseconds */
> >>>  unsigned long long tsc_minus(unsigned long long tsc_start, unsigned
> >>> long long tsc_end);
> >>>
> >>>  /* rt_nanosleep: sleep for ns nanoseconds using clock_nanosleep
> >>> diff -urN ltp-full-20090731/testcases/realtime.orig/include/libtsc.h
> >>> ltp-full-20090731/testcases/realtime/include/libtsc.h
> >>> ---
> >>> ltp-full-20090731/testcases/realtime.orig/include/libtsc.h  1970-01-01
> >>> 01:00:00.000000000 +0100
> >>> +++
> >>> ltp-full-20090731/testcases/realtime/include/libtsc.h       2009-11-04
> >>> 15:41:03.000000000 +0100
> >>> @@ -0,0 +1,72 @@
> >>> +/******************************************************************************
> >>> + *
> >>> + *   Copyright © International Business Machines  Corp., 2006-2008
> >>> + *
> >>> + *   This program 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.
> >>> + *
> >>> + *   This program 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 this program;  if not, write to the Free Software
> >>> + *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
> >>> 02111-1307 USA
> >>> + *
> >>> + * NAME
> >>> + *       libtsc.h
> >>> + *
> >>> + * DESCRIPTION
> >>> + *
> >>> + * USAGE:
> >>> + *       To be included in some testcases.
> >>> + *
> >>> + * AUTHOR
> >>> + *        Darren Hart <dvhltc@us.ibm.com>
> >>> + *        Giuseppe Cavallaro <peppe.cavallarost.com>
> >>> + *
> >>> + * HISTORY
> >>> + *      It directly comes from the librttest.h (see its HISTORY).
> >>> + *
> >>> +
> >>> *****************************************************************************/
> >>> +
> >>> +#undef TSC_UNSUPPORTED
> >>> +
> >>> +/* TSC macros */
> >>> +#if defined(__i386__)
> >>> +#define rdtscll(val) __asm__ __volatile__("rdtsc" : "=A" (val))
> >>> +#elif defined(__x86_64__)
> >>> +#define rdtscll(val)                                   \
> >>> +       do {                                            \
> >>> +               uint32_t low, high;                     \
> >>> +               __asm__ __volatile__ ("rdtsc" : "=a" (low),
> >>> "=d" (high)); \
> >>> +               val = (uint64_t)high << 32 | low;       \
> >>> +       } while (0)
> >>> +#elif defined(__powerpc__)
> >>> +#if defined(__powerpc64__)     /* 64bit version */
> >>> +#define rdtscll(val)                                   \
> >>> +       do
> >>> {                                                            \
> >>> +               __asm__ __volatile__ ("mfspr %0, 268" :
> >>> "=r" (val));    \
> >>> +       } while (0)
> >>> +#else  /*__powerpc__ 32bit version */
> >>> +#define
> >>> rdtscll(val)                                                   \
> >>> +        do
> >>> {                                                           \
> >>> +               uint32_t tbhi,
> >>> tblo ;                                   \
> >>> +               __asm__ __volatile__ ("mftbu %0" :
> >>> "=r" (tbhi));        \
> >>> +               __asm__ __volatile__ ("mftbl %0" :
> >>> "=r" (tblo));        \
> >>> +               val = 1000 * ((uint64_t) tbhi << 32) |
> >>> tblo;            \
> >>> +       } while (0)
> >>> +#endif
> >>> +#else
> >>> +#warning TSC UNSUPPORTED
> >>> +/* All tests will be compiled also for the
> >>> + * architecture without TSC support (e.g. SH).
> >>> + * At run-time these will fail with ENOTSUP.
> >>> + */
> >>> +#define rdtscll(val)   do {  } while (0)
> >>> +#define TSC_UNSUPPORTED
> >>> +#endif
> >>> +
> >>>
> >>
> >> ------------------------------------------------------------------------------
> >> Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
> >> trial. Simplify your report design, integration and deployment - and focus on 
> >> what you do best, core application coding. Discover what's new with
> >> Crystal Reports now.  http://p.sf.net/sfu/bobj-july
> >> _______________________________________________
> >> Ltp-list mailing list
> >> Ltp-list@lists.sourceforge.net
> >> https://lists.sourceforge.net/lists/listinfo/ltp-list
> > 
> 
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.9 (GNU/Linux)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
> 
> iEYEARECAAYFAkr9DXwACgkQ2Xo3j31MSSKO7wCgsH3KAqveTZfPlZhTeQDMLrMl
> +w4An0XRbe7MZQa/Nk5Rs6D58rvIHIZk
> =MRBR
> -----END PGP SIGNATURE-----


------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [LTP] [PATCH] compiling realtime tests for SH.
  2009-11-16  8:13       ` Subrata Modak
@ 2009-11-16 10:53         ` Giuseppe CAVALLARO
  2009-11-16 13:39           ` Subrata Modak
  0 siblings, 1 reply; 7+ messages in thread
From: Giuseppe CAVALLARO @ 2009-11-16 10:53 UTC (permalink / raw)
  To: subrata; +Cc: ltp-list, amrith, Gowrishankar, Sripathi Kodi

[-- Attachment #1: Type: text/plain, Size: 813 bytes --]

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Subrata Modak wrote:
>>>> In my opinion this patch would have been better split into 2
>>>> parts: one that separates out TSC parts and the other that adds atomic
>>>> functions for SH. That would make changelogs easier to search through
>>>> in future.
> if you like I can resend the patch splitted into two parts.
> Let me know.
> 
>> Yah, Please do so. I will do separate check-ins with separate LOG
>> messages.

Hi Subrata,
in attachment the two patches.

Regards
Peppe

> 
>> Regards--
>> Subrata
> 
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAksBLyoACgkQ2Xo3j31MSSIMfgCgn3qXNrOd/2mhyeri3loHGoBg
u1IAoIhbksE6wEIRWLYoIMGhQBZGF1dj
=QsPg
-----END PGP SIGNATURE-----

[-- Attachment #2: ltp-full-20090731-SH-atomic_add.patch --]
[-- Type: text/x-patch, Size: 944 bytes --]

[PATCH (1/2)] add atomi_add() define for __sh__.

Signed-off-by: Giuseppe Cavallaro <peppe.cavallaro@st.com>

--- ltp-full-20090731/testcases/realtime.orig/include/librttest.h	2009-11-04 15:55:58.000000000 +0100
+++ ltp-full-20090731/testcases/realtime/include/librttest.h	2009-11-16 11:27:23.000000000 +0100
@@ -135,7 +135,7 @@ extern double pass_criteria;
 
 /* function prototypes */
 
-/* atomic_add - add integer to atomic variable
+/* atomic_add - add integer to atomic variable and returns a value.
  * i: integer value to add
  * v: pointer of type atomic_t
  */
@@ -165,6 +165,20 @@ static inline int atomic_add(int i, atom
 	: "cc", "memory");
 
 	return t;
+#elif defined(__sh__)
+	unsigned long t;
+
+	__asm__ __volatile__ (
+"1:	 movli.l @%2, %0	\n"
+"	 add     %1, %0		\n"
+"	 movco.l %0, @%2	\n"
+"	 bf      1b		\n"
+"       synco			\n"
+	: "=&z" (t)
+	: "r" (i), "r" (&v->counter)
+	: "t");
+
+	return t;
 #else
 #error
 #endif

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #3: ltp-full-20090731-tsc_splitted.patch --]
[-- Type: text/x-patch; name="ltp-full-20090731-tsc_splitted.patch", Size: 8085 bytes --]

[PATCH (2/2)] splitting the tsc support.

The patch moves the tsc macros form the librttest.h
to another header file (named libtsc.h).

Without this I got the following error and no tests were built.

 [snip]
 In file included from librttest.c:43:
 ../include/librttest.h:127:2: error: #error 
 ../include/librttest.h:169:2: error: #error 
 In file included from librttest.c:43:
 ../include/librttest.h: In function ���atomic_add���:
 [snip]

The tsc macros header is only included in the following tests
(thus where necessary):

 o async_handler_tsc.c
 o preempt_timing.c
 o rdtsc-latency.c

Note1: instead of touching the make process the patch allows to build
the tests above also for architecture that do not support tsc, yet.
These tests will fail at run-time with ENOTSUP. A warning will
appear while compiling as well.
hmm, I do know if it is the right solution but it's simple and
a good starting point for me.

Signed-off-by: Giuseppe Cavallaro <peppe.cavallaro@st.com>

diff -uprN ltp-full-20090731/testcases/realtime.orig/func/async_handler/async_handler_tsc.c ltp-full-20090731/testcases/realtime/func/async_handler/async_handler_tsc.c
--- ltp-full-20090731/testcases/realtime.orig/func/async_handler/async_handler_tsc.c	2009-11-04 15:55:58.000000000 +0100
+++ ltp-full-20090731/testcases/realtime/func/async_handler/async_handler_tsc.c	2009-11-16 11:38:43.000000000 +0100
@@ -45,6 +45,7 @@
 #include <pthread.h>
 #include <librttest.h>
 #include <libstats.h>
+#include <libtsc.h>
 
 #define HANDLER_PRIO 98
 #define SIGNAL_PRIO 99
@@ -190,6 +191,11 @@ void *signal_thread(void *arg)
 int main(int argc, char *argv[])
 {
 	int signal_id, handler_id;
+
+#ifdef TSC_UNSUPPORTED
+	printf("Error: test cannot be executed on an arch wihout TSC.\n");
+	return ENOTSUP;
+#endif
 	setup();
 
 	rt_init("h", parse_args, argc, argv);
diff -uprN ltp-full-20090731/testcases/realtime.orig/func/measurement/preempt_timing.c ltp-full-20090731/testcases/realtime/func/measurement/preempt_timing.c
--- ltp-full-20090731/testcases/realtime.orig/func/measurement/preempt_timing.c	2009-11-04 15:55:58.000000000 +0100
+++ ltp-full-20090731/testcases/realtime/func/measurement/preempt_timing.c	2009-11-16 11:38:43.000000000 +0100
@@ -52,7 +52,7 @@
 #include <sys/mman.h>
 #include <stdint.h>
 #include <librttest.h>
-
+#include <libtsc.h>
 
 #define ITERATIONS 1000000ULL
 #define INTERVALS 10
@@ -86,6 +86,12 @@ int main(int argc, char *argv[])
 	struct sched_param param;
 	cpu_set_t mask;
 	int err;
+
+#ifdef TSC_UNSUPPORTED
+	printf("Error: test cannot be executed on an arch wihout TSC.\n");
+	return ENOTSUP;
+#endif
+
 	max = avg = 0;
 	min = -1;
 	setup();
diff -uprN ltp-full-20090731/testcases/realtime.orig/func/measurement/rdtsc-latency.c ltp-full-20090731/testcases/realtime/func/measurement/rdtsc-latency.c
--- ltp-full-20090731/testcases/realtime.orig/func/measurement/rdtsc-latency.c	2009-11-04 15:55:58.000000000 +0100
+++ ltp-full-20090731/testcases/realtime/func/measurement/rdtsc-latency.c	2009-11-16 11:38:43.000000000 +0100
@@ -44,6 +44,7 @@
 #include <errno.h>
 #include <stdint.h>
 #include <librttest.h>
+#include <libtsc.h>
 
 #define ITERATIONS 1000000
 
@@ -101,6 +102,12 @@ int main(int argc, char *argv[])
 	unsigned long long deltas[ITERATIONS];
 	unsigned long long max, min, avg, tsc_a, tsc_b, tsc_period;
 	struct sched_param param;
+
+#ifdef TSC_UNSUPPORTED
+	printf("Error: test cannot be executed on an arch wihout TSC.\n");
+	return ENOTSUP;
+#endif
+
 	setup();
 
 	rt_init("h",parse_args,argc,argv);
diff -uprN ltp-full-20090731/testcases/realtime.orig/include/librttest.h ltp-full-20090731/testcases/realtime/include/librttest.h
--- ltp-full-20090731/testcases/realtime.orig/include/librttest.h	2009-11-16 11:33:20.000000000 +0100
+++ ltp-full-20090731/testcases/realtime/include/librttest.h	2009-11-16 11:40:11.000000000 +0100
@@ -36,6 +36,7 @@
  *      2006-May-09: improved command line argument handling
  *      2007-Jul-12: Added latency tracing functions -- Josh Triplett
  *      2007-Jul-26: Renamed to librttest.h -- Josh Triplett
+ *      2009-Nov-4: TSC macros within another header -- Giuseppe Cavallaro
  *
  *****************************************************************************/
 
@@ -96,36 +97,7 @@ typedef struct { volatile int counter; }
 #define thread_quit(T) (((T)->flags) & THREAD_QUIT)
 
 #define PRINT_BUFFER_SIZE (1024*1024*4)
-
-/* TSC macros */
 #define ULL_MAX 18446744073709551615ULL // (1 << 64) - 1
-#if defined(__i386__)
-#define rdtscll(val) __asm__ __volatile__("rdtsc" : "=A" (val))
-#elif defined(__x86_64__)
-#define rdtscll(val)					\
-	do {						\
-		uint32_t low, high;			\
-		__asm__ __volatile__ ("rdtsc" : "=a" (low), "=d" (high)); \
-		val = (uint64_t)high << 32 | low;	\
-	} while(0)
-#elif defined(__powerpc__)
-#if defined(__powerpc64__)	/* 64bit version */
-#define rdtscll(val)					\
-	do {								\
-		__asm__ __volatile__ ("mfspr %0, 268" : "=r" (val));	\
-	} while(0)
-#else	/*__powerpc__ 32bit version */
-#define rdtscll(val)							\
-	 do {								\
-		uint32_t tbhi, tblo ;					\
-		__asm__ __volatile__ ("mftbu %0" : "=r" (tbhi));	\
-		__asm__ __volatile__ ("mftbl %0" : "=r" (tblo));	\
-		val = 1000 * ((uint64_t) tbhi << 32) | tblo;		\
-	} while(0)
-#endif
-#else
-#error
-#endif
 
 extern pthread_mutex_t _buffer_mutex;
 extern char * _print_buffer;
diff -uprN ltp-full-20090731/testcases/realtime.orig/include/libtsc.h ltp-full-20090731/testcases/realtime/include/libtsc.h
--- ltp-full-20090731/testcases/realtime.orig/include/libtsc.h	1970-01-01 01:00:00.000000000 +0100
+++ ltp-full-20090731/testcases/realtime/include/libtsc.h	2009-11-16 11:38:43.000000000 +0100
@@ -0,0 +1,72 @@
+/******************************************************************************
+ *
+ *   Copyright �� International Business Machines  Corp., 2006-2008
+ *
+ *   This program 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.
+ *
+ *   This program 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 this program;  if not, write to the Free Software
+ *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * NAME
+ *       libtsc.h
+ *
+ * DESCRIPTION
+ *
+ * USAGE:
+ *       To be included in some testcases.
+ *
+ * AUTHOR
+ *        Darren Hart <dvhltc@us.ibm.com>
+ *        Giuseppe Cavallaro <peppe.cavallarost.com>
+ *
+ * HISTORY
+ *      It directly comes from the librttest.h (see its HISTORY).
+ *
+ *****************************************************************************/
+
+#undef TSC_UNSUPPORTED
+
+/* TSC macros */
+#if defined(__i386__)
+#define rdtscll(val) __asm__ __volatile__("rdtsc" : "=A" (val))
+#elif defined(__x86_64__)
+#define rdtscll(val)					\
+	do {						\
+		uint32_t low, high;			\
+		__asm__ __volatile__ ("rdtsc" : "=a" (low), "=d" (high)); \
+		val = (uint64_t)high << 32 | low;	\
+	} while (0)
+#elif defined(__powerpc__)
+#if defined(__powerpc64__)	/* 64bit version */
+#define rdtscll(val)					\
+	do {								\
+		__asm__ __volatile__ ("mfspr %0, 268" : "=r" (val));	\
+	} while (0)
+#else	/*__powerpc__ 32bit version */
+#define rdtscll(val)							\
+	 do {								\
+		uint32_t tbhi, tblo ;					\
+		__asm__ __volatile__ ("mftbu %0" : "=r" (tbhi));	\
+		__asm__ __volatile__ ("mftbl %0" : "=r" (tblo));	\
+		val = 1000 * ((uint64_t) tbhi << 32) | tblo;		\
+	} while (0)
+#endif
+#else
+#warning TSC UNSUPPORTED
+/* All tests will be compiled also for the
+ * architecture without TSC support (e.g. SH).
+ * At run-time these will fail with ENOTSUP.
+ */
+#define rdtscll(val)	do {  } while (0)
+#define TSC_UNSUPPORTED
+#endif
+

[-- Attachment #4: Type: text/plain, Size: 354 bytes --]

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july

[-- Attachment #5: Type: text/plain, Size: 155 bytes --]

_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [LTP] [PATCH] compiling realtime tests for SH.
  2009-11-16 10:53         ` Giuseppe CAVALLARO
@ 2009-11-16 13:39           ` Subrata Modak
  0 siblings, 0 replies; 7+ messages in thread
From: Subrata Modak @ 2009-11-16 13:39 UTC (permalink / raw)
  To: Giuseppe CAVALLARO; +Cc: ltp-list, amrith, Gowrishankar, Sripathi Kodi

On Mon, 2009-11-16 at 11:53 +0100, Giuseppe CAVALLARO wrote: 
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> Subrata Modak wrote:
> >>>> In my opinion this patch would have been better split into 2
> >>>> parts: one that separates out TSC parts and the other that adds atomic
> >>>> functions for SH. That would make changelogs easier to search through
> >>>> in future.
> > if you like I can resend the patch splitted into two parts.
> > Let me know.
> > 
> >> Yah, Please do so. I will do separate check-ins with separate LOG
> >> messages.
> 
> Hi Subrata,
> in attachment the two patches.

Thanks. Applied.

Regards--
Subrata

> 
> Regards
> Peppe
> 
> > 
> >> Regards--
> >> Subrata
> > 
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.9 (GNU/Linux)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
> 
> iEYEARECAAYFAksBLyoACgkQ2Xo3j31MSSIMfgCgn3qXNrOd/2mhyeri3loHGoBg
> u1IAoIhbksE6wEIRWLYoIMGhQBZGF1dj
> =QsPg
> -----END PGP SIGNATURE-----


------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2009-11-16 13:59 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-11-04 15:48 [LTP] [PATCH] compiling realtime tests for SH Giuseppe CAVALLARO
2009-11-09 17:39 ` Subrata Modak
2009-11-12  8:48   ` Sripathi Kodi
2009-11-13  7:40     ` Giuseppe CAVALLARO
2009-11-16  8:13       ` Subrata Modak
2009-11-16 10:53         ` Giuseppe CAVALLARO
2009-11-16 13:39           ` Subrata Modak

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.