diff mbox

validation: sched: fix out of array reference

Message ID 1464368487-17510-1-git-send-email-maxim.uvarov@linaro.org
State Superseded
Headers show

Commit Message

Maxim Uvarov May 27, 2016, 5:01 p.m. UTC
If MAX_CPUS defined to less then current cpus, then
odp call calculates current available cpus and references
to array on thread creation. Do change to allocate array
dynamically.

Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org>
---
 Looks like I found why this test fails on arm64 :)

 test/performance/odp_scheduling.c | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

Comments

Bill Fischofer May 27, 2016, 6:53 p.m. UTC | #1
After applying this patch I get this:

bill@Ubuntu15:~/linaro/review/test/performance$ ./odp_scheduling

ODP example starts


ODP system info
---------------
ODP API version:  1.10.0
ODP impl name:    linux-generic
ODP impl details: linux-generic 1.10.0-0 (v1.10.0) '
https://git.linaro.org/lng/odp.git' (1.10.0.0.git150.g98f97ce)
CPU model:        Intel(R) Core(TM) i7-4790K CPU
CPU freq (hz):    4000000000
Cache line size:  64
Max CPU count:    4

num worker threads: 2
first CPU:          2
cpu mask:           0xC

CPU cycle count frequency test (runs about 2 sec)
odp_time               2000000027 ns
odp_cpu_cycles         7981526972 CPU cycles
odp_sys_cpu_hz         4000000000 hz
Diff from max CPU freq -0.230914%


Shared memory
 --------------
   page size:      4 kB
   huge page size: 2048 kB

   id name                       kB align huge addr
    0 odp_thread_globals          1    64      0x7fe9a13de000
    1 odp_buffer_pools          133  8512  *   0x7fe99fe006c0
    2 odp_queues                320   320  *   0x7fe99fc00040
    3 odp_scheduler              56    64  *   0x7fe99fa00000
    4 odp_sched_pool            272  4096  *   0x7fe99f800000
    5 odp_pktio_entries        4884  78144  *   0x7fe99f202200
    6 crypto_pool                15    64  *   0x7fe99f000000
    7 shm_odp_cos_tbl            16   256  *   0x7fe99ee00000
    8 shm_odp_pmr_tbl            80   320  *   0x7fe99ec00000
    9 test_globals                9    64  *   0x7fe99ea00000
   10 msg_pool                 98304  4096  *   0x7fe998800000

