Received: by 2002:a05:7412:3784:b0:e2:908c:2ebd with SMTP id jk4csp2791210rdb; Wed, 4 Oct 2023 11:28:38 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH6aLWHLSsxPOjFPXSFCLHr53OgHcwWEdlQQ5vIDXCiORgfvBg3qvBD3GGF83lznrCH6TSY X-Received: by 2002:a05:6a20:8e0c:b0:15a:7d2:7594 with SMTP id y12-20020a056a208e0c00b0015a07d27594mr3453532pzj.11.1696444118312; Wed, 04 Oct 2023 11:28:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696444118; cv=none; d=google.com; s=arc-20160816; b=SHqsSbCwJtoB/FP8WeofnXqY2GY4OuRIPJQOEAuoytolk95K6pnttDWhDzBaD/yYJI t01NJFxmuRZ7TBG9/3J/QN7PetzTQWwoWwLKCoTz3KAgp+3IwYRmLN5PhGRNSvsFDdMu eZ6eKH1cvup2ztvNFdIKjeFee9PoC8orpXWQIC588QaJInO50zz+2RIPjes2KNKfY6CU ARx/qyrkRmEOpjWVOjqKkHOa0Na/hcVZFPLCzIFkgD4g0rAPRRxXaGP+080gVytaziTT 38FoeB8kdNIJ/UYSknTOzraeZyeR9kO84PLKokeiUA10xtEppp3u4vpECl6KAhMflPBn IslQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature:dkim-filter; bh=H3hpMWGvjGtlXIXotdjlxYcAB+MUrjLHbNTb9FjcgmM=; fh=qBwm5HTkajOXv8w9Dqmg1uunne+a6U+2msPloO/WUuY=; b=fY9OXDAc4Bk7Kv4SceDahnccLPv9g6MJrkIlt6I2Cb8CO/GNHR45wB1729YQsyo8Hs Y9ZZVrm/Rn5dky08/6pQph3sbnzehk2J+yRdlbf0fWDKlK5PRVY+IuhxdO0046yVvGUd bEnjfpGdlPQ7uugziF5oeIPFXB+baOOQ7AG3atE4nmS4PFEktcjJrqMjxR5Gpuk8KNyK N/E+HvpoDcjXN8qUkmH0HrNzoKlKggqTnWGEUobOFkUPsAGIUfgkWbjzZP+E3G9KpjXr xGZF8JyKIv9ExhKLIgE/b9HdhyoLQdjPguOd5JVQ4PYBcUw/56Cp4+hZ3dDMvlrLY7Ne x5AA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.microsoft.com header.s=default header.b=E2F9qALp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 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 groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id v14-20020a056a00148e00b00686b62a6dc4si4471716pfu.145.2023.10.04.11.28.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Oct 2023 11:28:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.microsoft.com header.s=default header.b=E2F9qALp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 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 groat.vger.email (Postfix) with ESMTP id 4D9CF811EDA9; Wed, 4 Oct 2023 11:28:32 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243793AbjJDS2C (ORCPT + 99 others); Wed, 4 Oct 2023 14:28:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39226 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244235AbjJDS2B (ORCPT ); Wed, 4 Oct 2023 14:28:01 -0400 Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 0055198; Wed, 4 Oct 2023 11:27:57 -0700 (PDT) Received: from [10.0.0.178] (c-76-135-56-23.hsd1.wa.comcast.net [76.135.56.23]) by linux.microsoft.com (Postfix) with ESMTPSA id CA79020B74C0; Wed, 4 Oct 2023 11:27:56 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com CA79020B74C0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1696444077; bh=H3hpMWGvjGtlXIXotdjlxYcAB+MUrjLHbNTb9FjcgmM=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=E2F9qALpVjKLHPt1qgbv6o+F2urPzDJk9C0SK7tHGJgziy2Xd+HvQ7t2Fz4EUlsOI /I01+rs+iUyXP9YNe6t2U0mQTx3zz0+vNEaFzjubblqGCdCOOn3JmzAiqzHzoLEcrX Ha+iNvKWADExxT2I7VlTuwbBJkw9wzTIoNOJUw2E= Message-ID: Date: Wed, 4 Oct 2023 11:27:56 -0700 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v4 09/15] Drivers: hv: Introduce hv_output_arg_exists in hv_common.c Content-Language: en-US To: Alex Ionescu , Dexuan Cui , longli@microsoft.com, "Michael Kelley (LINUX)" Cc: linux-hyperv@vger.kernel.org, linux-kernel@vger.kernel.org, x86@kernel.org, linux-arm-kernel@lists.infradead.org, linux-arch@vger.kernel.org, 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 References: <1696010501-24584-1-git-send-email-nunodasneves@linux.microsoft.com> <1696010501-24584-10-git-send-email-nunodasneves@linux.microsoft.com> From: Nuno Das Neves In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS,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 groat.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 (groat.vger.email [0.0.0.0]); Wed, 04 Oct 2023 11:28:32 -0700 (PDT) On 10/2/2023 12:29 PM, Alex Ionescu wrote: > Hi Nuno, > > Is it possible to simply change to always allocating the output page? > For example, the output page could be needed in scenarios where Linux > is not running as the root partition, since certain hypercalls that a > guest can make will still require one (I realize that's not the case > _today_, but I don't believe this optimization buys much). I agree - it would indeed simplify the code, and guests will probably make use of it sooner or later. Happy to make that change if Hyper-V guest maintainers agree. Long, Dexuan, Michael, what do you think? Thanks, Nuno > Best regards, > Alex Ionescu > > > On Fri, Sep 29, 2023 at 2:02 PM Nuno Das Neves > wrote: >> >> 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); >> -- >> 2.25.1 >> >>