From patchwork Thu Aug 17 22:01:45 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: 136195 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b82d:0:b0:3f2:4152:657d with SMTP id z13csp2187585vqi; Sat, 19 Aug 2023 13:36:59 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHGBGdayRbd3WphdRbBa7TPUZ/zd9gdM9PmOH7BPbOO6C8LE7K1+23yBkKr9hoDhXD3kZu4 X-Received: by 2002:a05:6a20:6a05:b0:13f:9cee:ff42 with SMTP id p5-20020a056a206a0500b0013f9ceeff42mr3772806pzk.41.1692477419007; Sat, 19 Aug 2023 13:36:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692477418; cv=none; d=google.com; s=arc-20160816; b=cXewFzYt6ym2W3EUFx7PWgvbsNrpwD8gQhPvu6MivudnnUd+Jgu7llTEaOQ5nU9tbA gZo3JczqpAA7CX9aoTMWJBO7Gr8yD0PfPAbYrobo/OhxTxtOTdArYq6qgymbS4K7Hmzu MtX4X+df1DgbvGlrwd44VkXwRHPtNZesbcxzlAgqf1BhYhN5d1JHsZO8ZiZL7CJqXcod BpGYzCGhGZD71aJbnSlIop/T7MsDW2bIOHiSNQvKDUVjp2vBf3yJoe6AlpT7IyD4ua1z HiSfF++Jp68p3eX2MbxVZpnKGQFjKvK48pKB8qZ4T1dAY9PRcr0j/s1dymhtrDfHhCxn ZFcw== 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=UF9KXgy9RsSasqAfOy/c+T7O+q2CZQATwtSIp6QmwHs=; fh=0P4OqsannYDaa0gDecThG5I9JolTsg1HKUcZ8g+AtNU=; b=ZwtrknCMC/1K10FlqEY3wV3Cs4duFRnhGJ6Ik7DwDjvCdeHfxXukROLh4kwBFxQo2z eA0CWrypM7Kw9OCThBpcfTUVIbqwwL6O2gMxobMijiFC8jnnaHTRS7DcIj431R2DipUL XLWukBgfgTPga4KwAGKBjI2rvhjHBpKRonbhd7eZZkhKFQgF7mWCr2yfBUtL7W8guC3O PkmDYoNOclKu2VZYAF+ty9mQHRSt3zBflZ4dgFa3S76754FD0zZm0CpmDEVP8/ssoZsZ j+xXD4VoQC9X8L0gGNm3Y5DRlmus9yLvSw03CpNxSnW7GwQHqA78rO0pT6NAgan60Q7g aYpQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.microsoft.com header.s=default header.b=cewk1cU1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id ct13-20020a056a000f8d00b00625559a78a2si4059411pfb.107.2023.08.19.13.36.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 19 Aug 2023 13:36:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.microsoft.com header.s=default header.b=cewk1cU1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 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 09F2AA3AC4; Sat, 19 Aug 2023 01:40:36 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1355577AbjHQWC3 (ORCPT + 99 others); Thu, 17 Aug 2023 18:02:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39580 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1355501AbjHQWCC (ORCPT ); Thu, 17 Aug 2023 18:02:02 -0400 Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id B1605358D; Thu, 17 Aug 2023 15:02:01 -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 ACECA211F7DB; Thu, 17 Aug 2023 15:01:59 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com ACECA211F7DB DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1692309719; bh=UF9KXgy9RsSasqAfOy/c+T7O+q2CZQATwtSIp6QmwHs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cewk1cU1/KixfGm5zvZM4vAw/b6ilZ9X3mUQFA4BBXTSLgxJpJdBvXNENaj1hFnfo 4Pufotvn0O+1T77veXMx5mNEQIQ91p9T+mkvr5Ter7Wj4GPcqwVZkHjTaflFBaIHzA mB34M4LNc6IzPHAxgxuMy5ZYqkqPG5UgJw+ODGdw= 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, 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 v2 09/15] Drivers: hv: Introduce hv_output_arg_exists in hv_common.c Date: Thu, 17 Aug 2023 15:01:45 -0700 Message-Id: <1692309711-5573-10-git-send-email-nunodasneves@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1692309711-5573-1-git-send-email-nunodasneves@linux.microsoft.com> References: <1692309711-5573-1-git-send-email-nunodasneves@linux.microsoft.com> X-Spam-Status: No, score=-17.5 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_PASS,SPF_PASS,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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1774691201892037299 X-GMAIL-MSGID: 1774691201892037299 This is a more flexible approach for determining whether to allocate the output page. Signed-off-by: Nuno Das Neves --- drivers/hv/hv_common.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/drivers/hv/hv_common.c b/drivers/hv/hv_common.c index 0dd3091beef3..79efedc8bf39 100644 --- a/drivers/hv/hv_common.c +++ b/drivers/hv/hv_common.c @@ -57,6 +57,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; @@ -341,10 +349,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); } @@ -374,7 +384,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; /* hv_cpu_init() can be called with IRQs disabled from hv_resume() */ flags = irqs_disabled() ? GFP_ATOMIC : GFP_KERNEL; @@ -390,9 +400,11 @@ int hv_common_cpu_init(unsigned int cpu) if (!(*inputarg)) return -ENOMEM; - if (hv_root_partition) { + if (hv_output_arg_exists()) { outputarg = (void **)this_cpu_ptr(hyperv_pcpu_output_arg); *outputarg = (char *)(*inputarg) + 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);