*** Error in `./odp_scheduling': malloc(): smallbin double linked list
corrupted: 0x0000000001ffb900 ***
linux.c:272:odpthread_run_start_routine():helper: ODP worker thread started
as linux pthread. (pid=27616)
Thread 1 starts on CPU 2
======= Backtrace: =========
/lib/x86_64-linux-gnu/libc.so.6(+0x77725)[0x7fe9a03aa725]
/lib/x86_64-linux-gnu/libc.so.6(+0x81f01)[0x7fe9a03b4f01]
/lib/x86_64-linux-gnu/libc.so.6(__libc_malloc+0x54)[0x7fe9a03b65a4]
/lib/x86_64-linux-gnu/libc.so.6(realloc+0x358)[0x7fe9a03b6f98]
/lib/x86_64-linux-gnu/libpthread.so.0(pthread_attr_setaffinity_np+0x26)[0x7fe9a070d846]
./odp_scheduling[0x404f03]
./odp_scheduling[0x4034dd]
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf0)[0x7fe9a0353830]
./odp_scheduling[0x403679]
======= Memory map: ========
00400000-00437000 r-xp 00000000 08:01 3549341
 /home/bill/linaro/review/test/performance/odp_scheduling
00636000-00637000 r--p 00036000 08:01 3549341
 /home/bill/linaro/review/test/performance/odp_scheduling
00637000-00638000 rw-p 00037000 08:01 3549341
 /home/bill/linaro/review/test/performance/odp_scheduling
00638000-0066d000 rw-p 00000000 00:00 0
01ffb000-0201c000 rw-p 00000000 00:00 0
 [heap]
7fe990000000-7fe990021000 rw-p 00000000 00:00 0
7fe990021000-7fe994000000 ---p 00000000 00:00 0
7fe997de9000-7fe997dff000 r-xp 00000000 08:01 3015398
 /lib/x86_64-linux-gnu/libgcc_s.so.1
7fe997dff000-7fe997ffe000 ---p 00016000 08:01 3015398
 /lib/x86_64-linux-gnu/libgcc_s.so.1
7fe997ffe000-7fe997fff000 rw-p 00015000 08:01 3015398
 /lib/x86_64-linux-gnu/libgcc_s.so.1
7fe997fff000-7fe998000000 ---p 00000000 00:00 0
7fe998000000-7fe998800000 rw-p 00000000 00:00 0
7fe998800000-7fe99ea00000 rw-s 00000000 00:0f 5649403
 /anon_hugepage (deleted)
7fe99ea00000-7fe99ec00000 rw-s 00000000 00:0f 5649402
 /anon_hugepage (deleted)
7fe99ec00000-7fe99ee00000 rw-s 00000000 00:0f 5649401
 /anon_hugepage (deleted)
7fe99ee00000-7fe99f000000 rw-s 00000000 00:0f 5649400
 /anon_hugepage (deleted)
7fe99f000000-7fe99f200000 rw-s 00000000 00:0f 5649399
 /anon_hugepage (deleted)
7fe99f200000-7fe99f800000 rw-s 00000000 00:0f 5649398
 /anon_hugepage (deleted)
7fe99f800000-7fe99fa00000 rw-s 00000000 00:0f 5649397
 /anon_hugepage (deleted)
7fe99fa00000-7fe99fc00000 rw-s 00000000 00:0f 5649396
 /anon_hugepage (deleted)
7fe99fc00000-7fe99fe00000 rw-s 00000000 00:0f 5649395
 /anon_hugepage (deleted)
7fe99fe00000-7fe9a0000000 rw-s 00000000 00:0f 5649394
 /anon_hugepage (deleted)
7fe9a012f000-7fe9a0132000 r-xp 00000000 08:01 3015233
 /lib/x86_64-linux-gnu/libdl-2.23.so
7fe9a0132000-7fe9a0331000 ---p 00003000 08:01 3015233
 /lib/x86_64-linux-gnu/libdl-2.23.so
7fe9a0331000-7fe9a0332000 r--p 00002000 08:01 3015233
 /lib/x86_64-linux-gnu/libdl-2.23.so
7fe9a0332000-7fe9a0333000 rw-p 00003000 08:01 3015233
 /lib/x86_64-linux-gnu/libdl-2.23.so
7fe9a0333000-7fe9a04f3000 r-xp 00000000 08:01 3015232
 /lib/x86_64-linux-gnu/libc-2.23.so
7fe9a04f3000-7fe9a06f2000 ---p 001c0000 08:01 3015232
 /lib/x86_64-linux-gnu/libc-2.23.so
7fe9a06f2000-7fe9a06f6000 r--p 001bf000 08:01 3015232
 /lib/x86_64-linux-gnu/libc-2.23.so
7fe9a06f6000-7fe9a06f8000 rw-p 001c3000 08:01 3015232
 /lib/x86_64-linux-gnu/libc-2.23.so
7fe9a06f8000-7fe9a06fc000 rw-p 00000000 00:00 0
7fe9a06fc000-7fe9a0714000 r-xp 00000000 08:01 3015230
 /lib/x86_64-linux-gnu/libpthread-2.23.so
7fe9a0714000-7fe9a0913000 ---p 00018000 08:01 3015230
 /lib/x86_64-linux-gnu/libpthread-2.23.so
7fe9a0913000-7fe9a0914000 r--p 00017000 08:01 3015230
 /lib/x86_64-linux-gnu/libpthread-2.23.so
7fe9a0914000-7fe9a0915000 rw-p 00018000 08:01 3015230
 /lib/x86_64-linux-gnu/libpthread-2.23.so
7fe9a0915000-7fe9a0919000 rw-p 00000000 00:00 0
7fe9a0919000-7fe9a0957000 r-xp 00000000 08:01 1049131
 /usr/lib/x86_64-linux-gnu/libpcap.so.1.7.4
7fe9a0957000-7fe9a0b57000 ---p 0003e000 08:01 1049131
 /usr/lib/x86_64-linux-gnu/libpcap.so.1.7.4
7fe9a0b57000-7fe9a0b59000 r--p 0003e000 08:01 1049131
 /usr/lib/x86_64-linux-gnu/libpcap.so.1.7.4
7fe9a0b59000-7fe9a0b5a000 rw-p 00040000 08:01 1049131
 /usr/lib/x86_64-linux-gnu/libpcap.so.1.7.4
7fe9a0b5a000-7fe9a0b5b000 rw-p 00000000 00:00 0
7fe9a0b5b000-7fe9a0d8a000 r-xp 00000000 08:01 3015453
 /lib/x86_64-linux-gnu/libcrypto.so.1.0.0
7fe9a0d8a000-7fe9a0f89000 ---p 0022f000 08:01 3015453
 /lib/x86_64-linux-gnu/libcrypto.so.1.0.0
7fe9a0f89000-7fe9a0fa5000 r--p 0022e000 08:01 3015453
 /lib/x86_64-linux-gnu/libcrypto.so.1.0.0
7fe9a0fa5000-7fe9a0fb2000 rw-p 0024a000 08:01 3015453
 /lib/x86_64-linux-gnu/libcrypto.so.1.0.0
7fe9a0fb2000-7fe9a0fb6000 rw-p 00000000 00:00 0
7fe9a0fb6000-7fe9a0fbd000 r-xp 00000000 08:01 3015223
 /lib/x86_64-linux-gnu/librt-2.23.so
7fe9a0fbd000-7fe9a11bc000 ---p 00007000 08:01 3015223
 /lib/x86_64-linux-gnu/librt-2.23.so
7fe9a11bc000-7fe9a11bd000 r--p 00006000 08:01 3015223
 /lib/x86_64-linux-gnu/librt-2.23.so
7fe9a11bd000-7fe9a11be000 rw-p 00007000 08:01 3015223
 /lib/x86_64-linux-gnu/librt-2.23.so
7fe9a11be000-7fe9a11e4000 r-xp 00000000 08:01 3015226
 /lib/x86_64-linux-gnu/ld-2.23.so
7fe9a13bb000-7fe9a13c0000 rw-p 00000000 00:00 0
7fe9a13dd000-7fe9a13de000 rw-p 00000000 00:00 0
7fe9a13de000-7fe9a13df000 rw-s 00000000 00:05 5649393
 /dev/zero (deleted)
7fe9a13df000-7fe9a13e1000 rw-s 00000000 00:05 5649392
 /dev/zero (deleted)
7fe9a13e1000-7fe9a13e3000 rw-p 00000000 00:00 0
7fe9a13e3000-7fe9a13e4000 r--p 00025000 08:01 3015226
 /lib/x86_64-linux-gnu/ld-2.23.so
7fe9a13e4000-7fe9a13e5000 rw-p 00026000 08:01 3015226
 /lib/x86_64-linux-gnu/ld-2.23.so
7fe9a13e5000-7fe9a13e6000 rw-p 00000000 00:00 0
7ffe1f15b000-7ffe1f17c000 rw-p 00000000 00:00 0
 [stack]
7ffe1f1bd000-7ffe1f1bf000 r--p 00000000 00:00 0
 [vvar]
7ffe1f1bf000-7ffe1f1c1000 r-xp 00000000 00:00 0
 [vdso]
ffffffffff600000-ffffffffff601000 r-xp 00000000 00:00 0
 [vsyscall]
Aborted (core dumped)

gdb backtrace shows:

bill@Ubuntu15:~/linaro/review/test/performance$ gdb ./odp_scheduling core
GNU gdb (Ubuntu 7.11-0ubuntu1) 7.11
Copyright (C) 2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html
>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from ./odp_scheduling...done.
[New LWP 27616]
[New LWP 27625]
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
Core was generated by `./odp_scheduling'.
Program terminated with signal SIGABRT, Aborted.
#0  0x00007fe9a0368418 in __GI_raise (sig=sig@entry=6)
    at ../sysdeps/unix/sysv/linux/raise.c:54
