From patchwork Thu Feb 12 01:43:33 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Ledford X-Patchwork-Id: 5815071 Return-Path: X-Original-To: patchwork-linux-rdma@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 1C86D9F37F for ; Thu, 12 Feb 2015 01:44:23 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 38B17200E0 for ; Thu, 12 Feb 2015 01:44:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 36E33201ED for ; Thu, 12 Feb 2015 01:44:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751417AbbBLBoP (ORCPT ); Wed, 11 Feb 2015 20:44:15 -0500 Received: from mx1.redhat.com ([209.132.183.28]:54227 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753978AbbBLBoN (ORCPT ); Wed, 11 Feb 2015 20:44:13 -0500 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id t1C1i8hO031859 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 11 Feb 2015 20:44:08 -0500 Received: from linux-ws.xsintricity.com ([10.10.116.22]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t1C1i1El029536; Wed, 11 Feb 2015 20:44:07 -0500 From: Doug Ledford To: linux-rdma@vger.kernel.org, roland@kernel.org Cc: Or Gerlitz , Erez Shitrit , Doug Ledford Subject: [PATCH 10/22] IB/ipoib: Add a helper to restart the multicast task Date: Wed, 11 Feb 2015 20:43:33 -0500 Message-Id: <930178ab8a03be9a3934c68214a8e54aaf2df445.1423703861.git.dledford@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Add a simple helper to do the right thing when restarting the multicast thread. Call that helper from all the places that need to restart the thread. Add two places that didn't restart the thread, but should have. Signed-off-by: Doug Ledford --- drivers/infiniband/ulp/ipoib/ipoib_multicast.c | 46 ++++++++++++++++---------- 1 file changed, 29 insertions(+), 17 deletions(-) diff --git a/drivers/infiniband/ulp/ipoib/ipoib_multicast.c b/drivers/infiniband/ulp/ipoib/ipoib_multicast.c index 91b8fe118ec..cb1e495bd74 100644 --- a/drivers/infiniband/ulp/ipoib/ipoib_multicast.c +++ b/drivers/infiniband/ulp/ipoib/ipoib_multicast.c @@ -66,6 +66,13 @@ struct ipoib_mcast_iter { unsigned int send_only; }; +static void __ipoib_mcast_continue_join_thread(struct ipoib_dev_priv *priv, + int delay) +{ + if (test_bit(IPOIB_MCAST_RUN, &priv->flags)) + queue_delayed_work(priv->wq, &priv->mcast_task, delay); +} + static void ipoib_mcast_free(struct ipoib_mcast *mcast) { struct net_device *dev = mcast->dev; @@ -270,6 +277,7 @@ ipoib_mcast_sendonly_join_complete(int status, { struct ipoib_mcast *mcast = multicast->context; struct net_device *dev = mcast->dev; + struct ipoib_dev_priv *priv = netdev_priv(dev); /* * We have to take the mutex to force mcast_sendonly_join to @@ -309,6 +317,7 @@ out: complete(&mcast->done); if (status == -ENETRESET) status = 0; + __ipoib_mcast_continue_join_thread(priv, 0); mutex_unlock(&mcast_mutex); return status; } @@ -360,6 +369,7 @@ static int ipoib_mcast_sendonly_join(struct ipoib_mcast *mcast) complete(&mcast->done); ipoib_warn(priv, "ib_sa_join_multicast for sendonly join " "failed (ret = %d)\n", ret); + __ipoib_mcast_continue_join_thread(priv, 0); } else { ipoib_dbg_mcast(priv, "no multicast record for %pI6, starting " "sendonly join\n", mcast->mcmember.mgid.raw); @@ -431,8 +441,7 @@ static int ipoib_mcast_join_complete(int status, if (!status) { mcast->backoff = 1; - if (test_bit(IPOIB_MCAST_RUN, &priv->flags)) - queue_delayed_work(priv->wq, &priv->mcast_task, 0); + __ipoib_mcast_continue_join_thread(priv, 0); /* * Defer carrier on work to priv->wq to avoid a @@ -454,6 +463,13 @@ static int ipoib_mcast_join_complete(int status, mcast->backoff *= 2; if (mcast->backoff > IPOIB_MAX_BACKOFF_SECONDS) mcast->backoff = IPOIB_MAX_BACKOFF_SECONDS; + /* + * XXX - This is wrong. *Our* join failed, but because the + * join thread does the joins in a serial fashion, if there + * are any joins behind ours waiting to complete, they should + * not be subjected to our backoff delay. + */ + __ipoib_mcast_continue_join_thread(priv, mcast->backoff * HZ); } out: spin_lock_irq(&priv->lock); @@ -463,9 +479,6 @@ out: complete(&mcast->done); if (status == -ENETRESET) status = 0; - if (status && test_bit(IPOIB_MCAST_RUN, &priv->flags)) - queue_delayed_work(priv->wq, &priv->mcast_task, - mcast->backoff * HZ); spin_unlock_irq(&priv->lock); mutex_unlock(&mcast_mutex); @@ -532,10 +545,13 @@ static void ipoib_mcast_join(struct net_device *dev, struct ipoib_mcast *mcast, mcast->backoff *= 2; if (mcast->backoff > IPOIB_MAX_BACKOFF_SECONDS) mcast->backoff = IPOIB_MAX_BACKOFF_SECONDS; - - if (test_bit(IPOIB_MCAST_RUN, &priv->flags)) - queue_delayed_work(priv->wq, &priv->mcast_task, - mcast->backoff * HZ); + /* + * XXX - This is wrong. *Our* join failed, but because the + * join thread does the joins in a serial fashion, if there + * are any joins behind ours waiting to complete, they should + * not be subjected to our backoff delay. + */ + __ipoib_mcast_continue_join_thread(priv, mcast->backoff * HZ); } mutex_unlock(&mcast_mutex); } @@ -573,9 +589,7 @@ void ipoib_mcast_join_task(struct work_struct *work) if (!broadcast) { ipoib_warn(priv, "failed to allocate broadcast group\n"); mutex_lock(&mcast_mutex); - if (test_bit(IPOIB_MCAST_RUN, &priv->flags)) - queue_delayed_work(priv->wq, &priv->mcast_task, - HZ); + __ipoib_mcast_continue_join_thread(priv, HZ); mutex_unlock(&mcast_mutex); return; } @@ -723,8 +737,7 @@ void ipoib_mcast_send(struct net_device *dev, u8 *daddr, struct sk_buff *skb) memcpy(mcast->mcmember.mgid.raw, mgid, sizeof (union ib_gid)); __ipoib_mcast_add(dev, mcast); list_add_tail(&mcast->list, &priv->multicast_list); - if (test_bit(IPOIB_MCAST_RUN, &priv->flags)) - queue_delayed_work(priv->wq, &priv->mcast_task, 0); + __ipoib_mcast_continue_join_thread(priv, 0); } if (!mcast->ah) { @@ -947,10 +960,9 @@ void ipoib_mcast_restart_task(struct work_struct *work) ipoib_mcast_free(mcast); } /* - * Restart our join task if needed + * Restart our join task thread if needed */ - if (test_bit(IPOIB_MCAST_RUN, &priv->flags)) - queue_delayed_work(priv->wq, &priv->mcast_task, 0); + __ipoib_mcast_continue_join_thread(priv, 0); rtnl_unlock(); }