Received: by 2002:ac2:464d:0:0:0:0:0 with SMTP id s13csp1997575lfo; Sat, 28 May 2022 13:11:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzfYMylwxIrdwnEsby/AfFASP6UMwPgCvSnXxcgjduBSYVmg1P3Z3NGf9UhzKb3tAgJqE0Y X-Received: by 2002:a17:902:db04:b0:161:9fb0:b85d with SMTP id m4-20020a170902db0400b001619fb0b85dmr48626068plx.143.1653768714838; Sat, 28 May 2022 13:11:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653768714; cv=none; d=google.com; s=arc-20160816; b=Xn6Cqax9EaQISLUovEUtvw9Lx82NAL5Ef2g2O8A2ZmRQy3zzi/Bk83LclNoVhKUe+P K2K3A2PezPFCIauJZqjgt+kFTbzKF6gIe4mYoOZgsBOfSD6QPtYyUjMM6WprUMKAUR/s OMPO1j6L7MoHc2eWLSIHcMt+V+M18vEQXlDuXJEnc3xLr0gyrZnADvYrAFM2OGEafsUJ Y3FiKJhXL9ld30kbHx7hACq0XQZ0MBlWwuJCcsD1MNrczEwlrh0teFiGdaTR/Ov6gg71 JyzagpPy7V/KOBj8+lRsiJHdjrr8v8BkB6V15sil41mv6BGW00xFRBzXlQKFLSI/aGle tTaQ== 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=5tqGz/yf6oL6Kr2vtfQ/aaxDFL883Cb6xHPyCGWaG3U=; b=wCyF1bQ10ZIfkroPDE446FA60pPY0XGgEIGpSvMsiEgRmHj2IOrWhOlwsdXnuPC0MZ I3Wn02eH4LgxXn67WnC3p+tfcfSDxZqABqjbV07qs2nXK0Pw9qwNKoZCBzpIpVr2WBHX 1KelGHq/d3dnPetV456qAEdMZRsUY3HbyvxMZKr4PTJJ80dYCr87DbW9GTOTj1+XUJKe FKrTW7j8sEN2Bq97QZRD9r1JKIgSZG2lxLlyaabj6Z6qugYahvnJXB3+DSgNunaASRgf RrUOcgKU0+KtAOou9rY/wuQmHsxyfkbkDuvzy1y2Y5/JH7MB4RxVWKZfngZljeU8Q0Iq 9jSQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.microsoft.com header.s=default header.b=TscjQqLG; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id u2-20020a63a902000000b003db0f2baa25si10746611pge.90.2022.05.28.13.11.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 28 May 2022 13:11:54 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.microsoft.com header.s=default header.b=TscjQqLG; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id F140613F42C; Sat, 28 May 2022 12:25:27 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1348531AbiEZSzX (ORCPT + 99 others); Thu, 26 May 2022 14:55:23 -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 X-Spam-Status: No, score=-9.5 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE, USER_IN_DEF_DKIM_WL autolearn=no 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 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=managed_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 #include "hyperv_vmbus.h" @@ -728,16 +729,20 @@ static void init_vp_index(struct vmbus_channel *channel) u32 i, ncpu = num_online_cpus(); cpumask_var_t available_mask; struct cpumask *allocated_mask; + const struct cpumask *hk_mask = housekeeping_cpumask(HK_TYPE_MANAGED_IRQ); u32 target_cpu; int numa_node; 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 = VMBUS_CONNECT_CPU; if (perf_chn) @@ -758,17 +763,19 @@ static void init_vp_index(struct vmbus_channel *channel) } allocated_mask = &hv_context.hv_numa_map[numa_node]; - 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; } - cpumask_xor(available_mask, allocated_mask, - cpumask_of_node(numa_node)); - target_cpu = cpumask_first(available_mask); cpumask_set_cpu(target_cpu, allocated_mask); @@ -778,7 +785,6 @@ static void init_vp_index(struct vmbus_channel *channel) } channel->target_cpu = target_cpu; - free_cpumask_var(available_mask); } 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 #include @@ -1770,6 +1771,11 @@ static ssize_t target_cpu_store(struct vmbus_channel *channel, if (target_cpu >= nr_cpumask_bits) return -EINVAL; + if (!cpumask_test_cpu(target_cpu, housekeeping_cpumask(HK_TYPE_MANAGED_IRQ))) { + 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(); -- 1.8.3.1