Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp11161120imu; Thu, 6 Dec 2018 12:33:39 -0800 (PST) X-Google-Smtp-Source: AFSGD/XjgkNWegVBlLbeEbVXlzdTkunebNLrq5xTKpR+RcPUcNOzkOmbOhNdJ3XGbqY62MYjOxED X-Received: by 2002:a63:ff16:: with SMTP id k22mr25714119pgi.244.1544128419411; Thu, 06 Dec 2018 12:33:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544128419; cv=none; d=google.com; s=arc-20160816; b=MkEOi9a16Aw9uK2dfQmwifYGMrqum72nDdLM8I4LU+EGKg1ICiNTIKQvh7dMHD2nbU 64RmD0UmfEfhzlPuRgObPXJTNqZgKDNn0fA5v8EvNIrWSpufLFEgQ0UR6NdI5WgZS1Nj uiyFNrENK7pK9Br0qfFV+MJAKuEYC6MI2xQDwEwnLkQ3LbF2uYCt6fuOQkBa8aLJNgBM wb/JptrZnJiQ6mdTnGKxCyjCMNmBdButZNt/0HdcwbjwV4njrrOw2d1NkwdzsJjf7hVf gCvp5wtnAl1E0zuOK736GF/RFy56TtZ/SppFWnM/ymJRcHcBi3Vvpx5fOR5tk/9/SnLe wPsA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:to:from:cc:in-reply-to:subject:date:dkim-signature; bh=Xp7Sg5IArtbrr2C++6GeTh72xBYnG/glIJgBLPLQB2U=; b=SJvRBifSHSV+naGQIab0/SUfZS0CX+XfqJnAAD4LxSw03JEz6jw5VsI17PPIL1uths 0z9wp//AZiC8p2dH/ACJzBbVdgtaB1KTcsJagh0pWDvImgRoYKvKihlLFuHXL2YyFWWO pndrq+YN0gsbrhL2NeTvQa9Zr6vrPisYOEbftoyCEQ8sSiCTLwrSJEeDMSxku0kvQdoA tsM8wuBYPsuvhCf5F1Bxc2dSFiLOjoMbgXQ6Y6wgzldlffRPS5bBY4njVz7bz14CLkSV qY7JECBd/8IzKvMzR1k8k23kryOyJJkrK5kUDiCGiIewcK7pTCVHogjkwie4D1U0zZCL SvNA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sifive.com header.s=google header.b=g20DTmjx; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w1si1042926pgi.66.2018.12.06.12.33.06; Thu, 06 Dec 2018 12:33:39 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@sifive.com header.s=google header.b=g20DTmjx; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726047AbeLFUc0 (ORCPT + 99 others); Thu, 6 Dec 2018 15:32:26 -0500 Received: from mail-ot1-f68.google.com ([209.85.210.68]:40879 "EHLO mail-ot1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725916AbeLFUcZ (ORCPT ); Thu, 6 Dec 2018 15:32:25 -0500 Received: by mail-ot1-f68.google.com with SMTP id s5so1693514oth.7 for ; Thu, 06 Dec 2018 12:32:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; h=date:subject:in-reply-to:cc:from:to:message-id:mime-version :content-transfer-encoding; bh=Xp7Sg5IArtbrr2C++6GeTh72xBYnG/glIJgBLPLQB2U=; b=g20DTmjxKvwQa0klW5nooKf/iDQoykr8UT7FPPlWSkZZ7PIEKkMmf35RdZ9Ofrv2YN YaA1D7FJMobk+DJH5A0q+zRqKCqvRAqWXk53P34/y8J9Ij3RgYxSrAPvo+4obtbhjT48 ZgCoS505lAIMcgc9VOyH22FdKGR3SLAuoPeefi57iJtj/fKtdqLpU+ocWUlYqUyQymcy iWtUQaRE6vbvM7kMKbE3elwuPUpMEqiii0o2QD/KeLvh9PRcuCjhKi0Tkk3jimmluZsG oQ4IAvr+nccl895691Y/Et5V2T2/wKipnNNLgaxA37rDFmZEWnlW0ywODLXnXPshVeMz d5ug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:subject:in-reply-to:cc:from:to:message-id :mime-version:content-transfer-encoding; bh=Xp7Sg5IArtbrr2C++6GeTh72xBYnG/glIJgBLPLQB2U=; b=ujjs7JLAxMSM1Vui+ujRyO1d7qm+NutXjWstReQx2kqtOhLkWahHpvAoGwq9fEmCUm j6hNI47wE20Nl3UdPnVk1+YMiB+4S49Q3sln/4L3AtxXqWjFuiZa3XqYBhwM86nychh7 C587LV/p5FHFjgDhNKxcofBcYN2RlhRVFm01r4Dm/cp8sHM9PMAPN51IGuQf7SUPS/QK hdcLHj7oWwrxm2Ct7Yz0bO3k9FZBBeMdEUnGsXKSv9V+7RFKtcmUbzlvqsCT/u9XO8Vc 0B67+oGCchXlgcypTJXTMLuxNNVQHxyCLg+WCcYlacz96P3YqFM/5oUru7zdbtAp4mWS sTtw== X-Gm-Message-State: AA+aEWYqrZRUxUK1Zduujmd0LFUwg9xCiIfLgoJNJn72H1pxZSq8zbKr x7bqyW5zXq3iC4cgcQ8/V4ChBw== X-Received: by 2002:a9d:6a1a:: with SMTP id g26mr8753185otn.172.1544128344761; Thu, 06 Dec 2018 12:32:24 -0800 (PST) Received: from localhost ([208.115.86.72]) by smtp.gmail.com with ESMTPSA id f127sm671577oia.19.2018.12.06.12.32.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 06 Dec 2018 12:32:23 -0800 (PST) Date: Thu, 06 Dec 2018 12:32:23 -0800 (PST) X-Google-Original-Date: Thu, 06 Dec 2018 12:27:17 PST (-0800) Subject: Re: [PATCH] clocksource: riscv_timer: Provide sched_clock In-Reply-To: <20181203123524.11778-1-anup@brainfault.org> CC: daniel.lezcano@linaro.org, tglx@linutronix.de, aou@eecs.berkeley.edu, atish.patra@wdc.com, Christoph Hellwig , linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, anup@brainfault.org From: Palmer Dabbelt To: anup@brainfault.org Message-ID: Mime-Version: 1.0 (MHng) Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 03 Dec 2018 04:35:24 PST (-0800), anup@brainfault.org wrote: > Currently, we don't have a sched_clock registered for RISC-V systems. > This means Linux time keeping will use jiffies (running at HZ) as the > default sched_clock. > > To avoid this, we explicity provide sched_clock using RISC-V rdtime > instruction (similar to riscv_timer clocksource). > > Signed-off-by: Anup Patel > --- > drivers/clocksource/riscv_timer.c | 9 +++++++++ > 1 file changed, 9 insertions(+) > > diff --git a/drivers/clocksource/riscv_timer.c b/drivers/clocksource/riscv_timer.c > index 084e97dc10ed..431892200a08 100644 > --- a/drivers/clocksource/riscv_timer.c > +++ b/drivers/clocksource/riscv_timer.c > @@ -8,6 +8,7 @@ > #include > #include > #include > +#include > #include > #include > > @@ -49,6 +50,11 @@ static unsigned long long riscv_clocksource_rdtime(struct clocksource *cs) > return get_cycles64(); > } > > +static u64 riscv_sched_clock(void) > +{ > + return get_cycles64(); > +} > + > static DEFINE_PER_CPU(struct clocksource, riscv_clocksource) = { > .name = "riscv_clocksource", > .rating = 300, > @@ -97,6 +103,9 @@ static int __init riscv_timer_init_dt(struct device_node *n) > cs = per_cpu_ptr(&riscv_clocksource, cpuid); > clocksource_register_hz(cs, riscv_timebase); > > + sched_clock_register(riscv_sched_clock, > + BITS_PER_LONG, riscv_timebase); Shouldn't this just be 64, not BITS_PER_LONG? We have 64-bit counters on RV32I. > + > error = cpuhp_setup_state(CPUHP_AP_RISCV_TIMER_STARTING, > "clockevents/riscv/timer:starting", > riscv_timer_starting_cpu, riscv_timer_dying_cpu);