From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.1 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0FC94C282CB for ; Wed, 6 Feb 2019 00:35:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id BCA7C2183E for ; Wed, 6 Feb 2019 00:35:41 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="m3EAiA7b" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727397AbfBFAfk (ORCPT ); Tue, 5 Feb 2019 19:35:40 -0500 Received: from mail-pf1-f196.google.com ([209.85.210.196]:40936 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727165AbfBFAfk (ORCPT ); Tue, 5 Feb 2019 19:35:40 -0500 Received: by mail-pf1-f196.google.com with SMTP id i12so2295625pfo.7 for ; Tue, 05 Feb 2019 16:35:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=LFX77glR3/aZNFVih2EkiY1MNYfllUdcInb3re1ExOM=; b=m3EAiA7bkHaTcIsG3kowS11VJ9hpJ7Vq7fwCBygPSdeF1oglAk8TEpoOLY7jLMrNDa 4w9wz7im/szguwueitZJAW4WMZnOhERdHgiwA3vRWaAQYs6sppHBwLGniMFr70m6Vwbw jeo/9vd+nok72gV5LKusQ3lGzg/PJ0qxWB2O8rHxB9N3N3CWq9RGG4Gkj6A6yoNmCSaz bAKTcdpxFPPnZpCEKOpIBLyBtIIoa5PKpxP+DmorbLq2mVAxtHxjOGOGEYrS6ViebYXe TG6ZciaKec948+ZRwtjYhS64XHVB/efDf5yKw5NnlW53DC5C5MAkXZaSk84FB5gCRjri eAaQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=LFX77glR3/aZNFVih2EkiY1MNYfllUdcInb3re1ExOM=; b=JvoCkNcVhhPWbjjsAqrGQ2NNXW9iacKCdkrsbwMu4doxvLwAKePNsufQd0zSm4c0QD YmRG53RX/F103P+YuKh1IpX1M8ZlyYevC1iMwnAq/WZLsGGmgiMaBpNQfhlBoJ+hHxcR KK4TKeVEuGyPPdMyH3a2Ou7Au1r+HCVHl8kn6d5FKkdb4IRZ0BrXmILWCY732OlafAxk emHukL9NmrWMUdR69bvN/CsxoZ5O6925ovA1wJfgJo2y7farW21nBlMS43sBlJx+41VL WfStvkWjXj+G/DH/C0uJcDFHd3iOaDpGKcI2/LlMLXADM6bUwZ8aVN7MXV0Sk/ELh4j1 Hyxw== X-Gm-Message-State: AHQUAuYhLNDHpTGHAOCRd03vrNDzTjpIeG/FcQvfIBxZhPcTf2RRW//Q XrtTAQNV29LnMreY5G1/3f/3uwW9 X-Google-Smtp-Source: AHgI3IYQUdIaH1DeXkRXU8cOe7kFKVEDDEaGtOqrzh0ZZbf5u1nBIHou9y7QDJo3ogeV7sne7Uy8xg== X-Received: by 2002:a63:c503:: with SMTP id f3mr6902922pgd.431.1549413339086; Tue, 05 Feb 2019 16:35:39 -0800 (PST) Received: from tw-172-25-17-123.office.twttr.net ([8.25.197.27]) by smtp.gmail.com with ESMTPSA id c23sm5053640pgh.73.2019.02.05.16.35.37 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 05 Feb 2019 16:35:37 -0800 (PST) From: Cong Wang To: netdev@vger.kernel.org Cc: Cong Wang , Saeed Mahameed , Tariq Toukan Subject: [Patch net-next] mlx5: use RCU lock in mlx5_eq_cq_get() Date: Tue, 5 Feb 2019 16:35:25 -0800 Message-Id: <20190206003525.5041-1-xiyou.wangcong@gmail.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org mlx5_eq_cq_get() is called in IRQ handler, the spinlock inside gets a lot of contentions when we test some heavy workload with 60 RX queues and 80 CPU's, and it is clearly shown in the flame graph. In fact, radix_tree_lookup() is perfectly fine with RCU read lock, we don't have to take a spinlock on this hot path. It is pretty much similar to commit 291c566a2891 ("net/mlx4_core: Fix racy CQ (Completion Queue) free"). Slow paths are still serialized with the spinlock, and with synchronize_irq() it should be safe to just move the fast path to RCU read lock. This patch itself reduces the latency by about 50% with our workload. Cc: Saeed Mahameed Cc: Tariq Toukan Signed-off-by: Cong Wang --- drivers/net/ethernet/mellanox/mlx5/core/eq.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/eq.c b/drivers/net/ethernet/mellanox/mlx5/core/eq.c index ee04aab65a9f..7092457705a2 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/eq.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/eq.c @@ -114,11 +114,11 @@ static struct mlx5_core_cq *mlx5_eq_cq_get(struct mlx5_eq *eq, u32 cqn) struct mlx5_cq_table *table = &eq->cq_table; struct mlx5_core_cq *cq = NULL; - spin_lock(&table->lock); + rcu_read_lock(); cq = radix_tree_lookup(&table->tree, cqn); if (likely(cq)) mlx5_cq_hold(cq); - spin_unlock(&table->lock); + rcu_read_unlock(); return cq; } @@ -371,9 +371,9 @@ int mlx5_eq_add_cq(struct mlx5_eq *eq, struct mlx5_core_cq *cq) struct mlx5_cq_table *table = &eq->cq_table; int err; - spin_lock_irq(&table->lock); + spin_lock(&table->lock); err = radix_tree_insert(&table->tree, cq->cqn, cq); - spin_unlock_irq(&table->lock); + spin_unlock(&table->lock); return err; } @@ -383,9 +383,9 @@ int mlx5_eq_del_cq(struct mlx5_eq *eq, struct mlx5_core_cq *cq) struct mlx5_cq_table *table = &eq->cq_table; struct mlx5_core_cq *tmp; - spin_lock_irq(&table->lock); + spin_lock(&table->lock); tmp = radix_tree_delete(&table->tree, cq->cqn); - spin_unlock_irq(&table->lock); + spin_unlock(&table->lock); if (!tmp) { mlx5_core_warn(eq->dev, "cq 0x%x not found in eq 0x%x tree\n", eq->eqn, cq->cqn); -- 2.20.1