From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 80148 invoked by alias); 16 Apr 2016 07:40:08 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 80028 invoked by uid 89); 16 Apr 2016 07:40:07 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.6 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.2 spammy=acquire, held X-HELO: relay1.mentorg.com Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Sat, 16 Apr 2016 07:39:57 +0000 Received: from svr-orw-fem-02x.mgc.mentorg.com ([147.34.96.206] helo=SVR-ORW-FEM-02.mgc.mentorg.com) by relay1.mentorg.com with esmtp id 1arKpe-0007QF-QL from ChungLin_Tang@mentor.com ; Sat, 16 Apr 2016 00:39:54 -0700 Received: from [0.0.0.0] (147.34.91.1) by svr-orw-fem-02.mgc.mentorg.com (147.34.96.168) with Microsoft SMTP Server id 14.3.224.2; Sat, 16 Apr 2016 00:39:54 -0700 Subject: Re: [PATCH, libgomp] Fix deadlock in acc_set_device_type To: gcc-patches , Jakub Jelinek References: <56F8FD46.1060400@codesourcery.com> CC: Thomas Schwinge From: Chung-Lin Tang Message-ID: <2f8e763f-bd1e-5c2a-62c7-fa6e47536496@codesourcery.com> Date: Sat, 16 Apr 2016 07:40:00 -0000 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.0 MIME-Version: 1.0 In-Reply-To: <56F8FD46.1060400@codesourcery.com> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-IsSubscribed: yes X-SW-Source: 2016-04/txt/msg00774.txt.bz2 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 > > * 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. >