Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp4925424rwr; Mon, 8 May 2023 15:05:19 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5m6HS3pTruFG62c5PVDPNvQDbCWjZGtC8HpZnYIK25wcn6ap+mOMAf06a10kRwFrkaCVPO X-Received: by 2002:a05:6a00:14ca:b0:635:7fb2:2ab4 with SMTP id w10-20020a056a0014ca00b006357fb22ab4mr12725061pfu.6.1683583519042; Mon, 08 May 2023 15:05:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683583519; cv=none; d=google.com; s=arc-20160816; b=Big7MYn8CNoSA0Tr03sbyOPZqCPnubXwzAn2AFTkgsrMKRZA0GDW6K1jM/K58Ro5SG b0sDoV4ZQeVDsXWEVswiUnL7YK8UTUtcBDSpdl8tdjelAxDproJOsbuyTM5slamUg9Bp a3QFha8hG1Y0sQfpJWJ1U9efSHobfnN8BlkroesuWsir0RMwzSESMf3CtolHH4eP/X9D dLGQXzPzJ91uslv8xEZJZuGPelcazVVNvWXlVXqt40MF3CxvtO6EXfTXteT80NIU+mDm yu6dgE+SMrSVFXXOBUb7pgLxlufSWFjHLkBo4FyieYFNTTsJq9gsqxzr8LpXY7j7+0As aI0A== 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-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=qtKNFxhPgg3BSrBuRAoPQsywMwqf2dNNecUmmWb61Pk=; b=LeAzWazZDJtzKm6oN0WZWqwHFgTjFOi9bRdoK9qb+osyFY15hwCZcfcgWVE/vHt4UL dBIUjiU9ki5+CTSbMIzmsqIFGr4T4sZjyx+QDXpyButi+GLiC03YteENX+O6hf/SOiuX JvXwiy9QLMG44McgBVz3d3kx981DsF52/7jjeqUoB95lNwOkWmq0pcQichJx6uco0JUQ sFfewm0nmUD4XIgfAE6Qc2QL5qygTks4KPlU5uPhvAKr5uEJ9V92x57BMDR45Elmz43i s2chW6k2n5X9Ay93LONDD6WrtyB927mkSXZgGif5k4Ep7jWBvkdMHV8Lg+ifcWxsoTyl AQ2Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=desiato.20200630 header.b=gSLBBfzy; 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 b195-20020a6334cc000000b005135d3abc6asi9722521pga.90.2023.05.08.15.05.06; Mon, 08 May 2023 15:05:19 -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=gSLBBfzy; 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 S233856AbjEHVpa (ORCPT + 99 others); Mon, 8 May 2023 17:45:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56630 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233750AbjEHVpZ (ORCPT ); Mon, 8 May 2023 17:45:25 -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 B04801992; Mon, 8 May 2023 14:45:23 -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-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=qtKNFxhPgg3BSrBuRAoPQsywMwqf2dNNecUmmWb61Pk=; b=gSLBBfzyucafrU1IhbOQWelFJk SYVF8xaPH8v5HaQQcRZdUvZLnUEgHAhGO055CrkW3Ii/iMdhA2pLLxSHigt0lnVMvSpmD38T+JM3y Lok473TP3/vzc8DjMGt+eGB2XPFV/eHsB8P0xNZVKqvdp27vFKu816ASgbymZMJpkgM4YPZ7Pxq3g gJPeipxxMXF0oR3AABkZEFPxKYeBGJjqkkXXcgB2/gWEPFq145/IjrpBUGcZZTwKXspiKmONezmCF Xa4Q8JeUFPWNNPoLVcgZyTku3fRON8GcmgNqN4THBtiA2guHC+jAV1VCPDiWlaNFWT+lnViszKaou UmORhKBw==; 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 1pw8ec-005JE6-1b; Mon, 08 May 2023 21:44:25 +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)) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id 1C461300786; Mon, 8 May 2023 23:44:20 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 0101B243D394B; Mon, 8 May 2023 23:44:19 +0200 (CEST) Date: Mon, 8 May 2023 23:44:19 +0200 From: Peter Zijlstra To: bigeasy@linutronix.de Cc: mark.rutland@arm.com, maz@kernel.org, catalin.marinas@arm.com, will@kernel.org, chenhuacai@kernel.org, kernel@xen0n.name, hca@linux.ibm.com, gor@linux.ibm.com, agordeev@linux.ibm.com, borntraeger@linux.ibm.com, svens@linux.ibm.com, pbonzini@redhat.com, wanpengli@tencent.com, vkuznets@redhat.com, tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com, x86@kernel.org, hpa@zytor.com, jgross@suse.com, boris.ostrovsky@oracle.com, daniel.lezcano@linaro.org, kys@microsoft.com, haiyangz@microsoft.com, wei.liu@kernel.org, decui@microsoft.com, rafael@kernel.org, longman@redhat.com, boqun.feng@gmail.com, pmladek@suse.com, senozhatsky@chromium.org, rostedt@goodmis.org, john.ogness@linutronix.de, juri.lelli@redhat.com, vincent.guittot@linaro.org, dietmar.eggemann@arm.com, bsegall@google.com, mgorman@suse.de, bristot@redhat.com, vschneid@redhat.com, jstultz@google.com, sboyd@kernel.org, linux-kernel@vger.kernel.org, loongarch@lists.linux.dev, linux-s390@vger.kernel.org, kvm@vger.kernel.org, linux-hyperv@vger.kernel.org, linux-pm@vger.kernel.org Subject: Re: [RFC][PATCH 7/9] x86/tsc: Provide sched_clock_noinstr() Message-ID: <20230508214419.GA2053935@hirez.programming.kicks-ass.net> References: <20230508211951.901961964@infradead.org> <20230508213147.853677542@infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230508213147.853677542@infradead.org> 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 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 Mon, May 08, 2023 at 11:19:58PM +0200, Peter Zijlstra wrote: > --- a/drivers/clocksource/hyperv_timer.c > +++ b/drivers/clocksource/hyperv_timer.c > @@ -408,9 +408,9 @@ static u64 notrace read_hv_clock_tsc_cs( > return read_hv_clock_tsc(); > } > > -static u64 notrace read_hv_sched_clock_tsc(void) > +static u64 noinstr read_hv_sched_clock_tsc(void) > { > - return (read_hv_clock_tsc() - hv_sched_clock_offset) * > + return (hv_read_tsc_page(hv_get_tsc_page()) - hv_sched_clock_offset) * > (NSEC_PER_SEC / HV_CLOCK_HZ); > } > > --- a/include/clocksource/hyperv_timer.h > +++ b/include/clocksource/hyperv_timer.h > @@ -38,7 +38,7 @@ extern void hv_remap_tsc_clocksource(voi > extern unsigned long hv_get_tsc_pfn(void); > extern struct ms_hyperv_tsc_page *hv_get_tsc_page(void); > > -static inline notrace u64 > +static __always_inline notrace u64 > hv_read_tsc_page_tsc(const struct ms_hyperv_tsc_page *tsc_pg, u64 *cur_tsc) > { > u64 scale, offset; > @@ -85,7 +85,7 @@ hv_read_tsc_page_tsc(const struct ms_hyp > return mul_u64_u64_shr(*cur_tsc, scale, 64) + offset; > } > > -static inline notrace u64 > +static __always_inline notrace u64 > hv_read_tsc_page(const struct ms_hyperv_tsc_page *tsc_pg) > { > u64 cur_tsc; Hyper-V folks! While reviewing all this I found the following 'gem': hv_init_clocksource() hv_setup_sched_clock() paravirt_set_sched_clock(read_hv_sched_clock_msr) read_hv_sched_clock_msr() [notrace] read_hv_clock_msr() [notrace] hv_get_register() *traced* hv_get_non_nested_register() ... hv_ghcb_msr_read() WARN_ON(in_nmi()) ... local_irq_save() Note that: a) sched_clock() is used in NMI context a *LOT* b) sched_clock() is notrace (or even noinstr with these patches) and local_irq_save() implies tracing Can you pretty please: 1) delete all this; or, 2) fix it in a hurry? Thanks!