[ltt-dev] [UST PATCH] armv5 archs require write alignment

Mathieu Desnoyers mathieu.desnoyers at efficios.com
Wed May 4 11:15:33 EDT 2011


* Jason Wessel (jason.wessel at windriver.com) wrote:
> Reads and writes to unsigned int 32 bit numbers must be address
> aligned or the l2 cache can return junk in the high order 16 bits on
> reads.
> 
> This patch activates the original work done for alignment in ltt for
> the UST code.  The config.ac changes will isolate the use of alignment
> to the known arch type with the problem.

I got 

../../include/ust/core.h:34: warning: implicit declaration of function ‘min’

on x86. So two things:

1) there seems to be a missing include.
2) x86 should be an architecture with efficient unaligned accesses, so
   it looks like the wrong branch of the #ifndef is chosen.

So the code looks good overall, but some care would be required to solve
those two issues.

Thanks,

Mathieu

> 
> Signed-off-by: Jason Wessel <jason.wessel at windriver.com>
> ---
>  configure.ac       |   26 ++++++++++++++++++++++++++
>  include/ust/core.h |    6 +++---
>  2 files changed, 29 insertions(+), 3 deletions(-)
> 
> diff --git a/configure.ac b/configure.ac
> index 8ca32ff..d05b18c 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -10,6 +10,7 @@ AM_INIT_AUTOMAKE([foreign])
>  m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
>  AC_CONFIG_SRCDIR([ustctl/ustctl.c])
>  AC_CONFIG_HEADERS([config.h])
> +AH_TEMPLATE([HAVE_EFFICIENT_UNALIGNED_ACCESS], [Use efficient unaligned access.])
>  
>  # Checks for programs.
>  AC_PROG_CC
> @@ -108,6 +109,7 @@ changequote([,])dnl
>  	ppc64) LIBFORMAT="elf64-powerpc" ;;
>  	s390) LIBFORMAT="elf32-s390" ;;
>  	s390x) LIBFORMAT="elf64-s390" ;;
> +        armv5) LIBFORMAT="elf32-littlearm"; NO_UNALIGNED_ACCESS=1 ;;
>  	arm) LIBFORMAT="elf32-littlearm" ;;
>  	mips*) LIBFORMAT="" ;;
>  	*) AC_MSG_ERROR([unable to detect library format (unsupported architecture ($host_cpu)?)]) ;;
> @@ -115,6 +117,30 @@ esac
>  AC_SUBST(LIBFORMAT)
>  AC_MSG_RESULT($LIBFORMAT)
>  
> +if test "x$host_cpu" = "xarm" ; then
> +AC_MSG_CHECKING([checking for armv5])
> +AC_TRY_COMPILE(
> +[
> +],
> +[
> +#ifndef __ARM_ARCH_5TEJ__
> +#error "no arm5 here"
> +#endif
> +],
> +[
> +	AC_MSG_RESULT([yes])
> +	NO_UNALIGNED_ACCESS=1
> +]
> +,
> +[
> +	AC_MSG_RESULT([no])
> +]
> +)
> +fi
> +if test x$NO_UNALIGNED_ACCESS = x ; then
> +AC_DEFINE([HAVE_EFFICIENT_UNALIGNED_ACCESS], [1])
> +fi
> +
>  AC_CONFIG_FILES([
>  	Makefile
>  	doc/Makefile
> diff --git a/include/ust/core.h b/include/ust/core.h
> index e781a3a..4a2c6e5 100644
> --- a/include/ust/core.h
> +++ b/include/ust/core.h
> @@ -23,7 +23,7 @@
>  #define likely(x)	__builtin_expect(!!(x), 1)
>  #define unlikely(x)	__builtin_expect(!!(x), 0)
>  
> -#if defined(CONFIG_LTT) && defined(CONFIG_LTT_ALIGNMENT)
> +#ifndef HAVE_EFFICIENT_UNALIGNED_ACCESS
>  
>  /*
>   * Calculate the offset needed to align the type.
> @@ -42,7 +42,7 @@ static inline int ltt_get_alignment(void)
>  	return sizeof(void *);
>  }
>  
> -#else
> +#else /* HAVE_EFFICIENT_UNALIGNED_ACCESS */
>  
>  static inline unsigned int ltt_align(size_t align_drift,
>  		 size_t size_of_type)
> @@ -56,7 +56,7 @@ static inline int ltt_get_alignment(void)
>  {
>  	return 0;
>  }
> -#endif /* defined(CONFIG_LTT) && defined(CONFIG_LTT_ALIGNMENT) */
> +#endif /* HAVE_EFFICIENT_UNALIGNED_ACCESS */
>  
>  
>  /* ARRAYS */
> -- 
> 1.7.1
> 

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




More information about the lttng-dev mailing list