From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id BDAD5C7EE24 for ; Fri, 2 Jun 2023 06:45:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233989AbjFBGp6 (ORCPT ); Fri, 2 Jun 2023 02:45:58 -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: Precedence: bulk List-ID: X-Mailing-List: linux-doc@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.