* [PATCH] clocksource: Allow unregistering the watchdog
@ 2016-01-22 17:01 Vitaly Kuznetsov
2016-01-22 17:15 ` kbuild test robot
0 siblings, 1 reply; 2+ messages in thread
From: Vitaly Kuznetsov @ 2016-01-22 17:01 UTC (permalink / raw)
To: linux-kernel; +Cc: John Stultz, Thomas Gleixner, Dexuan Cui, K. Y. Srinivasan
Hyper-V vmbus module register TSC page clocksource when loaded. This is the
clocksource with the highest rating and thus it becomes the watchdog making
unloading of the vmbus module impossible.
Separate clocksource_select_watchdog() from clocksource_enqueue_watchdog()
and use it on clocksource rating change/unregister.
After all, lobotomized monkeys may need some love too.
Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
---
kernel/time/clocksource.c | 52 ++++++++++++++++++++++++++++++++++++++---------
1 file changed, 42 insertions(+), 10 deletions(-)
diff --git a/kernel/time/clocksource.c b/kernel/time/clocksource.c
index 664de53..51e71e4 100644
--- a/kernel/time/clocksource.c
+++ b/kernel/time/clocksource.c
@@ -323,13 +323,43 @@ static void clocksource_enqueue_watchdog(struct clocksource *cs)
/* cs is a watchdog. */
if (cs->flags & CLOCK_SOURCE_IS_CONTINUOUS)
cs->flags |= CLOCK_SOURCE_VALID_FOR_HRES;
+ }
+ spin_unlock_irqrestore(&watchdog_lock, flags);
+}
+
+static void clocksource_select_watchdog(bool fallback)
+{
+ unsigned long flags;
+ struct clocksource *cs;
+ struct clocksource *old_wd;
+
+ spin_lock_irqsave(&watchdog_lock, flags);
+ /* save current watchdog */
+ old_wd = watchdog;
+ if (fallback)
+ watchdog = NULL;
+
+ list_for_each_entry(cs, &clocksource_list, list) {
+ /* cs is a clocksource to be watched. */
+ if (cs->flags & CLOCK_SOURCE_MUST_VERIFY)
+ continue;
+
+ /* Skip current if we were requested for a fallback. */
+ if (fallback && cs == old_wd)
+ continue;
+
/* Pick the best watchdog. */
- if (!watchdog || cs->rating > watchdog->rating) {
+ if (!watchdog || cs->rating > watchdog->rating)
watchdog = cs;
- /* Reset watchdog cycles */
- clocksource_reset_watchdog();
- }
}
+ /* If we failed to find a fallback restore the old one. */
+ if (!watchdog)
+ watchdog = old_wd;
+
+ /* If we changed the watchdog we need to reset cycles. */
+ if (watchdog != old_wd)
+ clocksource_reset_watchdog();
+
/* Check if the watchdog timer needs to be started. */
clocksource_start_watchdog();
spin_unlock_irqrestore(&watchdog_lock, flags);
@@ -736,6 +766,7 @@ int __clocksource_register_scale(struct clocksource *cs, u32 scale, u32 freq)
clocksource_enqueue(cs);
clocksource_enqueue_watchdog(cs);
clocksource_select();
+ clocksource_select_watchdog(false);
mutex_unlock(&clocksource_mutex);
return 0;
}
@@ -758,6 +789,7 @@ void clocksource_change_rating(struct clocksource *cs, int rating)
mutex_lock(&clocksource_mutex);
__clocksource_change_rating(cs, rating);
clocksource_select();
+ clocksource_select_watchdog(false);
mutex_unlock(&clocksource_mutex);
}
EXPORT_SYMBOL(clocksource_change_rating);
@@ -767,12 +799,12 @@ EXPORT_SYMBOL(clocksource_change_rating);
*/
static int clocksource_unbind(struct clocksource *cs)
{
- /*
- * I really can't convince myself to support this on hardware
- * designed by lobotomized monkeys.
- */
- if (clocksource_is_watchdog(cs))
- return -EBUSY;
+ if (clocksource_is_watchdog(cs)) {
+ /* Select and try to install a replacement watchdog. */
+ clocksource_select_watchdog(true);
+ if (clocksource_is_watchdog(cs))
+ return -EBUSY;
+ }
if (cs == curr_clocksource) {
/* Select and try to install a replacement clock source */
--
2.5.0
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: [PATCH] clocksource: Allow unregistering the watchdog
2016-01-22 17:01 [PATCH] clocksource: Allow unregistering the watchdog Vitaly Kuznetsov
@ 2016-01-22 17:15 ` kbuild test robot
0 siblings, 0 replies; 2+ messages in thread
From: kbuild test robot @ 2016-01-22 17:15 UTC (permalink / raw)
To: Vitaly Kuznetsov
Cc: kbuild-all, linux-kernel, John Stultz, Thomas Gleixner,
Dexuan Cui, K. Y. Srinivasan
[-- Attachment #1: Type: text/plain, Size: 1533 bytes --]
Hi Vitaly,
[auto build test ERROR on tip/timers/core]
[also build test ERROR on v4.4 next-20160122]
[if your patch is applied to the wrong git tree, please drop us a note to help improving the system]
url: https://github.com/0day-ci/linux/commits/Vitaly-Kuznetsov/clocksource-Allow-unregistering-the-watchdog/20160123-010529
config: xtensa-allyesconfig (attached as .config)
reproduce:
wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=xtensa
All errors (new ones prefixed by >>):
kernel/time/clocksource.c: In function '__clocksource_register_scale':
>> kernel/time/clocksource.c:769:2: error: implicit declaration of function 'clocksource_select_watchdog' [-Werror=implicit-function-declaration]
clocksource_select_watchdog(false);
^
cc1: some warnings being treated as errors
vim +/clocksource_select_watchdog +769 kernel/time/clocksource.c
763
764 /* Add clocksource to the clocksource list */
765 mutex_lock(&clocksource_mutex);
766 clocksource_enqueue(cs);
767 clocksource_enqueue_watchdog(cs);
768 clocksource_select();
> 769 clocksource_select_watchdog(false);
770 mutex_unlock(&clocksource_mutex);
771 return 0;
772 }
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
[-- Attachment #2: .config.gz --]
[-- Type: application/octet-stream, Size: 43387 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2016-01-22 17:13 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-01-22 17:01 [PATCH] clocksource: Allow unregistering the watchdog Vitaly Kuznetsov
2016-01-22 17:15 ` kbuild test robot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®