[PATCH] smptests/smpcache01: Remove invalidation of data cache lines from test

Sebastian Huber sebastian.huber at embedded-brains.de
Thu Sep 11 11:23:54 UTC 2014


On 10/09/14 15:12, Daniel Cederman wrote:
> Invalidation of data cache lines might cause data written to the stack
> to get lost.
> ---
>   testsuites/smptests/smpcache01/init.c         | 45 +++++++++++++++------------
>   testsuites/smptests/smpcache01/smpcache01.doc |  2 --
>   testsuites/smptests/smpcache01/smpcache01.scn | 18 ++++-------
>   3 files changed, 31 insertions(+), 34 deletions(-)
>
> diff --git a/testsuites/smptests/smpcache01/init.c b/testsuites/smptests/smpcache01/init.c
> index dd2f9f1..99df974 100644
> --- a/testsuites/smptests/smpcache01/init.c
> +++ b/testsuites/smptests/smpcache01/init.c
> @@ -20,6 +20,8 @@
>
>   const char rtems_test_name[] = "SMPCACHE 1";
>
> +const char data_to_flush[1024];
> +

Please use static variables whenever possible.

>   #define CPU_COUNT 32
>
>   #define WORKER_PRIORITY 100
> @@ -44,6 +46,11 @@ static test_context ctx = {
>     .barrier = SMP_BARRIER_CONTROL_INITIALIZER,
>   };
>
> +static void function_to_flush( void )
> +{
> +  /* Does nothing. Used to give a pointer to instruction address space. */
> +}
> +
>   static void test_cache_message( const void *d_addr, size_t n_bytes )
>   {
>     rtems_test_assert(n_bytes == 123);
> @@ -52,22 +59,20 @@ static void test_cache_message( const void *d_addr, size_t n_bytes )
>     ctx.count[rtems_get_current_processor()]++;
>   }
>
> -static void all_cache_manager_smp_functions( size_t set_size,
> +static void cache_manager_smp_functions( size_t set_size,
>       cpu_set_t *cpu_set )
>   {
> -  rtems_cache_flush_multiple_data_lines_processor_set( 0, 10, set_size,
> -      cpu_set );
> -  rtems_cache_invalidate_multiple_data_lines_processor_set( 0, 10, set_size,
> -      cpu_set );

There is nothing wrong with 
rtems_cache_invalidate_multiple_data_lines_processor_set() provided you use the 
right data area.

> +  rtems_cache_flush_multiple_data_lines_processor_set( &data_to_flush,
> +      sizeof(data_to_flush), set_size, cpu_set );
>     rtems_cache_flush_entire_data_processor_set( set_size, cpu_set );
> -  rtems_cache_invalidate_entire_data_processor_set( set_size, cpu_set );

Yes, this one is problematic since it may kill your stack frame.

>     rtems_cache_invalidate_entire_instruction();
> -  rtems_cache_invalidate_multiple_instruction_lines( 0, 10 );
> +  rtems_cache_invalidate_multiple_instruction_lines( &function_to_flush,
> +      4 /* arbitrary size */ );
>   }


-- 
Sebastian Huber, embedded brains GmbH

Address : Dornierstr. 4, D-82178 Puchheim, Germany
Phone   : +49 89 189 47 41-16
Fax     : +49 89 189 47 41-09
E-Mail  : sebastian.huber at embedded-brains.de
PGP     : Public key available on request.

Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG.


More information about the devel mailing list