Message ID | 20221101053019.174948-1-fei1.li@intel.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp2748971wru; Mon, 31 Oct 2022 22:29:26 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5YV1H9Dkx+OLHyJohsaRqOEmVpaomj1HKPXSbd7Mpm+9vd446eRQje/XNGGXbibmJ4Lc+v X-Received: by 2002:a17:906:9bc2:b0:7ad:975f:b567 with SMTP id de2-20020a1709069bc200b007ad975fb567mr16935825ejc.107.1667280566789; Mon, 31 Oct 2022 22:29:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667280566; cv=none; d=google.com; s=arc-20160816; b=hxD4iCGFtsmeFtiiESP2gUNvjLIwsKiQLdecy5TDFD0pD9tA6Ye659hmZ5yGi30HYQ BBT+MyPuF2OQv2ibztmbaA0VUwRuL2IrDFmBhJ44ZztFN1w271nwV7N4/Tf9yWEQQKk5 cKeT+iKNaY5ftOLFbu2RubKYdtcaeco6FFFuoPeFZVMgQrCLLkm4LvcI8+krO+0i4uPT QXsplEDLI6qYzR6ZiWkflWSU2Jzk0ZahdSX/+/xTvd8+S4Agu7tNCCLk/Co5CHYHCe8u YHow1p1bT3YsmnXr4b/h/1mXnEx5QB9UwB/bCz+l+nrVB528T6wF2S67YaFVuuzfS/D9 hk8Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=xENrV5HN02lL/rHi8prlMTkuVG/Ntzh1rUkeH43ZD7Y=; b=CrxcUqd1WkUZrxZJdbjqUtMkVv5iIFo0pFmeB72jEiFskLkWYxW8ju046fQXdNz4PY B6i5a5YqKYWcYkWsUUH4Z5IG9uGtMU1Bw3vAVNyxRyWxpiYM9H4AMr8KCvdWFd5SMmMc CeoYUIKxU2AjS/viOVCE21pbFynGUoRh3v4hPg7AUuLhz3wb0OJqzsjjp8Ga0SmX5Fpx P58x+yxuZugEZd1K7T4tt81YcduL45+9dwCWhuZstFlEFOh57p5FOy+Ak/tSGMRERdeS QVIGLv/m4XIiMrAJFNN/WMgEPFfR6TaDBM51ZaMlg4myIkUqQmz7JQtTw9NE+yfMMH3j LqSg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=GY2mCd+k; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id sc23-20020a1709078a1700b00787b0b0a96esi12199874ejc.131.2022.10.31.22.29.02; Mon, 31 Oct 2022 22:29:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=GY2mCd+k; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229866AbiKAFYu (ORCPT <rfc822;kartikey406@gmail.com> + 99 others); Tue, 1 Nov 2022 01:24:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46244 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229952AbiKAFYb (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Tue, 1 Nov 2022 01:24:31 -0400 Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 99CE213CD8 for <linux-kernel@vger.kernel.org>; Mon, 31 Oct 2022 22:24:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1667280265; x=1698816265; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=0x5C1nQK2uQCFLLwOkAmqcIqfySyFJsnR0olbPOIh0w=; b=GY2mCd+kbHSGOeOLi04lhqBHk6Wdcn76slKyFugBR9UHpSipGWem7+n7 +3HE3Pd+PsPQLb7H4lDIrFtf02GqsTK3OapyWxehht6g1qFp+B+XhbPk5 2kLF62qkzBCLyTgcJgHzlCuVKXBHSfx2nDdK7jIPj91brtMexsc95a2gN GacJH168tmDrgVlk1ALkvu8Ys1rPJJWxFF3GbF2/UCyPudd2P/Y4yOJ6h UdAcwtxG3bn5IIpxVbCIeHrCBJ7Sm5YK/dhAzD0bqyHitldrTB0kBraXC 0/KQXdgmTSVhsyPqvecAWiF0YjVz1G/GEEqwrob7t0ijwL5SkjRvZ5seg Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10517"; a="292371390" X-IronPort-AV: E=Sophos;i="5.95,229,1661842800"; d="scan'208";a="292371390" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 31 Oct 2022 22:24:25 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10517"; a="759080366" X-IronPort-AV: E=Sophos;i="5.95,229,1661842800"; d="scan'208";a="759080366" Received: from louislifei-optiplex-7090.sh.intel.com ([10.239.146.218]) by orsmga004.jf.intel.com with ESMTP; 31 Oct 2022 22:24:22 -0700 From: Fei Li <fei1.li@intel.com> To: linux-kernel@vger.kernel.org, x86@kernel.org, peterz@infradead.org Cc: dave.hansen@intel.com, gregkh@linuxfoundation.org, tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com, hpa@zytor.com, Yu1.Wang@intel.com, conghui.chen@intel.com, fengwei.yin@intel.com Subject: [PATCH v2] x86/acrn: Set X86_FEATURE_TSC_KNOWN_FREQ Date: Tue, 1 Nov 2022 13:30:19 +0800 Message-Id: <20221101053019.174948-1-fei1.li@intel.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_NONE 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1748270387186324616?= X-GMAIL-MSGID: =?utf-8?q?1748270387186324616?= |
Series |
[v2] x86/acrn: Set X86_FEATURE_TSC_KNOWN_FREQ
|
|
Commit Message
Fei Li
Nov. 1, 2022, 5:30 a.m. UTC
If the TSC frequency is known from the acrn_get_tsc_khz(), the TSC frequency does not need to be recalibrated. Avoiding recalibration by setting X86_FEATURE_TSC_KNOWN_FREQ. This patch also removes `inline` for acrn_get_tsc_khz() since it doesn't make sense. Signed-off-by: Fei Li <fei1.li@intel.com> Reviewed-by: Yin, Fengwei <fengwei.yin@intel.com> --- v2: - Detail the commit message --- arch/x86/include/asm/acrn.h | 5 ----- arch/x86/kernel/cpu/acrn.c | 6 ++++++ 2 files changed, 6 insertions(+), 5 deletions(-) base-commit: 5aaef24b5c6d4246b2cac1be949869fa36577737
Comments
On 2022-11-01 at 13:30:19 +0800, Fei Li wrote: > If the TSC frequency is known from the acrn_get_tsc_khz(), > the TSC frequency does not need to be recalibrated. > > Avoiding recalibration by setting X86_FEATURE_TSC_KNOWN_FREQ. > This patch also removes `inline` for acrn_get_tsc_khz() since > it doesn't make sense. > > Signed-off-by: Fei Li <fei1.li@intel.com> > Reviewed-by: Yin, Fengwei <fengwei.yin@intel.com> > > --- > v2: > - Detail the commit message Ping ... > --- > arch/x86/include/asm/acrn.h | 5 ----- > arch/x86/kernel/cpu/acrn.c | 6 ++++++ > 2 files changed, 6 insertions(+), 5 deletions(-) > > diff --git a/arch/x86/include/asm/acrn.h b/arch/x86/include/asm/acrn.h > index 1dd14381bcb6..aa12c74ea959 100644 > --- a/arch/x86/include/asm/acrn.h > +++ b/arch/x86/include/asm/acrn.h > @@ -30,11 +30,6 @@ static inline u32 acrn_cpuid_base(void) > return 0; > } > > -static inline unsigned long acrn_get_tsc_khz(void) > -{ > - return cpuid_eax(ACRN_CPUID_TIMING_INFO); > -} > - > /* > * Hypercalls for ACRN > * > diff --git a/arch/x86/kernel/cpu/acrn.c b/arch/x86/kernel/cpu/acrn.c > index 485441b7f030..c5ff75b6a949 100644 > --- a/arch/x86/kernel/cpu/acrn.c > +++ b/arch/x86/kernel/cpu/acrn.c > @@ -24,6 +24,12 @@ static u32 __init acrn_detect(void) > return acrn_cpuid_base(); > } > > +static unsigned long acrn_get_tsc_khz(void) > +{ > + setup_force_cpu_cap(X86_FEATURE_TSC_KNOWN_FREQ); > + return cpuid_eax(ACRN_CPUID_TIMING_INFO); > +} > + > static void __init acrn_init_platform(void) > { > /* Setup the IDT for ACRN hypervisor callback */ > > base-commit: 5aaef24b5c6d4246b2cac1be949869fa36577737 > -- > 2.34.1 >
On Tue, Nov 01, 2022 at 01:30:19PM +0800, Fei Li wrote: > If the TSC frequency is known from the acrn_get_tsc_khz(), > the TSC frequency does not need to be recalibrated. What if the HV has unstable TSCs? How do you handle that? > Avoiding recalibration by setting X86_FEATURE_TSC_KNOWN_FREQ. Pls read section "2) Describe your changes" in Documentation/process/submitting-patches.rst for more details on how to write your commit message. > This patch also removes `inline` for acrn_get_tsc_khz() since > it doesn't make sense. Avoid having "This patch" or "This commit" in the commit message. It is tautologically useless. Also, do $ git grep 'This patch' Documentation/process for more details. Thx.
On 2022-11-07 at 16:30:27 +0100, Borislav Petkov wrote: > On Tue, Nov 01, 2022 at 01:30:19PM +0800, Fei Li wrote: > > If the TSC frequency is known from the acrn_get_tsc_khz(), > > the TSC frequency does not need to be recalibrated. Hi Borislav Thanks for your comments. So sorry to reply you late. > > What if the HV has unstable TSCs? How do you handle that? > ACRN hypervisor assumes: a) The TSC runs at a constant rate in all ACPI P-, C-. and T-states (i.e. invariant TSC) b) The invariant TSC is based on only one invariant timekeeping hardware (called Always Running Timer or ART). ACRN main target uses for IoT devices which are typically one-socket c) ACRN lives with temperature influence on TSC frequency > > Avoiding recalibration by setting X86_FEATURE_TSC_KNOWN_FREQ. > > Pls read section "2) Describe your changes" in > Documentation/process/submitting-patches.rst for more details on how to > write your commit message. OK, will refine the commit message in v3. Thanks. > > > This patch also removes `inline` for acrn_get_tsc_khz() since > > it doesn't make sense. > > Avoid having "This patch" or "This commit" in the commit message. It is > tautologically useless. > > Also, do > > $ git grep 'This patch' Documentation/process > > for more details. OK. Thanks. > > Thx. > > -- > Regards/Gruss, > Boris. > > https://people.kernel.org/tglx/notes-about-netiquette
> Hi Borislav > > Thanks for your comments. So sorry to reply you late. > > > > > What if the HV has unstable TSCs? How do you handle that? > > > ACRN hypervisor assumes: > a) The TSC runs at a constant rate in all ACPI P-, C-. and T-states (i.e. invariant TSC) > b) The invariant TSC is based on only one invariant timekeeping hardware (called > Always Running Timer or ART). ACRN main target uses for IoT devices > which are typically one-socket > c) ACRN lives with temperature influence on TSC frequency > Hi Borislav Kindly ping for any comments here ?
On Mon, Nov 14, 2022 at 04:14:25PM +0800, Fei Li wrote:
> ACRN hypervisor assumes:
So ACRN assumes the HV has a good TSC and if it doesn't, oh well, tough
luck.
At least this is how I read this.
diff --git a/arch/x86/include/asm/acrn.h b/arch/x86/include/asm/acrn.h index 1dd14381bcb6..aa12c74ea959 100644 --- a/arch/x86/include/asm/acrn.h +++ b/arch/x86/include/asm/acrn.h @@ -30,11 +30,6 @@ static inline u32 acrn_cpuid_base(void) return 0; } -static inline unsigned long acrn_get_tsc_khz(void) -{ - return cpuid_eax(ACRN_CPUID_TIMING_INFO); -} - /* * Hypercalls for ACRN * diff --git a/arch/x86/kernel/cpu/acrn.c b/arch/x86/kernel/cpu/acrn.c index 485441b7f030..c5ff75b6a949 100644 --- a/arch/x86/kernel/cpu/acrn.c +++ b/arch/x86/kernel/cpu/acrn.c @@ -24,6 +24,12 @@ static u32 __init acrn_detect(void) return acrn_cpuid_base(); } +static unsigned long acrn_get_tsc_khz(void) +{ + setup_force_cpu_cap(X86_FEATURE_TSC_KNOWN_FREQ); + return cpuid_eax(ACRN_CPUID_TIMING_INFO); +} + static void __init acrn_init_platform(void) { /* Setup the IDT for ACRN hypervisor callback */