Mirror of the lttng-dev mailing list
 help / color / mirror / Atom feed
* [ltt-dev] [PATCH 0/4] Embedded UST support for ARM and busybox
@ 2011-02-22 21:48 Jason Wessel
  2011-02-22 21:48 ` [ltt-dev] [PATCH 1/4] add ARM specific support for UST Jason Wessel
  2011-02-22 22:24 ` [ltt-dev] [PATCH 0/4] Embedded UST support for ARM and busybox Mathieu Desnoyers
  0 siblings, 2 replies; 8+ messages in thread
From: Jason Wessel @ 2011-02-22 21:48 UTC (permalink / raw)


With all the generic code in UST now fixed, here is the patch series
to implement ARM and busybox support.

This patch set was tested on powerpc e500v2 in addition to ARMv5 and ARMv6.

Comments are welcome.

Thanks,
Jason.

--

The following changes since commit 34174843695ce2380fed2bddb1c631be97420f8d:
  Mathieu Desnoyers (1):
        markers: ensure assembly is portable by using .hword instead of .word

Jason Wessel (4):
      add ARM specific support for UST
      add a definition for fls() for ARM, taken from the linux kernel
      usttrace: Use /bin/sh instead of /bin/bash for busybox compatibility
      usttrace: use short signal names for busybox compatibility

 configure.ac            |    1 +
 include/ust/processor.h |   68 +++++++++++++++++++++++++++++++++++++++++++++++
 usttrace                |   16 +++++-----
 3 files changed, 77 insertions(+), 8 deletions(-)




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

* [ltt-dev] [PATCH 1/4] add ARM specific support for UST
  2011-02-22 21:48 [ltt-dev] [PATCH 0/4] Embedded UST support for ARM and busybox Jason Wessel
@ 2011-02-22 21:48 ` Jason Wessel
  2011-02-22 21:48   ` [ltt-dev] [PATCH 2/4] add a definition for fls() for ARM, taken from the linux kernel Jason Wessel
  2011-02-22 22:24 ` [ltt-dev] [PATCH 0/4] Embedded UST support for ARM and busybox Mathieu Desnoyers
  1 sibling, 1 reply; 8+ messages in thread
From: Jason Wessel @ 2011-02-22 21:48 UTC (permalink / raw)


Add the link definition and the inline assembly required for User
Space Trace support on ARM.

Signed-off-by: Jason Wessel <jason.wessel at windriver.com>
---
 configure.ac            |    1 +
 include/ust/processor.h |   15 +++++++++++++++
 2 files changed, 16 insertions(+), 0 deletions(-)

diff --git a/configure.ac b/configure.ac
index e57b356..5e58eab 100644
--- a/configure.ac
+++ b/configure.ac
@@ -104,6 +104,7 @@ changequote([,])dnl
 	ppc64) LIBFORMAT="elf64-powerpc" ;;
 	s390) LIBFORMAT="elf32-s390" ;;
 	s390x) LIBFORMAT="elf64-s390" ;;
+	arm) LIBFORMAT="elf32-littlearm" ;;
 	*) AC_MSG_ERROR([unable to detect library format (unsupported architecture ($host_cpu)?)]) ;;
 esac
 AC_SUBST(LIBFORMAT)
diff --git a/include/ust/processor.h b/include/ust/processor.h
index 8a01a88..01aa290 100644
--- a/include/ust/processor.h
+++ b/include/ust/processor.h
@@ -449,4 +449,19 @@ static __inline__ int fls(unsigned int x)
 
 #endif /* __PPC__ */
 
+#ifdef __arm__
+
+struct registers {
+};
+
+#define ARCH_COPY_ADDR(dst) "ldr "dst", =2b\n\t" \
+"b 55f\n\t" \
+".ltorg\n\t" \
+"55:\n\t"
+
+#define _ASM_PTR ".long "
+#define save_registers(a)
+
+#endif /* __arm__ */
+
 #endif /* UST_PROCESSOR_H */
-- 
1.6.6.2





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

* [ltt-dev] [PATCH 2/4] add a definition for fls() for ARM, taken from the linux kernel
  2011-02-22 21:48 ` [ltt-dev] [PATCH 1/4] add ARM specific support for UST Jason Wessel
@ 2011-02-22 21:48   ` Jason Wessel
  2011-02-22 21:48     ` [ltt-dev] [PATCH 3/4] usttrace: Use /bin/sh instead of /bin/bash for busybox compatibility Jason Wessel
  2011-02-22 22:21     ` [ltt-dev] [PATCH 2/4] add a definition for fls() for ARM, taken from the linux kernel Mathieu Desnoyers
  0 siblings, 2 replies; 8+ messages in thread
From: Jason Wessel @ 2011-02-22 21:48 UTC (permalink / raw)


Insert the definition from the linux kernel along with the copyright
attribution for the fls() operation for ARM.

Signed-off-by: Jason Wessel <jason.wessel at windriver.com>
---
 include/ust/processor.h |   53 +++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 53 insertions(+), 0 deletions(-)

diff --git a/include/ust/processor.h b/include/ust/processor.h
index 01aa290..70e244b 100644
--- a/include/ust/processor.h
+++ b/include/ust/processor.h
@@ -454,6 +454,59 @@ static __inline__ int fls(unsigned int x)
 struct registers {
 };
 
+/* constant_fls() and fls() were take directly from the linux kernel
+ * sources in 2.6.37 from the file arch/arm/include/asm/bitops.h
+ * which had the following copyright.
+ *
+ * Copyright 1995, Russell King.
+ * Various bits and pieces copyrights include:
+ *  Linus Torvalds (test_bit).
+ * Big endian support: Copyright 2001, Nicolas Pitre
+ *  reworked by rmk.
+ */
+
+static inline int constant_fls(int x)
+{
+	int r = 32;
+
+	if (!x)
+		return 0;
+	if (!(x & 0xffff0000u)) {
+		x <<= 16;
+		r -= 16;
+	}
+	if (!(x & 0xff000000u)) {
+		x <<= 8;
+		r -= 8;
+	}
+	if (!(x & 0xf0000000u)) {
+		x <<= 4;
+		r -= 4;
+	}
+	if (!(x & 0xc0000000u)) {
+		x <<= 2;
+		r -= 2;
+	}
+	if (!(x & 0x80000000u)) {
+		x <<= 1;
+		r -= 1;
+	}
+	return r;
+}
+
+static __inline__ int fls(unsigned int x)
+{
+        int ret;
+
+        if (__builtin_constant_p(x))
+               return constant_fls(x);
+
+        asm("clz\t%0, %1" : "=r" (ret) : "r" (x) : "cc");
+        ret = 32 - ret;
+        return ret;
+}
+/*------- end of source taken from linux kernel headers -------*/
+
 #define ARCH_COPY_ADDR(dst) "ldr "dst", =2b\n\t" \
 "b 55f\n\t" \
 ".ltorg\n\t" \
-- 
1.6.6.2





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

* [ltt-dev] [PATCH 3/4] usttrace: Use /bin/sh instead of /bin/bash for busybox compatibility
  2011-02-22 21:48   ` [ltt-dev] [PATCH 2/4] add a definition for fls() for ARM, taken from the linux kernel Jason Wessel
@ 2011-02-22 21:48     ` Jason Wessel
  2011-02-22 21:48       ` [ltt-dev] [PATCH 4/4] usttrace: use short signal names " Jason Wessel
  2011-02-22 22:21     ` [ltt-dev] [PATCH 2/4] add a definition for fls() for ARM, taken from the linux kernel Mathieu Desnoyers
  1 sibling, 1 reply; 8+ messages in thread
From: Jason Wessel @ 2011-02-22 21:48 UTC (permalink / raw)


The busybox posix like shell does not understand the "function"
directive nor does it understand the syntax for redirecting a file via
a shell expanded variable with $(<$pidfilepath).  Busybox also does
not typically provide a link to /bin/bash since busybox does not
provide bash.

It is possible to work around all these limitations in order to allow
user space tracing to work properly in a busybox based environment
with several syntax changes to the usttrace script.

Signed-off-by: Jason Wessel <jason.wessel at windriver.com>
---
 usttrace |   12 ++++++------
 1 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/usttrace b/usttrace
index 7c34ca2..54266db 100755
--- a/usttrace
+++ b/usttrace
@@ -1,16 +1,16 @@
-#!/bin/bash
+#!/bin/sh
 
 # usttrace  by Pierre-Marc Fournier 2009
 # Distributed under the GPLv2.
 
-function error() {
+error() {
 	echo "$0: error: $1" 2>/dev/stderr
 }
 
-function sighandler() {
+sighandler() {
 	echo "Caught Ctrl-C"
 	if [ -z "${UST_CONSUMERD_PID}" ]; then
-		UST_CONSUMERD_PID="$(<$pidfilepath)"
+		UST_CONSUMERD_PID=`cat $pidfilepath`
 	fi
 	# Tell the daemon to die
 	kill -SIGTERM "${UST_CONSUMERD_PID}"
@@ -44,7 +44,7 @@ fi
 
 BASE_TRACE_DIR="${HOME}/.usttraces"
 
-function usage () {
+usage() {
 	echo "usage:  $0 OPTIONS COMMAND" 2>/dev/stderr
 	echo "" 2>/dev/stderr
 	echo "Options:" 2>/dev/stderr
@@ -134,7 +134,7 @@ then
 	# ust-consumerd writes to pidfile
 	# ust-consumerd closes pidfile
 	# we unblock reading pidfile
-	UST_CONSUMERD_PID="$(<$pidfilepath)"
+	UST_CONSUMERD_PID=`cat $pidfilepath`
 	export UST_DAEMON_SOCKET="${UST_CONSUMERD_SOCKPATH}"
 fi
 
-- 
1.6.6.2





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

* [ltt-dev] [PATCH 4/4] usttrace: use short signal names for busybox compatibility
  2011-02-22 21:48     ` [ltt-dev] [PATCH 3/4] usttrace: Use /bin/sh instead of /bin/bash for busybox compatibility Jason Wessel
