Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp4341599rdb; Thu, 28 Dec 2023 20:21:18 -0800 (PST) X-Google-Smtp-Source: AGHT+IGcWHBJdd9p3pn9JJnRgy5Boh/9hREYzC0ahcokeRpN8JjaRFqw7++t33eEI7gl9/TaGAYg X-Received: by 2002:a05:622a:138b:b0:423:93a5:32 with SMTP id o11-20020a05622a138b00b0042393a50032mr17658916qtk.31.1703823678520; Thu, 28 Dec 2023 20:21:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703823678; cv=none; d=google.com; s=arc-20160816; b=gcBxsAiFHGTTpuimuuJMlDOq0RzZkrPeVmC4QY8a7Dl/wEuRGS+vIfsSe9Fhiv2wMF Od7L0HAgle9vylc86gCpCoQoAlU5bY5F3iDHic32FzTae7JN4tDTU1N3RuMzgH0cYWAh rSnOYmNpUJnSaegMr+yoj/X75fEwF0d1/RzUmwr8oZ0O45vrG//Y4iPKk2PcsxWRzxVz yyr3loNeuNIbPvtnasOJEQIYWoU+shwnMsqFJjajiw5jJRsqG+5kiD9XQV5mIDnvuVHs zNwRiDl54FuwPjSWNxYs2AlV4IcT8ljqm3mHzuRS/G8YD3pVaqi2UI39o/oc5PJoU110 y+aQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:references:cc:to:from :content-language:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=5c2gUSkqwmMTgTJ8hHo0SmGyLYLf8frjv153xsRpBVA=; fh=wu6/LcA7ViOsSr5vOXhdZdHUUl/lXWM89r/mcoWJXEA=; b=vbmhWBKIZUKPT4u7NYj1C0HhaSsttuTC+BhdeGHrOV7iMo7BMp73jkCSQKXjJF6OPh euMjTr05mXQDpg97du3hA/mURzh3V0yOSmggUe6BKQaWFcUdyBM4frr9AwPx/lRKvfxn MbCYjXV1Bo7akngY9FVpU5OdNyfRu57ckxkb2erekle3a3j4kux3QqqaLPHyX6mbls8Q UYpZ3HT1ARsWvuQE9U2v1jt+vXXZKMDaj9uKKsKg4Nz/dWUAqZeRhamDDfrUT6U+GDHJ AKVdlvRZCU5RUMdHYfnpxLzqc/RBAde4/O5PcYEJFexY9w7DpUzQdMTv8dSgmrqcANFa WItg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=hwEuCGuG; spf=pass (google.com: domain of linux-kernel+bounces-12942-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-12942-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id v2-20020a05622a144200b0042778adc8e1si19313543qtx.694.2023.12.28.20.21.18 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Dec 2023 20:21:18 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-12942-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=hwEuCGuG; spf=pass (google.com: domain of linux-kernel+bounces-12942-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-12942-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 48A061C2158B for ; Fri, 29 Dec 2023 04:21:18 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 023A223B3; Fri, 29 Dec 2023 04:21:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="hwEuCGuG" X-Original-To: linux-kernel@vger.kernel.org Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A1E221FA8; Fri, 29 Dec 2023 04:21:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1703823665; x=1735359665; h=message-id:date:mime-version:subject:from:to:cc: references:in-reply-to:content-transfer-encoding; bh=bCk1WmPQGNe7VSwvo3KzDGGlaLdYm0gwge09YznPONI=; b=hwEuCGuG+hbLU/WbK8Goo6Ia0hJ05zQ5hsdpIqhMd3Xa453MnuarUlYD DXO6Q2MREo/X3UoYhjv5fOBF/Tvyx9owFV+/KFPGIR8o1dSx/zUJcX1Vm +YL8ga7dhYpvkh6y4rW832PPpzM3oCtQrq8TbGAJLgXTMPW1GotM/aESE D5G1WRuuOCzpZ52xAw9p0xMdVOvnh6OdyT5PajS2t9V0K54+OU3Vqkyyu tzMmROucTTa6d93MRM83+4HFqz9fE8/m8XDv0rDjmiUvPL3aKnzcF9eCM 37e8pBN6Y1wbXaV4g93PYGHPMZBiNCOtQ7fi1ARYDuvz5BBTI6zywpgOA Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10937"; a="482801277" X-IronPort-AV: E=Sophos;i="6.04,314,1695711600"; d="scan'208";a="482801277" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Dec 2023 20:21:04 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10937"; a="728502480" X-IronPort-AV: E=Sophos;i="6.04,314,1695711600"; d="scan'208";a="728502480" Received: from xiaoyaol-hp-g830.ccr.corp.intel.com (HELO [10.93.22.149]) ([10.93.22.149]) by orsmga003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Dec 2023 20:21:01 -0800 Message-ID: <7e614fab-8f91-4a91-bfbf-1b02b9f12cdb@intel.com> Date: Fri, 29 Dec 2023 12:20:57 +0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v3 1/4] KVM: x86/hyperv: Calculate APIC bus frequency for hyper-v Content-Language: en-US From: Xiaoyao Li To: Isaku Yamahata , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Paolo Bonzini , erdemaktas@google.com, Sean Christopherson , Vishal Annapurve , Jim Mattson , Maxim Levitsky Cc: isaku.yamahata@gmail.com References: <09cec4fd-2d79-4925-bb2b-7814032fdda3@intel.com> In-Reply-To: <09cec4fd-2d79-4925-bb2b-7814032fdda3@intel.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit On 12/21/2023 1:26 PM, Xiaoyao Li wrote: > On 12/19/2023 4:34 PM, Isaku Yamahata wrote: >> Remove APIC_BUS_FREUQNCY and calculate it based on APIC bus cycles per >> NS. >> APIC_BUS_FREUQNCY is used only for HV_X64_MSR_APIC_FREQUENCY.  The MSR is >> not frequently read, calculate it every time. >> >> In order to make APIC bus frequency configurable, we need to make make >> two > > two 'make', please drop one. With this and other typos pointed by Maxim fixed. Reviewed-by: Xiaoyao Li >> related constants into variables.  APIC_BUS_FREUQNCY and >> APIC_BUS_CYCLE_NS. >> One can be calculated from the other. >>     APIC_BUS_CYCLES_NS = 1000 * 1000 * 1000 / APIC_BUS_FREQUENCY. >> By removing APIC_BUS_FREQUENCY, we need to track only single variable >> instead of two. >> >> Signed-off-by: Isaku Yamahata >> --- >> Changes v3: >> - Newly added according to Maxim Levistsky suggestion. >> --- >>   arch/x86/kvm/hyperv.c | 2 +- >>   arch/x86/kvm/lapic.h  | 1 - >>   2 files changed, 1 insertion(+), 2 deletions(-) >> >> diff --git a/arch/x86/kvm/hyperv.c b/arch/x86/kvm/hyperv.c >> index 238afd7335e4..a40ca2fef58c 100644 >> --- a/arch/x86/kvm/hyperv.c >> +++ b/arch/x86/kvm/hyperv.c >> @@ -1687,7 +1687,7 @@ static int kvm_hv_get_msr(struct kvm_vcpu *vcpu, >> u32 msr, u64 *pdata, >>           data = (u64)vcpu->arch.virtual_tsc_khz * 1000; >>           break; >>       case HV_X64_MSR_APIC_FREQUENCY: >> -        data = APIC_BUS_FREQUENCY; >> +        data = div64_u64(1000000000ULL, APIC_BUS_CYCLE_NS); >>           break; >>       default: >>           kvm_pr_unimpl_rdmsr(vcpu, msr); >> diff --git a/arch/x86/kvm/lapic.h b/arch/x86/kvm/lapic.h >> index 0a0ea4b5dd8c..a20cb006b6c8 100644 >> --- a/arch/x86/kvm/lapic.h >> +++ b/arch/x86/kvm/lapic.h >> @@ -17,7 +17,6 @@ >>   #define APIC_DEST_MASK            0x800 >>   #define APIC_BUS_CYCLE_NS       1 >> -#define APIC_BUS_FREQUENCY      (1000000000ULL / APIC_BUS_CYCLE_NS) >>   #define APIC_BROADCAST            0xFF >>   #define X2APIC_BROADCAST        0xFFFFFFFFul > >