From nobody Wed Sep 10 02:39:11 2025 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 E4D6EE728D5 for ; Fri, 29 Sep 2023 18:03:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233871AbjI2SDE (ORCPT ); Fri, 29 Sep 2023 14:03:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52662 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233796AbjI2SCI (ORCPT ); Fri, 29 Sep 2023 14:02:08 -0400 Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 3F42ACE2; Fri, 29 Sep 2023 11:02:05 -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 4C3E420B74D1; Fri, 29 Sep 2023 11:01:57 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 4C3E420B74D1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1696010517; bh=giaPGAUBP/shqQFPfTt6khDXOM7sp4gdgMa7HKBM+B4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=autZ+nlbio19vV1N44KFuWajdjOGS9q3VtnUPg4ASCsa5i25pCp+uEAnoMopJ1SE5 r2jVHHMGq+bYNvYehiylq7U5ddAroxfI2WdcpqKfoj/8Mx72zzEv+deMGjU5eVV2RS fO11rlhBrd1OjDxQGe3NUDX/TAJaRCyfSamKsjuY= From: Nuno Das Neves To: linux-hyperv@vger.kernel.org, linux-kernel@vger.kernel.org, x86@kernel.org, linux-arm-kernel@lists.infradead.org, linux-arch@vger.kernel.org Cc: patches@lists.linux.dev, mikelley@microsoft.com, kys@microsoft.com, wei.liu@kernel.org, gregkh@linuxfoundation.org, haiyangz@microsoft.com, decui@microsoft.com, apais@linux.microsoft.com, Tianyu.Lan@microsoft.com, ssengar@linux.microsoft.com, mukeshrathor@microsoft.com, stanislav.kinsburskiy@gmail.com, jinankjain@linux.microsoft.com, vkuznets@redhat.com, tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com, hpa@zytor.com, will@kernel.org, catalin.marinas@arm.com Subject: [PATCH v4 09/15] Drivers: hv: Introduce hv_output_arg_exists in hv_common.c Date: Fri, 29 Sep 2023 11:01:35 -0700 Message-Id: <1696010501-24584-10-git-send-email-nunodasneves@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1696010501-24584-1-git-send-email-nunodasneves@linux.microsoft.com> References: <1696010501-24584-1-git-send-email-nunodasneves@linux.microsoft.com> 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" This is a more flexible approach for determining whether to allocate the output page. Signed-off-by: Nuno Das Neves Acked-by: Wei Liu --- drivers/hv/hv_common.c | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/drivers/hv/hv_common.c b/drivers/hv/hv_common.c index 39077841d518..3f6f23e4c579 100644 --- a/drivers/hv/hv_common.c +++ b/drivers/hv/hv_common.c @@ -58,6 +58,14 @@ EXPORT_SYMBOL_GPL(hyperv_pcpu_input_arg); void * __percpu *hyperv_pcpu_output_arg; EXPORT_SYMBOL_GPL(hyperv_pcpu_output_arg); =20 +/* + * Determine whether output arg is needed + */ +static inline bool hv_output_arg_exists(void) +{ + return hv_root_partition ? true : false; +} + static void hv_kmsg_dump_unregister(void); =20 static struct ctl_table_header *hv_ctl_table_hdr; @@ -342,10 +350,12 @@ int __init hv_common_init(void) hyperv_pcpu_input_arg =3D alloc_percpu(void *); BUG_ON(!hyperv_pcpu_input_arg); =20 - /* Allocate the per-CPU state for output arg for root */ - if (hv_root_partition) { + if (hv_output_arg_exists()) { hyperv_pcpu_output_arg =3D alloc_percpu(void *); BUG_ON(!hyperv_pcpu_output_arg); + } + + if (hv_root_partition) { hv_synic_eventring_tail =3D alloc_percpu(u8 *); BUG_ON(hv_synic_eventring_tail =3D=3D NULL); } @@ -375,7 +385,7 @@ int hv_common_cpu_init(unsigned int cpu) u8 **synic_eventring_tail; u64 msr_vp_index; gfp_t flags; - int pgcount =3D hv_root_partition ? 2 : 1; + int pgcount =3D hv_output_arg_exists() ? 2 : 1; void *mem; int ret; =20 @@ -393,9 +403,12 @@ int hv_common_cpu_init(unsigned int cpu) if (!mem) return -ENOMEM; =20 - if (hv_root_partition) { + if (hv_output_arg_exists()) { outputarg =3D (void **)this_cpu_ptr(hyperv_pcpu_output_arg); *outputarg =3D (char *)mem + HV_HYP_PAGE_SIZE; + } + + if (hv_root_partition) { synic_eventring_tail =3D (u8 **)this_cpu_ptr(hv_synic_eventring_tail); *synic_eventring_tail =3D kcalloc(HV_SYNIC_SINT_COUNT, sizeof(u8), flags); --=20 2.25.1