@ 2011-02-22 21:48       ` Jason Wessel
  0 siblings, 0 replies; 8+ messages in thread
From: Jason Wessel @ 2011-02-22 21:48 UTC (permalink / raw)


The kill command in coreutils will accept the short signal name, but
various versions of busybox will not accept the long signal name.  For
compatibility with busybox use the short signal name.

Signed-off-by: Jason Wessel <jason.wessel at windriver.com>
---
 usttrace |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/usttrace b/usttrace
index 54266db..d7c5977 100755
--- a/usttrace
+++ b/usttrace
@@ -13,7 +13,7 @@ sighandler() {
 		UST_CONSUMERD_PID=`cat $pidfilepath`
 	fi
 	# Tell the daemon to die
-	kill -SIGTERM "${UST_CONSUMERD_PID}"
+	kill -TERM "${UST_CONSUMERD_PID}"
 
 	echo "Waiting for ust-consumerd to shutdown..."
 	wait "${UST_CONSUMERD_PID}"
@@ -206,7 +206,7 @@ fi
 if [ "$arg_syswide_daemon" != "1" ];
 then
 	# Tell the daemon to die
-	kill -SIGTERM "${UST_CONSUMERD_PID}"
+	kill -TERM "${UST_CONSUMERD_PID}"
 
 	echo "Waiting for ust-consumerd to shutdown..."
 	wait "${UST_CONSUMERD_PID}"
-- 
1.6.6.2





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

* [ltt-dev] [PATCH 2/4] add a definition for fls() for ARM, taken from the linux kernel
  2011-02-22 21:48   ` [ltt-dev] [PATCH 2/4] add a definition for fls() for ARM, taken from the linux kernel Jason Wessel
  2011-02-22 21:48     ` [ltt-dev] [PATCH 3/4] usttrace: Use /bin/sh instead of /bin/bash for busybox compatibility Jason Wessel
@ 2011-02-22 22:21     ` Mathieu Desnoyers
  2011-02-22 22:31       ` Mathieu Desnoyers
  1 sibling, 1 reply; 8+ messages in thread
From: Mathieu Desnoyers @ 2011-02-22 22:21 UTC (permalink / raw)


* Jason Wessel (jason.wessel at windriver.com) wrote:
> Insert the definition from the linux kernel along with the copyright
> attribution for the fls() operation for ARM.

You could instead use my own clean room reimplementation at:

http://git.efficios.com/?p=babeltrace.git;a=blob;f=tests/test-bitfield.c

(for LGPLv2.1 licensing concerns)

The header of this file states "GPL", but I give you my blessing to relicense
the arch-agnostic fls() implementation as LGPL for UST.

If you don't feel like recoding the arm-specific fls, we can leave it out and
just use the arch-agnostic version for now.

Thanks,

Mathieu

> 
> Signed-off-by: Jason Wessel <jason.wessel at windriver.com>
> ---
>  include/ust/processor.h |   53 +++++++++++++++++++++++++++++++++++++++++++++++
>  1 files changed, 53 insertions(+), 0 deletions(-)
> 
> diff --git a/include/ust/processor.h b/include/ust/processor.h
> index 01aa290..70e244b 100644
> --- a/include/ust/processor.h
> +++ b/include/ust/processor.h
> @@ -454,6 +454,59 @@ static __inline__ int fls(unsigned int x)
>  struct registers {
>  };
>  
> +/* constant_fls() and fls() were take directly from the linux kernel
> + * sources in 2.6.37 from the file arch/arm/include/asm/bitops.h
> + * which had the following copyright.
> + *
> + * Copyright 1995, Russell King.
> + * Various bits and pieces copyrights include:
> + *  Linus Torvalds (test_bit).
> + * Big endian support: Copyright 2001, Nicolas Pitre
> + *  reworked by rmk.
> + */
> +
> +static inline int constant_fls(int x)
> +{
> +	int r = 32;
> +
> +	if (!x)
> +		return 0;
> +	if (!(x & 0xffff0000u)) {
> +		x <<= 16;
> +		r -= 16;
> +	}
> +	if (!(x & 0xff000000u)) {
> +		x <<= 8;
> +		r -= 8;
> +	}
> +	if (!(x & 0xf0000000u)) {
> +		x <<= 4;
> +		r -= 4;
> +	}
> +	if (!(x & 0xc0000000u)) {
> +		x <<= 2;
> +		r -= 2;
> +	}
> +	if (!(x & 0x80000000u)) {
> +		x <<= 1;
> +		r -= 1;
> +	}
> +	return r;
> +}
> +
> +static __inline__ int fls(unsigned int x)
> +{
> +        int ret;
> +
> +        if (__builtin_constant_p(x))
> +               return constant_fls(x);
> +
> +        asm("clz\t%0, %1" : "=r" (ret) : "r" (x) : "cc");
> +        ret = 32 - ret;
> +        return ret;
> +}
> +/*------- end of source taken from linux kernel headers -------*/
> +
>  #define ARCH_COPY_ADDR(dst) "ldr "dst", =2b\n\t" \
>  "b 55f\n\t" \
>  ".ltorg\n\t" \
> -- 
> 1.6.6.2
> 

-- 
Mathieu Desnoyers
Operating System Efficiency R&D Consultant
EfficiOS Inc.
http://www.efficios.com




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

* [ltt-dev] [PATCH 0/4] Embedded UST support for ARM and busybox
  2011-02-22 21:48 [ltt-dev] [PATCH 0/4] Embedded UST support for ARM and busybox Jason Wessel
  2011-02-22 21:48 ` [ltt-dev] [PATCH 1/4] add ARM specific support for UST Jason Wessel
