From patchwork Wed Sep 14 17:37:50 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joao Martins X-Patchwork-Id: 9332185 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 5A04E607FD for ; Wed, 14 Sep 2016 17:39:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4F7D32A246 for ; Wed, 14 Sep 2016 17:39:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4405F2A24F; Wed, 14 Sep 2016 17:39:14 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 9ABFA2A246 for ; Wed, 14 Sep 2016 17:39:13 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bkE7L-00012f-42; Wed, 14 Sep 2016 17:37:03 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bkE7J-00011R-8b for xen-devel@lists.xenproject.org; Wed, 14 Sep 2016 17:37:01 +0000 Received: from [85.158.137.68] by server-9.bemta-3.messagelabs.com id 0B/7F-27233-CBA89D75; Wed, 14 Sep 2016 17:37:00 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrHLMWRWlGSWpSXmKPExsXSO6nOVXd3181 wg4UHrSy+b5nM5MDocfjDFZYAxijWzLyk/IoE1oyzF1azF/TKVsz8v5O1gfGfeBcjF4eQwEQm ibansxghnL+MEh23GlkgnI2MEj+/NbBCOI2MEm9OnmXuYuTkYBPQk2g9/xnMFhFQkri3ajITS BGzQAejxJfzp5hAEsICnhK/Ju0GK2IRUJXY8XcjG4jNK+AhcW3XG7C4hICcxPnjP8FsTqD6Hz c+s4DYQkA1Bx7cgqoxlPi8cSnzBEa+BYwMqxg1ilOLylKLdA0N9JKKMtMzSnITM3OAPGO93NT i4sT01JzEpGK95PzcTYzAcKlnYGDcwbity/kQoyQHk5Iob2nwzXAhvqT8lMqMxOKM+KLSnNTi Q4wyHBxKErxcnUA5waLU9NSKtMwcYODCpCU4eJREeKVA0rzFBYm5xZnpEKlTjIpS4rw7OoASA iCJjNI8uDZYtFxilJUS5mVkYGAQ4ilILcrNLEGVf8UozsGoJMxrBTKeJzOvBG76K6DFTECLt6 y5DrK4JBEhJdXAWJXere/0SnTamdCwIC/5jCtvuVlXnf8U0u7zO75a4lt1Uoomw9wVMy8rVKv r7axkXHqk8GqCz9TqJyWHYwJYQrdb3LCvWtV3dprM1h8ioZeqRXVcCgreHrap4Wky/uZ0wG9S /nJhruccMdfuaV/d8Pve3/LJyzNsul0y8g9K5Ggd+iwnrvVBiaU4I9FQi7moOBEAd4rJdZECA AA= X-Env-Sender: joao.m.martins@oracle.com X-Msg-Ref: server-9.tower-31.messagelabs.com!1473874618!13316519!1 X-Originating-IP: [141.146.126.69] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogMTQxLjE0Ni4xMjYuNjkgPT4gMjc3MjE4\n X-StarScan-Received: X-StarScan-Version: 8.84; banners=-,-,- X-VirusChecked: Checked Received: (qmail 57474 invoked from network); 14 Sep 2016 17:36:59 -0000 Received: from aserp1040.oracle.com (HELO aserp1040.oracle.com) (141.146.126.69) by server-9.tower-31.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 14 Sep 2016 17:36:59 -0000 Received: from userv0022.oracle.com (userv0022.oracle.com [156.151.31.74]) by aserp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id u8EHaucf014483 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 14 Sep 2016 17:36:57 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by userv0022.oracle.com (8.14.4/8.13.8) with ESMTP id u8EHauI4019703 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 14 Sep 2016 17:36:56 GMT Received: from abhmp0007.oracle.com (abhmp0007.oracle.com [141.146.116.13]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id u8EHatQi003835; Wed, 14 Sep 2016 17:36:55 GMT Received: from paddy.lan (/89.114.92.174) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 14 Sep 2016 10:36:55 -0700 From: Joao Martins To: xen-devel@lists.xenproject.org Date: Wed, 14 Sep 2016 18:37:50 +0100 Message-Id: <1473874670-4986-6-git-send-email-joao.m.martins@oracle.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1473874670-4986-1-git-send-email-joao.m.martins@oracle.com> References: <1473874670-4986-1-git-send-email-joao.m.martins@oracle.com> X-Source-IP: userv0022.oracle.com [156.151.31.74] Cc: Andrew Cooper , Joao Martins , Jan Beulich Subject: [Xen-devel] [PATCH v4 5/5] x86/time: extend "tsc" param with "stable:socket" X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP Extend the "tsc" boot parameter is to further relax TSC restrictions and allow it to be used on machines that guarantee reliable TSC across sockets. This is up to board manufacturers and there's no way for the OS to probe this property, therefore user needs to explicitly set this option. Also make one style adjustment that is to remove the unnecessary parenthesis around clearing TSC_RELIABLE. Signed-off-by: Joao Martins --- Cc: Jan Beulich Cc: Andrew Cooper Alternatively to having tsc_flags, I could instead introduce a new X86_FEATURE in the Xen defined mapping. This would mean introducing a "set_caps" similar to "cleared_caps" in order to set the feature bit after x86_capability get's zeroed out in common identify_cpu(). It was unclear to me what would maintainers prefer so I went for the simplest for starters. If you prefer the other way I can redo it. NB: Didn't add "stable:node" (and consequently tsc=stable as it would refer to both) because I don't have a host with multiple nodes that I can test with. --- docs/misc/xen-command-line.markdown | 6 ++++-- xen/arch/x86/time.c | 11 ++++++++--- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/docs/misc/xen-command-line.markdown b/docs/misc/xen-command-line.markdown index f92fb3f..7161788 100644 --- a/docs/misc/xen-command-line.markdown +++ b/docs/misc/xen-command-line.markdown @@ -270,7 +270,9 @@ If set, override Xen's default choice for the platform timer. Having TSC as platform timer requires being explicitly set. This is because TSC can only be safely used if CPU hotplug isn't performed on the system. In some platforms, "maxcpus" parameter may require further adjustment to the -number of online cpus. +number of online cpus. When running under platforms that can guarantee a +monotonic TSC across sockets you require adjusting "tsc" command line parameter +parameter to "stable:sockets". ### cmci-threshold > `= ` @@ -1508,7 +1510,7 @@ pages) must also be specified via the tbuf\_size parameter. > `= ` ### tsc -> `= unstable | skewed` +> `= unstable | skewed | stable:socket` ### ucode > `= [ | scan]` diff --git a/xen/arch/x86/time.c b/xen/arch/x86/time.c index 0c1badc..c1255db 100644 --- a/xen/arch/x86/time.c +++ b/xen/arch/x86/time.c @@ -477,6 +477,10 @@ uint64_t ns_to_acpi_pm_tick(uint64_t ns) /************************************************************ * PLATFORM TIMER 4: TSC */ +static unsigned int __read_mostly tsc_flags; + +/* TSC is reliable across sockets */ +#define TSC_RELIABLE_SOCKET (1 << 0) /* * Called in verify_tsc_reliability() under reliable TSC conditions @@ -492,7 +496,7 @@ static s64 __init init_tsc(struct platform_timesource *pts) ret = 0; } - if ( nr_sockets > 1 ) + if ( nr_sockets > 1 && !(tsc_flags & TSC_RELIABLE_SOCKET) ) { printk(XENLOG_INFO "TSC: Not invariant across sockets\n"); ret = 0; @@ -1851,6 +1855,7 @@ int hwdom_pit_access(struct ioreq *ioreq) /* * tsc=unstable: Override all tests; assume TSC is unreliable. * tsc=skewed: Assume TSCs are individually reliable, but skewed across CPUs. + * tsc=stable:socket: Assume TSCs are reliable across sockets. */ static void __init tsc_parse(const char *s) { @@ -1861,9 +1866,9 @@ static void __init tsc_parse(const char *s) setup_clear_cpu_cap(X86_FEATURE_TSC_RELIABLE); } else if ( !strcmp(s, "skewed") ) - { setup_clear_cpu_cap(X86_FEATURE_TSC_RELIABLE); - } + else if ( !strcmp(s, "stable:socket") ) + tsc_flags |= TSC_RELIABLE_SOCKET; } custom_param("tsc", tsc_parse);