Skip to contentSkip to conversation

re-adding clocksource_get_next ?

PATCH Giuseppe CAVALLARO 2 participants 5 messages Apr 9, 2010 – Apr 13, 2010 Timekeeping, clocksource core, NTP, alarmtimer

lore
Share & tools
lore
#0 lore raw

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

Quoted 1 line

From d05e9a31e4d697b704a1d9170aeee7235ffffb0f Mon Sep 17 00:00:00 2001

From: Giuseppe Cavallaro <[email protected]>
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.

---
 kernel/time/clocksource.c |   17 +++++++++++++++++
 1 files changed, 17 insertions(+), 0 deletions(-)
kernel/time/clocksource.c +17 -0
index 0e98497..c9e8f56 100644
@@ -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
Signature · 1 line
1.6.0.4
#1 lore raw
Quoted 8 lines · Giuseppe CAVALLARO

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

#2 lore raw

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

Hello John,

Quoted 11 lines · john stultz
Quoted 8 lines · Giuseppe CAVALLARO

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.

Quoted 3 lines

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

Quoted 2 lines

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-----

#3 lore raw
Quoted 21 lines · Giuseppe CAVALLARO

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

Hello John,

Quoted 11 lines · john stultz
Quoted 8 lines · Giuseppe CAVALLARO

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.

Quoted 3 lines

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()?

Quoted 8 lines

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

#4 lore raw

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

Quoted 35 lines · john stultz
Quoted 21 lines · Giuseppe CAVALLARO

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

Hello John,

Quoted 11 lines · john stultz
Quoted 8 lines · Giuseppe CAVALLARO

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.

Quoted 3 lines

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()?

Quoted 8 lines

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?

Quoted 5 lines

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

Quoted 2 lines

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-----