@ 2011-02-22 22:24 ` Mathieu Desnoyers
  1 sibling, 0 replies; 8+ messages in thread
From: Mathieu Desnoyers @ 2011-02-22 22:24 UTC (permalink / raw)


* Jason Wessel (jason.wessel at windriver.com) wrote:
> With all the generic code in UST now fixed, here is the patch series
> to implement ARM and busybox support.
> 
> This patch set was tested on powerpc e500v2 in addition to ARMv5 and ARMv6.
> 
> Comments are welcome.

Except for the fls licensing, the other patches look good! I'll merge them when
you post an updated fls() patch.

Thanks,

Mathieu

> 
> Thanks,
> Jason.
> 
> --
> 
> The following changes since commit 34174843695ce2380fed2bddb1c631be97420f8d:
>   Mathieu Desnoyers (1):
>         markers: ensure assembly is portable by using .hword instead of .word
> 
> Jason Wessel (4):
>       add ARM specific support for UST
>       add a definition for fls() for ARM, taken from the linux kernel
>       usttrace: Use /bin/sh instead of /bin/bash for busybox compatibility
>       usttrace: use short signal names for busybox compatibility
> 
>  configure.ac            |    1 +
>  include/ust/processor.h |   68 +++++++++++++++++++++++++++++++++++++++++++++++
>  usttrace                |   16 +++++-----
>  3 files changed, 77 insertions(+), 8 deletions(-)

-- 
Mathieu Desnoyers
Operating System Efficiency R&D Consultant
EfficiOS Inc.
http://www.efficios.com




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

* [ltt-dev] [PATCH 2/4] add a definition for fls() for ARM, taken from the linux kernel
  2011-02-22 22:21     ` [ltt-dev] [PATCH 2/4] add a definition for fls() for ARM, taken from the linux kernel Mathieu Desnoyers
