From nobody Wed Apr 29 00:32:00 2026 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 BB316C433F5 for ; Thu, 26 May 2022 18:55:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1348546AbiEZSzY (ORCPT ); Thu, 26 May 2022 14:55:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56896 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348535AbiEZSzU (ORCPT ); Thu, 26 May 2022 14:55:20 -0400 Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id AC684C9EC9; Thu, 26 May 2022 11:55:18 -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 5659F20B894E; Thu, 26 May 2022 11:55:18 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 5659F20B894E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1653591318; bh=5tqGz/yf6oL6Kr2vtfQ/aaxDFL883Cb6xHPyCGWaG3U=; h=From:To:Subject:Date:From; b=TscjQqLGBTcl6ydS6EVtmiSuEgZ4Yda+18cSwGTMG2fIsP/aCRqUAeuMGH+1utgAE +rsNe7eDUhz1B0YeW32/xtrhWtCf6zMr5Ae7wIyeoQngSxgz2qCeoRaSATWkk0rMx9 JVvEkn7weHE93eWq6QJx+qVrCPN1g3zAPATxIX8U= 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: Adding isolated cpu support for channel interrupts mapping Date: Thu, 26 May 2022 11:55:14 -0700 Message-Id: <1653591314-7077-1-git-send-email-ssengar@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Adding support for vmbus channels to take isolated cpu in consideration while assigning interrupt to different cpus. This also prevents user from setting any isolated cpu to vmbus channel interrupt assignment by sysfs entry. Isolated cpu can be configured by kernel command line parameter 'isolcpus=3Dmanaged_irq,<#cpu>'. Signed-off-by: Saurabh Sengar --- drivers/hv/channel_mgmt.c | 18 ++++++++++++------ drivers/hv/vmbus_drv.c | 6 ++++++ 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/drivers/hv/channel_mgmt.c b/drivers/hv/channel_mgmt.c index 97d8f56..e1fe029 100644 --- a/drivers/hv/channel_mgmt.c +++ b/drivers/hv/channel_mgmt.c @@ -21,6 +21,7 @@ #include #include #include +#include =20 #include "hyperv_vmbus.h" =20 @@ -728,16 +729,20 @@ static void init_vp_index(struct vmbus_channel *chann= el) u32 i, ncpu =3D num_online_cpus(); cpumask_var_t available_mask; struct cpumask *allocated_mask; + const struct cpumask *hk_mask =3D housekeeping_cpumask(HK_TYPE_MANAGED_IR= Q); u32 target_cpu; int numa_node; =20 if (!perf_chn || - !alloc_cpumask_var(&available_mask, GFP_KERNEL)) { + !alloc_cpumask_var(&available_mask, GFP_KERNEL) || + cpumask_empty(hk_mask)) { /* * If the channel is not a performance critical * channel, bind it to VMBUS_CONNECT_CPU. * In case alloc_cpumask_var() fails, bind it to * VMBUS_CONNECT_CPU. + * If all the cpus are isolated, bind it to + * VMBUS_CONNECT_CPU. */ channel->target_cpu =3D VMBUS_CONNECT_CPU; if (perf_chn) @@ -758,17 +763,19 @@ static void init_vp_index(struct vmbus_channel *chann= el) } allocated_mask =3D &hv_context.hv_numa_map[numa_node]; =20 - if (cpumask_equal(allocated_mask, cpumask_of_node(numa_node))) { +retry: + cpumask_xor(available_mask, allocated_mask, cpumask_of_node(numa_node)); + cpumask_and(available_mask, available_mask, hk_mask); + + if (cpumask_empty(available_mask)) { /* * We have cycled through all the CPUs in the node; * reset the allocated map. */ cpumask_clear(allocated_mask); + goto retry; } =20 - cpumask_xor(available_mask, allocated_mask, - cpumask_of_node(numa_node)); - target_cpu =3D cpumask_first(available_mask); cpumask_set_cpu(target_cpu, allocated_mask); =20 @@ -778,7 +785,6 @@ static void init_vp_index(struct vmbus_channel *channel) } =20 channel->target_cpu =3D target_cpu; - free_cpumask_var(available_mask); } =20 diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c index 714d549..23660a8 100644 --- a/drivers/hv/vmbus_drv.c +++ b/drivers/hv/vmbus_drv.c @@ -21,6 +21,7 @@ #include #include #include +#include #include =20 #include @@ -1770,6 +1771,11 @@ static ssize_t target_cpu_store(struct vmbus_channel= *channel, if (target_cpu >=3D nr_cpumask_bits) return -EINVAL; =20 + if (!cpumask_test_cpu(target_cpu, housekeeping_cpumask(HK_TYPE_MANAGED_IR= Q))) { + dev_err(&channel->device_obj->device, + "cpu (%d) is isolated, can't be assigned\n", target_cpu); + return -EINVAL; + } /* No CPUs should come up or down during this. */ cpus_read_lock(); =20 --=20 1.8.3.1