Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp784954rwd; Tue, 16 May 2023 07:43:12 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7Jmt/gniafsb+0JwndVD2pFHYJUN2zszmXNxJDJGxi0aY5Fp7DswEq4Rl5MbkIMCJBf85f X-Received: by 2002:a05:6a20:3d17:b0:102:5f75:91ea with SMTP id y23-20020a056a203d1700b001025f7591eamr28415585pzi.47.1684248192482; Tue, 16 May 2023 07:43:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684248192; cv=none; d=google.com; s=arc-20160816; b=z/0WhmF/RAq0z7EI9UqY7suWGds0DIMqDvVHziuvr7i6NOXqSquTfwBB/pcScjQpSX xG6iek7HB1RhFUswHRcUhSrxYiDbCsXSAXYjJ+f+cmP6t+iftyH7fNvi7rAfL9C4iYdC Bw615Q1yFoLnP8058uAgZD4mKo0yiBdr14i26vxyzsQcEtn8tLKl8ZaRZaUyl7MkgS/R TI5aO6GXoPyi1FifkAHtrZ6+bA0e0FWAsiewPqwt7iZa/3yhzUezwY68wXzw0C45jMkX Hqfjzjhys6IjJj5TfAD2Ow2Zz8HV4N/M7Z2qejLegTh8/3US2nqkhiFYOcPD0v1MU/0j BBYg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:in-reply-to:subject :cc:to:dkim-signature:dkim-signature:from; bh=FkXFAZYIh0haPSOcnt1eOZKRDhLeWlVCTunLq/bj9vc=; b=dgFwd1dF/k4fxpzilVVScRm+SFSvu9Wfir9br6OfNsUZ0q9YaWvubouJkUn+/wfxwi f4KPqhw4afjy8z3uTTgpN/1lzhBkJLjIHsiApc0YZu97erOGvpF94oOU5MdNo5H4sKaD b74fltSFkYw1nrfL1Ltol1CIcAin+o3gccJkUEMRv6lLUTT2B1gtnnZpVFtriwPSu33Z EjVpds9C6n8UgmwhVWJPtpVJXW150Up8vUIdv+BxBZrpQaJeT7PZLpsD+MEEbCtyztaq HRHrmlTq95z008pGgHWfDpua4XYfWFLm8bC2QXJ49Wu+Yl6H8oLA2sMFx+75739dG6Jf ElnQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=B5v0P+HY; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h3-20020a633843000000b0053072cbae69si13030747pgn.169.2023.05.16.07.42.57; Tue, 16 May 2023 07:43:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=B5v0P+HY; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233928AbjEPOUz (ORCPT + 99 others); Tue, 16 May 2023 10:20:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56424 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233878AbjEPOUb (ORCPT ); Tue, 16 May 2023 10:20:31 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0CFBA7ED9 for ; Tue, 16 May 2023 07:20:18 -0700 (PDT) From: Thomas Gleixner DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1684246809; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to; bh=FkXFAZYIh0haPSOcnt1eOZKRDhLeWlVCTunLq/bj9vc=; b=B5v0P+HYuHs8awq1DZLsQ4kqlnyl0mhVnxUEkFVi9MqzUnYnNGkeqTxrNIotxSalBFC10+ Hlw0xFA09mL3+td7bpsJferpf2xy8sfE9T26w7EHciXWaxM8cOR8rXGVJSR/BMgG9PUft9 zdg1qqcpkMU6y1JYIuIRfudoedFcUqPqKt8WmYGPNM/NBZxO03Aky7h5dKqoVjTXiJ+QCg 85jYUfWlWtAFrILeTDLw1N7e+G+aOt7CNIINPu9PO3ADmJxmHSykCBeixdH7HKJMuRcxO6 aK0Vz4KlXz8wTPGFQsGU/c+hg/247pS2TaHn82bALtxNpRF3fyU6pe5/Khlz2w== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1684246809; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to; bh=FkXFAZYIh0haPSOcnt1eOZKRDhLeWlVCTunLq/bj9vc=; b=KVIg+5re+0nftM7WOpVd6795CiyX2EXG8Zw4zyBUZ1n/PoatUkzTue/l2YJ8qfmzO+OGGR ssOKcZ4Nhad2cABA== To: Rong Tao Cc: rtoax@foxmail.com, Rong Tao , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , linux-kernel@vger.kernel.org Subject: Re: [PATCH] x86/vdso: Use non-serializing instruction rdtsc In-Reply-To: Date: Tue, 16 May 2023 16:20:09 +0200 Message-ID: <87ttwc73za.ffs@tglx> MIME-Version: 1.0 Content-Type: text/plain X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Rong! On Tue, May 16 2023 at 14:52, Rong Tao wrote: > Replacing rdtscp or 'lfence;rdtsc' with the non-serializable instruction > rdtsc can achieve a 40% performance improvement with only a small loss of > precision. That rdtsc_ordered() is not there to achieve precision. It's there to guarantee correctness. The correctness requirement is that reading clock MONOTONIC is strictly monotonic, i.e. there is no way that you can observe time going backwards. Neither locally nor accross CPUs. As you explained: > The RDTSC instruction is not a serializing instruction. It does not > necessarily wait until all previous instructions have been executed > before reading the counter. Q: What guarantees that this does not speculate deep enough to actually make time go backwards? A: Nothing Conclusion: The fence stays, unless you can prove the contrary under all circumstances and microarchitecture generations. Thanks, tglx