From patchwork Tue Sep 19 07:37:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhu Yanjun X-Patchwork-Id: 13390906 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 07FDCCD5488 for ; Tue, 19 Sep 2023 07:37:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231841AbjISHiB (ORCPT ); Tue, 19 Sep 2023 03:38:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44626 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231903AbjISHhz (ORCPT ); Tue, 19 Sep 2023 03:37:55 -0400 Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8656311F for ; Tue, 19 Sep 2023 00:37:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1695109069; x=1726645069; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=1hFOHOesRL6U2PlMb2ZYvfBkyMbnNF8vkDsAkmHId5U=; b=DyqmNL8Z390F06kzvegu9FYQyOOCYURerAQG/kASs54fRmnwcKF93Z9O qaD/tUO5rNOe7BxWh9bbNDdzx3/9+hKKkNGO8kgpGiEO8qGNYhpknvgEl EU9BeYA4WmDLf2KdeWv0O6mfKZkLgKYmmtVXR1fYR2uOruhgvF3vuKDLG Iui4Dgt5gJuu5dAVHeMcrvHGIYDTZWCOxkrwcbcpnia10o9pKwk6jejyU nTJJanZ4yicSkG95FjJKaF+pUDy2UmSA2sqC7WI5j6rgWgE+HEB9vQGw4 f/CWddZwLKQdqajOKE8JpmYDQwaE2rMJiRyD5y6cLCCAo+V3qEoIvXSNm w==; X-IronPort-AV: E=McAfee;i="6600,9927,10837"; a="383696897" X-IronPort-AV: E=Sophos;i="6.02,158,1688454000"; d="scan'208";a="383696897" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Sep 2023 00:37:47 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10837"; a="869874613" X-IronPort-AV: E=Sophos;i="6.02,158,1688454000"; d="scan'208";a="869874613" Received: from unknown (HELO intel-71.bj.intel.com) ([10.238.154.71]) by orsmga004.jf.intel.com with ESMTP; 19 Sep 2023 00:37:46 -0700 From: Zhu Yanjun To: haris.iqbal@ionos.com, jinpu.wang@ionos.com, jgg@ziepe.ca, leon@kernel.org, linux-rdma@vger.kernel.org Cc: Zhu Yanjun Subject: [PATCH v2 1/1] RDMA/rtrs: Require holding rcu_read_lock explicitly Date: Tue, 19 Sep 2023 15:37:27 +0800 Message-Id: <20230919073727.540207-1-yanjun.zhu@intel.com> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org From: Zhu Yanjun No functional change. The function get_next_path_rr needs to hold rcu_read_lock. As such, if no rcu read lock, warnings will pop out. Acked-by: Jack Wang Signed-off-by: Zhu Yanjun --- V1->V2: Replace WARN_ON_ONCE with RCU_LOCKDEP_WARN --- drivers/infiniband/ulp/rtrs/rtrs-clt.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/infiniband/ulp/rtrs/rtrs-clt.c b/drivers/infiniband/ulp/rtrs/rtrs-clt.c index b6ee801fd0ff..07261523c554 100644 --- a/drivers/infiniband/ulp/rtrs/rtrs-clt.c +++ b/drivers/infiniband/ulp/rtrs/rtrs-clt.c @@ -775,7 +775,7 @@ rtrs_clt_get_next_path_or_null(struct list_head *head, struct rtrs_clt_path *clt * Related to @MP_POLICY_RR * * Locks: - * rcu_read_lock() must be hold. + * rcu_read_lock() must be held. */ static struct rtrs_clt_path *get_next_path_rr(struct path_it *it) { @@ -783,6 +783,11 @@ static struct rtrs_clt_path *get_next_path_rr(struct path_it *it) struct rtrs_clt_path *path; struct rtrs_clt_sess *clt; + /* + * Assert that rcu lock must be held + */ + RCU_LOCKDEP_WARN(!rcu_read_lock_held(), "no rcu read lock held"); + clt = it->clt; /*