All of lore.kernel.org
 help / color / mirror / Atom feed
* re-adding clocksource_get_next ?
@ 2010-04-09  6:53 Giuseppe CAVALLARO
  2010-04-09 20:58 ` john stultz
  0 siblings, 1 reply; 5+ messages in thread
From: Giuseppe CAVALLARO @ 2010-04-09  6:53 UTC (permalink / raw)
  To: linux-kernel

[-- Attachment #1: Type: text/plain, Size: 451 bytes --]

Hello!
this function was removed in the past but I've not clear all the details.
While testing LLTng, I wrote the patch, in attachment, that re-adds it
again.
The clocksource_get_next returns the first clock source available
(without looking at the rating).
In my environment, a clock source is a TMU channel (e.g. TMU1) and,
indeed, clocksource_get_next works fine.

Let me know if it makes sense or if I'm missing something.

Best Regards,
Giuseppe

[-- Attachment #2: 0001-add-clocksource_get_next.patch --]
[-- Type: text/x-patch, Size: 1330 bytes --]

>From d05e9a31e4d697b704a1d9170aeee7235ffffb0f Mon Sep 17 00:00:00 2001
From: Giuseppe Cavallaro <peppe.cavallaro@st.com>
Date: Tue, 6 Apr 2010 16:04:46 +0200
Subject: [PATCH] add clocksource_get_next

Added the clocksource_get_next function, it returns a source clock.
The clocksource_get_next function has been used for testing LTT
and implementing trace clock definitions on ST platforms.

Signed-off-by: Giuseppe Cavallaro <peppe.cavallaro@st.com>
---
 kernel/time/clocksource.c |   17 +++++++++++++++++
 1 files changed, 17 insertions(+), 0 deletions(-)

diff --git a/kernel/time/clocksource.c b/kernel/time/clocksource.c
index 0e98497..c9e8f56 100644
--- a/kernel/time/clocksource.c
+++ b/kernel/time/clocksource.c
@@ -613,6 +613,23 @@ static void clocksource_enqueue(struct clocksource *cs)
 	list_add(&cs->list, entry);
 }
 
+/*
+ * Return a clocksource if available
+ */
+struct clocksource *clocksource_get_next(void)
+{
+	struct clocksource *clock = NULL;
+
+	mutex_lock(&clocksource_mutex);
+	if (!list_empty(&clocksource_list)) {
+		struct list_head *list = clocksource_list.next;
+		clock = container_of(list, struct clocksource, list);
+	}
+	mutex_unlock(&clocksource_mutex);
+
+	return clock;
+}
+
 /**
  * clocksource_register - Used to install new clocksources
  * @t:		clocksource to be registered
-- 
1.6.0.4


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: re-adding clocksource_get_next ?
  2010-04-09  6:53 re-adding clocksource_get_next ? Giuseppe CAVALLARO
@ 2010-04-09 20:58 ` john stultz
  2010-04-12  6:02   ` Giuseppe CAVALLARO
  0 siblings, 1 reply; 5+ messages in thread
From: john stultz @ 2010-04-09 20:58 UTC (permalink / raw)
  To: Giuseppe CAVALLARO; +Cc: linux-kernel

On Thu, Apr 8, 2010 at 11:53 PM, Giuseppe CAVALLARO
<peppe.cavallaro@st.com> wrote:
> Hello!
> this function was removed in the past but I've not clear all the details.
> While testing LLTng, I wrote the patch, in attachment, that re-adds it
> again.
> The clocksource_get_next returns the first clock source available
> (without looking at the rating).
> In my environment, a clock source is a TMU channel (e.g. TMU1) and,
> indeed, clocksource_get_next works fine.

Could you provide some more details as to why you need raw access to
the clocksource, instead of using something like ktime_get(),
getrawmonotonic() or sched_clock()?

thanks
-john

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: re-adding clocksource_get_next ?
  2010-04-09 20:58 ` john stultz
@ 2010-04-12  6:02   ` Giuseppe CAVALLARO
  2010-04-12 18:50     ` john stultz
  0 siblings, 1 reply; 5+ messages in thread
