Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp1198212imm; Fri, 15 Jun 2018 12:52:02 -0700 (PDT) X-Google-Smtp-Source: ADUXVKI5xJFKXatKlHtgr3RBVG2MSi8Y1xqASnRW9Fa+EqNPKI+oDqzuqCR5SiomBA+pt8165s78 X-Received: by 2002:a63:7943:: with SMTP id u64-v6mr2772545pgc.411.1529092322548; Fri, 15 Jun 2018 12:52:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529092322; cv=none; d=google.com; s=arc-20160816; b=bKAOLXI8S1idK56m6DDu4/wrZ4lrkD4hrWwkCR2iZbjCxBYXIk1EMgZ34kZfqvSfKD LlM9h4OaUmqF7MFgkYZsDcHClElMzmBD9QVIV9dDFd2CODUuLLCdkyca0RYbc7GUsJX4 9vyC4GoePA/Ia353h4HF0/nFBQo3FTeuiGsyeLNEa551El4/5BRLSIoUaj9od7l+1WUG Cd8c0IoIHQMGw9rXlzGDTxguChbgpdEfSvkB5lBmDi1NLJR5F0sWJTWkBoX9io58s9l5 eN56Qlg/CtEHeKEC4KUnNzB9XRM9tyvSpEOApe/ZLSBMzdU2MrOyQs303ZwNq/Sx66im uEoQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=6fmmyY8t0e9Rh1Wnkxc3Z3+JuTtxw68OUcSqX6zs+RE=; b=pn1BLSOasU7c/GNxeCrF+9YwRWgOdh04lbmPb/1Hb8E101gLMl8Sg5kQyybXw/zemQ Pri6Fmeb+Ucepxsw/wlLCK9hNeFz1kVOMw8eTAi6CT8pR01iRzCnSW9OLEVJUhgAERjd oHr6K7CNlww0MD1bUXpXeLSAMUufIbchTqhY9oNQLWP9TAewnuSCzcROgh5sK3E6ANY0 0TBO+HzkAGPt/ZlpZDiQvynb8SPdD1cuUdEnHTwPjLmQqS/1WXWjgPq9FzApke+IKlEW 2w6pX8A7QqMfhqUog54XP8ziya24vtV4hWVpygNKWZUreuwZDoPw/98F74DfYV1Wywld DlIA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=DI9YAVj1; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h33-v6si9206264plh.124.2018.06.15.12.51.48; Fri, 15 Jun 2018 12:52:02 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=DI9YAVj1; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S966334AbeFOTvR (ORCPT + 99 others); Fri, 15 Jun 2018 15:51:17 -0400 Received: from mail-lf0-f68.google.com ([209.85.215.68]:39406 "EHLO mail-lf0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S966065AbeFOTvQ (ORCPT ); Fri, 15 Jun 2018 15:51:16 -0400 Received: by mail-lf0-f68.google.com with SMTP id t2-v6so9853504lfd.6 for ; Fri, 15 Jun 2018 12:51:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=6fmmyY8t0e9Rh1Wnkxc3Z3+JuTtxw68OUcSqX6zs+RE=; b=DI9YAVj1TfTAKogvm+Wua2jAX48qdiquscksQq7zlwRUKYqmKHvNuONOYI4nlEqJW4 kDUHhFQZ9kIId7lFTE4DZtbrAKxvSRrJBlz8gwRUKYrq9iuWbqSQ3iKu59Vn/2nMtoU5 52aTFgpj+g1qecsAtwq41go2fcV7Nki2cWkv+TqVboLyk5weFrO/WheLdZd+j909ufWy CBEeb/PGJx52J5+56uC22wVHhk/XgmKj0YTJviHURKn5v3cDLL2p4um4I/MHVERCkaFI sElKxLa/GDtDFfH75oufHkbRgOx9iaGqQnPw8Z+t8qFAd33nOOsHCEtQjNlkCDoCIfaX U7pQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=6fmmyY8t0e9Rh1Wnkxc3Z3+JuTtxw68OUcSqX6zs+RE=; b=Rnpl9ghmlSA3GD3KMJaZv8P+J4MjT5JQmWlyiXz0hnQGKvf8tMV7h8OFCKYcMeeuAD 198i5zWd69YIePIOLjx5nYARfpLvgwzh2v1TyRIBBhlnyzXCZwrTVa7hB8AR9Ovz9Q12 2nlJ1x8nymWuJesz04NKS0+/EWdPVRsMpCilA6iCowJIta5qWAxqYbDULXoc6Lef1MJT ZIFC7pXj7waCdfCk5Kf7U4mxSTe/mGp7psq/f2bE7HE5DHxP70YsMbtFYGZdXj+9Pdh9 XOOLG5vuZah0mbC/v+QwWVlvkvOmBLiRt5yJX1H7jiOy3GJa8lSWGdjvFiure3aEvQCB konw== X-Gm-Message-State: APt69E2vSJMAs0bEcfJsKEswkeXoRq9Ev/cAloq/Jwe+95+ofgFetd5Z 75hn9cSNn7jXZQqjY0Qgr+g= X-Received: by 2002:a19:148d:: with SMTP id 13-v6mr1911929lfu.84.1529092274530; Fri, 15 Jun 2018 12:51:14 -0700 (PDT) Received: from mobilestation ([5.166.218.73]) by smtp.gmail.com with ESMTPSA id g62-v6sm1624563lfk.54.2018.06.15.12.51.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 15 Jun 2018 12:51:13 -0700 (PDT) Date: Fri, 15 Jun 2018 22:51:22 +0300 From: Serge Semin To: Logan Gunthorpe Cc: linux-kernel@vger.kernel.org, linux-ntb@googlegroups.com, Jon Mason , Dave Jiang , Allen Hubbe , Shyam Sundar S K , Shuah Khan Subject: Re: [PATCH 7/8] NTB: perf: Fix race condition when run with ntb_test Message-ID: <20180615195122.GA25387@mobilestation> References: <20180609000819.13883-1-logang@deltatee.com> <20180609000819.13883-9-logang@deltatee.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180609000819.13883-9-logang@deltatee.com> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jun 08, 2018 at 06:08:18PM -0600, Logan Gunthorpe wrote: > When running ntb_test, the script tries to run the ntb_perf test > immediately after probing the modules. Since adding multi-port support, > this fails seeing the new initialization procedure in ntb_perf > can not complete instantly. > > To fix this we add a completion which is waited on when a test is > started. In this way, run can be written any time after the module is > loaded and it will wait for the initialization to complete instead of > sending an error. > Hmm, this behavior is the feature of the driver and isn't a bug or race to be fixed. ntb_perf driver returns -ENOLINK until the link is actually established, when the memory windows are properly initialized so the test can be performed. What do you think of leaving the algorithm as is, but instead to develop the polling scheme in the ntb_test.sh script and break the script execution if the link isn't established after sometime? At least we won't need to wait forever in case if the peer hanged up or crashed while the NTB link negotiation algorithm was in-progress. Regards, -Sergey > Fixes: 5648e56d03fa ("NTB: ntb_perf: Add full multi-port NTB API support") > Signed-off-by: Logan Gunthorpe > --- > drivers/ntb/test/ntb_perf.c | 10 ++++++++-- > 1 file changed, 8 insertions(+), 2 deletions(-) > > diff --git a/drivers/ntb/test/ntb_perf.c b/drivers/ntb/test/ntb_perf.c > index 6285cb8515ac..8e2b7630ecc9 100644 > --- a/drivers/ntb/test/ntb_perf.c > +++ b/drivers/ntb/test/ntb_perf.c > @@ -158,6 +158,8 @@ struct perf_peer { > /* NTB connection setup service */ > struct work_struct service; > unsigned long sts; > + > + struct completion init_comp; > }; > #define to_peer_service(__work) \ > container_of(__work, struct perf_peer, service) > @@ -549,6 +551,7 @@ static int perf_setup_outbuf(struct perf_peer *peer) > > /* Initialization is finally done */ > set_bit(PERF_STS_DONE, &peer->sts); > + complete_all(&peer->init_comp); > > return 0; > } > @@ -639,6 +642,7 @@ static void perf_service_work(struct work_struct *work) > perf_setup_outbuf(peer); > > if (test_and_clear_bit(PERF_CMD_CLEAR, &peer->sts)) { > + init_completion(&peer->init_comp); > clear_bit(PERF_STS_DONE, &peer->sts); > if (test_bit(0, &peer->perf->busy_flag) && > peer == peer->perf->test_peer) { > @@ -1046,8 +1050,9 @@ static int perf_submit_test(struct perf_peer *peer) > struct perf_thread *pthr; > int tidx, ret; > > - if (!test_bit(PERF_STS_DONE, &peer->sts)) > - return -ENOLINK; > + ret = wait_for_completion_interruptible(&peer->init_comp); > + if (ret < 0) > + return ret; > > if (test_and_set_bit_lock(0, &perf->busy_flag)) > return -EBUSY; > @@ -1413,6 +1418,7 @@ static int perf_init_peers(struct perf_ctx *perf) > peer->gidx = pidx; > } > INIT_WORK(&peer->service, perf_service_work); > + init_completion(&peer->init_comp); > } > if (perf->gidx == -1) > perf->gidx = pidx; > -- > 2.11.0 > > -- > You received this message because you are subscribed to the Google Groups "linux-ntb" group. > To unsubscribe from this group and stop receiving emails from it, send an email to linux-ntb+unsubscribe@googlegroups.com. > To post to this group, send email to linux-ntb@googlegroups.com. > To view this discussion on the web visit https://groups.google.com/d/msgid/linux-ntb/20180609000819.13883-9-logang%40deltatee.com. > For more options, visit https://groups.google.com/d/optout.