Message ID | 20230519102715.502547082@infradead.org |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp1130967vqo; Fri, 19 May 2023 03:36:25 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5cUVLmAJVzDU973PTC0B1Wge7o2loSHuPACkZPE3ZV1zzgqC1atvlbzygLagFdILVpZc1U X-Received: by 2002:a17:903:246:b0:1ad:fcdc:bcb9 with SMTP id j6-20020a170903024600b001adfcdcbcb9mr2272352plh.23.1684492585300; Fri, 19 May 2023 03:36:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684492585; cv=none; d=google.com; s=arc-20160816; b=gvuWwyde4xXp4D30TigTqTcwFTc3fsj+HCM4auTaLRnhJWRlM8r22o8IDa56I3tp8/ g4rxI17ZOlV0X23hScjvUmjc0Q61IMtKI2C2jz5avtIhbVf8AGWOba4OWtpl5ht5bchg aJUIuCNkxECfkOfJVsnX3LpuaJ3Mou/au4aZKSv3C7xGw/A5xT5sjoWkLbhxIqDfGKco DnuRASiBY+p7GI1mPL47KI/emHPCs9+sfeCvV2FsekWln1enCi1zjU48X3kOkc2ZH2sq M9p2xjdc+Po4g+NmGLFIPn3dt+8Qh/hYqzc2+5bbi4EvfuorHtOS8O+lXJGhTt/3hdEO oncw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:subject:cc:to:from:date :user-agent:message-id:dkim-signature; bh=YB2UOIFIw2gwCNTVh1j30XHP2RZzZzmzkIRobxbOGl0=; b=PlRbtBE6F9pdQskx0AaJeyvXwemiB0E17lKUtt1EQ+m263z/WvDQ90nIr9VTZ1HUbS 4bFmGyFWYHUpuZMC2UQcAARVhi4vT5GKql8eDtLoym7dop50wphpzuCkLriwKlJWDHmd Aoa8kS5UCtrxdO/mWLcV5dCVrJcmNbkKWXfLiaBHBNcBqeyzh1g3M7yoLqY6vCN7iPM/ a7PWEghgiBLfiVJEOP0eosZBp4PYWKUScBKoCunJ1BRKRnr78EjbjWmbBTeDDEdzyI1h pNfHl1LS5WPt77oQPDJjo4tBxy2xiKWznxevzxp9Xu6f7TzYnuI0RL2+8pbIR/tXBDFF mGKA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=ghSSZdzk; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ix2-20020a170902f80200b001a2513b8e14si3281622plb.84.2023.05.19.03.36.13; Fri, 19 May 2023 03:36:25 -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=casper.20170209 header.b=ghSSZdzk; 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 S232106AbjESKfL (ORCPT <rfc822;wlfightup@gmail.com> + 99 others); Fri, 19 May 2023 06:35:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53796 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231954AbjESKeU (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Fri, 19 May 2023 06:34:20 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6B6E110E0; Fri, 19 May 2023 03:34:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Type:MIME-Version:References: Subject:Cc:To:From:Date:Message-ID:Sender:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:In-Reply-To; bh=YB2UOIFIw2gwCNTVh1j30XHP2RZzZzmzkIRobxbOGl0=; b=ghSSZdzkafHz78mzS4GGbj71O7 SXXaHp+mpN010O+0jF+6pvvZGjzNbCeL9fRihXGCSrCvKmjJFi1w7JR/UVVTMMEXVA1Xnrdzu7+sB CpSLRVsXbmqoKQ1sJACrj4KY/PgWjUhWPBWqCcijzl6OImzKJISzAOd8sciG4X41lrr6zgoUpIKap paqHTBLRhlA/vM1uMKEqMUzfJCW+NvPNQOZMfIzoFLPznYjoSv44/83tGcfCgLWSn9Qwm8ElMANui kt8AgiykeY0kez68CgoqtGvGH1RwAJFfF20uQNpp87aEng/rdSek17PDz3oqM71sIF9yg35f2qVeS RZbT/x4Q==; Received: from j130084.upc-j.chello.nl ([24.132.130.84] helo=noisy.programming.kicks-ass.net) by casper.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1pzxPv-006UqP-M2; Fri, 19 May 2023 10:33:00 +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 109C630611B; Fri, 19 May 2023 12:32:56 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 0) id C35A8235EF0A0; Fri, 19 May 2023 12:32:55 +0200 (CEST) Message-ID: <20230519102715.502547082@infradead.org> User-Agent: quilt/0.66 Date: Fri, 19 May 2023 12:21:03 +0200 From: Peter Zijlstra <peterz@infradead.org> 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, peterz@infradead.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: [PATCH v2 05/13] loongarch: Provide noinstr sched_clock_read() References: <20230519102058.581557770@infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1766318497090953709?= X-GMAIL-MSGID: =?utf-8?q?1766318497090953709?= |
Series |
local_clock() vs noinstr
|
|
Commit Message
Peter Zijlstra
May 19, 2023, 10:21 a.m. UTC
With the intent to provide local_clock_noinstr(), a variant of
local_clock() that's safe to be called from noinstr code (with the
assumption that any such code will already be non-preemptible),
prepare for things by providing a noinstr sched_clock_read() function.
Specifically, preempt_enable_*() calls out to schedule(), which upsets
noinstr validation efforts.
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
---
arch/loongarch/include/asm/loongarch.h | 2 +-
arch/loongarch/kernel/time.c | 6 +++---
2 files changed, 4 insertions(+), 4 deletions(-)
--- a/arch/loongarch/include/asm/loongarch.h +++ b/arch/loongarch/include/asm/loongarch.h @@ -1167,7 +1167,7 @@ static __always_inline void iocsr_write6 #ifndef __ASSEMBLY__ -static inline u64 drdtime(void) +static __always_inline u64 drdtime(void) { int rID = 0; u64 val = 0; --- a/arch/loongarch/kernel/time.c +++ b/arch/loongarch/kernel/time.c @@ -190,9 +190,9 @@ static u64 read_const_counter(struct clo return drdtime(); } -static u64 native_sched_clock(void) +static noinstr u64 sched_clock_read(void) { - return read_const_counter(NULL); + return drdtime(); } static struct clocksource clocksource_const = { @@ -211,7 +211,7 @@ int __init constant_clocksource_init(voi res = clocksource_register_hz(&clocksource_const, freq); - sched_clock_register(native_sched_clock, 64, freq); + sched_clock_register(sched_clock_read, 64, freq); pr_info("Constant clock source device register\n");