From: Zdenek Kabelac <zkabelac@sourceware.org>
To: lvm-devel@redhat.com
Subject: stable-2.02 - dmeventd: enhance time waiting loop
Date: Wed, 8 Apr 2020 13:36:25 +0000 (GMT) [thread overview]
Message-ID: <20200408133625.D87A3385DC0B@sourceware.org> (raw)
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=5d93892d4ae67b355ab6b418c0c404e1536d055f
Commit: 5d93892d4ae67b355ab6b418c0c404e1536d055f
Parent: 8f3d2d5e11305b5f3fc7ced7bd2f81412c9e7d93
Author: Zdenek Kabelac <zkabelac@redhat.com>
AuthorDate: Wed Mar 4 15:56:09 2020 +0100
Committer: Zdenek Kabelac <zkabelac@redhat.com>
CommitterDate: Wed Apr 8 15:22:54 2020 +0200
dmeventd: enhance time waiting loop
dmeventd is 'scanning' statuses in loop (most usually in 10sec
intervals) - and meanwhile it sleeps within:
pthread_cond_timedwait()
However this function call tends to wakeup sometimes a short amount of
time sooner - and our code still believe the 'right time' has not yet
arrived and basically for a moment 'busy-looped' on calling this
function - so for systems with 'clock_gettime()' present we obtain
time and we go 10ms to the future second - this avoids unneeded
repeated invocation of our time scheduling loop.
TODO: monitoring during 1 hour 'time-change'...
---
daemons/dmeventd/dmeventd.c | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/daemons/dmeventd/dmeventd.c b/daemons/dmeventd/dmeventd.c
index 8917422fc..1b84c28ba 100644
--- a/daemons/dmeventd/dmeventd.c
+++ b/daemons/dmeventd/dmeventd.c
@@ -752,7 +752,7 @@ static void _exit_timeout(void *unused __attribute__((unused)))
static void *_timeout_thread(void *unused __attribute__((unused)))
{
struct thread_status *thread;
- struct timespec timeout;
+ struct timespec timeout, real_time;
time_t curr_time;
int ret;
@@ -763,7 +763,16 @@ static void *_timeout_thread(void *unused __attribute__((unused)))
while (!dm_list_empty(&_timeout_registry)) {
timeout.tv_sec = 0;
timeout.tv_nsec = 0;
+#ifndef HAVE_REALTIME
curr_time = time(NULL);
+#else
+ if (clock_gettime(CLOCK_REALTIME, &real_time)) {
+ log_error("Failed to read clock_gettime().");
+ break;
+ }
+ /* 10ms back to the future */
+ curr_time = real_time.tv_sec + ((real_time.tv_nsec > (1000000000 - 10000000)) ? 1 : 0);
+#endif
dm_list_iterate_items_gen(thread, &_timeout_registry, timeout_list) {
if (thread->next_time <= curr_time) {
reply other threads:[~2020-04-08 13:36 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20200408133625.D87A3385DC0B@sourceware.org \
--to=zkabelac@sourceware.org \
--cc=lvm-devel@redhat.com \
/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 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.