Linux-RISC-V Archive on lore.kernel.org
 help / color / Atom feed
From: Anup Patel <anup@brainfault.org>
To: Palmer Dabbelt <palmer@sifive.com>
Cc: Albert Ou <aou@eecs.berkeley.edu>,
	Daniel Lezcano <daniel.lezcano@linaro.org>,
	"linux-kernel@vger.kernel.org List"
	<linux-kernel@vger.kernel.org>,
	Christoph Hellwig <hch@infradead.org>,
	Atish Patra <atish.patra@wdc.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	linux-riscv@lists.infradead.org
Subject: Re: [PATCH] clocksource: riscv_timer: Provide sched_clock
Date: Fri, 7 Dec 2018 07:57:26 +0530
Message-ID: <CAAhSdy2g_-kYYrW4VJffLPA8evK9mjby06izC6FmNkRe3SceSQ@mail.gmail.com> (raw)
In-Reply-To: <mhng-41a72f59-6506-420f-a01e-b01c81ab6e33@palmer-si-x1c4>

On Fri, Dec 7, 2018 at 2:02 AM Palmer Dabbelt <palmer@sifive.com> 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 <anup@brainfault.org>
> > ---
> >  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 <linux/cpu.h>
> >  #include <linux/delay.h>
> >  #include <linux/irq.h>
> > +#include <linux/sched_clock.h>
> >  #include <asm/smp.h>
> >  #include <asm/sbi.h>
> >
> > @@ -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

_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

      reply index

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-03 12:35 Anup Patel
2018-12-03 12:59 ` Daniel Lezcano
2018-12-03 14:50   ` Anup Patel
2018-12-03 14:53     ` Daniel Lezcano
2018-12-06 20:32 ` Palmer Dabbelt
2018-12-07  2:27   ` Anup Patel [this message]

Reply instructions:

You may reply publically to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAAhSdy2g_-kYYrW4VJffLPA8evK9mjby06izC6FmNkRe3SceSQ@mail.gmail.com \
    --to=anup@brainfault.org \
    --cc="linux-kernel@vger.kernel.org \
    --cc=aou@eecs.berkeley.edu \
    --cc=atish.patra@wdc.com \
    --cc=daniel.lezcano@linaro.org \
    --cc=hch@infradead.org \
    --cc=linux-riscv@lists.infradead.org \
    --cc=palmer@sifive.com \
    --cc=tglx@linutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Linux-RISC-V Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-riscv/0 linux-riscv/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-riscv linux-riscv/ https://lore.kernel.org/linux-riscv \
		linux-riscv@lists.infradead.org infradead-linux-riscv@archiver.kernel.org
	public-inbox-index linux-riscv


Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.infradead.lists.linux-riscv


AGPL code for this site: git clone https://public-inbox.org/ public-inbox