Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp1373611rwd; Thu, 8 Jun 2023 17:23:55 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5A+2p5gj6BfaFgnctzumuqPv1iK1RkF3bXQVOf3F5g0Lnp+h7YhaITMIQyqVqYNS2K1Fjh X-Received: by 2002:a17:902:f68a:b0:1ad:d542:6e14 with SMTP id l10-20020a170902f68a00b001add5426e14mr236104plg.12.1686270235290; Thu, 08 Jun 2023 17:23:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686270235; cv=none; d=google.com; s=arc-20160816; b=UB9qqgXuGTkfNr+yXHwAHZb51BIv1c4Mx1l71T+NrimgwIiXfZu23ZLNIP3zZRU4y4 vXpZeuseyf4y0xTeL6SEuf5aE11Yrs1sFxk+lnoxuPInyECv712ipmp48rPJLshBC3wA FAEQd5O2rzzbtXiCYNjq8nLJfrPQjWWeMvp8b65xlKQiAZrN8dQfVQbyWWv+BaXpSTbB bOgQZOqH/w5LRTJLBNsWtaguwd+5Prp854mn0lfYrAQ98eq+SXzQmUkhaRBLtb10cGNK 5kvLLHLoDWx9juVjHGuLss/UgnCt66lKvZxuvL94VKhdfPg1lZlO8mla06zxq2/lmNtV u++Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature:dkim-filter; bh=eETL6+MlMl0BOovD6hR1LxTwJy34pjipmc6N88BiyoY=; b=pCeGGcZm+P8AXd592oYHOH/ykQ2yx34OHkqerMcskp8ReuGDWSp2CYrJoIWb5KuXQ4 wiADMAvN5C1ly0moO/zuTsT1y2WmVzjftm71dQ9gkEKlN9/oUr/FksK1hNm7zellk6/g 5hMp+T+fqbITnzWUa8eLk/diJVz3HkDe9K3PulSkbPc2VTbA8VWwAB6+KXzJdBzbf7In 2fdghHmhs7W2N9kkNa1Hl2XA8xeR6cZEuxzogm9EyHbcUorJkDbYdkfjYS2A5Q6htWSu y7U0Fv2q1ETqdNRiSK76mQuEwerG8wK88wnIBuk+Ih3Mdv16/P/oaYuN/AW6yW2J/06e xxfg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@zytor.com header.s=2023051001 header.b=nkA2WU9V; 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=fail (p=NONE sp=NONE dis=NONE) header.from=zytor.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id km4-20020a17090327c400b001b212ecbcf8si1698773plb.528.2023.06.08.17.23.43; Thu, 08 Jun 2023 17:23:55 -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=fail header.i=@zytor.com header.s=2023051001 header.b=nkA2WU9V; 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=fail (p=NONE sp=NONE dis=NONE) header.from=zytor.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237401AbjFIAPX (ORCPT + 99 others); Thu, 8 Jun 2023 20:15:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41178 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229981AbjFIAPW (ORCPT ); Thu, 8 Jun 2023 20:15:22 -0400 Received: from mail.zytor.com (unknown [IPv6:2607:7c80:54:3::138]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9229C2D68; Thu, 8 Jun 2023 17:15:21 -0700 (PDT) Received: from [172.27.2.41] ([73.231.166.163]) (authenticated bits=0) by mail.zytor.com (8.17.1/8.17.1) with ESMTPSA id 3590EBwb1069072 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NO); Thu, 8 Jun 2023 17:14:11 -0700 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.zytor.com 3590EBwb1069072 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zytor.com; s=2023051001; t=1686269655; bh=eETL6+MlMl0BOovD6hR1LxTwJy34pjipmc6N88BiyoY=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=nkA2WU9VUv+xW1YPZFGnwcSq6G/5AFtmFSKNwIjsqdU8yMvYEqjQNTyqX7SwXiVdH NBPYrXo3KQQt3sVa827d69La1n74ytlWcVlVajaL8C9Aa/GJKWLmPC3I3k3ZRoQWtF HHHDwZTANxoHh6iphKSW5D6CL/SzDM9gNwVtD3aUxeaG202qL0zCOAk9RggyxHAG7G pSI3NZy+HlPZ5+e0J6tLFutQ8N4LVDO6Qp1aGpHVuSIPQEJGVUEXBQFICFnTAJYA7E rz8EFfbtzKrUHpXLd2ssOwJTlvTo9yTLlglJt1XEYPXrhhZ3S8xKGXp9RyefMhXdW+ BEz71wLR4dAwQ== Message-ID: <98718c79-d589-3689-3c59-6ca158148641@zytor.com> Date: Thu, 8 Jun 2023 17:14:10 -0700 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.10.0 Subject: Re: Direct rdtsc call side-effect Content-Language: en-US To: David Laight , "'Thomas Gleixner'" , Muhammad Usama Anjum , Jonathan Corbet , Ingo Molnar , Borislav Petkov , Dave Hansen , "maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT)" , "open list:DOCUMENTATION" , open list , "Guilherme G. Piccoli" Cc: Steven Noonan , "kernel@collabora.com" References: <6719fb05-382c-8ec4-ccda-72798906a54b@collabora.com> <87mt1jeax1.ffs@tglx> <353732783fde46919fdcf698c326b7ed@AcuMS.aculab.com> <87jzwi55qo.ffs@tglx> <4ea6e82c-4761-e0c9-3e75-8ec39eecb30a@zytor.com> From: "H. Peter Anvin" In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,NICE_REPLY_A,SPF_HELO_PASS,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 On 6/6/23 01:23, David Laight wrote: > > IIRC the x86 performance counters aren't dependent on anything > so they tend to execute much earlier than you want. > OTOH rdtsc is likely to be synchronising and affect what follows. > ISTR using rdtsc to wait for instructions to complete and then > the performance clock counter to see how long it took. > RDPMC and RDTSC have the same (lack of) synchronization guarantees; you need to fence them appropriately for your application no matter what. -hpa