[{"id":699,"web_url":"http://patchwork.ozlabs.org/comment/699/","msgid":"<48CF55F2.8020309@sm.sony.co.jp>","list_archive_url":null,"date":"2008-09-16T06:45:06","subject":"Re: [Cbe-oss-dev] [PATCH 07/11 v3]MARS: Remove api argument params\n\tstructs","submitter":{"id":39,"url":"http://patchwork.ozlabs.org/api/people/39/","name":"Kazunori Asayama","email":"asayama@sm.sony.co.jp"},"content":"Yuji Mano wrote:\n> This removes the mars_params and mars_task_params structure previously passed\n> into the mars context and mars task APIs.\n> \n> Parameter arguments are now passed in directly.\n> \n> Signed-off-by: Yuji Mano <yuji.mano@am.sony.com>\n> \n> ---\n> v3:\n>  - revert v2 change and keep num_mpus_max() function but cache the result of\n>    spe_cpu_info_get (so we can use the cached spe count later if needed)\n> v2:\n>  - replace num_mpus_max() with mpu_check() that avoids calling spe_cpu_info_get\n>    multiple times\n> \n>  include/host/mars/mars_context.h |   23 +++---------------\n>  include/host/mars/mars_task.h    |   32 +++++++------------------\n>  src/host/lib/mars_context.c      |   49 +++++++++++++++++----------------------\n>  src/host/lib/mars_task.c         |   34 +++++++++++----------------\n>  4 files changed, 50 insertions(+), 88 deletions(-)\n(snip)\n> --- a/src/host/lib/mars_context.c\n> +++ b/src/host/lib/mars_context.c\n> @@ -48,9 +48,17 @@\n>  \n>  extern struct spe_program_handle mars_kernel_entry;\n>  \n> -static int num_mpus_max(void)\n> +static uint32_t num_mpus_max(void)\n>  {\n> -\treturn spe_cpu_info_get(SPE_COUNT_PHYSICAL_SPES, -1);\n> +\tstatic int count = -1;\n> +\n> +\tif (count < 0) {\n> +\t\tcount = spe_cpu_info_get(SPE_COUNT_PHYSICAL_SPES, -1);\n> +\t\tif (count < 0)\n> +\t\t\tcount = 0;\n> +\t}\n> +\n> +\treturn count;\n>  }\n\nThis doesn't seem to be thread-safe?","headers":{"Return-Path":"<cbe-oss-dev-bounces+patchwork=ozlabs.org@ozlabs.org>","X-Original-To":["patchwork@ozlabs.org","cbe-oss-dev@ozlabs.org"],"Delivered-To":["patchwork@ozlabs.org","cbe-oss-dev@ozlabs.org"],"Received":["from ozlabs.org (localhost [127.0.0.1])\n\tby ozlabs.org (Postfix) with ESMTP id 6CA6EDE252\n\tfor <patchwork@ozlabs.org>; Tue, 16 Sep 2008 16:45:20 +1000 (EST)","from ms5.sony.co.jp (ms5.Sony.CO.JP [211.125.136.201])\n\t(using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))\n\t(Client did not present a certificate)\n\tby ozlabs.org (Postfix) with ESMTPS id 29FF0DDE06\n\tfor <cbe-oss-dev@ozlabs.org>; Tue, 16 Sep 2008 16:45:10 +1000 (EST)","from mta7.sony.co.jp (mta7.Sony.CO.JP [137.153.71.12])\n\tby ms5.sony.co.jp (R8/Sony) with ESMTP id m8G6j8EH009419\n\tfor <cbe-oss-dev@ozlabs.org>; Tue, 16 Sep 2008 15:45:08 +0900 (JST)","from mta7.sony.co.jp (localhost [127.0.0.1])\n\tby mta7.sony.co.jp (R8/Sony) with ESMTP id m8G6j8vV000513\n\tfor <cbe-oss-dev@ozlabs.org>; Tue, 16 Sep 2008 15:45:08 +0900 (JST)","from ibex.sm.sony.co.jp ([43.4.142.104])\n\tby mta7.sony.co.jp (R8/Sony) with ESMTP id m8G6j8c2000508\n\tfor <cbe-oss-dev@ozlabs.org>; Tue, 16 Sep 2008 15:45:08 +0900 (JST)","from [192.168.99.230] ([43.24.196.155]) (authenticated bits=0)\n\tby ibex.sm.sony.co.jp (8.13.1/8.13.1) with ESMTP id m8G6j7Yq017465;\n\tTue, 16 Sep 2008 15:45:07 +0900"],"Message-ID":"<48CF55F2.8020309@sm.sony.co.jp>","Date":"Tue, 16 Sep 2008 15:45:06 +0900","From":"Kazunori Asayama <asayama@sm.sony.co.jp>","User-Agent":"Thunderbird 2.0.0.16 (Windows/20080708)","MIME-Version":"1.0","To":"Yuji Mano <yuji.mano@am.sony.com>","References":"<48C972DF.4080409@am.sony.com> <48CB0D0A.1080302@am.sony.com>","In-Reply-To":"<48CB0D0A.1080302@am.sony.com>","Cc":"CBE Development <cbe-oss-dev@ozlabs.org>","Subject":"Re: [Cbe-oss-dev] [PATCH 07/11 v3]MARS: Remove api argument params\n\tstructs","X-BeenThere":"cbe-oss-dev@ozlabs.org","X-Mailman-Version":"2.1.11","Precedence":"list","List-Id":"Discussion about Open Source Software for the Cell Broadband Engine\n\t<cbe-oss-dev.ozlabs.org>","List-Unsubscribe":"<https://ozlabs.org/mailman/options/cbe-oss-dev>,\n\t<mailto:cbe-oss-dev-request@ozlabs.org?subject=unsubscribe>","List-Archive":"<http://ozlabs.org/pipermail/cbe-oss-dev>","List-Post":"<mailto:cbe-oss-dev@ozlabs.org>","List-Help":"<mailto:cbe-oss-dev-request@ozlabs.org?subject=help>","List-Subscribe":"<https://ozlabs.org/mailman/listinfo/cbe-oss-dev>,\n\t<mailto:cbe-oss-dev-request@ozlabs.org?subject=subscribe>","Content-Type":"text/plain; charset=\"us-ascii\"","Content-Transfer-Encoding":"7bit","Sender":"cbe-oss-dev-bounces+patchwork=ozlabs.org@ozlabs.org","Errors-To":"cbe-oss-dev-bounces+patchwork=ozlabs.org@ozlabs.org"}},{"id":983,"web_url":"http://patchwork.ozlabs.org/comment/983/","msgid":"<48D156AF.8060706@am.sony.com>","list_archive_url":null,"date":"2008-09-17T19:12:47","subject":"Re: [Cbe-oss-dev] [PATCH 07/11 v3]MARS: Remove api argument params\n\tstructs","submitter":{"id":127,"url":"http://patchwork.ozlabs.org/api/people/127/","name":"Yuji Mano","email":"yuji.mano@am.sony.com"},"content":"Kazunori Asayama wrote:\n> Yuji Mano wrote:\n>> This removes the mars_params and mars_task_params structure previously passed\n>> into the mars context and mars task APIs.\n>> \n>> Parameter arguments are now passed in directly.\n>> \n>> Signed-off-by: Yuji Mano <yuji.mano@am.sony.com>\n>> \n>> ---\n>> v3:\n>>  - revert v2 change and keep num_mpus_max() function but cache the result of\n>>    spe_cpu_info_get (so we can use the cached spe count later if needed)\n>> v2:\n>>  - replace num_mpus_max() with mpu_check() that avoids calling spe_cpu_info_get\n>>    multiple times\n>> \n>>  include/host/mars/mars_context.h |   23 +++---------------\n>>  include/host/mars/mars_task.h    |   32 +++++++------------------\n>>  src/host/lib/mars_context.c      |   49 +++++++++++++++++----------------------\n>>  src/host/lib/mars_task.c         |   34 +++++++++++----------------\n>>  4 files changed, 50 insertions(+), 88 deletions(-)\n> (snip)\n>> --- a/src/host/lib/mars_context.c\n>> +++ b/src/host/lib/mars_context.c\n>> @@ -48,9 +48,17 @@\n>>  \n>>  extern struct spe_program_handle mars_kernel_entry;\n>>  \n>> -static int num_mpus_max(void)\n>> +static uint32_t num_mpus_max(void)\n>>  {\n>> -\treturn spe_cpu_info_get(SPE_COUNT_PHYSICAL_SPES, -1);\n>> +\tstatic int count = -1;\n>> +\n>> +\tif (count < 0) {\n>> +\t\tcount = spe_cpu_info_get(SPE_COUNT_PHYSICAL_SPES, -1);\n>> +\t\tif (count < 0)\n>> +\t\t\tcount = 0;\n>> +\t}\n>> +\n>> +\treturn count;\n>>  }\n> \n> This doesn't seem to be thread-safe?\n> \n\nYes it is not thread-safe. This fix allows spe_cpu_info_get() to be called only once,\neven after we allow for shared contexts and mars_initialize() may be called multiple\ntimes.\n\nI can fix this so that spe_cpu_info_get() gets called once per each mars_initialize()\ncall, but I think once we have the global shared context we still have the same\nproblem?\n\nRegards,\nYuji","headers":{"Return-Path":"<cbe-oss-dev-bounces+patchwork-incoming=ozlabs.org@ozlabs.org>","X-Original-To":["patchwork-incoming@ozlabs.org","cbe-oss-dev@ozlabs.org"],"Delivered-To":["patchwork-incoming@ozlabs.org","cbe-oss-dev@ozlabs.org"],"Received":["from ozlabs.org (localhost [127.0.0.1])\n\tby ozlabs.org (Postfix) with ESMTP id A41BADE211\n\tfor <patchwork-incoming@ozlabs.org>;\n\tThu, 18 Sep 2008 05:15:58 +1000 (EST)","from SG2EHSOBE006.bigfish.com (outbound-sin.frontbridge.com\n\t[207.46.51.80]) by ozlabs.org (Postfix) with ESMTP id A760ADE048\n\tfor <cbe-oss-dev@ozlabs.org>; Thu, 18 Sep 2008 05:12:57 +1000 (EST)","from mail178-sin-R.bigfish.com (10.3.40.3) by\n\tSG2EHSOBE006.bigfish.com (10.3.40.26) with Microsoft SMTP Server id\n\t8.1.291.1; Wed, 17 Sep 2008 19:12:52 +0000","from mail178-sin (localhost.localdomain [127.0.0.1])\tby\n\tmail178-sin-R.bigfish.com (Postfix) with ESMTP id 0EDC614680DF\tfor\n\t<cbe-oss-dev@ozlabs.org>; Wed, 17 Sep 2008 19:12:52 +0000 (UTC)","by mail178-sin (MessageSwitch) id 1221678771163195_5481;\n\tWed, 17 Sep 2008 19:12:51 +0000 (UCT)","from mail8.fw-sd.sony.com (mail8.fw-sd.sony.com [160.33.66.75])\tby\n\tmail178-sin.bigfish.com (Postfix) with ESMTP id AE87F39005F\tfor\n\t<cbe-oss-dev@ozlabs.org>; Wed, 17 Sep 2008 19:12:50 +0000 (UTC)","from mail3.sjc.in.sel.sony.com (mail3.sjc.in.sel.sony.com\n\t[43.134.1.211])\tby mail8.fw-sd.sony.com (8.14.2/8.14.2) with ESMTP id\n\tm8HJCnj5024738\tfor <cbe-oss-dev@ozlabs.org>;\n\tWed, 17 Sep 2008 19:12:49 GMT","from USSDIXIM02.am.sony.com (ussdixim02.am.sony.com\n\t[43.130.140.34])\n\tby mail3.sjc.in.sel.sony.com (8.12.11/8.12.11) with ESMTP id\n\tm8HJCm1E022320; Wed, 17 Sep 2008 19:12:48 GMT","from ussdixms03.am.sony.com ([43.130.140.23]) by\n\tUSSDIXIM02.am.sony.com with Microsoft SMTPSVC(5.0.2195.6713);\n\tWed, 17 Sep 2008 12:12:48 -0700","from [43.135.148.175] ([43.135.148.175]) by ussdixms03.am.sony.com\n\twith Microsoft SMTPSVC(5.0.2195.6713);\n\tWed, 17 Sep 2008 12:12:48 -0700"],"X-BigFish":"VS-20(z34a4lz1432R98dR1805M3117Kzz10c0j10d3izz1497iz2dh6bh61h)","X-Spam-TCS-SCL":"0:0","Message-ID":"<48D156AF.8060706@am.sony.com>","Date":"Wed, 17 Sep 2008 12:12:47 -0700","From":"Yuji Mano <yuji.mano@am.sony.com>","User-Agent":"Thunderbird 2.0.0.5 (X11/20070719)","MIME-Version":"1.0","To":"Kazunori Asayama <asayama@sm.sony.co.jp>","References":"<48C972DF.4080409@am.sony.com> <48CB0D0A.1080302@am.sony.com>\n\t<48CF55F2.8020309@sm.sony.co.jp>","In-Reply-To":"<48CF55F2.8020309@sm.sony.co.jp>","X-Enigmail-Version":"0.95.7","X-OriginalArrivalTime":"17 Sep 2008 19:12:48.0256 (UTC)\n\tFILETIME=[5F5C0800:01C918F9]","X-SEL-encryption-scan":"scanned","Cc":"CBE Development <cbe-oss-dev@ozlabs.org>","Subject":"Re: [Cbe-oss-dev] [PATCH 07/11 v3]MARS: Remove api argument params\n\tstructs","X-BeenThere":"cbe-oss-dev@ozlabs.org","X-Mailman-Version":"2.1.11","Precedence":"list","List-Id":"Discussion about Open Source Software for the Cell Broadband Engine\n\t<cbe-oss-dev.ozlabs.org>","List-Unsubscribe":"<https://ozlabs.org/mailman/options/cbe-oss-dev>,\n\t<mailto:cbe-oss-dev-request@ozlabs.org?subject=unsubscribe>","List-Archive":"<http://ozlabs.org/pipermail/cbe-oss-dev>","List-Post":"<mailto:cbe-oss-dev@ozlabs.org>","List-Help":"<mailto:cbe-oss-dev-request@ozlabs.org?subject=help>","List-Subscribe":"<https://ozlabs.org/mailman/listinfo/cbe-oss-dev>,\n\t<mailto:cbe-oss-dev-request@ozlabs.org?subject=subscribe>","Content-Type":"text/plain; charset=\"us-ascii\"","Content-Transfer-Encoding":"7bit","Sender":"cbe-oss-dev-bounces+patchwork-incoming=ozlabs.org@ozlabs.org","Errors-To":"cbe-oss-dev-bounces+patchwork-incoming=ozlabs.org@ozlabs.org"}},{"id":989,"web_url":"http://patchwork.ozlabs.org/comment/989/","msgid":"<48D15C20.8030901@am.sony.com>","list_archive_url":null,"date":"2008-09-17T19:36:00","subject":"Re: [Cbe-oss-dev] [PATCH 07/11 v3]MARS: Remove api argument params\n\tstructs","submitter":{"id":127,"url":"http://patchwork.ozlabs.org/api/people/127/","name":"Yuji Mano","email":"yuji.mano@am.sony.com"},"content":"Yuji Mano wrote:\n> Kazunori Asayama wrote:\n>> Yuji Mano wrote:\n>>> This removes the mars_params and mars_task_params structure previously passed\n>>> into the mars context and mars task APIs.\n>>> \n>>> Parameter arguments are now passed in directly.\n>>> \n>>> Signed-off-by: Yuji Mano <yuji.mano@am.sony.com>\n>>> \n>>> ---\n>>> v3:\n>>>  - revert v2 change and keep num_mpus_max() function but cache the result of\n>>>    spe_cpu_info_get (so we can use the cached spe count later if needed)\n>>> v2:\n>>>  - replace num_mpus_max() with mpu_check() that avoids calling spe_cpu_info_get\n>>>    multiple times\n>>> \n>>>  include/host/mars/mars_context.h |   23 +++---------------\n>>>  include/host/mars/mars_task.h    |   32 +++++++------------------\n>>>  src/host/lib/mars_context.c      |   49 +++++++++++++++++----------------------\n>>>  src/host/lib/mars_task.c         |   34 +++++++++++----------------\n>>>  4 files changed, 50 insertions(+), 88 deletions(-)\n>> (snip)\n>>> --- a/src/host/lib/mars_context.c\n>>> +++ b/src/host/lib/mars_context.c\n>>> @@ -48,9 +48,17 @@\n>>>  \n>>>  extern struct spe_program_handle mars_kernel_entry;\n>>>  \n>>> -static int num_mpus_max(void)\n>>> +static uint32_t num_mpus_max(void)\n>>>  {\n>>> -\treturn spe_cpu_info_get(SPE_COUNT_PHYSICAL_SPES, -1);\n>>> +\tstatic int count = -1;\n>>> +\n>>> +\tif (count < 0) {\n>>> +\t\tcount = spe_cpu_info_get(SPE_COUNT_PHYSICAL_SPES, -1);\n>>> +\t\tif (count < 0)\n>>> +\t\t\tcount = 0;\n>>> +\t}\n>>> +\n>>> +\treturn count;\n>>>  }\n>> \n>> This doesn't seem to be thread-safe?\n>> \n> \n> Yes it is not thread-safe. This fix allows spe_cpu_info_get() to be called only once,\n> even after we allow for shared contexts and mars_initialize() may be called multiple\n> times.\n> \n> I can fix this so that spe_cpu_info_get() gets called once per each mars_initialize()\n> call, but I think once we have the global shared context we still have the same\n> problem?\n\nSorry. What I meant was I think we can deal with making mars_initialize() thread-safe\nonce we implement the shared contexts. Or we can protect mars_initialize with a pthread\nmutex now.\n\nRegards,\nYuji","headers":{"Return-Path":"<cbe-oss-dev-bounces+patchwork-incoming=ozlabs.org@ozlabs.org>","X-Original-To":["patchwork-incoming@ozlabs.org","cbe-oss-dev@ozlabs.org"],"Delivered-To":["patchwork-incoming@ozlabs.org","cbe-oss-dev@ozlabs.org"],"Received":["from ozlabs.org (localhost [127.0.0.1])\n\tby ozlabs.org (Postfix) with ESMTP id 2D1C0DE283\n\tfor <patchwork-incoming@ozlabs.org>;\n\tThu, 18 Sep 2008 05:39:22 +1000 (EST)","from VA3EHSOBE003.bigfish.com (outbound-va3.frontbridge.com\n\t[216.32.180.16]) by ozlabs.org (Postfix) with ESMTP id 40A5DDE01F\n\tfor <cbe-oss-dev@ozlabs.org>; Thu, 18 Sep 2008 05:36:07 +1000 (EST)","from mail91-va3-R.bigfish.com (10.7.14.249) by\n\tVA3EHSOBE003.bigfish.com (10.7.40.23) with Microsoft SMTP Server id\n\t8.1.291.1; Wed, 17 Sep 2008 19:36:05 +0000","from mail91-va3 (localhost.localdomain [127.0.0.1])\tby\n\tmail91-va3-R.bigfish.com (Postfix) with ESMTP id B0FA0320258\tfor\n\t<cbe-oss-dev@ozlabs.org>; Wed, 17 Sep 2008 19:36:04 +0000 (UTC)","by mail91-va3 (MessageSwitch) id 1221680163162263_3975; Wed, 17 Sep\n\t2008 19:36:03 +0000 (UCT)","from mail8.fw-sd.sony.com (mail8.fw-sd.sony.com [160.33.66.75])\tby\n\tmail91-va3.bigfish.com (Postfix) with ESMTP id F35AF1748063\tfor\n\t<cbe-oss-dev@ozlabs.org>; Wed, 17 Sep 2008 19:36:02 +0000 (UTC)","from mail3.sjc.in.sel.sony.com (mail3.sjc.in.sel.sony.com\n\t[43.134.1.211])\tby mail8.fw-sd.sony.com (8.14.2/8.14.2) with ESMTP id\n\tm8HJa2Lx014924\tfor <cbe-oss-dev@ozlabs.org>;\n\tWed, 17 Sep 2008 19:36:02 GMT","from USSDIXIM02.am.sony.com (ussdixim02.am.sony.com\n\t[43.130.140.34])\n\tby mail3.sjc.in.sel.sony.com (8.12.11/8.12.11) with ESMTP id\n\tm8HJa2i6010886; Wed, 17 Sep 2008 19:36:02 GMT","from ussdixms03.am.sony.com ([43.130.140.23]) by\n\tUSSDIXIM02.am.sony.com with Microsoft SMTPSVC(5.0.2195.6713);\n\tWed, 17 Sep 2008 12:36:02 -0700","from [43.135.148.175] ([43.135.148.175]) by ussdixms03.am.sony.com\n\twith Microsoft SMTPSVC(5.0.2195.6713);\n\tWed, 17 Sep 2008 12:36:01 -0700"],"X-BigFish":"VS-20(z34a4lz1432R98dR1805M3117Kzz10c0j10d3izz1497iz2dh6bh61h)","X-Spam-TCS-SCL":"0:0","X-FB-SS":"5,","Message-ID":"<48D15C20.8030901@am.sony.com>","Date":"Wed, 17 Sep 2008 12:36:00 -0700","From":"Yuji Mano <yuji.mano@am.sony.com>","User-Agent":"Thunderbird 2.0.0.5 (X11/20070719)","MIME-Version":"1.0","To":"Kazunori Asayama <asayama@sm.sony.co.jp>","References":"<48C972DF.4080409@am.sony.com>\n\t<48CB0D0A.1080302@am.sony.com>\t<48CF55F2.8020309@sm.sony.co.jp>\n\t<48D156AF.8060706@am.sony.com>","In-Reply-To":"<48D156AF.8060706@am.sony.com>","X-Enigmail-Version":"0.95.7","X-OriginalArrivalTime":"17 Sep 2008 19:36:01.0444 (UTC)\n\tFILETIME=[9DC3A640:01C918FC]","X-SEL-encryption-scan":"scanned","Cc":"CBE Development <cbe-oss-dev@ozlabs.org>","Subject":"Re: [Cbe-oss-dev] [PATCH 07/11 v3]MARS: Remove api argument params\n\tstructs","X-BeenThere":"cbe-oss-dev@ozlabs.org","X-Mailman-Version":"2.1.11","Precedence":"list","List-Id":"Discussion about Open Source Software for the Cell Broadband Engine\n\t<cbe-oss-dev.ozlabs.org>","List-Unsubscribe":"<https://ozlabs.org/mailman/options/cbe-oss-dev>,\n\t<mailto:cbe-oss-dev-request@ozlabs.org?subject=unsubscribe>","List-Archive":"<http://ozlabs.org/pipermail/cbe-oss-dev>","List-Post":"<mailto:cbe-oss-dev@ozlabs.org>","List-Help":"<mailto:cbe-oss-dev-request@ozlabs.org?subject=help>","List-Subscribe":"<https://ozlabs.org/mailman/listinfo/cbe-oss-dev>,\n\t<mailto:cbe-oss-dev-request@ozlabs.org?subject=subscribe>","Content-Type":"text/plain; charset=\"us-ascii\"","Content-Transfer-Encoding":"7bit","Sender":"cbe-oss-dev-bounces+patchwork-incoming=ozlabs.org@ozlabs.org","Errors-To":"cbe-oss-dev-bounces+patchwork-incoming=ozlabs.org@ozlabs.org"}},{"id":1034,"web_url":"http://patchwork.ozlabs.org/comment/1034/","msgid":"<48D1BB6A.1050609@sm.sony.co.jp>","list_archive_url":null,"date":"2008-09-18T02:22:34","subject":"Re: [Cbe-oss-dev] [PATCH 07/11 v3]MARS: Remove api argument params\n\tstructs","submitter":{"id":39,"url":"http://patchwork.ozlabs.org/api/people/39/","name":"Kazunori Asayama","email":"asayama@sm.sony.co.jp"},"content":"Yuji Mano wrote:\n> Yuji Mano wrote:\n>> Kazunori Asayama wrote:\n>>> Yuji Mano wrote:\n>>>> --- a/src/host/lib/mars_context.c\n>>>> +++ b/src/host/lib/mars_context.c\n>>>> @@ -48,9 +48,17 @@\n>>>>  \n>>>>  extern struct spe_program_handle mars_kernel_entry;\n>>>>  \n>>>> -static int num_mpus_max(void)\n>>>> +static uint32_t num_mpus_max(void)\n>>>>  {\n>>>> -\treturn spe_cpu_info_get(SPE_COUNT_PHYSICAL_SPES, -1);\n>>>> +\tstatic int count = -1;\n>>>> +\n>>>> +\tif (count < 0) {\n>>>> +\t\tcount = spe_cpu_info_get(SPE_COUNT_PHYSICAL_SPES, -1);\n>>>> +\t\tif (count < 0)\n>>>> +\t\t\tcount = 0;\n>>>> +\t}\n>>>> +\n>>>> +\treturn count;\n>>>>  }\n>>> This doesn't seem to be thread-safe?\n>>>\n>> Yes it is not thread-safe. This fix allows spe_cpu_info_get() to be called only once,\n>> even after we allow for shared contexts and mars_initialize() may be called multiple\n>> times.\n>>\n>> I can fix this so that spe_cpu_info_get() gets called once per each mars_initialize()\n>> call, but I think once we have the global shared context we still have the same\n>> problem?\n> \n> Sorry. What I meant was I think we can deal with making mars_initialize() thread-safe\n> once we implement the shared contexts. Or we can protect mars_initialize with a pthread\n> mutex now.\n\nI think an easy solution at this point is to store the return value of\nnum_mpu_max() in a local auto variable (not a static variable) of\nmars_initialize() and reuse it during each mars_initialize() call.","headers":{"Return-Path":"<cbe-oss-dev-bounces+patchwork-incoming=ozlabs.org@ozlabs.org>","X-Original-To":["patchwork-incoming@ozlabs.org","cbe-oss-dev@ozlabs.org"],"Delivered-To":["patchwork-incoming@ozlabs.org","cbe-oss-dev@ozlabs.org"],"Received":["from ozlabs.org (localhost [127.0.0.1])\n\tby ozlabs.org (Postfix) with ESMTP id 07239DDF9C\n\tfor <patchwork-incoming@ozlabs.org>;\n\tThu, 18 Sep 2008 12:23:06 +1000 (EST)","from ms4.sony.co.jp (ms4.Sony.CO.JP [211.125.136.198])\n\t(using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))\n\t(Client did not present a certificate)\n\tby ozlabs.org (Postfix) with ESMTPS id 498DADDE20\n\tfor <cbe-oss-dev@ozlabs.org>; Thu, 18 Sep 2008 12:22:57 +1000 (EST)","from mta8.sony.co.jp (mta8.Sony.CO.JP [137.153.71.15])\n\tby ms4.sony.co.jp (R8/Sony) with ESMTP id m8I2Mmro022169\n\tfor <cbe-oss-dev@ozlabs.org>; Thu, 18 Sep 2008 11:22:48 +0900 (JST)","from mta8.sony.co.jp (localhost [127.0.0.1])\n\tby mta8.sony.co.jp (R8/Sony) with ESMTP id m8I2MlJd001267\n\tfor <cbe-oss-dev@ozlabs.org>; Thu, 18 Sep 2008 11:22:47 +0900 (JST)","from ibex.sm.sony.co.jp ([43.4.142.104])\n\tby mta8.sony.co.jp (R8/Sony) with ESMTP id m8I2Mlqc001264\n\tfor <cbe-oss-dev@ozlabs.org>; Thu, 18 Sep 2008 11:22:47 +0900 (JST)","from [192.168.99.230] ([43.24.196.155]) (authenticated bits=0)\n\tby ibex.sm.sony.co.jp (8.13.1/8.13.1) with ESMTP id m8I2Mbp6019205;\n\tThu, 18 Sep 2008 11:22:37 +0900"],"Message-ID":"<48D1BB6A.1050609@sm.sony.co.jp>","Date":"Thu, 18 Sep 2008 11:22:34 +0900","From":"Kazunori Asayama <asayama@sm.sony.co.jp>","User-Agent":"Thunderbird 2.0.0.16 (Windows/20080708)","MIME-Version":"1.0","To":"Yuji Mano <yuji.mano@am.sony.com>","References":"<48C972DF.4080409@am.sony.com>\n\t<48CB0D0A.1080302@am.sony.com>\t<48CF55F2.8020309@sm.sony.co.jp>\n\t<48D156AF.8060706@am.sony.com> <48D15C20.8030901@am.sony.com>","In-Reply-To":"<48D15C20.8030901@am.sony.com>","Cc":"CBE Development <cbe-oss-dev@ozlabs.org>","Subject":"Re: [Cbe-oss-dev] [PATCH 07/11 v3]MARS: Remove api argument params\n\tstructs","X-BeenThere":"cbe-oss-dev@ozlabs.org","X-Mailman-Version":"2.1.11","Precedence":"list","List-Id":"Discussion about Open Source Software for the Cell Broadband Engine\n\t<cbe-oss-dev.ozlabs.org>","List-Unsubscribe":"<https://ozlabs.org/mailman/options/cbe-oss-dev>,\n\t<mailto:cbe-oss-dev-request@ozlabs.org?subject=unsubscribe>","List-Archive":"<http://ozlabs.org/pipermail/cbe-oss-dev>","List-Post":"<mailto:cbe-oss-dev@ozlabs.org>","List-Help":"<mailto:cbe-oss-dev-request@ozlabs.org?subject=help>","List-Subscribe":"<https://ozlabs.org/mailman/listinfo/cbe-oss-dev>,\n\t<mailto:cbe-oss-dev-request@ozlabs.org?subject=subscribe>","Content-Type":"text/plain; charset=\"us-ascii\"","Content-Transfer-Encoding":"7bit","Sender":"cbe-oss-dev-bounces+patchwork-incoming=ozlabs.org@ozlabs.org","Errors-To":"cbe-oss-dev-bounces+patchwork-incoming=ozlabs.org@ozlabs.org"}}]