From: Giuseppe CAVALLARO @ 2010-04-12  6:02 UTC (permalink / raw)
  To: john stultz; +Cc: linux-kernel

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hello John,

john stultz wrote:
> On Thu, Apr 8, 2010 at 11:53 PM, Giuseppe CAVALLARO
> <peppe.cavallaro@st.com> wrote:
>> Hello!
>> this function was removed in the past but I've not clear all the details.
>> While testing LLTng, I wrote the patch, in attachment, that re-adds it
>> again.
>> The clocksource_get_next returns the first clock source available
>> (without looking at the rating).
>> In my environment, a clock source is a TMU channel (e.g. TMU1) and,
>> indeed, clocksource_get_next works fine.
> 
> Could you provide some more details as to why you need raw access to
> the clocksource, instead of using something like ktime_get(),
> getrawmonotonic() or sched_clock()?

I wanted to directly read the value of the TCNT register of a TMU
channel registered as clocksource in an SH platform.
My idea was to get the first clocksource available and than use the read
hook to get its raw value.
Indeed, on SH4, the clocksource_get_next returns the TMU channel 1
(usually registered as clocksource); the clk->reads points to
sh_tmu_clocksource_read (drivers/clocksource/sh_tmu.c). This returns the
value of the timer count register (TCNT).

Best Regards,
Giuseppe

> thanks
> -john

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQEcBAEBAgAGBQJLwrdqAAoJEAm9vY9Tshdv2HAH/RdL0cKvYAjcnS4lzJGppbzX
NdZL6WTW3wNfrqBzm7g8OGy+ZX3Fd+yQKbR41qGcH1agQ5JKMN5aDLzVhw91CG9o
aJAqsYyMVxetDa1iDxmqHpwctbeQfACwxztX1wceG/YuAGM7XXHevVN/ywQZn10c
qxSb+bgNr4T489f7EkCLTwvk+iutRY0TRQIJX0/40qIO/UGpjiNODkfbCXAaU2QC
Cw5zq59UY7gvbnrAmjthxTq91kWqUAunk4UaliSaxV7n+JJziWPKDQ7iXzbSk/sv
CJmec+/1ZmnISBYyjCMtRX5o0xDjxfWgWSVI7YiS7lPOtV+b/QN4a5gr/g1UP7w=
=wuHC
-----END PGP SIGNATURE-----

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: re-adding clocksource_get_next ?
  2010-04-12  6:02   ` Giuseppe CAVALLARO
@ 2010-04-12 18:50     ` john stultz
  2010-04-13  5:44       ` Giuseppe CAVALLARO
  0 siblings, 1 reply; 5+ messages in thread
From: john stultz @ 2010-04-12 18:50 UTC (permalink / raw)
  To: Giuseppe CAVALLARO; +Cc: linux-kernel

On Mon, 2010-04-12 at 08:02 +0200, Giuseppe CAVALLARO wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> Hello John,
> 
> john stultz wrote:
> > On Thu, Apr 8, 2010 at 11:53 PM, Giuseppe CAVALLARO
> > <peppe.cavallaro@st.com> wrote:
> >> Hello!
> >> this function was removed in the past but I've not clear all the details.
> >> While testing LLTng, I wrote the patch, in attachment, that re-adds it
> >> again.
> >> The clocksource_get_next returns the first clock source available
> >> (without looking at the rating).
> >> In my environment, a clock source is a TMU channel (e.g. TMU1) and,
> >> indeed, clocksource_get_next works fine.
> > 
> > Could you provide some more details as to why you need raw access to
> > the clocksource, instead of using something like ktime_get(),
> > getrawmonotonic() or sched_clock()?
> 
> I wanted to directly read the value of the TCNT register of a TMU
> channel registered as clocksource in an SH platform.
> My idea was to get the first clocksource available and than use the read
> hook to get its raw value.
> Indeed, on SH4, the clocksource_get_next returns the TMU channel 1
> (usually registered as clocksource); the clk->reads points to
> sh_tmu_clocksource_read (drivers/clocksource/sh_tmu.c). This returns the
> value of the timer count register (TCNT).

If you specifically want the function sh_tmu_clocksource_read(), why not
call it directly instead of indirecting through the clocksource
infrastructure?

Additionally, since the clocksource code is dynamic, you might get a
different clocksource then you expect (such as jiffies) depending on
user config or user actions.

So I'd advise against using the clocksource code here.

thanks
-john





^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: re-adding clocksource_get_next ?
  2010-04-12 18:50     ` john stultz
