diff mbox

validation: synchronizers: use number of workers instead of threads

Message ID 1438178940-13557-1-git-send-email-maxim.uvarov@linaro.org
State Accepted
Commit c06a2258226b9b13a110c76b4c295895c147857c
Headers show

Commit Message

Maxim Uvarov July 29, 2015, 2:09 p.m. UTC
Use number of workers to not deadlock on barrier.

Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org>
---
 test/validation/synchronizers/synchronizers.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

Comments

Maxim Uvarov July 31, 2015, 9:25 a.m. UTC | #1
Please review. That patch is needed for dpdk.

Maxim.

On 07/29/15 17:09, Maxim Uvarov wrote:
> Use number of workers to not deadlock on barrier.
>
> Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org>
> ---
>   test/validation/synchronizers/synchronizers.c | 8 +++++---
>   1 file changed, 5 insertions(+), 3 deletions(-)
>
> diff --git a/test/validation/synchronizers/synchronizers.c b/test/validation/synchronizers/synchronizers.c
> index 6b354b6..7c521ca 100644
> --- a/test/validation/synchronizers/synchronizers.c
> +++ b/test/validation/synchronizers/synchronizers.c
> @@ -1054,8 +1054,9 @@ int synchronizers_suite_init(void)
>   
>   int synchronizers_init(void)
>   {
> -	uint32_t core_count, max_threads;
> +	uint32_t workers_count, max_threads;
>   	int ret = 0;
> +	odp_cpumask_t mask;
>   
>   	if (0 != odp_init_global(NULL, NULL)) {
>   		fprintf(stderr, "error: odp_init_global() failed.\n");
> @@ -1081,9 +1082,10 @@ int synchronizers_init(void)
>   	global_mem->g_iterations = MAX_ITERATIONS;
>   	global_mem->g_verbose = VERBOSE;
>   
> -	core_count = odp_cpu_count();
> +	workers_count = odp_cpumask_def_worker(&mask, 0);
>   
> -	max_threads = (core_count >= MAX_WORKERS) ? MAX_WORKERS : core_count;
> +	max_threads = (workers_count >= MAX_WORKERS) ?
> +			MAX_WORKERS : workers_count;
>   
>   	if (max_threads < global_mem->g_num_threads) {
>   		printf("Requested num of threads is too large\n");
Zoltan Kiss Aug. 3, 2015, 5:13 p.m. UTC | #2
I'm not sure I get the entire context of why it deadlocks on barrier, 
but otherwise it seems OK, and it fixes the problem in the ODP-DPDK unit 
tests.

Tested-by: Zoltan Kiss <zoltan.kiss@linaro.org>

Let me know when it gets applied so I can pull it.

On 29/07/15 15:09, Maxim Uvarov wrote:
> Use number of workers to not deadlock on barrier.
>
> Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org>
> ---
>   test/validation/synchronizers/synchronizers.c | 8 +++++---
>   1 file changed, 5 insertions(+), 3 deletions(-)
>
> diff --git a/test/validation/synchronizers/synchronizers.c b/test/validation/synchronizers/synchronizers.c
> index 6b354b6..7c521ca 100644
> --- a/test/validation/synchronizers/synchronizers.c
> +++ b/test/validation/synchronizers/synchronizers.c
> @@ -1054,8 +1054,9 @@ int synchronizers_suite_init(void)
>
>   int synchronizers_init(void)
>   {
> -	uint32_t core_count, max_threads;
> +	uint32_t workers_count, max_threads;
>   	int ret = 0;
> +	odp_cpumask_t mask;
>
>   	if (0 != odp_init_global(NULL, NULL)) {
>   		fprintf(stderr, "error: odp_init_global() failed.\n");
> @@ -1081,9 +1082,10 @@ int synchronizers_init(void)
>   	global_mem->g_iterations = MAX_ITERATIONS;
>   	global_mem->g_verbose = VERBOSE;
>
> -	core_count = odp_cpu_count();
> +	workers_count = odp_cpumask_def_worker(&mask, 0);
>
> -	max_threads = (core_count >= MAX_WORKERS) ? MAX_WORKERS : core_count;
> +	max_threads = (workers_count >= MAX_WORKERS) ?
> +			MAX_WORKERS : workers_count;
>
>   	if (max_threads < global_mem->g_num_threads) {
>   		printf("Requested num of threads is too large\n");
>
Maxim Uvarov Aug. 4, 2015, 11:30 a.m. UTC | #3
Merged as.

commit c06a2258226b9b13a110c76b4c295895c147857c


On 08/03/15 20:13, Zoltan Kiss wrote:
> I'm not sure I get the entire context of why it deadlocks on barrier, 
> but otherwise it seems OK, and it fixes the problem in the ODP-DPDK 
> unit tests.
>

The idea is that if you have X cpu, and one thread is control thread 
then odp_barrier() initialized to X but actually X-1 threads started and 
all of them locked on barrier, waiting for last thread. So that barrier 
should be initialized only for number of active workers, not to the 
total number of cpus.

Maxim.
> Tested-by: Zoltan Kiss <zoltan.kiss@linaro.org>
>
> Let me know when it gets applied so I can pull it.
>
> On 29/07/15 15:09, Maxim Uvarov wrote:
>> Use number of workers to not deadlock on barrier.
>>
>> Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org>
>> ---
>>   test/validation/synchronizers/synchronizers.c | 8 +++++---
>>   1 file changed, 5 insertions(+), 3 deletions(-)
>>
>> diff --git a/test/validation/synchronizers/synchronizers.c 
>> b/test/validation/synchronizers/synchronizers.c
>> index 6b354b6..7c521ca 100644
>> --- a/test/validation/synchronizers/synchronizers.c
>> +++ b/test/validation/synchronizers/synchronizers.c
>> @@ -1054,8 +1054,9 @@ int synchronizers_suite_init(void)
>>
>>   int synchronizers_init(void)
>>   {
>> -    uint32_t core_count, max_threads;
>> +    uint32_t workers_count, max_threads;
>>       int ret = 0;
>> +    odp_cpumask_t mask;
>>
>>       if (0 != odp_init_global(NULL, NULL)) {
>>           fprintf(stderr, "error: odp_init_global() failed.\n");
>> @@ -1081,9 +1082,10 @@ int synchronizers_init(void)
>>       global_mem->g_iterations = MAX_ITERATIONS;
>>       global_mem->g_verbose = VERBOSE;
>>
>> -    core_count = odp_cpu_count();
>> +    workers_count = odp_cpumask_def_worker(&mask, 0);
>>
>> -    max_threads = (core_count >= MAX_WORKERS) ? MAX_WORKERS : 
>> core_count;
>> +    max_threads = (workers_count >= MAX_WORKERS) ?
>> +            MAX_WORKERS : workers_count;
>>
>>       if (max_threads < global_mem->g_num_threads) {
>>           printf("Requested num of threads is too large\n");
>>
diff mbox

Patch

diff --git a/test/validation/synchronizers/synchronizers.c b/test/validation/synchronizers/synchronizers.c
index 6b354b6..7c521ca 100644
--- a/test/validation/synchronizers/synchronizers.c
+++ b/test/validation/synchronizers/synchronizers.c
@@ -1054,8 +1054,9 @@  int synchronizers_suite_init(void)
 
 int synchronizers_init(void)
 {
-	uint32_t core_count, max_threads;
+	uint32_t workers_count, max_threads;
 	int ret = 0;
+	odp_cpumask_t mask;
 
 	if (0 != odp_init_global(NULL, NULL)) {
 		fprintf(stderr, "error: odp_init_global() failed.\n");
@@ -1081,9 +1082,10 @@  int synchronizers_init(void)
 	global_mem->g_iterations = MAX_ITERATIONS;
 	global_mem->g_verbose = VERBOSE;
 
-	core_count = odp_cpu_count();
+	workers_count = odp_cpumask_def_worker(&mask, 0);
 
-	max_threads = (core_count >= MAX_WORKERS) ? MAX_WORKERS : core_count;
+	max_threads = (workers_count >= MAX_WORKERS) ?
+			MAX_WORKERS : workers_count;
 
 	if (max_threads < global_mem->g_num_threads) {
 		printf("Requested num of threads is too large\n");