@ 2011-02-22 22:31       ` Mathieu Desnoyers
  0 siblings, 0 replies; 8+ messages in thread
From: Mathieu Desnoyers @ 2011-02-22 22:31 UTC (permalink / raw)


* Mathieu Desnoyers (mathieu.desnoyers at efficios.com) wrote:
> * Jason Wessel (jason.wessel at windriver.com) wrote:
> > Insert the definition from the linux kernel along with the copyright
> > attribution for the fls() operation for ARM.
> 
> You could instead use my own clean room reimplementation at:
> 
> http://git.efficios.com/?p=babeltrace.git;a=blob;f=tests/test-bitfield.c
> 
> (for LGPLv2.1 licensing concerns)

Actually, I just imported in into the UST git tree. I'll merge your other
patches, thanks !

Mathieu

> 
> The header of this file states "GPL", but I give you my blessing to relicense
> the arch-agnostic fls() implementation as LGPL for UST.
> 
> If you don't feel like recoding the arm-specific fls, we can leave it out and
> just use the arch-agnostic version for now.
> 
> Thanks,
> 
> Mathieu
> 
> > 
> > Signed-off-by: Jason Wessel <jason.wessel at windriver.com>
> > ---
> >  include/ust/processor.h |   53 +++++++++++++++++++++++++++++++++++++++++++++++
> >  1 files changed, 53 insertions(+), 0 deletions(-)
> > 
> > diff --git a/include/ust/processor.h b/include/ust/processor.h
> > index 01aa290..70e244b 100644
> > --- a/include/ust/processor.h
> > +++ b/include/ust/processor.h
> > @@ -454,6 +454,59 @@ static __inline__ int fls(unsigned int x)
> >  struct registers {
> >  };
> >  
> > +/* constant_fls() and fls() were take directly from the linux kernel
> > + * sources in 2.6.37 from the file arch/arm/include/asm/bitops.h
> > + * which had the following copyright.
> > + *
> > + * Copyright 1995, Russell King.
> > + * Various bits and pieces copyrights include:
> > + *  Linus Torvalds (test_bit).
> > + * Big endian support: Copyright 2001, Nicolas Pitre
> > + *  reworked by rmk.
> > + */
> > +
> > +static inline int constant_fls(int x)
> > +{
> > +	int r = 32;
> > +
> > +	if (!x)
> > +		return 0;
> > +	if (!(x & 0xffff0000u)) {
> > +		x <<= 16;
> > +		r -= 16;
> > +	}
> > +	if (!(x & 0xff000000u)) {
> > +		x <<= 8;
> > +		r -= 8;
> > +	}
> > +	if (!(x & 0xf0000000u)) {
> > +		x <<= 4;
> > +		r -= 4;
> > +	}
> > +	if (!(x & 0xc0000000u)) {
> > +		x <<= 2;
> > +		r -= 2;
> > +	}
> > +	if (!(x & 0x80000000u)) {
> > +		x <<= 1;
> > +		r -= 1;
> > +	}
> > +	return r;
> > +}
> > +
> > +static __inline__ int fls(unsigned int x)
> > +{
> > +        int ret;
> > +
> > +        if (__builtin_constant_p(x))
> > +               return constant_fls(x);
> > +
> > +        asm("clz\t%0, %1" : "=r" (ret) : "r" (x) : "cc");
> > +        ret = 32 - ret;
> > +        return ret;
> > +}
> > +/*------- end of source taken from linux kernel headers -------*/
> > +
> >  #define ARCH_COPY_ADDR(dst) "ldr "dst", =2b\n\t" \
> >  "b 55f\n\t" \
> >  ".ltorg\n\t" \
> > -- 
> > 1.6.6.2
> > 
> 
> -- 
> Mathieu Desnoyers
> Operating System Efficiency R&D Consultant
> EfficiOS Inc.
> http://www.efficios.com

-- 
Mathieu Desnoyers
Operating System Efficiency R&D Consultant
EfficiOS Inc.
http://www.efficios.com



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

end of thread, other threads:[~2011-02-22 22:31 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-02-22 21:48 [ltt-dev] [PATCH 0/4] Embedded UST support for ARM and busybox Jason Wessel
2011-02-22 21:48 ` [ltt-dev] [PATCH 1/4] add ARM specific support for UST Jason Wessel
2011-02-22 21:48   ` [ltt-dev] [PATCH 2/4] add a definition for fls() for ARM, taken from the linux kernel Jason Wessel
2011-02-22 21:48     ` [ltt-dev] [PATCH 3/4] usttrace: Use /bin/sh instead of /bin/bash for busybox compatibility Jason Wessel
2011-02-22 21:48       ` [ltt-dev] [PATCH 4/4] usttrace: use short signal names " Jason Wessel
2011-02-22 22:21     ` [ltt-dev] [PATCH 2/4] add a definition for fls() for ARM, taken from the linux kernel Mathieu Desnoyers
2011-02-22 22:31       ` Mathieu Desnoyers
2011-02-22 22:24 ` [ltt-dev] [PATCH 0/4] Embedded UST support for ARM and busybox Mathieu Desnoyers

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox