Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp1092862ybh; Tue, 10 Mar 2020 14:32:51 -0700 (PDT) X-Google-Smtp-Source: ADFU+vuIbMKTFq9OoBk/Hr9ZVdOGNi4ctM4W+zZl/Ene8N73BqGSGK7ViQFIThBKhqVNpOEjyijo X-Received: by 2002:aca:3287:: with SMTP id y129mr2777573oiy.1.1583875971057; Tue, 10 Mar 2020 14:32:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1583875971; cv=none; d=google.com; s=arc-20160816; b=PuyPzV6NzWoXqXTUWPJi3TmCPJh7XdlhRp2Zd9R/5wlF/In2v5JEKqq0yjD1Dcfx94 79OXjyXkm5crDy55FKxxqo0GWdkWQN2EZht43JKOjkevWgA+KU8AbFp/8wy1xqBMl7DZ KHpyjvF2JIu4npQrchzZLH+LbNUtxDhN9++SkD9gE25YDUpA260Mx6LldU+ns7kDQCir nWvz7wQkmK4TMFgqXdEz2iPIbtG+x/JxbSTI0p0sVyxUfd17Ql8nRBPDeW0rCet36deH V5uSPuWBBIu6UFQNC7QYtjeoJUXAYs115io9XPdkHxhTaY111GTG4UIXd5dbJ8Dg4VrD QUYg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:subject:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to; bh=sbmScAS5oDiHwfYtKwdT+LgtGu9qi5J/RARX9y2ASvk=; b=siODyI6sliDk3Bci1H0lMs2R08ESnm/0YdJ8cCiaN4Il0M11fJZOUkMNlcEV87E/5C o6Uv28SolP5KMI1wENHkStLKwwICQrGvXgKnsF82DHciZmdmG3df2bGseZ0t+h7a4GTE pceI+HYJ1gDsHbzbRDyZOAu/g9IiK//6WYRBTUxOy7g1HkmtTbVro3VL6NoBmkMS0q4d 6764uHqs3d194cSKOr2xRAnXtqLUTlm2XWXQunnaQPtCKx6R523bQjvrxYqdTfVyMlJr XKwWNISxYW1rJ+W2/bapPYrmKnIfl5uIkM+7E07jN8qUpyO049S0EwtwbF8887bivoo+ IfWg== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s2si6360977otp.266.2020.03.10.14.32.16; Tue, 10 Mar 2020 14:32:51 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727662AbgCJVbN (ORCPT + 99 others); Tue, 10 Mar 2020 17:31:13 -0400 Received: from ale.deltatee.com ([207.54.116.67]:42244 "EHLO ale.deltatee.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726265AbgCJVbN (ORCPT ); Tue, 10 Mar 2020 17:31:13 -0400 Received: from guinness.priv.deltatee.com ([172.16.1.162]) by ale.deltatee.com with esmtp (Exim 4.92) (envelope-from ) id 1jBmT1-0001Zy-DR; Tue, 10 Mar 2020 15:31:12 -0600 To: Sanjay R Mehta , jdmason@kudzu.us, dave.jiang@intel.com, allenbh@gmail.com, arindam.nath@amd.com, Shyam-sundar.S-k@amd.com Cc: linux-ntb@googlegroups.com, linux-kernel@vger.kernel.org References: <1583873694-19151-1-git-send-email-sanju.mehta@amd.com> <1583873694-19151-3-git-send-email-sanju.mehta@amd.com> From: Logan Gunthorpe Message-ID: <3c350277-8fe6-04b2-673e-7d4c8fb6ce24@deltatee.com> Date: Tue, 10 Mar 2020 15:31:10 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.9.0 MIME-Version: 1.0 In-Reply-To: <1583873694-19151-3-git-send-email-sanju.mehta@amd.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-CA Content-Transfer-Encoding: 7bit X-SA-Exim-Connect-IP: 172.16.1.162 X-SA-Exim-Rcpt-To: linux-kernel@vger.kernel.org, linux-ntb@googlegroups.com, Shyam-sundar.S-k@amd.com, arindam.nath@amd.com, allenbh@gmail.com, dave.jiang@intel.com, jdmason@kudzu.us, sanju.mehta@amd.com X-SA-Exim-Mail-From: logang@deltatee.com X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on ale.deltatee.com X-Spam-Level: X-Spam-Status: No, score=-8.9 required=5.0 tests=ALL_TRUSTED,BAYES_00, GREYLIST_ISWHITE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Subject: Re: [PATCH v2 2/5] ntb_perf: send command in response to EAGAIN X-SA-Exim-Version: 4.2.1 (built Wed, 08 May 2019 21:11:16 +0000) X-SA-Exim-Scanned: Yes (on ale.deltatee.com) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2020-03-10 2:54 p.m., Sanjay R Mehta wrote: > From: Arindam Nath > > perf_spad_cmd_send() and perf_msg_cmd_send() return > -EAGAIN after trying to send commands for a maximum > of MSG_TRIES re-tries. But currently there is no > handling for this error. These functions are invoked > from perf_service_work() through function pointers, > so rather than simply call these functions is not > enough. We need to make sure to invoke them again in > case of -EAGAIN. Since peer status bits were cleared > before calling these functions, we set the same status > bits before queueing the work again for later invocation. > This way we simply won't go ahead and initialize the > XLAT registers wrongfully in case sending the very first > command itself fails. So what happens if there's an actual non-recoverable error that causes perf_msg_cmd_send() to fail? Are you proposing it just requeues high priority work forever? I never really reviewed this stuff properly but it looks like it has a bunch of problems. Using the high priority work queue for some low priority setup work seems wrong, at the very least. The spad and msg send loops also look like they have a bunch of inter-host race condition problems as well. Yikes. Logan > Signed-off-by: Arindam Nath > Signed-off-by: Sanjay R Mehta > --- > drivers/ntb/test/ntb_perf.c | 18 ++++++++++++++---- > 1 file changed, 14 insertions(+), 4 deletions(-) > > diff --git a/drivers/ntb/test/ntb_perf.c b/drivers/ntb/test/ntb_perf.c > index 6d16628..9068e42 100644 > --- a/drivers/ntb/test/ntb_perf.c > +++ b/drivers/ntb/test/ntb_perf.c > @@ -625,14 +625,24 @@ static void perf_service_work(struct work_struct *work) > { > struct perf_peer *peer = to_peer_service(work); > > - if (test_and_clear_bit(PERF_CMD_SSIZE, &peer->sts)) > - perf_cmd_send(peer, PERF_CMD_SSIZE, peer->outbuf_size); > + if (test_and_clear_bit(PERF_CMD_SSIZE, &peer->sts)) { > + if (perf_cmd_send(peer, PERF_CMD_SSIZE, peer->outbuf_size) > + == -EAGAIN) { > + set_bit(PERF_CMD_SSIZE, &peer->sts); > + (void)queue_work(system_highpri_wq, &peer->service); > + } > + } > > if (test_and_clear_bit(PERF_CMD_RSIZE, &peer->sts)) > perf_setup_inbuf(peer); > > - if (test_and_clear_bit(PERF_CMD_SXLAT, &peer->sts)) > - perf_cmd_send(peer, PERF_CMD_SXLAT, peer->inbuf_xlat); > + if (test_and_clear_bit(PERF_CMD_SXLAT, &peer->sts)) { > + if (perf_cmd_send(peer, PERF_CMD_SXLAT, peer->inbuf_xlat) > + == -EAGAIN) { > + set_bit(PERF_CMD_SXLAT, &peer->sts); > + (void)queue_work(system_highpri_wq, &peer->service); > + } > + } > > if (test_and_clear_bit(PERF_CMD_RXLAT, &peer->sts)) > perf_setup_outbuf(peer); >