Received: by 2002:ac0:98c7:0:0:0:0:0 with SMTP id g7-v6csp414317imd; Sat, 3 Nov 2018 03:05:03 -0700 (PDT) X-Google-Smtp-Source: AJdET5fAShOSs9o7x93AEaZUW2H3qL+B9sI8cSlwtCAFDPLY+WjLCcbOQL0fis87jbMMAIgXLfqo X-Received: by 2002:a63:e84c:: with SMTP id a12mr4600598pgk.241.1541239503237; Sat, 03 Nov 2018 03:05:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1541239503; cv=none; d=google.com; s=arc-20160816; b=tM/ToRu3XfK9IzhVQrJCw9c21qE46q9BnYDLfrsuHPqZ+xaKwltJnCAT9a38CnF60g DFeRqo2jsn2aQNUQhKR3Lxl6rlir3TEgCHqF0nN5seM3722Y/6S07scxkotoCVITJCWn VZQXO4+eJ4mqV+XvjMzcax4ZFSzw4+4o2fD9vcbk1Oem712GGbTLTIrSxpbvi0nQBhxB gyGlsO2lnTc1lqdfopO6TccdV9sEPdABStBsf2WOmuUW8hEnUSRYZudKpAZcuQQdH5H3 WuxlwWREF7+DxhsVWSGmmZML1kvKdVS0CleJZJST1szdCR7fkcWqUsFmpzTWSQ6UG2YX ggVQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :message-id:in-reply-to:subject:cc:to:from:date; bh=YXnxgyAzicl5QHUxs9UlCXq462txDvf4JkCEG3LWZd4=; b=0Qsrjd3MDgrdeKDTmZrX2lZNpNCIHp34zbXKqKZ6qy8pkJrACu3ii6M4plZgjdsqde sctoxic0ECnPym2UvXBszYzWyYT7xh6Rdd/c5ZEYJJzD1BNfDQfc77gJs4R5tUM/ZlhP B3cG5JrNCS907okPfcAOaakuxx/eFnHxpO11EYOstGrx19scVXbmjEw4fBI2GRMauNBY fP9rqv9XyrxrX5zQ6Ag/3KzT8QiBx2m89GBbM5HYqwGi7Q8Sz0ORWOb6YDmJStxIJrYo COlb2u+yTh428pwkhN7aSrWoKIigVjBKvDtlWYtfsebBIVLjyNxx9aalaOG5RCrBpkwh 3jjA== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x11-v6si19371358pgp.592.2018.11.03.03.04.48; Sat, 03 Nov 2018 03:05:03 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728071AbeKCTPI (ORCPT + 99 others); Sat, 3 Nov 2018 15:15:08 -0400 Received: from Galois.linutronix.de ([146.0.238.70]:60081 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726632AbeKCTPI (ORCPT ); Sat, 3 Nov 2018 15:15:08 -0400 Received: from p5492fe24.dip0.t-ipconnect.de ([84.146.254.36] helo=nanos) by Galois.linutronix.de with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1gIsmp-00040N-6N; Sat, 03 Nov 2018 11:04:11 +0100 Date: Sat, 3 Nov 2018 11:04:10 +0100 (CET) From: Thomas Gleixner To: Daniel Vacek cc: x86@kernel.org, Ingo Molnar , Borislav Petkov , "H. Peter Anvin" , LKML , Peter Zijlstra Subject: Re: [PATCH] tsc: make calibration refinement more robust In-Reply-To: Message-ID: References: <1541085133-32534-1-git-send-email-neelx@redhat.com> User-Agent: Alpine 2.21 (DEB 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Linutronix-Spam-Score: -1.0 X-Linutronix-Spam-Level: - X-Linutronix-Spam-Status: No , -1.0 points, 5.0 required, ALL_TRUSTED=-1,SHORTCIRCUIT=-0.0001 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Daniel, On Fri, 2 Nov 2018, Daniel Vacek wrote: > On Thu, Nov 1, 2018 at 4:34 PM, Thomas Gleixner wrote: > >> -#define MAX_RETRIES 5 > >> -#define SMI_TRESHOLD 50000 > >> +#define MAX_RETRIES 5 > >> +#define TSC_THRESHOLD (tsc_khz >> 5) > > > > This breaks pit_hpet_ptimer_calibrate_cpu() because at that point tsc_hkz is 0. > > That did not show up with my testing, sorry. I guess > pit_calibrate_tsc() never failed for me. Hmm, actually it looks like > quick_pit_calibrate() does the job for me so > pit_hpet_ptimer_calibrate_cpu() is likely not even called. Right. It's only called when quick calibration fails. Testing does not replace code inspection :) > Would this: > > #define TSC_THRESHOLD (tsc_khz? tsc_khz >> 5: 0x20000) > > work for you instead? Or alternatively at some point when chasing this > down I used: > > #define TSC_THRESHOLD (0x10000 + (tsc_khz >> 6)) > > The first one seems better though. I can send v2 next week if you like it. Can you please avoid hiding the logic in a macro? Just use a local variable: u64 thresh = tsc_khz ? tsc_khz >> 5 : TSC_DEFAULT_THRESHOLD; and use that in the comparison. Thanks, tglx