54 ../sysdeps/unix/sysv/linux/raise.c: No such file or directory.
[Current thread is 1 (Thread 0x7fe9a13bb7c0 (LWP 27616))]
(gdb) bt
#0  0x00007fe9a0368418 in __GI_raise (sig=sig@entry=6)
    at ../sysdeps/unix/sysv/linux/raise.c:54
#1  0x00007fe9a036a01a in __GI_abort () at abort.c:89
#2  0x00007fe9a03aa72a in __libc_message (do_abort=do_abort@entry=2,
    fmt=fmt@entry=0x7fe9a04c36b0 "*** Error in `%s': %s: 0x%s ***\n")
    at ../sysdeps/posix/libc_fatal.c:175
#3  0x00007fe9a03b4f01 in malloc_printerr (ar_ptr=0x3, ptr=<optimized out>,
    str=0x7fe9a04c3ae0 "malloc(): smallbin double linked list corrupted",
    action=3) at malloc.c:5007
#4  _int_malloc (av=av@entry=0x7fe9a06f6b20 <main_arena>,
    bytes=bytes@entry=128) at malloc.c:3387
#5  0x00007fe9a03b65a4 in __GI___libc_malloc (bytes=128) at malloc.c:2914
#6  0x00007fe9a03b6f98 in __GI___libc_realloc (oldmem=0x0,
    bytes=bytes@entry=128) at malloc.c:2995
#7  0x00007fe9a070d846 in __pthread_attr_setaffinity_new (
    attr=attr@entry=0x1ffbb38, cpusetsize=cpusetsize@entry=128,
    cpuset=cpuset@entry=0x7ffe1f1790f0) at pthread_attr_setaffinity.c:47
#8  0x0000000000404f03 in odph_linux_thread_create
(thr_params=0x7ffe1f179230,
    cpu=3, thread_tbl=0x1ffbb00) at linux.c:356
#9  odph_odpthreads_create (thread_tbl=thread_tbl@entry=0x1ffba90,
    mask=mask@entry=0x7ffe1f179260, thr_params=thr_params@entry
=0x7ffe1f179230)
    at linux.c:403
#10 0x00000000004034dd in main (argc=<optimized out>, argv=<optimized out>)
---Type <return> to continue, or q <return> to quit---
    at odp_scheduling.c:941
(gdb)


On Fri, May 27, 2016 at 12:01 PM, Maxim Uvarov <maxim.uvarov@linaro.org>
wrote:

> If MAX_CPUS defined to less then current cpus, then
> odp call calculates current available cpus and references
> to array on thread creation. Do change to allocate array
> dynamically.
>
> Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org>
> ---
>  Looks like I found why this test fails on arm64 :)
>
>  test/performance/odp_scheduling.c | 12 ++++--------
>  1 file changed, 4 insertions(+), 8 deletions(-)
>
> diff --git a/test/performance/odp_scheduling.c
> b/test/performance/odp_scheduling.c
> index 1d3bfd1..e64de6e 100644
> --- a/test/performance/odp_scheduling.c
> +++ b/test/performance/odp_scheduling.c
> @@ -27,8 +27,6 @@
>  /* GNU lib C */
>  #include <getopt.h>
>
> -
> -#define MAX_WORKERS           32            /**< Max worker threads */
>  #define MSG_POOL_SIZE         (4*1024*1024) /**< Message pool size */
>  #define MAX_ALLOCS            35            /**< Alloc burst size */
>  #define QUEUES_PER_PRIO       64            /**< Queue per priority */
> @@ -775,7 +773,7 @@ static void parse_args(int argc, char *argv[],
> test_args_t *args)
>   */
>  int main(int argc, char *argv[])
>  {
> -       odph_odpthread_t thread_tbl[MAX_WORKERS];
> +       odph_odpthread_t *thread_tbl;
>         test_args_t args;
>         int num_workers;
>         odp_cpumask_t cpumask;
> @@ -795,8 +793,6 @@ int main(int argc, char *argv[])
>         memset(&args, 0, sizeof(args));
>         parse_args(argc, argv, &args);
>
> -       memset(thread_tbl, 0, sizeof(thread_tbl));
> -
>         /* ODP global init */
>         if (odp_init_global(&instance, NULL, NULL)) {
>                 LOG_ERR("ODP global init failed.\n");
> @@ -826,9 +822,8 @@ int main(int argc, char *argv[])
>         printf("\n");
>
>         /* Default to system CPU count unless user specified */
> -       num_workers = MAX_WORKERS;
> -       if (args.cpu_count)
> -               num_workers = args.cpu_count;
> +       num_workers = args.cpu_count;
> +       thread_tbl = calloc(sizeof(odph_odpthread_t), num_workers);
>
>         /* Get default worker cpumask */
>         num_workers = odp_cpumask_default_worker(&cpumask, num_workers);
> @@ -947,6 +942,7 @@ int main(int argc, char *argv[])
>
>         /* Wait for worker threads to terminate */
>         odph_odpthreads_join(thread_tbl);
> +       free(thread_tbl);
>
>         printf("ODP example complete\n\n");
>
> --
> 2.7.1.250.gff4ea60
>
> _______________________________________________
> lng-odp mailing list
> lng-odp@lists.linaro.org
> https://lists.linaro.org/mailman/listinfo/lng-odp
>
Maxim Uvarov May 27, 2016, 7:43 p.m. UTC | #2
On 05/27/16 21:53, Bill Fischofer wrote:
> After applying this patch I get this:
>
> bill@Ubuntu15:~/linaro/review/test/performance$ ./odp_schedulingha
>

ah, sorry, I tested that it runs from _run.sh script with -c parameters 
and did not check direct call,
will send v2.

Maxim.


> ODP example starts
>
>
> ODP system info
> ---------------
> ODP API version:  1.10.0
> ODP impl name:    linux-generic
> ODP impl details: linux-generic 1.10.0-0 (v1.10.0) 
> 'https://git.linaro.org/lng/odp.git' (1.10.0.0.git150.g98f97ce)
> CPU model:        Intel(R) Core(TM) i7-4790K CPU
> CPU freq (hz):    4000000000
> Cache line size:  64
> Max CPU count:    4
>
> num worker threads: 2
> first CPU:          2
> cpu mask:           0xC
>
> CPU cycle count frequency test (runs about 2 sec)
> odp_time               2000000027 ns
> odp_cpu_cycles         7981526972 CPU cycles
> odp_sys_cpu_hz         4000000000 hz
> Diff from max CPU freq -0.230914%
>
> Shared memory
>  --------------
>    page size:      4 kB
>    huge page size: 2048 kB
>    id name                       kB align huge addr
>     0 odp_thread_globals          1    64  0x7fe9a13de000
>     1 odp_buffer_pools          133  8512  * 0x7fe99fe006c0
>     2 odp_queues                320   320  * 0x7fe99fc00040
>     3 odp_scheduler              56    64  * 0x7fe99fa00000
>     4 odp_sched_pool            272  4096  * 0x7fe99f800000
>     5 odp_pktio_entries        4884  78144  * 0x7fe99f202200
>     6 crypto_pool                15    64  * 0x7fe99f000000
>     7 shm_odp_cos_tbl            16   256  * 0x7fe99ee00000
>     8 shm_odp_pmr_tbl            80   320  * 0x7fe99ec00000
>     9 test_globals                9    64  * 0x7fe99ea00000
>    10 msg_pool                 98304  4096  * 0x7fe998800000
> *** Error in `./odp_scheduling': malloc(): smallbin double linked list 
> corrupted: 0x0000000001ffb900 ***
> linux.c:272:odpthread_run_start_routine():helper: ODP worker thread 
> started as linux pthread. (pid=27616)
> Thread 1 starts on CPU 2
> ======= Backtrace: =========
> /lib/x86_64-linux-gnu/libc.so.6(+0x77725)[0x7fe9a03aa725]
> /lib/x86_64-linux-gnu/libc.so.6(+0x81f01)[0x7fe9a03b4f01]
> /lib/x86_64-linux-gnu/libc.so.6(__libc_malloc+0x54)[0x7fe9a03b65a4]
> /lib/x86_64-linux-gnu/libc.so.6(realloc+0x358)[0x7fe9a03b6f98]
> /lib/x86_64-linux-gnu/libpthread.so.0(pthread_attr_setaffinity_np+0x26)[0x7fe9a070d846]
> ./odp_scheduling[0x404f03]
> ./odp_scheduling[0x4034dd]
> /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf0)[0x7fe9a0353830]
> ./odp_scheduling[0x403679]
> ======= Memory map: ========
> 00400000-00437000 r-xp 00000000 08:01 3549341 
>  /home/bill/linaro/review/test/performance/odp_scheduling
> 00636000-00637000 r--p 00036000 08:01 3549341 
>  /home/bill/linaro/review/test/performance/odp_scheduling
> 00637000-00638000 rw-p 00037000 08:01 3549341 
>  /home/bill/linaro/review/test/performance/odp_scheduling
> 00638000-0066d000 rw-p 00000000 00:00 0
> 01ffb000-0201c000 rw-p 00000000 00:00 0                [heap]
> 7fe990000000-7fe990021000 rw-p 00000000 00:00 0
> 7fe990021000-7fe994000000 ---p 00000000 00:00 0
> 7fe997de9000-7fe997dff000 r-xp 00000000 08:01 3015398               
>  /lib/x86_64-linux-gnu/libgcc_s.so.1
> 7fe997dff000-7fe997ffe000 ---p 00016000 08:01 3015398               
>  /lib/x86_64-linux-gnu/libgcc_s.so.1
> 7fe997ffe000-7fe997fff000 rw-p 00015000 08:01 3015398               
>  /lib/x86_64-linux-gnu/libgcc_s.so.1
> 7fe997fff000-7fe998000000 ---p 00000000 00:00 0
> 7fe998000000-7fe998800000 rw-p 00000000 00:00 0
> 7fe998800000-7fe99ea00000 rw-s 00000000 00:0f 5649403               
>  /anon_hugepage (deleted)
> 7fe99ea00000-7fe99ec00000 rw-s 00000000 00:0f 5649402               
>  /anon_hugepage (deleted)
> 7fe99ec00000-7fe99ee00000 rw-s 00000000 00:0f 5649401               
>  /anon_hugepage (deleted)
> 7fe99ee00000-7fe99f000000 rw-s 00000000 00:0f 5649400               
>  /anon_hugepage (deleted)
> 7fe99f000000-7fe99f200000 rw-s 00000000 00:0f 5649399               
>  /anon_hugepage (deleted)
> 7fe99f200000-7fe99f800000 rw-s 00000000 00:0f 5649398               
>  /anon_hugepage (deleted)
> 7fe99f800000-7fe99fa00000 rw-s 00000000 00:0f 5649397               
>  /anon_hugepage (deleted)
> 7fe99fa00000-7fe99fc00000 rw-s 00000000 00:0f 5649396               
>  /anon_hugepage (deleted)
> 7fe99fc00000-7fe99fe00000 rw-s 00000000 00:0f 5649395               
>  /anon_hugepage (deleted)
> 7fe99fe00000-7fe9a0000000 rw-s 00000000 00:0f 5649394               
>  /anon_hugepage (deleted)
> 7fe9a012f000-7fe9a0132000 r-xp 00000000 08:01 3015233               
>  /lib/x86_64-linux-gnu/libdl-2.23.so <http://libdl-2.23.so>
> 7fe9a0132000-7fe9a0331000 ---p 00003000 08:01 3015233               
>  /lib/x86_64-linux-gnu/libdl-2.23.so <http://libdl-2.23.so>
> 7fe9a0331000-7fe9a0332000 r--p 00002000 08:01 3015233               
>  /lib/x86_64-linux-gnu/libdl-2.23.so <http://libdl-2.23.so>
> 7fe9a0332000-7fe9a0333000 rw-p 00003000 08:01 3015233               
>  /lib/x86_64-linux-gnu/libdl-2.23.so <http://libdl-2.23.so>
> 7fe9a0333000-7fe9a04f3000 r-xp 00000000 08:01 3015232               
>  /lib/x86_64-linux-gnu/libc-2.23.so <http://libc-2.23.so>
> 7fe9a04f3000-7fe9a06f2000 ---p 001c0000 08:01 3015232               
>  /lib/x86_64-linux-gnu/libc-2.23.so <http://libc-2.23.so>
> 7fe9a06f2000-7fe9a06f6000 r--p 001bf000 08:01 3015232               
>  /lib/x86_64-linux-gnu/libc-2.23.so <http://libc-2.23.so>
> 7fe9a06f6000-7fe9a06f8000 rw-p 001c3000 08:01 3015232               
>  /lib/x86_64-linux-gnu/libc-2.23.so <http://libc-2.23.so>
> 7fe9a06f8000-7fe9a06fc000 rw-p 00000000 00:00 0
> 7fe9a06fc000-7fe9a0714000 r-xp 00000000 08:01 3015230               
>  /lib/x86_64-linux-gnu/libpthread-2.23.so <http://libpthread-2.23.so>
> 7fe9a0714000-7fe9a0913000 ---p 00018000 08:01 3015230               
>  /lib/x86_64-linux-gnu/libpthread-2.23.so <http://libpthread-2.23.so>
> 7fe9a0913000-7fe9a0914000 r--p 00017000 08:01 3015230               
>  /lib/x86_64-linux-gnu/libpthread-2.23.so <http://libpthread-2.23.so>
> 7fe9a0914000-7fe9a0915000 rw-p 00018000 08:01 3015230               
>  /lib/x86_64-linux-gnu/libpthread-2.23.so <http://libpthread-2.23.so>
> 7fe9a0915000-7fe9a0919000 rw-p 00000000 00:00 0
> 7fe9a0919000-7fe9a0957000 r-xp 00000000 08:01 1049131               
>  /usr/lib/x86_64-linux-gnu/libpcap.so.1.7.4
> 7fe9a0957000-7fe9a0b57000 ---p 0003e000 08:01 1049131               
>  /usr/lib/x86_64-linux-gnu/libpcap.so.1.7.4
> 7fe9a0b57000-7fe9a0b59000 r--p 0003e000 08:01 1049131               
>  /usr/lib/x86_64-linux-gnu/libpcap.so.1.7.4
> 7fe9a0b59000-7fe9a0b5a000 rw-p 00040000 08:01 1049131               
>  /usr/lib/x86_64-linux-gnu/libpcap.so.1.7.4
> 7fe9a0b5a000-7fe9a0b5b000 rw-p 00000000 00:00 0
> 7fe9a0b5b000-7fe9a0d8a000 r-xp 00000000 08:01 3015453               
>  /lib/x86_64-linux-gnu/libcrypto.so.1.0.0
> 7fe9a0d8a000-7fe9a0f89000 ---p 0022f000 08:01 3015453               
>  /lib/x86_64-linux-gnu/libcrypto.so.1.0.0
> 7fe9a0f89000-7fe9a0fa5000 r--p 0022e000 08:01 3015453               
>  /lib/x86_64-linux-gnu/libcrypto.so.1.0.0
> 7fe9a0fa5000-7fe9a0fb2000 rw-p 0024a000 08:01 3015453               
>  /lib/x86_64-linux-gnu/libcrypto.so.1.0.0
> 7fe9a0fb2000-7fe9a0fb6000 rw-p 00000000 00:00 0
> 7fe9a0fb6000-7fe9a0fbd000 r-xp 00000000 08:01 3015223               
>  /lib/x86_64-linux-gnu/librt-2.23.so <http://librt-2.23.so>
> 7fe9a0fbd000-7fe9a11bc000 ---p 00007000 08:01 3015223               
>  /lib/x86_64-linux-gnu/librt-2.23.so <http://librt-2.23.so>
> 7fe9a11bc000-7fe9a11bd000 r--p 00006000 08:01 3015223               
>  /lib/x86_64-linux-gnu/librt-2.23.so <http://librt-2.23.so>
> 7fe9a11bd000-7fe9a11be000 rw-p 00007000 08:01 3015223               
>  /lib/x86_64-linux-gnu/librt-2.23.so <http://librt-2.23.so>
> 7fe9a11be000-7fe9a11e4000 r-xp 00000000 08:01 3015226               
>  /lib/x86_64-linux-gnu/ld-2.23.so <http://ld-2.23.so>
> 7fe9a13bb000-7fe9a13c0000 rw-p 00000000 00:00 0
> 7fe9a13dd000-7fe9a13de000 rw-p 00000000 00:00 0
> 7fe9a13de000-7fe9a13df000 rw-s 00000000 00:05 5649393               
>  /dev/zero (deleted)
> 7fe9a13df000-7fe9a13e1000 rw-s 00000000 00:05 5649392               
>  /dev/zero (deleted)
> 7fe9a13e1000-7fe9a13e3000 rw-p 00000000 00:00 0
> 7fe9a13e3000-7fe9a13e4000 r--p 00025000 08:01 3015226               
>  /lib/x86_64-linux-gnu/ld-2.23.so <http://ld-2.23.so>
> 7fe9a13e4000-7fe9a13e5000 rw-p 00026000 08:01 3015226               
>  /lib/x86_64-linux-gnu/ld-2.23.so <http://ld-2.23.so>
> 7fe9a13e5000-7fe9a13e6000 rw-p 00000000 00:00 0
> 7ffe1f15b000-7ffe1f17c000 rw-p 00000000 00:00 0                [stack]
> 7ffe1f1bd000-7ffe1f1bf000 r--p 00000000 00:00 0                [vvar]
> 7ffe1f1bf000-7ffe1f1c1000 r-xp 00000000 00:00 0                [vdso]
> ffffffffff600000-ffffffffff601000 r-xp 00000000 00:00 0               
>  [vsyscall]
> Aborted (core dumped)
>
> gdb backtrace shows:
>
> bill@Ubuntu15:~/linaro/review/test/performance$ gdb ./odp_scheduling core
> GNU gdb (Ubuntu 7.11-0ubuntu1) 7.11
> Copyright (C) 2016 Free Software Foundation, Inc.
> License GPLv3+: GNU GPL version 3 or later 
> <http://gnu.org/licenses/gpl.html>
> This is free software: you are free to change and redistribute it.
> There is NO WARRANTY, to the extent permitted by law. Type "show copying"
> and "show warranty" for details.
> This GDB was configured as "x86_64-linux-gnu".
> Type "show configuration" for configuration details.
> For bug reporting instructions, please see:
> <http://www.gnu.org/software/gdb/bugs/>.
> Find the GDB manual and other documentation resources online at:
> <http://www.gnu.org/software/gdb/documentation/>.
> For help, type "help".
> Type "apropos word" to search for commands related to "word"...
> Reading symbols from ./odp_scheduling...done.
> [New LWP 27616]
> [New LWP 27625]
> [Thread debugging using libthread_db enabled]
> Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
> Core was generated by `./odp_scheduling'.
> Program terminated with signal SIGABRT, Aborted.
> #0  0x00007fe9a0368418 in __GI_raise (sig=sig@entry=6)
>     at ../sysdeps/unix/sysv/linux/raise.c:54
> 54../sysdeps/unix/sysv/linux/raise.c: No such file or directory.
> [Current thread is 1 (Thread 0x7fe9a13bb7c0 (LWP 27616))]
> (gdb) bt
> #0  0x00007fe9a0368418 in __GI_raise (sig=sig@entry=6)
>     at ../sysdeps/unix/sysv/linux/raise.c:54
> #1  0x00007fe9a036a01a in __GI_abort () at abort.c:89
> #2  0x00007fe9a03aa72a in __libc_message (do_abort=do_abort@entry=2,
>     fmt=fmt@entry=0x7fe9a04c36b0 "*** Error in `%s': %s: 0x%s ***\n")
>     at ../sysdeps/posix/libc_fatal.c:175
> #3  0x00007fe9a03b4f01 in malloc_printerr (ar_ptr=0x3, ptr=<optimized 
> out>,
>     str=0x7fe9a04c3ae0 "malloc(): smallbin double linked list corrupted",
>     action=3) at malloc.c:5007
> #4  _int_malloc (av=av@entry=0x7fe9a06f6b20 <main_arena>,
>     bytes=bytes@entry=128) at malloc.c:3387
> #5  0x00007fe9a03b65a4 in __GI___libc_malloc (bytes=128) at malloc.c:2914
> #6  0x00007fe9a03b6f98 in __GI___libc_realloc (oldmem=0x0,
>     bytes=bytes@entry=128) at malloc.c:2995
> #7  0x00007fe9a070d846 in __pthread_attr_setaffinity_new (
>     attr=attr@entry=0x1ffbb38, cpusetsize=cpusetsize@entry=128,
>     cpuset=cpuset@entry=0x7ffe1f1790f0) at pthread_attr_setaffinity.c:47
> #8  0x0000000000404f03 in odph_linux_thread_create 
> (thr_params=0x7ffe1f179230,
>     cpu=3, thread_tbl=0x1ffbb00) at linux.c:356
> #9  odph_odpthreads_create (thread_tbl=thread_tbl@entry=0x1ffba90,
>     mask=mask@entry=0x7ffe1f179260, 
> thr_params=thr_params@entry=0x7ffe1f179230)
>     at linux.c:403
> #10 0x00000000004034dd in main (argc=<optimized out>, argv=<optimized 
> out>)
> ---Type <return> to continue, or q <return> to quit---
>     at odp_scheduling.c:941
> (gdb)
>
>
> On Fri, May 27, 2016 at 12:01 PM, Maxim Uvarov 
> <maxim.uvarov@linaro.org <mailto:maxim.uvarov@linaro.org>> wrote:
>
>     If MAX_CPUS defined to less then current cpus, then
>     odp call calculates current available cpus and references
>     to array on thread creation. Do change to allocate array
>     dynamically.
>
>     Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org
>     <mailto:maxim.uvarov@linaro.org>>
>     ---
>      Looks like I found why this test fails on arm64 :)
>
>      test/performance/odp_scheduling.c | 12 ++++--------
>      1 file changed, 4 insertions(+), 8 deletions(-)
>
>     diff --git a/test/performance/odp_scheduling.c
>     b/test/performance/odp_scheduling.c
>     index 1d3bfd1..e64de6e 100644
>     --- a/test/performance/odp_scheduling.c
>     +++ b/test/performance/odp_scheduling.c
>     @@ -27,8 +27,6 @@
>      /* GNU lib C */
>      #include <getopt.h>
>
>     -
>     -#define MAX_WORKERS           32            /**< Max worker
>     threads */
>      #define MSG_POOL_SIZE         (4*1024*1024) /**< Message pool size */
>      #define MAX_ALLOCS            35            /**< Alloc burst size */
>      #define QUEUES_PER_PRIO       64            /**< Queue per
>     priority */
>     @@ -775,7 +773,7 @@ static void parse_args(int argc, char *argv[],
>     test_args_t *args)
>       */
>      int main(int argc, char *argv[])
>      {
>     -       odph_odpthread_t thread_tbl[MAX_WORKERS];
>     +       odph_odpthread_t *thread_tbl;
>             test_args_t args;
>             int num_workers;
>             odp_cpumask_t cpumask;
>     @@ -795,8 +793,6 @@ int main(int argc, char *argv[])
>             memset(&args, 0, sizeof(args));
>             parse_args(argc, argv, &args);
>
>     -       memset(thread_tbl, 0, sizeof(thread_tbl));
>     -
>             /* ODP global init */
>             if (odp_init_global(&instance, NULL, NULL)) {
>                     LOG_ERR("ODP global init failed.\n");
>     @@ -826,9 +822,8 @@ int main(int argc, char *argv[])
>             printf("\n");
>
>             /* Default to system CPU count unless user specified */
>     -       num_workers = MAX_WORKERS;
>     -       if (args.cpu_count)
>     -               num_workers = args.cpu_count;
>     +       num_workers = args.cpu_count;
>     +       thread_tbl = calloc(sizeof(odph_odpthread_t), num_workers);
>
>             /* Get default worker cpumask */
>             num_workers = odp_cpumask_default_worker(&cpumask,
>     num_workers);
>     @@ -947,6 +942,7 @@ int main(int argc, char *argv[])
>
>             /* Wait for worker threads to terminate */
>             odph_odpthreads_join(thread_tbl);
>     +       free(thread_tbl);
>
>             printf("ODP example complete\n\n");
>
>     --
>     2.7.1.250.gff4ea60
>
>     _______________________________________________
>     lng-odp mailing list
>     lng-odp@lists.linaro.org <mailto:lng-odp@lists.linaro.org>
>     https://lists.linaro.org/mailman/listinfo/lng-odp
>
>
diff mbox

Patch

diff --git a/test/performance/odp_scheduling.c b/test/performance/odp_scheduling.c
index 1d3bfd1..e64de6e 100644
--- a/test/performance/odp_scheduling.c
+++ b/test/performance/odp_scheduling.c
@@ -27,8 +27,6 @@ 
 /* GNU lib C */
 #include <getopt.h>
 
-
-#define MAX_WORKERS           32            /**< Max worker threads */
 #define MSG_POOL_SIZE         (4*1024*1024) /**< Message pool size */
 #define MAX_ALLOCS            35            /**< Alloc burst size */
 #define QUEUES_PER_PRIO       64            /**< Queue per priority */
@@ -775,7 +773,7 @@  static void parse_args(int argc, char *argv[], test_args_t *args)
  */
 int main(int argc, char *argv[])
 {
-	odph_odpthread_t thread_tbl[MAX_WORKERS];
+	odph_odpthread_t *thread_tbl;
 	test_args_t args;
 	int num_workers;
 	odp_cpumask_t cpumask;
@@ -795,8 +793,6 @@  int main(int argc, char *argv[])
 	memset(&args, 0, sizeof(args));
 	parse_args(argc, argv, &args);
 
-	memset(thread_tbl, 0, sizeof(thread_tbl));
-
 	/* ODP global init */
 	if (odp_init_global(&instance, NULL, NULL)) {
 		LOG_ERR("ODP global init failed.\n");
@@ -826,9 +822,8 @@  int main(int argc, char *argv[])
 	printf("\n");
 
 	/* Default to system CPU count unless user specified */
-	num_workers = MAX_WORKERS;
-	if (args.cpu_count)
-		num_workers = args.cpu_count;
+	num_workers = args.cpu_count;
+	thread_tbl = calloc(sizeof(odph_odpthread_t), num_workers);
 
 	/* Get default worker cpumask */
 	num_workers = odp_cpumask_default_worker(&cpumask, num_workers);
@@ -947,6 +942,7 @@  int main(int argc, char *argv[])
 
 	/* Wait for worker threads to terminate */
 	odph_odpthreads_join(thread_tbl);
+	free(thread_tbl);
 
 	printf("ODP example complete\n\n");