Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp1243941ybb; Fri, 20 Mar 2020 16:24:37 -0700 (PDT) X-Google-Smtp-Source: ADFU+vv3nm58rX0SZ+msmK0R5paJsuy7tcfA1o8e3escNDsaQQGkibNpH+nDgAOEcwxR30HFV8La X-Received: by 2002:aca:2801:: with SMTP id 1mr8768766oix.168.1584746677564; Fri, 20 Mar 2020 16:24:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584746677; cv=none; d=google.com; s=arc-20160816; b=Odx/1q0tuqzB2bqoRXclv6dW3GBYG4jcxnwyF3D7wizW1WcjtrhgHeik3Wxq7D+6KU umUBGQemNX5NgEd44TQP+uSV7MsfP7E5a4/RJJGDYM4NrUwhhWUWrGj7FpJZfC1YgMU7 CSu3i99ynOzYulWRyd/R8QPIW67m4zuR/QnprQ6vWCL+fcECE3F9Cclzupk0U7OQZCvh zjGNgcKWhCtqwRY99wIa7u2g+cY0rF5S2dGP5Be/EZbI02iF+S1kjmr/L/DHz4I8YhVO ZAJTZI6wDTcTv9++b0cRhn6ZmhuxIFgJMAarcrVIAC8/bPEOFdFUEAYpbVIcLgkKzYY+ Zn+g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:references :in-reply-to:subject:cc:to:from; bh=AsL/V8i1b3EfexabJNB5w14K+jXO6awUYqe66edrOGU=; b=PzSvB0XY6obssgLaSFPBNzkgQ2LlSnFx/Wnmv5yfNjT75gO2UkIi6d9WtZmNic0J+z WXpHer6oG9j7/kcMWuFSLuC9vvD+jV0X0gvDhiEi9eD5NLZkyA1IsAIQlqjKAskcbKoo W13zePGxe1V2il5BoG+xHxez8EWzDvwpNSwQhsYqq3qjK/S/3lTFNLFk6BjnK4Qgykq1 dx5P0ZRBATv9mZCFbvMu3goXhtRtFvlww9TRiagGmGeHnM38s6Y7TYu7QkxNxpIrKBnW +8yEqZrnXrAE3tc4WSRekGpyKyZcCQ/xDDzMWrHmR61SgkJ9HI7XSU/6AK+RLlohcI7J 2rXQ== 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 a1si3724638otr.322.2020.03.20.16.24.25; Fri, 20 Mar 2020 16:24:37 -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 S1727032AbgCTXYF (ORCPT + 99 others); Fri, 20 Mar 2020 19:24:05 -0400 Received: from Galois.linutronix.de ([193.142.43.55]:37647 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726738AbgCTXYF (ORCPT ); Fri, 20 Mar 2020 19:24:05 -0400 Received: from p5de0bf0b.dip0.t-ipconnect.de ([93.224.191.11] helo=nanos.tec.linutronix.de) by Galois.linutronix.de with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1jFQzX-0005ew-Fg; Sat, 21 Mar 2020 00:23:51 +0100 Received: by nanos.tec.linutronix.de (Postfix, from userid 1000) id D71B1FFC77; Sat, 21 Mar 2020 00:23:50 +0100 (CET) From: Thomas Gleixner To: Andy Lutomirski Cc: Andy Lutomirski , Kyung Min Park , X86 ML , LKML , Ingo Molnar , "H. Peter Anvin" , Greg KH , Andi Kleen , Tony Luck , "Raj\, Ashok" , "Ravi V. Shankar" , Fenghua Yu Subject: Re: [PATCH v2 2/2] x86/delay: Introduce TPAUSE delay In-Reply-To: References: <1584677604-32707-1-git-send-email-kyung.min.park@intel.com> <1584677604-32707-3-git-send-email-kyung.min.park@intel.com> <877dzf4a8v.fsf@nanos.tec.linutronix.de> Date: Sat, 21 Mar 2020 00:23:50 +0100 Message-ID: <87zhcaobjt.fsf@nanos.tec.linutronix.de> MIME-Version: 1.0 Content-Type: text/plain 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 Andy Lutomirski writes: > On Fri, Mar 20, 2020 at 3:00 AM Thomas Gleixner wrote: >> >> Andy Lutomirski writes: >> > On Thu, Mar 19, 2020 at 9:13 PM Kyung Min Park wrote: >> >> void use_tsc_delay(void) >> >> { >> >> - if (delay_fn == delay_loop) >> >> + if (static_cpu_has(X86_FEATURE_WAITPKG)) { >> >> + delay_halt_fn = delay_halt_tpause; >> >> + delay_fn = delay_halt; >> >> + } else if (delay_fn == delay_loop) { >> >> delay_fn = delay_tsc; >> >> + } >> >> } >> > >> > This is an odd way to dispatch: you're using static_cpu_has(), but >> > you're using it once to populate a function pointer. Why not just put >> > the static_cpu_has() directly into delay_halt() and open-code the >> > three variants? >> >> Two: mwaitx and tpause. > > I was imagining there would also be a variant for systems with neither feature. Oh I see, you want to get rid of both function pointers. That's tricky. The boot time function is delay_loop() which is using the magic (1 << 12) boot time value until calibration in one way or the other happens and something calls use_tsc_delay() or use_mwaitx_delay(). Yes, that's all horrible but X86_FEATURE_TSC is unusable for this. Let me think about it. Thanks, tglx