From patchwork Fri Sep 29 18:01:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nuno Das Neves X-Patchwork-Id: 148941 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2016:b0:403:3b70:6f57 with SMTP id fe22csp441536vqb; Thu, 5 Oct 2023 10:07:22 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEsSOzkp0imNh5xyXpbub3MIjllHpLFrH+e77mmHyfAIuWSGLHeB5rBs+AVmugwHx5ZFm0o X-Received: by 2002:a05:6e02:1061:b0:34f:d9db:66c4 with SMTP id q1-20020a056e02106100b0034fd9db66c4mr5212375ilj.30.1696525642146; Thu, 05 Oct 2023 10:07:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696525642; cv=none; d=google.com; s=arc-20160816; b=Q35vZqG/FfYCUCbMDM0hE5ZyMlEkTiPikPYkufarbvRCqMIaFFhMDGme66FwGBWUe3 I1jcyxO0SCx9UJ2O0hYSQn8Rq/oWn3HZL8WN25bIRML7Te4PugviE2WFduQMgf2SlTir m1sz+tDzcz7ph1j6buHP/8SCtMgD/Cyeca//CvLmlDuR9Ivx2uCv9qtnWuCmQSG60oeq DvJP1QtSmvETj+PY5b2aJv/eQYrMajEV8H5mO+sF7qJgTSpuf6RDzqWY0x6UJ7hlEJVo Ch7pAQVpL699mxlcFfGSNIxBF3yxcg9a38KXp5pcURvvHuwtWFgx0wDa9RConVvGIjoG Gr2Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from:dkim-signature:dkim-filter; bh=giaPGAUBP/shqQFPfTt6khDXOM7sp4gdgMa7HKBM+B4=; fh=rrENblR9DW+P8f8MSnFC4QkpxyTeAbSNxgPLVTXlWGs=; b=ILyua0r1Ks5AodGkxKSXytl/MrrfefTLccNTBqNtr7LmPCiTcuds1WoFiJx2DXeei8 uJuCjXFm8sjWnEvL8lqgY8z2k5v2Npu8g3tjocNSmHSWETBSYPagHQd0crRLcvrwYvtH BMFrYiuBGciR9nZYdjjt6J/g6vLsM/zLbeFA+6jc54xiTTWLEu8aE7w8Y/ueyzz5J1lT Oh9xuohovwuuK1ptda32IUvhYb6q2nHZOLhLL+PoIalV0aNVskgyz8wTnnC+wHvK+UNg uMYSAcCg45GqHyywVNnjisVzIstmVmy7YiCYIDL8l0XtKnJrF1Mio7KhP2I8Z7uWCDV/ tdSg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.microsoft.com header.s=default header.b=autZ+nlb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 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 morse.vger.email (morse.vger.email. [2620:137:e000::3:1]) by mx.google.com with ESMTPS id s14-20020a65644e000000b0054fdb18c877si1785207pgv.607.2023.10.05.10.07.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Oct 2023 10:07:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) client-ip=2620:137:e000::3:1; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.microsoft.com header.s=default header.b=autZ+nlb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 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 out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id E8C088082CC3; Fri, 29 Sep 2023 11:04:09 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233962AbjI2SDD (ORCPT + 19 others); Fri, 29 Sep 2023 14:03:03 -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> X-Spam-Status: No, score=-8.4 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Fri, 29 Sep 2023 11:04:10 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778679076449492714 X-GMAIL-MSGID: 1778936071635206473 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); +/* + * 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); static struct ctl_table_header *hv_ctl_table_hdr; @@ -342,10 +350,12 @@ int __init hv_common_init(void) hyperv_pcpu_input_arg = alloc_percpu(void *); BUG_ON(!hyperv_pcpu_input_arg); - /* Allocate the per-CPU state for output arg for root */ - if (hv_root_partition) { + if (hv_output_arg_exists()) { hyperv_pcpu_output_arg = alloc_percpu(void *); BUG_ON(!hyperv_pcpu_output_arg); + } + + if (hv_root_partition) { hv_synic_eventring_tail = alloc_percpu(u8 *); BUG_ON(hv_synic_eventring_tail == 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 = hv_root_partition ? 2 : 1; + int pgcount = hv_output_arg_exists() ? 2 : 1; void *mem; int ret; @@ -393,9 +403,12 @@ int hv_common_cpu_init(unsigned int cpu) if (!mem) return -ENOMEM; - if (hv_root_partition) { + if (hv_output_arg_exists()) { outputarg = (void **)this_cpu_ptr(hyperv_pcpu_output_arg); *outputarg = (char *)mem + HV_HYP_PAGE_SIZE; + } + + if (hv_root_partition) { synic_eventring_tail = (u8 **)this_cpu_ptr(hv_synic_eventring_tail); *synic_eventring_tail = kcalloc(HV_SYNIC_SINT_COUNT, sizeof(u8), flags);