Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp577167imm; Fri, 29 Jun 2018 02:55:13 -0700 (PDT) X-Google-Smtp-Source: AAOMgpe0N5i+1O+GXsU/4YHMU6iv75hhxPLrg3etWY5sqn/zV8wRNSEkV/GgjUQFTd4BM5VYi9R3 X-Received: by 2002:a65:4541:: with SMTP id x1-v6mr7151146pgr.26.1530266113171; Fri, 29 Jun 2018 02:55:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530266113; cv=none; d=google.com; s=arc-20160816; b=0Qh875//Dxa1h0jWAta/0a1GqcGPX5qKFOMAP1S9FyGGxVBX1/pgRbvAVrESJb4twX jR3I3lF7rnaIin4IzKjGOVF4w6gg1yj4XeYlCtn+knWCNlkBvPjzQ8sCVoiATwt2RSX7 Xwjn3QMYLQn/zYzRpJ9AIC76SShcUZJXK2To7MpdQjWD6QycxXZpBxDp163m1BWVEWx5 Om9hJhsgW+ZcNKFJgpVjByisxDGlh/j/rfwZ2UDXoKZ6R8SXTiHJU+UgX7AxB2gWowXv 64kIj8AaypPFWvrGjJtSPG02lovBaX36LanzfYCFJqRwkLkicFERkMYcrDNJ/CLcVDPO VUfA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=csuUhpURCuP43mF5GT7WwC/kQ9wb3Mw17ZG0z/BvsbQ=; b=cxKiJ6znrbrqwBymg4nm55AjfypovtTg/0pci1A0Fv7V3rfu4dkDVTUHDNOfL1lCod SMdglW3OfFREGM+T/6irRimGT/kx18SCZ/gt6SWpC3Q49PBeGtGELS6L3fmhO9BbR39x c07nQz9lXUK7M549Un1tI3LtvEyFNjitYEb/9Hr2YCG5NpSSoI3VwYIgUtje3B66vHg9 1KaR9fgj6vUfMVMK7n1RKt8PDpZI5q3Txbyql7wM8T1zJY2vZZ4gb6lOJoHz5qdN7X84 GxH53fc+cWL7am1MEsOFdLyNpN3/yxEJxWONXJrbCg0Gyg/j9Dor7w4652cwwcgVIVvu qsWQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2017-10-26 header.b="hiVJV//k"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r9-v6si7493726pgp.591.2018.06.29.02.54.58; Fri, 29 Jun 2018 02:55:13 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2017-10-26 header.b="hiVJV//k"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935366AbeF2JAc (ORCPT + 99 others); Fri, 29 Jun 2018 05:00:32 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:38356 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932894AbeF2JAM (ORCPT ); Fri, 29 Jun 2018 05:00:12 -0400 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w5T8rVHf089858; Fri, 29 Jun 2018 08:58:03 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=date : from : to : cc : subject : message-id : references : mime-version : content-type : in-reply-to; s=corp-2017-10-26; bh=csuUhpURCuP43mF5GT7WwC/kQ9wb3Mw17ZG0z/BvsbQ=; b=hiVJV//k4oO4xObWerNJRugPoyHUlze+UN8eSV/wC7SoAq5PuaMZ6QHO8C4DqI3bkw8r TgAThnR5X+Br3uRKc5FoIITqNJ4VHl91HwFuSmHZh6mPs4E0oPjbmG+cks6QWOgqOff3 e1fi0PG3QoYm3e5lcfwx7MlS//Sbm68bctpwA3V0qtfp/NPISAs4oNzVhdluf45HmIxq fxwkPPa/Al/7teSYbJk3cmzrWR1bT3Cdni6wcikr4fJ6ZETTfrtsirDggI3D+CKb8orJ fyci4xwaNQMo6BfSHGBlz0Rzwmzue4fz9pok+Sn+ahpufngfCMj4uJ6kdIwDrPKuH2R3 PA== Received: from userv0022.oracle.com (userv0022.oracle.com [156.151.31.74]) by aserp2120.oracle.com with ESMTP id 2jukhsnna1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 29 Jun 2018 08:58:02 +0000 Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by userv0022.oracle.com (8.14.4/8.14.4) with ESMTP id w5T8w0De019504 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 29 Jun 2018 08:58:00 GMT Received: from abhmp0014.oracle.com (abhmp0014.oracle.com [141.146.116.20]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id w5T8vuWY012289; Fri, 29 Jun 2018 08:57:57 GMT Received: from xakep.localdomain (/73.69.118.222) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 29 Jun 2018 01:57:56 -0700 Date: Fri, 29 Jun 2018 04:57:52 -0400 From: Pavel Tatashin To: Thomas Gleixner Cc: Steven Sistare , Daniel Jordan , linux@armlinux.org.uk, Martin Schwidefsky , Heiko Carstens , John Stultz , sboyd@codeaurora.org, x86@kernel.org, LKML , mingo@redhat.com, "H. Peter Anvin" , douly.fnst@cn.fujitsu.com, Peter Zijlstra , Prarit Bhargava , feng.tang@intel.com, Petr Mladek , gnomes@lxorguk.ukuu.org.uk, linux-s390@vger.kernel.org, andriy.shevchenko@linux.intel.com, boris.ostrovsky@oracle.com, pbonzini@redhat.com Subject: Re: [PATCH v12 09/11] x86/tsc: prepare for early sched_clock Message-ID: <20180629085752.zkbxlwc2rzlm63lk@xakep.localdomain> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20180622 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=8938 signatures=668703 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1806210000 definitions=main-1806290099 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 18-06-29 09:30:10, Thomas Gleixner wrote: > On Thu, 28 Jun 2018, Pavel Tatashin wrote: > > On Thu, Jun 28, 2018 at 11:23 AM Thomas Gleixner wrote: > > Hi Thomas, > > > > In addition to above, we have xen hvm: > > > > setup_arch() > > ... > > init_hypervisor_platform(); > > x86_init.hyper.init_platform(); > > xen_hvm_guest_init() > > xen_hvm_init_time_ops(); > > Duh. Missed that completely. > > > ... > > tsc_early_delay_calibrate(); > > tsc_khz = x86_platform.calibrate_tsc(); == xen_tsc_khz() > > ... > > > > Which works early. > > > > So, what should we do with xen, which seems to be the only platform > > that would provide different tsc frequency early and late, because of > > different calibration method? > > Fix it? I have no idea why XEN has two variants of the scheme and I neither > have a clue why the KVM clock stuff is late. kvm clock I have fixed in my series. http://lkml.kernel.org/r/20180621212518.19914-5-pasha.tatashin@oracle.com It was late because, it depended on memblock, which is initialized later, after e820 ranges are read. So, after my series kvm clock will work right after init_hypervisor_platform, the same as with most other hypervisors. With xen, it is a little more challenging: I do not have a hardware configured to run xen to test it. On the other hand, most likely that tsc_early_delay_calibrate() now fails to calibrate tsc on xen, and calibrates correctly later in tsc_init(). I doubt, that we can use CPUID method to determine tsc frequency on xen cpu. Anyways, that would be accidental behavior. To make xen clock available early, we need HYPERVISOR_shared_info. So, at least that part of xen_setup_shared_info() must be called/available from init_hypervisor_platform(): void xen_setup_shared_info(void) { set_fixmap(FIX_PARAVIRT_BOOTMAP, xen_start_info->shared_info); HYPERVISOR_shared_info = (struct shared_info *)fix_to_virt(FIX_PARAVIRT_BOOTMAP); xen_setup_mfn_list_list(); ... Which, I have no idea if it is possible, or safe to do. For now, in my series, I would like check in tsc_early_init() if we are running xen, and set tsc_khz to 0 if so. Later in tsc_init() we will get a proper calibration. The question is how to make this check least intrusive. Pavel