Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp31146imu; Thu, 6 Dec 2018 18:31:56 -0800 (PST) X-Google-Smtp-Source: AFSGD/U16v63U313FfsrLJ8ZtO8VHekV9y5bgIEh88NlI8pysr6Ww2Rp5/Go4eyObyPSzjOcvD2k X-Received: by 2002:a62:36c1:: with SMTP id d184mr482434pfa.242.1544149916679; Thu, 06 Dec 2018 18:31:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544149916; cv=none; d=google.com; s=arc-20160816; b=z29hkcjgFmSkIJzNbECjBqMWrCZxqcKefo7rPodgMAcu1aFeGce065FexYrOFBzYjg udz27FwcMHfb86NcaPBVh8GZCSfp8xFAm9wezN5fXrYwoFX3gxZsaMdWDNwmnn77qcXq O2lYOg3uKw8gxv1KWVMwSaXew2hKcCXri3+xqrQk0ksJfVehVkJBRWgtzW3pLWsz4JHw A+eHI1isjo23/6VezmR9TH5GdeAaUfrraZhP6h39oTrYpbu9xYYILWsugdt4W51rjKka U+6dKVvXOR1K1m3tSn5QFs3tCVWiKQ5t7eebRDeDIaJzxjFLZNc9Wg4oZ+P6WpxpbOHJ gNiA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=kyIUJyfH0fsnc29YOAnZAeFtg8S1AAXJx1uXbtvDs5Y=; b=F+HQGeLTxn61ZPeD8Sk2JS3fuEm4adGaov0h3sFqqa0F71yh4oBhB3x0gz6zprdt90 2NHgDIoUccx0KzdcHqGxbKl55LVh2n4FgdZWo5blFM2fpY0vNZuXQZa0xyB/EuTgfLH8 CLyUXAVkPVWRv2jMHDHxouJuOJ4Y3x15ozOnTwkYn0GoQPcxeMD8Qpuw49Kj49H2mE/x 9kjhrO2O0NDjQY2xwJt/1m0bzjZ0YhyT4PFxdJeBEzL3nfXjIWBcfrHdyF24w9KEnR+k zyrN5t2ckJ4Rwo+/PR51UtFIn7rJDAPpisn1997jESD3CWkHbZ63TTGFSRKkcTapncmA 77JQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@brainfault-org.20150623.gappssmtp.com header.s=20150623 header.b=ieOtFERH; 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 a11si1765446pla.20.2018.12.06.18.31.40; Thu, 06 Dec 2018 18:31:56 -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=@brainfault-org.20150623.gappssmtp.com header.s=20150623 header.b=ieOtFERH; 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 S1725976AbeLGCae (ORCPT + 99 others); Thu, 6 Dec 2018 21:30:34 -0500 Received: from mail-wr1-f65.google.com ([209.85.221.65]:46994 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725939AbeLGCae (ORCPT ); Thu, 6 Dec 2018 21:30:34 -0500 Received: by mail-wr1-f65.google.com with SMTP id l9so2324842wrt.13 for ; Thu, 06 Dec 2018 18:30:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brainfault-org.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=kyIUJyfH0fsnc29YOAnZAeFtg8S1AAXJx1uXbtvDs5Y=; b=ieOtFERHdhgYkSx5Jp3wMyQvcAPcDnsZ96zEVKrB5XGy1p6TvB8n4Uie+yBMz/oXlH 6dyEpuVnKoaPXpdhSWxaX1zpMh5bqWUXU9gQjplVaidd/l129tV79y3D+NjA8HWvPktp WYbno9E8tN4J3P3ZNo4uZekQwp0WAyQhhLtZ0EOLzjlPb6Wm1L/ki1Zu/Fbn4Jri/4Fk mulZmRzC2DD7BoWGzMPaslLjawqkDPIsDVVGQek7+giPb+gddPTc1hvHhi1ol7wQ2z+n UVHv2SbQqqRE6ChjbWlh7A1ccurxqYOj57eTcRlyEtZHIjPmcSnADqVFcutk2fzqNjk2 MJPg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=kyIUJyfH0fsnc29YOAnZAeFtg8S1AAXJx1uXbtvDs5Y=; b=pisnngaKT3auK8gymCjt/ewCi00JQPcUoE7Wg57sJDPL1sb93ybXoZ9ingYj9jUII3 Vbrjh7AfQJemQvtFtkQ8ziVktTJ8+RNUnHit6/X0/AtTGKSqjpDOssoigNtyH81Gungo z+Y1W2xi/JwHgGEvBcmAA7XhCTcfywMTyiTQNwmQibqLA1ia36XOT/eI7bisNtBkw6g5 QJIb5VuwUMoV47ieNThsxhHYu+fkedUZ1murkoiGDk5pEM32Q1/SI4i8WGnrZY8VBtNG OqkKDuYOJX+OAe3mdhyi3fJLXSg1rbm6Qjt2XFPBev+ZyH3r+m301JX+3jdEhFwG5HON Y3iQ== X-Gm-Message-State: AA+aEWatsAkUYorDj6NQlMMbny//fyT7tHBk4j5WCgW6hRMxW7z3ciQV zQN/IFTJ6VcF40Kg1rP6ehu+ZoXehxEz7g66dLZT4g== X-Received: by 2002:a5d:4ec4:: with SMTP id s4mr296187wrv.187.1544149832601; Thu, 06 Dec 2018 18:30:32 -0800 (PST) MIME-Version: 1.0 References: <20181203123524.11778-1-anup@brainfault.org> In-Reply-To: From: Anup Patel Date: Fri, 7 Dec 2018 07:57:26 +0530 Message-ID: Subject: Re: [PATCH] clocksource: riscv_timer: Provide sched_clock To: Palmer Dabbelt Cc: Daniel Lezcano , Thomas Gleixner , Albert Ou , Atish Patra , Christoph Hellwig , linux-riscv@lists.infradead.org, "linux-kernel@vger.kernel.org List" Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Dec 7, 2018 at 2:02 AM Palmer Dabbelt wrote: > > 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. Ahh, yes. I got mislead by "mask" field of clocksource. I will change this to 64 and add another patch on fix "mask" of clocksource as well. Regards, Anup