From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754223AbcKUMdK (ORCPT ); Mon, 21 Nov 2016 07:33:10 -0500 Received: from mail-wm0-f67.google.com ([74.125.82.67]:35754 "EHLO mail-wm0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753873AbcKUMdI (ORCPT ); Mon, 21 Nov 2016 07:33:08 -0500 Subject: Re: [PATCH v5 5/9] IB/isert: Replace semaphore sem with completion To: Arnd Bergmann References: <1479708496-9828-1-git-send-email-binoy.jayan@linaro.org> <1479708496-9828-6-git-send-email-binoy.jayan@linaro.org> <2625189.HB0S3sfnY7@wuerfel> Cc: Binoy Jayan , Doug Ledford , Sean Hefty , Hal Rosenstock , Leon Romanovsky , Sagi Grimberg , Bart Van Assche , Nicholas Bellinger , Jenny Derzhavetz , Ira Weiny , Steve Wise , Mark Bloch , Tatyana E Nikolova , Matan Barak , Lijun Ou , "Wei Hu(Xavier)" , Faisal Latif , Mustafa Ismail , Mark Brown , linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org, target-devel@vger.kernel.org From: Sagi Grimberg Message-ID: <5489f4ef-02fb-5207-6261-c08ee805acae@grimberg.me> Date: Mon, 21 Nov 2016 14:33:02 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: <2625189.HB0S3sfnY7@wuerfel> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org >>> diff --git a/drivers/infiniband/ulp/isert/ib_isert.c b/drivers/infiniband/ulp/isert/ib_isert.c >>> index 6dd43f6..de80f56 100644 >>> --- a/drivers/infiniband/ulp/isert/ib_isert.c >>> +++ b/drivers/infiniband/ulp/isert/ib_isert.c >>> @@ -619,7 +619,7 @@ >>> mutex_unlock(&isert_np->mutex); >>> >>> isert_info("np %p: Allow accept_np to continue\n", isert_np); >>> - up(&isert_np->sem); >>> + complete(&isert_np->comp); >>> } >>> >>> static void >>> @@ -2311,7 +2311,7 @@ struct rdma_cm_id * >>> isert_err("Unable to allocate struct isert_np\n"); >>> return -ENOMEM; >>> } >>> - sema_init(&isert_np->sem, 0); >>> + init_completion(&isert_np->comp); >> >> This is still racy, a connect event can complete just before we >> init the completion and *will* get lost... >> >> This code started off with a waitqueue which exposes the same >> problem, see: >> 531b7bf4bd79 Target/iser: Fix iscsit_accept_np and rdma_cm racy flow >> >> So, still NAK from me... > > I don't see what you mean here. The code using a waitqueue had no > counter but the completion does. The problem here is that init_completion sets the counter to zero and between this thread wakes up and until it initializes comp->done we might have another connect event completing it and I fail to see how this is handled correctly.