Received: by 2002:a5d:925a:0:0:0:0:0 with SMTP id e26csp91660iol; Wed, 8 Jun 2022 22:56:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyxvfska+83VFb2UDGt+8tdexqm2P8Py1CUCD4AsBAzq8DHS94DFAp/6n3GeduM8lqbd2v6 X-Received: by 2002:a63:8a4c:0:b0:3fc:5c99:a195 with SMTP id y73-20020a638a4c000000b003fc5c99a195mr33055252pgd.29.1654754176999; Wed, 08 Jun 2022 22:56:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654754176; cv=none; d=google.com; s=arc-20160816; b=fobJS7eG4CVMCqjqx+6YZACDSKQO8XKr/56Kgc05tpDp0X+dc9x/ENxEovfVl3E/ZQ DCVPkad5OjLW5BdPHxtvhd1HGjJFRDtJ3r91vdX3TkLR+nsDY7VPw4EkTEoTHNmNAEZO YBV60za145ga8PA1Z6sv41v4e/xa/Icw2B4ghezP8U/XGUamY+oU8XmmGZUbybOA3RJ7 WaqeI3K5x70ptdPtrM746pmBelcwCJtZu0zs4AbFdvDgMqW/cZd7kLmN4PtUeFks4gUU d/AJhjnJQCUPdHxgO3uv5svqud6loa+/d+MgwFJcWPLMr54jiFPp4XsI9lEAZNHt1GoE bvyg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:to:from:dkim-signature :dkim-filter; bh=DF6REoJcbQxjyeIVLO2TSXKP3/EtC32cmh3TcxvbOV4=; b=iK0DEcjRgkX31jTQ8rl5ksz5jR4gABkl0FVbviGhyLX1xIgoiLGJFVpLoFlB6mpdPZ vBq+17+KrS61MwygPV6ZDCU5aCb2p6f0abCFLtHwEoIfBCcoagQkpHeOg/kfecBR/K4X PtiPt2GgDAcXe7kPBHqWL+Dlgy3aNY1BpBCje7x64cGrVSjVzdWL8d0YPgGbjk2egAuy Q2Wxm3lD/1jTF5km0S37p4T8VBG0sDyDRMNZEL/UWHjrkg6FLfqGZ2X1DX9ob9ZeU+zf ShcI/wa+7hWnBGDqJGjvmiViRwOhKrmvWCLtkuLEuwI3vjiexuf3+LUVbyHW15h057eE k1Ng== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.microsoft.com header.s=default header.b="W9/bIBeY"; 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=linux.microsoft.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p14-20020a170902a40e00b00158e566366dsi28756189plq.366.2022.06.08.22.56.03; Wed, 08 Jun 2022 22:56:16 -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=@linux.microsoft.com header.s=default header.b="W9/bIBeY"; 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=linux.microsoft.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237616AbiFIF1e (ORCPT + 99 others); Thu, 9 Jun 2022 01:27:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35174 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234229AbiFIF1c (ORCPT ); Thu, 9 Jun 2022 01:27:32 -0400 Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id E703551E7C; Wed, 8 Jun 2022 22:27:31 -0700 (PDT) Received: from linuxonhyperv3.guj3yctzbm1etfxqx2vob5hsef.xx.internal.cloudapp.net (linux.microsoft.com [13.77.154.182]) by linux.microsoft.com (Postfix) with ESMTPSA id 9104820BE676; Wed, 8 Jun 2022 22:27:31 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 9104820BE676 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1654752451; bh=DF6REoJcbQxjyeIVLO2TSXKP3/EtC32cmh3TcxvbOV4=; h=From:To:Subject:Date:From; b=W9/bIBeYXrStNF0X3M0ozw7EK2zyTUcMy8XR/Ity05/aXZSoo09p6sq8M3NYmuaEf S5PsqyBnxs3Jn9BXheWm5BIborQqD0z3DfDY9ALR0IZ/E8N947jpUFSV5rhQSJDfKb v4QXu02ZgV1ItsdQmYU1dT3RgHTjhVfIrk5DHARQ= From: Saurabh Sengar To: kys@microsoft.com, haiyangz@microsoft.com, sthemmin@microsoft.com, wei.liu@kernel.org, decui@microsoft.com, linux-hyperv@vger.kernel.org, linux-kernel@vger.kernel.org, ssengar@microsoft.com, mikelley@microsoft.com Subject: [PATCH] Drivers: hv: vmbus: Add cpu read lock Date: Wed, 8 Jun 2022 22:27:26 -0700 Message-Id: <1654752446-20113-1-git-send-email-ssengar@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 X-Spam-Status: No, score=-19.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_MED, SPF_HELO_PASS,SPF_PASS,T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL, USER_IN_DEF_SPF_WL 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 Add cpus_read_lock to prevent CPUs from going offline between query and actual use of cpumask. cpumask_of_node is first queried, and based on it used later, in case any CPU goes offline between these two events, it can potentially cause an infinite loop of retries. Signed-off-by: Saurabh Sengar --- drivers/hv/channel_mgmt.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/hv/channel_mgmt.c b/drivers/hv/channel_mgmt.c index 85a2142..6a88b7e 100644 --- a/drivers/hv/channel_mgmt.c +++ b/drivers/hv/channel_mgmt.c @@ -749,6 +749,9 @@ static void init_vp_index(struct vmbus_channel *channel) return; } + /* No CPUs should come up or down during this. */ + cpus_read_lock(); + for (i = 1; i <= ncpu + 1; i++) { while (true) { numa_node = next_numa_node_id++; @@ -781,6 +784,7 @@ static void init_vp_index(struct vmbus_channel *channel) break; } + cpus_read_unlock(); channel->target_cpu = target_cpu; free_cpumask_var(available_mask); -- 1.8.3.1