This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH, libgomp] Fix deadlock in acc_set_device_type (ping x3)
- From: Chung-Lin Tang <cltang at codesourcery dot com>
- To: gcc-patches <gcc-patches at gcc dot gnu dot org>, Jakub Jelinek <jakub at redhat dot com>
- Cc: Thomas Schwinge <thomas at codesourcery dot com>
- Date: Wed, 11 May 2016 14:48:00 +0800
- Subject: Re: [PATCH, libgomp] Fix deadlock in acc_set_device_type (ping x3)
- Authentication-results: sourceware.org; auth=none
- References: <56F8FD46 dot 1060400 at codesourcery dot com> <2f8e763f-bd1e-5c2a-62c7-fa6e47536496 at codesourcery dot com> <358b7045-70ce-8576-0d97-9c8191d9729b at codesourcery dot com>
Ping x3
On 2016/4/19 10:30 PM, Chung-Lin Tang wrote:
> Ping x2.
>
> Hi Jakub,
> This patch is fairly straightforward, and solves a easily encountered
> deadlock. Please approve for trunk and gcc-6-branch.
>
> Thanks,
> Chung-Lin
>
> On 2016/4/16 03:39 PM, Chung-Lin Tang wrote:
>> Ping.
>>
>> On 2016/3/28 05:45 PM, Chung-Lin Tang wrote:
>>> Hi Jakub, there's a path for deadlock on acc_device_lock when going
>>> through the acc_set_device_type() OpenACC library function.
>>> Basically, the gomp_init_targets_once() function should not be
>>> called with that held. The attached patch moves it appropriately.
>>>
>>> Also in this patch, there are several cases in acc_* functions
>>> where gomp_init_targets_once() is guarded by a test of
>>> !cached_base_dev. Since that function already uses pthread_once() to
>>> call gomp_target_init(), and technically cached_base_dev
>>> is protected by acc_device_lock, the cleanest way should be to
>>> simply drop those "if(!cached_base_dev)" tests.
>>>
>>> Tested libgomp without regressions on an nvptx offloaded system,
>>> is this okay for trunk?
>>>
>>> Thanks,
>>> Chung-Lin
>>>
>>> 2016-03-28 Chung-Lin Tang <cltang@codesourcery.com>
>>>
>>> * oacc-init.c (acc_init): Remove !cached_base_dev condition on call to
>>> gomp_init_targets_once().
>>> (acc_set_device_type): Remove !cached_base_dev condition on call to
>>> gomp_init_targets_once(), move call to before acc_device_lock acquire,
>>> to avoid deadlock.
>>> (acc_get_device_num): Remove !cached_base_dev condition on call to
>>> gomp_init_targets_once().
>>> (acc_set_device_num): Likewise.
>>>
>>
>