@ 2010-04-13  5:44       ` Giuseppe CAVALLARO
  0 siblings, 0 replies; 5+ messages in thread
From: Giuseppe CAVALLARO @ 2010-04-13  5:44 UTC (permalink / raw)
  To: john stultz; +Cc: linux-kernel

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 04/12/2010 08:50 PM, john stultz wrote:
> On Mon, 2010-04-12 at 08:02 +0200, Giuseppe CAVALLARO wrote:
>> -----BEGIN PGP SIGNED MESSAGE-----
>> Hash: SHA1
>>
>> Hello John,
>>
>> john stultz wrote:
>>> On Thu, Apr 8, 2010 at 11:53 PM, Giuseppe CAVALLARO
>>> <peppe.cavallaro@st.com> wrote:
>>>> Hello!
>>>> this function was removed in the past but I've not clear all the details.
>>>> While testing LLTng, I wrote the patch, in attachment, that re-adds it
>>>> again.
>>>> The clocksource_get_next returns the first clock source available
>>>> (without looking at the rating).
>>>> In my environment, a clock source is a TMU channel (e.g. TMU1) and,
>>>> indeed, clocksource_get_next works fine.
>>>
>>> Could you provide some more details as to why you need raw access to
>>> the clocksource, instead of using something like ktime_get(),
>>> getrawmonotonic() or sched_clock()?
>>
>> I wanted to directly read the value of the TCNT register of a TMU
>> channel registered as clocksource in an SH platform.
>> My idea was to get the first clocksource available and than use the read
>> hook to get its raw value.
>> Indeed, on SH4, the clocksource_get_next returns the TMU channel 1
>> (usually registered as clocksource); the clk->reads points to
>> sh_tmu_clocksource_read (drivers/clocksource/sh_tmu.c). This returns the
>> value of the timer count register (TCNT).
> 
> If you specifically want the function sh_tmu_clocksource_read(), why not
> call it directly instead of indirecting through the clocksource
> infrastructure?
> 
> Additionally, since the clocksource code is dynamic, you might get a
> different clocksource then you expect (such as jiffies) depending on
> user config or user actions.
> 
> So I'd advise against using the clocksource code here.

This means I should export the sh_tmu_clocksource_read (currently
static) and don't pass for the clocksource code at all.

Thanks for your prompt feedback.

Best Regards,
Giuseppe

> thanks
> -john
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQEcBAEBAgAGBQJLxATDAAoJEAm9vY9TshdvKI8H/1kuVTOCVEJvwjroRiy8X3eK
aW891639hsCcQYjmf+XGEuP9YUUP+n6sIMFqAB0tcNLNurJndmIumjQgsgyvniB/
5sI7B+nltyR+A5Z7jHjufXcmOr93DKv+3uudbbFDs0CREFuawR3LhSikkAdooPVR
ff0o7JYqknatsoZARRSrH/uQDDe0bWQLV0mT8sOIDmmMaOn2AE69IzA7CraKLchj
U0IW29OB6g6S+TwnXRA4+P6L8udNsR3ymEwL2jicj8TDoDUMBtoqO5cUivHalHWX
xokdi3vsgvZ3/3sGpnXYyOtueo8bQ2+XUbzbUdIhte9DdJliYSVuC2vAppU1z2A=
=8sFm
-----END PGP SIGNATURE-----

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2010-04-13  5:44 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-04-09  6:53 re-adding clocksource_get_next ? Giuseppe CAVALLARO
2010-04-09 20:58 ` john stultz
2010-04-12  6:02   ` Giuseppe CAVALLARO
2010-04-12 18:50     ` john stultz
2010-04-13  5:44       ` Giuseppe CAVALLARO

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.