Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp2348257imm; Mon, 16 Jul 2018 06:37:22 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfCpl2sNfEBSaPpD7Ik3Qr1n2/CgrKdN7dyAceQ6IY8F+t0I7pVB/9PwUBUMao9VVOy2kdO X-Received: by 2002:a17:902:8f82:: with SMTP id z2-v6mr16736841plo.203.1531748242015; Mon, 16 Jul 2018 06:37:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531748241; cv=none; d=google.com; s=arc-20160816; b=P0OJYIPlc2m6K/GFNYDapIxZwohSQjPBwsjuuXa8qfNUs7BtYE+tImoEngketQIoyM hX2cQWv9G/QjuiJWtvu2WX5MOnkWXgtVGJdJEgmbC5CKqRAR8i7MCOdc7onDKzeSlJZk k9Tgh/XTfCfeFTUSULdO0Zd827vxwEaXpusL95WxRo9cMibeaL4wmdK9Yx+32BhIZ+nJ MHv1FWiaXah0a+3W5oQBAkU3A3mXOy+BwMjPEfl5QIOpeI7VmtdDfMW4VlLyhmgsYoyM 7+M0tY36xqd7xxwukL02Ilyn6FbQLHTbdM7GHZYj5YTG+Dq0rpDlQsgdkzvgOfB3RRqg cwmg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature :arc-authentication-results; bh=OQKKuSNbv+RWJeKT49Mom/AN79Yj+PRhrcHGtNNecus=; b=UYI8CAMQwVEJDY8pVgVIPKWhwxBxiMCdCnlRubf06QPWdNQ+5qmlHIcc19qLrGdkkk G5GdjVs0ot88c3yqGgO6DZMrULWqHEPQVQH9gtI9wf2MZnKn1QWpShhfKrE/rtSojfuW 3y3hwWRNaYJ5OBOmal0g212kZ+IZnaTSMp9xDi/91jJmOPlNFlS3i/49/S07m/hRIc/Y l3/jrFkgFl4KUL69S8XFbbMI8ImDUoPbsFig6HpHQofRTW+apZXhwZBCIND+bre6cYC1 Xw8oZTrsvqSfaVhSkrfqZ2jC9osliz/uHYZT1OtL1r9PQz8wISCnuWxH83W4g2saCmcX +rqg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b="ZS+8/efr"; 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 n38-v6si29900023pgb.536.2018.07.16.06.37.07; Mon, 16 Jul 2018 06:37:21 -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-2018-07-02 header.b="ZS+8/efr"; 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 S1728417AbeGPODu (ORCPT + 99 others); Mon, 16 Jul 2018 10:03:50 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:43214 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728037AbeGPODu (ORCPT ); Mon, 16 Jul 2018 10:03:50 -0400 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w6GDYE7V159954; Mon, 16 Jul 2018 13:36:19 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=mime-version : references : in-reply-to : from : date : message-id : subject : to : cc : content-type; s=corp-2018-07-02; bh=OQKKuSNbv+RWJeKT49Mom/AN79Yj+PRhrcHGtNNecus=; b=ZS+8/efrfwf5k9vyUkKUzaJTuye3H4inv71Ot5EfzA9slYQSfVAX/SD+P5vk2r4GxqoY UtgUoo5CL3vhF+D0w6UgmuwWR9tg6byWqyEOh2nb/TFb9wgygJn8BNPKyJ20d5ZHmrmn XQBz0BzX6iOWBXFDYxiRfs11UiROyC8n9EQcELUP72ENKfMODfSEoo3q2xNNqQWVy05b IY0zfMslt8jijP9fed98sKuvEMGKsxiE/A1wcgm3Kn5XLLW6YGz1i8vDORhRdqqDmQzA aBrHP/tdBJ1fVgCqpdurkz9+nVDpTdqyUh7p0N3ScdrULbk6lMkP7hH9MQdrGCyZ5maI DQ== Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71]) by userp2120.oracle.com with ESMTP id 2k7a3jmesc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 16 Jul 2018 13:36:19 +0000 Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userv0021.oracle.com (8.14.4/8.14.4) with ESMTP id w6GDaGfX031961 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 16 Jul 2018 13:36:17 GMT Received: from abhmp0009.oracle.com (abhmp0009.oracle.com [141.146.116.15]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id w6GDaG68006938; Mon, 16 Jul 2018 13:36:16 GMT Received: from mail-oi0-f44.google.com (/209.85.218.44) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 16 Jul 2018 06:36:16 -0700 Received: by mail-oi0-f44.google.com with SMTP id w126-v6so74779622oie.7; Mon, 16 Jul 2018 06:36:16 -0700 (PDT) X-Gm-Message-State: AOUpUlGzRbSTQ+KFJgoW0LnL5NsKDh7RXin1/H7njrpWCqshdgpNISFg ji/R/KUP6vhHT7hQFi4MiGm8RS08khKB38hJ+Bo= X-Received: by 2002:a54:4f88:: with SMTP id g8-v6mr19410820oiy.191.1531748175811; Mon, 16 Jul 2018 06:36:15 -0700 (PDT) MIME-Version: 1.0 References: <20180712000419.5165-1-pasha.tatashin@oracle.com> <20180712000419.5165-14-pasha.tatashin@oracle.com> <928b8490-89d2-46a3-8596-16751bcd12db@cn.fujitsu.com> <01812492-b88b-4436-570b-ef776eaafc6a@cn.fujitsu.com> In-Reply-To: <01812492-b88b-4436-570b-ef776eaafc6a@cn.fujitsu.com> From: Pavel Tatashin Date: Mon, 16 Jul 2018 09:35:40 -0400 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v13 13/18] x86/tsc: calibrate tsc only once To: douly.fnst@cn.fujitsu.com Cc: Steven Sistare , Daniel Jordan , linux@armlinux.org.uk, schwidefsky@de.ibm.com, Heiko Carstens , John Stultz , sboyd@codeaurora.org, x86@kernel.org, LKML , mingo@redhat.com, tglx@linutronix.de, hpa@zytor.com, peterz@infradead.org, prarit@redhat.com, feng.tang@intel.com, Petr Mladek , gnomes@lxorguk.ukuu.org.uk, linux-s390@vger.kernel.org, boris.ostrovsky@oracle.com, jgross@suse.com Content-Type: text/plain; charset="UTF-8" X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=8955 signatures=668706 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=3 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-1807160160 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jul 16, 2018 at 5:33 AM Dou Liyang wrote: > > > > At 07/13/2018 07:30 PM, Pavel Tatashin wrote: > > On Fri, Jul 13, 2018 at 3:24 AM Dou Liyang wrote: > >> > >> > >> At 07/12/2018 08:04 AM, Pavel Tatashin wrote: > >>> During boot tsc is calibrated twice: once in tsc_early_delay_calibrate(), > >>> and the second time in tsc_init(). > >>> > >>> Rename tsc_early_delay_calibrate() to tsc_early_init(), and rework it so > >>> the calibration is done only early, and make tsc_init() to use the values > >>> already determined in tsc_early_init(). > >>> > >>> Sometimes it is not possible to determine tsc early, as the subsystem that > >>> is required is not yet initialized, in such case try again later in > >>> tsc_init(). > >>> > >>> Suggested-by: Thomas Gleixner > >>> Signed-off-by: Pavel Tatashin > >> > >> Hi Pavel, > >> > >> Aha, a complex solution for a simple problem! ;-) And I did find any > >> benefits of doing that. did I miss something? > > > > Hi Dou, > > > > I had this in previous version: init early, and unconditionally > > re-init later (which required to resync sched clocks for continuity, > > and check for some other corner cases). Thomas did not like the idea, > > as it is less deterministic: it leads for code to work by accident, > > where we might get one tsc frequency early and another later, and so > > on. The request was to initialize only once, and if that fails do it > > again later. This way, if early initialization is broken, we will know > > and fix it. > > > > Hi Pavel, > > Yes, right, I have seen the purpose in v12. > > >> > >> As the cpu_khz and tsc_khz are global variables and the tsc_khz may > >> be reset to cpu_khz. How about the following patch. > > > > Could you please explain where you think this patch can be applied, > > and what it fixes? > > > > This patch is just an simple alternative to realize what you want in > your patch. your patch is also good but complex, and need some scrub. > eg: > - Is it suitable to using the WARN_ON() > - the name of determine_cpu_tsc_frequncies() function, > s/frequncies/frequencies/. BTW, How about tsc_calibrate_frequencies() > - ... > > BTW, before this patch, seems we need make sure xen should work well, I > can investigate and try to test if we can also move the pagetable_init() > to the front of tsc_early_init() for you. v13 has xen patches, so xen timestamps work early as well now. Thank you, Pavel