From mboxrd@z Thu Jan 1 00:00:00 1970 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 73F79C00528 for ; Thu, 3 Aug 2023 00:10:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=l9Ji3NAZmmU1v3VYBC+pssIDPX8UMfPmGs5TV09A7SA=; b=10/HHW1TYCTN8K FcCzLAD6Z5RhUQrf3NWNmjjmSX5zr879MgcRIHWntTrI4NLEILb9BjcYTdnYLuN888F9hu1afkaVz jvMpIOnHHupeXXFnuMReeL2daXXAJ3d+Bos3PaGNrNG5FYlDSIcKNegqgZFJjuvbh4P6JX1QmoC6Y HWz25vdrRC0tOGmzCvbPQc5M+BdN8UMjGtUyS16Yz8l/Ck9KFrwfkouuAlb/ehRJDmqiOMKhR2aLt w1Rtvqs35gzNI+mvtNCX215P+0UTkBzzUVg3PBOF+zPssLCWYR3Cw87x6AuUesoM4PNxsuKqDVoWk xm06RMcKM2zOOacLe93Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qRLvF-006EfW-0t; Thu, 03 Aug 2023 00:10:33 +0000 Received: from mail-oi1-f174.google.com ([209.85.167.174]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qRLut-006EER-07 for linux-arm-kernel@lists.infradead.org; Thu, 03 Aug 2023 00:10:12 +0000 Received: by mail-oi1-f174.google.com with SMTP id 5614622812f47-3a38953c928so278061b6e.1 for ; Wed, 02 Aug 2023 17:10:10 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691021409; x=1691626209; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=TOSDZ8OL0UiQZVyYk0lTuuVm/SjnI4aI4oQHKVpBxmU=; b=EWkHsrSPusY3JHI1DO3YlrMJBj1Xw2R92a1u/HdbxNiAYNIz8mQXvvcStgxFgGMH2b D1ZP1Z25t1BuZTUSlLIYiZVLusvim0l/q/RJ8yNt5js9BODj64AIBB6rXhMlhVqlQ3EC sXFlK1ftL9P7I4dyCgXfUB1PBQQv9G16/nmynEVDnlE120NOjuFCYDoH9rIA5J85hJM8 45ut9GIHHdBGzqFyZsKXAnHLUkc4si7AbIRbDokm87ELUB1RmcvzTPRmaNcOH0eH7iDD H7YYpACcOwrr+eIWx4ScOm8oEMwDoyv/MSsX16oTFgHbAGUo1aZepXngBL6AISpVWRky 4/4A== X-Gm-Message-State: ABy/qLawGUAvMU5qYVjE0yc5X9jOuivA9iiGvZWDATrTCRTdTmSwbNhg 5qtB5itrHww1Ma8cZw8AHiE= X-Google-Smtp-Source: APBJJlGJuUgeaX5hUASc4468mdN2X3XK5fAI+FdbKgJSUsP6MGjW+9jgQv5ggG+vYzY3yXWZAoDU3w== X-Received: by 2002:aca:f14:0:b0:3a7:8f7:62ee with SMTP id 20-20020aca0f14000000b003a708f762eemr15154852oip.12.1691021409620; Wed, 02 Aug 2023 17:10:09 -0700 (PDT) Received: from liuwe-devbox-debian-v2 ([20.69.120.36]) by smtp.gmail.com with ESMTPSA id v14-20020a63bf0e000000b0055c558ac4edsm11069481pgf.46.2023.08.02.17.10.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Aug 2023 17:10:09 -0700 (PDT) Date: Thu, 3 Aug 2023 00:10:03 +0000 From: Wei Liu To: Nuno Das Neves 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, mikelley@microsoft.com, kys@microsoft.com, wei.liu@kernel.org, haiyangz@microsoft.com, decui@microsoft.com, ssengar@linux.microsoft.com, mukeshrathor@microsoft.com, stanislav.kinsburskiy@gmail.com, jinankjain@linux.microsoft.com, apais@linux.microsoft.com, Tianyu.Lan@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: Re: [PATCH 08/15] Drivers: hv: Introduce per-cpu event ring tail Message-ID: References: <1690487690-2428-1-git-send-email-nunodasneves@linux.microsoft.com> <1690487690-2428-9-git-send-email-nunodasneves@linux.microsoft.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1690487690-2428-9-git-send-email-nunodasneves@linux.microsoft.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230802_171011_106620_2B283B0C X-CRM114-Status: GOOD ( 24.89 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Thu, Jul 27, 2023 at 12:54:43PM -0700, Nuno Das Neves wrote: > Add a pointer hv_synic_eventring_tail to track the tail pointer for the > SynIC event ring buffer for each SINT. > This will be used by the mshv driver, but must be tracked independently > since the driver module could be removed and re-inserted. > > Signed-off-by: Nuno Das Neves I understand the general idea, but see below. > --- > drivers/hv/hv_common.c | 25 +++++++++++++++++++++++++ > include/asm-generic/mshyperv.h | 2 ++ > 2 files changed, 27 insertions(+) > > diff --git a/drivers/hv/hv_common.c b/drivers/hv/hv_common.c > index 9f9c3dc89bb2..99d9b262b8a7 100644 > --- a/drivers/hv/hv_common.c > +++ b/drivers/hv/hv_common.c > @@ -61,6 +61,16 @@ static void hv_kmsg_dump_unregister(void); > > static struct ctl_table_header *hv_ctl_table_hdr; > > +/* > + * Per-cpu array holding the tail pointer for the SynIC event ring buffer > + * for each SINT. > + * > + * We cannot maintain this in mshv driver because the tail pointer should > + * persist even if the mshv driver is unloaded. > + */ > +u8 __percpu **hv_synic_eventring_tail; > +EXPORT_SYMBOL_GPL(hv_synic_eventring_tail); > + > /* > * Hyper-V specific initialization and shutdown code that is > * common across all architectures. Called from architecture > @@ -332,6 +342,8 @@ int __init hv_common_init(void) > if (hv_root_partition) { > hyperv_pcpu_output_arg = alloc_percpu(void *); > BUG_ON(!hyperv_pcpu_output_arg); > + hv_synic_eventring_tail = alloc_percpu(u8 *); > + BUG_ON(hv_synic_eventring_tail == NULL); > } > > hv_vp_index = kmalloc_array(num_possible_cpus(), sizeof(*hv_vp_index), > @@ -356,6 +368,7 @@ int __init hv_common_init(void) > int hv_common_cpu_init(unsigned int cpu) > { > void **inputarg, **outputarg; > + u8 **synic_eventring_tail; > u64 msr_vp_index; > gfp_t flags; > int pgcount = hv_root_partition ? 2 : 1; > @@ -371,6 +384,14 @@ int hv_common_cpu_init(unsigned int cpu) > if (hv_root_partition) { > outputarg = (void **)this_cpu_ptr(hyperv_pcpu_output_arg); > *outputarg = (char *)(*inputarg) + HV_HYP_PAGE_SIZE; > + synic_eventring_tail = (u8 **)this_cpu_ptr(hv_synic_eventring_tail); > + *synic_eventring_tail = kcalloc(HV_SYNIC_SINT_COUNT, sizeof(u8), > + flags); > + > + if (unlikely(!*synic_eventring_tail)) { > + kfree(*inputarg); > + return -ENOMEM; > + } > } > > msr_vp_index = hv_get_register(HV_MSR_VP_INDEX); > @@ -387,6 +408,7 @@ int hv_common_cpu_die(unsigned int cpu) > { > unsigned long flags; > void **inputarg, **outputarg; > + u8 **synic_eventring_tail; > void *mem; > > local_irq_save(flags); > @@ -398,6 +420,9 @@ int hv_common_cpu_die(unsigned int cpu) > if (hv_root_partition) { > outputarg = (void **)this_cpu_ptr(hyperv_pcpu_output_arg); > *outputarg = NULL; > + synic_eventring_tail = (u8 **)this_cpu_ptr(hv_synic_eventring_tail); > + kfree(*synic_eventring_tail); > + *synic_eventring_tail = NULL; The upstream code looks different now. See 9636be85cc. > } > > local_irq_restore(flags); > diff --git a/include/asm-generic/mshyperv.h b/include/asm-generic/mshyperv.h > index 0c94d20b4d44..9118d678b27a 100644 > --- a/include/asm-generic/mshyperv.h > +++ b/include/asm-generic/mshyperv.h > @@ -73,6 +73,8 @@ extern bool hv_nested; > extern void * __percpu *hyperv_pcpu_input_arg; > extern void * __percpu *hyperv_pcpu_output_arg; > > +extern u8 __percpu **hv_synic_eventring_tail; > + > extern u64 hv_do_hypercall(u64 control, void *inputaddr, void *outputaddr); > extern u64 hv_do_fast_hypercall8(u16 control, u64 input8); > extern bool hv_isolation_type_snp(void); > -- > 2.25.1 > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel