From: Wu Zhangjin <wuzhangjin@gmail.com>
To: linux-mips@linux-mips.org, Ralf Baechle <ralf@linux-mips.org>
Cc: linux-kernel@vger.kernel.org,
Frederic Weisbecker <fweisbec@gmail.com>,
rostedt@goodmis.org, Thomas Gleixner <tglx@linutronix.de>,
Ralf Baechle <ralf@linux-mips.org>,
Richard Sandiford <rdsandiford@googlemail.com>,
Nicholas Mc Guire <der.herr@hofr.at>,
David Daney <ddaney@caviumnetworks.com>,
Adam Nemet <anemet@caviumnetworks.com>,
Patrik Kluba <kpajko79@gmail.com>
Subject: Re: [PATCH -v6 02/13] tracing: add mips_timecounter_read() for MIPS
Date: Mon, 09 Nov 2009 12:15:16 +0800 [thread overview]
Message-ID: <1257740116.3451.14.camel@falcon.domain.org> (raw)
In-Reply-To: <3f47087b70a965fd679b17a59521671296457df1.1256569489.git.wuzhangjin@gmail.com>
Hi Ralf,
Could you please give some feedback on this patch?
Really looking forward to your feedback and then resend this patchset
out ;)
Thanks & Regards,
Wu Zhangjin
On Mon, 2009-10-26 at 23:13 +0800, Wu Zhangjin wrote:
> This patch add a new function: mips_timecounter_read() to get high
> precision timestamp without extra lock.
>
> It is based on the clock counter register and the
> timecounter/cyclecounter abstraction layer of kernel.
>
> Signed-off-by: Wu Zhangjin <wuzhangjin@gmail.com>
> ---
> arch/mips/include/asm/time.h | 19 +++++++++++++++++++
> arch/mips/kernel/csrc-r4k.c | 41 +++++++++++++++++++++++++++++++++++++++++
> arch/mips/kernel/time.c | 2 ++
> 3 files changed, 62 insertions(+), 0 deletions(-)
>
> diff --git a/arch/mips/include/asm/time.h b/arch/mips/include/asm/time.h
> index df6a430..b8af7fa 100644
> --- a/arch/mips/include/asm/time.h
> +++ b/arch/mips/include/asm/time.h
> @@ -73,8 +73,18 @@ static inline int mips_clockevent_init(void)
> */
> #ifdef CONFIG_CSRC_R4K_LIB
> extern int init_r4k_clocksource(void);
> +extern int init_r4k_timecounter(void);
> +extern u64 r4k_timecounter_read(void);
> #endif
>
> +static inline u64 mips_timecounter_read(void)
> +{
> +#ifdef CONFIG_CSRC_R4K
> + return r4k_timecounter_read();
> +#else
> + return sched_clock();
> +#endif
> +}
> static inline int init_mips_clocksource(void)
> {
> #ifdef CONFIG_CSRC_R4K
> @@ -84,6 +94,15 @@ static inline int init_mips_clocksource(void)
> #endif
> }
>
> +static inline int init_mips_timecounter(void)
> +{
> +#ifdef CONFIG_CSRC_R4K
> + return init_r4k_timecounter();
> +#else
> + return 0;
> +#endif
> +}
> +
> extern void clocksource_set_clock(struct clocksource *cs, unsigned int clock);
> extern void clockevent_set_clock(struct clock_event_device *cd,
> unsigned int clock);
> diff --git a/arch/mips/kernel/csrc-r4k.c b/arch/mips/kernel/csrc-r4k.c
> index e95a3cd..4e7705f 100644
> --- a/arch/mips/kernel/csrc-r4k.c
> +++ b/arch/mips/kernel/csrc-r4k.c
> @@ -7,6 +7,7 @@
> */
> #include <linux/clocksource.h>
> #include <linux/init.h>
> +#include <linux/sched.h>
>
> #include <asm/time.h>
>
> @@ -36,3 +37,43 @@ int __init init_r4k_clocksource(void)
>
> return 0;
> }
> +
> +static struct timecounter r4k_tc = {
> + .cc = NULL,
> +};
> +
> +static cycle_t r4k_cc_read(const struct cyclecounter *cc)
> +{
> + return read_c0_count();
> +}
> +
> +static struct cyclecounter r4k_cc = {
> + .read = r4k_cc_read,
> + .mask = CLOCKSOURCE_MASK(32),
> + .shift = 32,
> +};
> +
> +int __init init_r4k_timecounter(void)
> +{
> + if (!cpu_has_counter || !mips_hpt_frequency)
> + return -ENXIO;
> +
> + r4k_cc.mult = div_sc((unsigned long)mips_hpt_frequency, NSEC_PER_SEC,
> + 32);
> +
> + timecounter_init(&r4k_tc, &r4k_cc, sched_clock());
> +
> + return 0;
> +}
> +
> +u64 r4k_timecounter_read(void)
> +{
> + u64 clock;
> +
> + if (r4k_tc.cc != NULL)
> + clock = timecounter_read(&r4k_tc);
> + else
> + clock = sched_clock();
> +
> + return clock;
> +}
> diff --git a/arch/mips/kernel/time.c b/arch/mips/kernel/time.c
> index 1f467d5..e38cca1 100644
> --- a/arch/mips/kernel/time.c
> +++ b/arch/mips/kernel/time.c
> @@ -156,4 +156,6 @@ void __init time_init(void)
>
> if (!mips_clockevent_init() || !cpu_has_mfc0_count_bug())
> init_mips_clocksource();
> + if (!cpu_has_mfc0_count_bug())
> + init_mips_timecounter();
> }
WARNING: multiple messages have this Message-ID (diff)
From: Wu Zhangjin <wuzhangjin@gmail.com>
To: linux-mips@linux-mips.org, Ralf Baechle <ralf@linux-mips.org>
Cc: linux-kernel@vger.kernel.org,
Frederic Weisbecker <fweisbec@gmail.com>,
rostedt@goodmis.org, Thomas Gleixner <tglx@linutronix.de>,
Richard Sandiford <rdsandiford@googlemail.com>,
Nicholas Mc Guire <der.herr@hofr.at>,
David Daney <ddaney@caviumnetworks.com>,
Adam Nemet <anemet@caviumnetworks.com>,
Patrik Kluba <kpajko79@gmail.com>
Subject: Re: [PATCH -v6 02/13] tracing: add mips_timecounter_read() for MIPS
Date: Mon, 09 Nov 2009 12:15:16 +0800 [thread overview]
Message-ID: <1257740116.3451.14.camel@falcon.domain.org> (raw)
Message-ID: <20091109041516.zoSOdhKXlT-VtDrWzIs6xRLBmAywsMNNo1w-4kKjPig@z> (raw)
In-Reply-To: <3f47087b70a965fd679b17a59521671296457df1.1256569489.git.wuzhangjin@gmail.com>
Hi Ralf,
Could you please give some feedback on this patch?
Really looking forward to your feedback and then resend this patchset
out ;)
Thanks & Regards,
Wu Zhangjin
On Mon, 2009-10-26 at 23:13 +0800, Wu Zhangjin wrote:
> This patch add a new function: mips_timecounter_read() to get high
> precision timestamp without extra lock.
>
> It is based on the clock counter register and the
> timecounter/cyclecounter abstraction layer of kernel.
>
> Signed-off-by: Wu Zhangjin <wuzhangjin@gmail.com>
> ---
> arch/mips/include/asm/time.h | 19 +++++++++++++++++++
> arch/mips/kernel/csrc-r4k.c | 41 +++++++++++++++++++++++++++++++++++++++++
> arch/mips/kernel/time.c | 2 ++
> 3 files changed, 62 insertions(+), 0 deletions(-)
>
> diff --git a/arch/mips/include/asm/time.h b/arch/mips/include/asm/time.h
> index df6a430..b8af7fa 100644
> --- a/arch/mips/include/asm/time.h
> +++ b/arch/mips/include/asm/time.h
> @@ -73,8 +73,18 @@ static inline int mips_clockevent_init(void)
> */
> #ifdef CONFIG_CSRC_R4K_LIB
> extern int init_r4k_clocksource(void);
> +extern int init_r4k_timecounter(void);
> +extern u64 r4k_timecounter_read(void);
> #endif
>
> +static inline u64 mips_timecounter_read(void)
> +{
> +#ifdef CONFIG_CSRC_R4K
> + return r4k_timecounter_read();
> +#else
> + return sched_clock();
> +#endif
> +}
> static inline int init_mips_clocksource(void)
> {
> #ifdef CONFIG_CSRC_R4K
> @@ -84,6 +94,15 @@ static inline int init_mips_clocksource(void)
> #endif
> }
>
> +static inline int init_mips_timecounter(void)
> +{
> +#ifdef CONFIG_CSRC_R4K
> + return init_r4k_timecounter();
> +#else
> + return 0;
> +#endif
> +}
> +
> extern void clocksource_set_clock(struct clocksource *cs, unsigned int clock);
> extern void clockevent_set_clock(struct clock_event_device *cd,
> unsigned int clock);
> diff --git a/arch/mips/kernel/csrc-r4k.c b/arch/mips/kernel/csrc-r4k.c
> index e95a3cd..4e7705f 100644
> --- a/arch/mips/kernel/csrc-r4k.c
> +++ b/arch/mips/kernel/csrc-r4k.c
> @@ -7,6 +7,7 @@
> */
> #include <linux/clocksource.h>
> #include <linux/init.h>
> +#include <linux/sched.h>
>
> #include <asm/time.h>
>
> @@ -36,3 +37,43 @@ int __init init_r4k_clocksource(void)
>
> return 0;
> }
> +
> +static struct timecounter r4k_tc = {
> + .cc = NULL,
> +};
> +
> +static cycle_t r4k_cc_read(const struct cyclecounter *cc)
> +{
> + return read_c0_count();
> +}
> +
> +static struct cyclecounter r4k_cc = {
> + .read = r4k_cc_read,
> + .mask = CLOCKSOURCE_MASK(32),
> + .shift = 32,
> +};
> +
> +int __init init_r4k_timecounter(void)
> +{
> + if (!cpu_has_counter || !mips_hpt_frequency)
> + return -ENXIO;
> +
> + r4k_cc.mult = div_sc((unsigned long)mips_hpt_frequency, NSEC_PER_SEC,
> + 32);
> +
> + timecounter_init(&r4k_tc, &r4k_cc, sched_clock());
> +
> + return 0;
> +}
> +
> +u64 r4k_timecounter_read(void)
> +{
> + u64 clock;
> +
> + if (r4k_tc.cc != NULL)
> + clock = timecounter_read(&r4k_tc);
> + else
> + clock = sched_clock();
> +
> + return clock;
> +}
> diff --git a/arch/mips/kernel/time.c b/arch/mips/kernel/time.c
> index 1f467d5..e38cca1 100644
> --- a/arch/mips/kernel/time.c
> +++ b/arch/mips/kernel/time.c
> @@ -156,4 +156,6 @@ void __init time_init(void)
>
> if (!mips_clockevent_init() || !cpu_has_mfc0_count_bug())
> init_mips_clocksource();
> + if (!cpu_has_mfc0_count_bug())
> + init_mips_timecounter();
> }
next prev parent reply other threads:[~2009-11-09 4:15 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-10-26 15:13 [PATCH -v6 00/13] ftrace for MIPS Wu Zhangjin
2009-10-26 15:13 ` [PATCH -v6 01/13] tracing: convert trace_clock_local() as weak function Wu Zhangjin
2009-11-09 2:10 ` Frederic Weisbecker
2009-10-26 15:13 ` [PATCH -v6 02/13] tracing: add mips_timecounter_read() for MIPS Wu Zhangjin
2009-11-09 4:15 ` Wu Zhangjin [this message]
2009-11-09 4:15 ` Wu Zhangjin
2009-10-26 15:13 ` [PATCH -v6 03/13] tracing: add MIPS specific trace_clock_local() Wu Zhangjin
2009-10-26 15:13 ` [PATCH -v6 04/13] tracing: add static function tracer support for MIPS Wu Zhangjin
2009-10-26 15:13 ` [PATCH -v6 05/13] tracing: enable HAVE_FUNCTION_TRACE_MCOUNT_TEST " Wu Zhangjin
2009-10-26 15:41 ` Sergei Shtylyov
2009-10-26 15:57 ` Steven Rostedt
2009-10-26 15:57 ` Steven Rostedt
2009-10-26 16:16 ` Wu Zhangjin
2009-10-26 15:13 ` [PATCH -v6 06/13] tracing: add an endian argument to scripts/recordmcount.pl Wu Zhangjin
2009-10-26 15:13 ` [PATCH -v6 07/13] tracing: add dynamic function tracer support for MIPS Wu Zhangjin
2009-10-26 16:06 ` Steven Rostedt
2009-10-26 16:35 ` Wu Zhangjin
2009-10-26 16:45 ` Steven Rostedt
2009-10-26 17:35 ` Wu Zhangjin
2009-10-26 15:13 ` [PATCH -v6 08/13] tracing: add IRQENTRY_EXIT section " Wu Zhangjin
2009-11-09 2:26 ` Frederic Weisbecker
2009-11-09 3:31 ` Wu Zhangjin
2009-11-09 3:31 ` Wu Zhangjin
2009-11-09 11:36 ` Frederic Weisbecker
2009-11-09 12:46 ` Steven Rostedt
2009-11-09 12:48 ` Steven Rostedt
2009-11-09 4:16 ` Wu Zhangjin
2009-10-26 15:13 ` [PATCH -v6 09/13] tracing: Add __arch_notrace for arch specific requirement Wu Zhangjin
2009-10-26 15:13 ` [PATCH -v6 10/13] tracing: not trace the timecounter_read* in kernel/time/clocksource.c Wu Zhangjin
2009-10-26 15:13 ` [PATCH -v6 11/13] tracing: not trace mips_timecounter_read() for MIPS Wu Zhangjin
2009-10-26 15:13 ` [PATCH -v6 12/13] tracing: add function graph tracer support " Wu Zhangjin
2009-10-26 15:13 ` [PATCH -v6 13/13] tracing: add dynamic function graph tracer " Wu Zhangjin
Reply instructions:
You may reply publicly 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=1257740116.3451.14.camel@falcon.domain.org \
--to=wuzhangjin@gmail.com \
--cc=anemet@caviumnetworks.com \
--cc=ddaney@caviumnetworks.com \
--cc=der.herr@hofr.at \
--cc=fweisbec@gmail.com \
--cc=kpajko79@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mips@linux-mips.org \
--cc=ralf@linux-mips.org \
--cc=rdsandiford@googlemail.com \
--cc=rostedt@goodmis.org \
--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
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).