Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp2272604pxp; Fri, 18 Mar 2022 07:10:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJznshUJ/dEi6XzOE6AnGGxAMmnVGcfbtx/XlGWPQRC/HgmWtE5mrMdo7Vxzga042K69fYeE X-Received: by 2002:aa7:cc96:0:b0:410:b9ac:241 with SMTP id p22-20020aa7cc96000000b00410b9ac0241mr9736810edt.246.1647612630625; Fri, 18 Mar 2022 07:10:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647612630; cv=none; d=google.com; s=arc-20160816; b=eugbUHul2bG+oFWmtFTz0DVg2Il6QtKyg/JXi/ivKP/lQb3eNtveom/oWG1FL7WjQC RQewh/IlPk4IepVzESHfnPIGuw08rbTyXTXpjVTolo/fQ+5l3ASsrB1e+nxCTBEyav8H G6cEHrTvJJ1/Ncd//lWJjFZkUR7Nv4NMV1DjqYQkfsJx7rSXYTyEp5yY9lJhblG6jMli GtlmBpEiLXq8oPx28C79dpecK3OF4amPSf27YOC9o+nCJ23gE/AUNXvByKhsP8u3+I0M ufuC/UUp56N492kGGxf+iPFSmCD0GZXgAfiw8HJPLPsb/W0VlxM/olzGsdeNYiqgkQtW KK0A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=WX58IbSF15Pg5RBjyXq5yxaD+Drce4wLDHMa3F5H9G4=; b=ivRS9Ot5hXgT3CaEdQ+vEpMMl8b4NG0PAyEO3xdY1ku/VYeeR3cjkt+XOzVQMId3Ft TNoEdlwfySzcK8PqRs0FBRN7mpBnLtYjb9Tjsc2wDRRaO92yWNVSI/9VJy6XP/rVCXCn 4DpuNr+2Wq9xaEGATA01SM+HByy4mo4w3l2YyhTbGNz6udUQH9E4OsLpFIsex/UoHh49 htgluqczCD0UcY8wvmjYbVd/ybgu0VrP/xHkkoLuXRaufIJm+kw+k9fm13QWrLcjPeZj TSbcVbBxB4R6hoWvuwYcrh7D/bfdU1oYyANUuQ3WQ/5o0Ic138CSoHBK6/zFwZq37QzV t98A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=C15T3OZd; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g22-20020a17090670d600b006df76385ea3si1243734ejk.835.2022.03.18.07.10.04; Fri, 18 Mar 2022 07:10:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=C15T3OZd; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233364AbiCRIIN (ORCPT + 99 others); Fri, 18 Mar 2022 04:08:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52678 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233540AbiCRIID (ORCPT ); Fri, 18 Mar 2022 04:08:03 -0400 Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AB907234573; Fri, 18 Mar 2022 01:06:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1647590805; x=1679126805; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=MDKfpbmqsYBc9QIWNSmIFA0nJUUciIBV2RazBxDZDXk=; b=C15T3OZd5fOvNc2Og9VzbjO5UKbIro+Tc7ySpgVwA1ZVITjpmaSmFf0W bc2OzvCQewAMXz43eIq7anLCshJg4KxtWknsIfUtc0ymZrw3TojKVJZbs PMmw5LII1RolMdbsJzg/1onyc0OxAqq5JUc08wdh5fqS2bh/WPG4391Pm Mr6t8mlGfQX6s1G+NDqgqZq0A57XiT2Q24Tbv1M4ArAaH0v8KqMu787Cu ELz6MiosDFeHHQxbij1iYtdEZaj4tUNUfl6gB/LHaHPokTdjJ8UTgGH26 Pnx7sCamyHJHGy+VNpJCP4n5tBc7e9xfHHVlcF425mrbXGMsQcv9HL1GD A==; X-IronPort-AV: E=McAfee;i="6200,9189,10289"; a="256817481" X-IronPort-AV: E=Sophos;i="5.90,191,1643702400"; d="scan'208";a="256817481" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Mar 2022 01:06:44 -0700 X-IronPort-AV: E=Sophos;i="5.90,191,1643702400"; d="scan'208";a="541734794" Received: from zq-optiplex-7090.bj.intel.com ([10.238.156.125]) by orsmga007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Mar 2022 01:06:42 -0700 From: Zqiang To: paulmck@kernel.org, frederic@kernel.org Cc: rcu@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 2/2] rcu: Invert the locking dependency order between rcu_state.barrier_mutex and hotplug lock Date: Fri, 18 Mar 2022 16:07:19 +0800 Message-Id: <20220318080719.1501471-3-qiang1.zhang@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220318080719.1501471-1-qiang1.zhang@intel.com> References: <20220318080719.1501471-1-qiang1.zhang@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When call rcutree_prepare_cpu(), the cpus write lock has been held, just lock the barrier_mutex before calling rcu_nocb_rdp_deoffload() from failure path. therefore, invert the locking dependency order. Signed-off-by: Zqiang --- kernel/rcu/tree_nocb.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/kernel/rcu/tree_nocb.h b/kernel/rcu/tree_nocb.h index e8265e4ec5ee..fe0063a23fbb 100644 --- a/kernel/rcu/tree_nocb.h +++ b/kernel/rcu/tree_nocb.h @@ -1072,8 +1072,8 @@ int rcu_nocb_cpu_deoffload(int cpu) struct rcu_data *rdp = per_cpu_ptr(&rcu_data, cpu); int ret = 0; - mutex_lock(&rcu_state.barrier_mutex); cpus_read_lock(); + mutex_lock(&rcu_state.barrier_mutex); if (rcu_rdp_is_offloaded(rdp)) { if (cpu_online(cpu)) { ret = work_on_cpu(cpu, rcu_nocb_rdp_deoffload, rdp); @@ -1084,8 +1084,8 @@ int rcu_nocb_cpu_deoffload(int cpu) ret = -EINVAL; } } - cpus_read_unlock(); mutex_unlock(&rcu_state.barrier_mutex); + cpus_read_unlock(); return ret; } @@ -1167,8 +1167,8 @@ int rcu_nocb_cpu_offload(int cpu) struct rcu_data *rdp = per_cpu_ptr(&rcu_data, cpu); int ret = 0; - mutex_lock(&rcu_state.barrier_mutex); cpus_read_lock(); + mutex_lock(&rcu_state.barrier_mutex); if (!rcu_rdp_is_offloaded(rdp)) { if (cpu_online(cpu)) { ret = work_on_cpu(cpu, rcu_nocb_rdp_offload, rdp); @@ -1179,8 +1179,8 @@ int rcu_nocb_cpu_offload(int cpu) ret = -EINVAL; } } - cpus_read_unlock(); mutex_unlock(&rcu_state.barrier_mutex); + cpus_read_unlock(); return ret; } -- 2.25.1