Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp1814426rwd; Thu, 1 Jun 2023 23:59:08 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5W03UluL/BQipbDXm0tomcpg8uc/NTY7GkAFojagA1iA42Ba72kHf+Q/jVofbI0YoRFvus X-Received: by 2002:a05:620a:1b83:b0:75b:23a1:3605 with SMTP id dv3-20020a05620a1b8300b0075b23a13605mr13877748qkb.22.1685689147930; Thu, 01 Jun 2023 23:59:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685689147; cv=none; d=google.com; s=arc-20160816; b=HKY95SPwGW4TkPso0TQEe2z2VcuYdVz36WWnO0UJm3zAt8cpMEdq084bywScQvsBp7 eL7LbGNjf9halgzT5Lowj8MqoX59tK372ejcGpEOojTwWLVb+rHiYaxII+d+vXLR6rd/ KECBLjjVpUsPJwnyqE5eHpd6aZGvb/QcXiOeDI3FzbWsMaCQHrX3Gya2nhl2spPg2HRo /DPkst8lpB+hdzobiI4a/KN9tsg7dPh4K8Sb1xTDOsqbZ6wTrV4iUrc5a0KDOy+msb+r GEte1WVFuIGtzJHmaoo8zp1+RFC9bqbJYrK3p53Q9AHO6g6mk4n7pUXTbTp7Lmct/ErE Q/wA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=Bnlp6MxAg99YCHUoCG4a6Z05t5+lypBAqx5s7zPKO8c=; b=TRZxxEvG/za0yNtEzxKEJ2ZntwztrEAmmAS+PRVRquGma326HatG2TgdUUlpkiFX1k qHGpiT4QcDku5vgXIM/YYKgSl71Ez5HJbwF2raXkMaOEYY5+2VmM6W7pFWtup7ed8JLR JM4tTKQbTzjemrK4YMGufki4oByUC3qwJaB6V7AmPZF6NF/5hzVWO0JXGiBL4OL3Afgz gxh2vv92e5rJdQpk4/xDdFbcaDshXphMTChvHmWaIaCAciwYvXhRJmwQND9nhHZrDvgK R9nSoc/faY+a4p94L3jKKOivHsCvr0iUN5SGwjFVwnRde/G8eSe9JB27A7RMboFWnGCo JCng== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=desiato.20200630 header.b=PLEtxF59; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 19-20020a631753000000b005304208cfe3si491590pgx.685.2023.06.01.23.58.55; Thu, 01 Jun 2023 23:59:07 -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=@infradead.org header.s=desiato.20200630 header.b=PLEtxF59; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233998AbjFBGp7 (ORCPT + 99 others); Fri, 2 Jun 2023 02:45:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49062 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233879AbjFBGp5 (ORCPT ); Fri, 2 Jun 2023 02:45:57 -0400 Received: from desiato.infradead.org (desiato.infradead.org [IPv6:2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 615B0EB; Thu, 1 Jun 2023 23:45:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=In-Reply-To:Content-Transfer-Encoding: Content-Type:MIME-Version:References:Message-ID:Subject:Cc:To:From:Date: Sender:Reply-To:Content-ID:Content-Description; bh=Bnlp6MxAg99YCHUoCG4a6Z05t5+lypBAqx5s7zPKO8c=; b=PLEtxF59sPHDqs2J6RDAZz9QEX Iy7PWm5ZDd8O1vBV+G/4rBZRnFOLP/M1bFTEb/e3XXQ4RJ2Oss7LDCS1/6i5lzEpKOMleXQse+bTq khynrKbRDpiVt9oQo0oVhOpEO1O9uKp9mNRr5HJ+UoPF2ctCxMFaxBFyONnC/7nsBSH7VeDeDKaze mzjmVhtibXAa0a1j/eQbFKYyH3vOEKKsxtZ3HaWSySGtnoVInWlxb87IRFfm/6Hmf4eJrOz3Tipu1 lH5gcVVrWO0/gNKoZ4GvDieaO0kZEx2N0AaKUHHrejiCiQYFov8dw/m0VSUXZJ1OD8gf+/nae+2MM gXhc5zpw==; Received: from j130084.upc-j.chello.nl ([24.132.130.84] helo=noisy.programming.kicks-ass.net) by desiato.infradead.org with esmtpsa (Exim 4.96 #2 (Red Hat Linux)) id 1q4yXH-001FrB-2i; Fri, 02 Jun 2023 06:45:22 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id 3E84630031F; Fri, 2 Jun 2023 08:45:16 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 1FA23214120A1; Fri, 2 Jun 2023 08:45:16 +0200 (CEST) Date: Fri, 2 Jun 2023 08:45:15 +0200 From: Peter Zijlstra To: Steven Noonan Cc: Thomas Gleixner , Muhammad Usama Anjum , Jonathan Corbet , Ingo Molnar , Borislav Petkov , Dave Hansen , "maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT)" , "H. Peter Anvin" , "open list:DOCUMENTATION" , open list , "Guilherme G. Piccoli" , kernel@collabora.com Subject: Re: Direct rdtsc call side-effect Message-ID: <20230602064515.GA620383@hirez.programming.kicks-ass.net> References: <6719fb05-382c-8ec4-ccda-72798906a54b@collabora.com> <87mt1jeax1.ffs@tglx> <87h6rrdoy0.ffs@tglx> <20230601203127.GY4253@hirez.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable In-Reply-To: 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_NONE,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 Thu, Jun 01, 2023 at 09:41:15PM +0000, Steven Noonan wrote: > On Thursday, June 1st, 2023 at 1:31 PM, Peter Zijlstra wrote: > > What about kernel based emulation? You could tie it into user_dispatch > > and have a user_dispatch tsc offset. > >=20 >=20 > > So regular kernel emulation simply returns the native value (keeps the > > VDSO working for one), but then from a user_dispatch range, it returns > > +offset. > >=20 >=20 > > That is; how slow is the below? >=20 > It's around 1800-1900 clock cycles on this system=20 Much more expensive than the actual instruction ofcourse, but that seems eminently usable. > (modified patch attached, compile fix + rdtscp support). Right, that's what I get for writing 'patches' while falling asleep :/ > Since faulting would still make the vDSO clocks go through this path > we'd have to be careful that whatever offsets we throw into this path > don't affect the correctness of the other clocks. Hence the suggested tie-in with user-dispatch; only add the offset when the IP is from the user-dispatch range.