linux-trace-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Tzvetomir Stoyanov (VMware)" <tz.stoyanov@gmail.com>
To: rostedt@goodmis.org
Cc: linux-trace-devel@vger.kernel.org, ycaibb@gmail.com
Subject: [PATCH] trace-cmd: Unlock tsync mutex on thread exit
Date: Mon, 11 Apr 2022 07:10:02 +0300	[thread overview]
Message-ID: <20220411041002.132379-1-tz.stoyanov@gmail.com> (raw)

The logic for synchronising host and guest time stamps uses pthreads and
mutexes. The guest pthread locks a mutex on the beginning of each
synchronization iteration and uses it to wait on a conditional variable.
When the synchronization is done and the thread exists, this mutex
should be unlocked.

fixes: 08b9d507 ("trace-cmd: Basic infrastructure for host - guest timestamp synchronization")
Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=215808
Reported-by: Ryan <ycaibb@gmail.com>
Signed-off-by: Tzvetomir Stoyanov (VMware) <tz.stoyanov@gmail.com>
---
 lib/trace-cmd/trace-timesync.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/lib/trace-cmd/trace-timesync.c b/lib/trace-cmd/trace-timesync.c
index f8ec15a3..90ffa6d0 100644
--- a/lib/trace-cmd/trace-timesync.c
+++ b/lib/trace-cmd/trace-timesync.c
@@ -807,8 +807,10 @@ static int tsync_with_guest(struct tracecmd_time_sync *tsync)
 			first = false;
 			pthread_barrier_wait(&tsync->first_sync);
 		}
-		if (end || i < tsync->vcpu_count)
+		if (end || i < tsync->vcpu_count) {
+			pthread_mutex_unlock(&tsync->lock);
 			break;
+		}
 		if (tsync->loop_interval > 0) {
 			get_ts_loop_delay(&timeout, tsync->loop_interval);
 			ret = pthread_cond_timedwait(&tsync->cond, &tsync->lock, &timeout);
-- 
2.35.1


                 reply	other threads:[~2022-04-11  4:10 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=20220411041002.132379-1-tz.stoyanov@gmail.com \
    --to=tz.stoyanov@gmail.com \
    --cc=linux-trace-devel@vger.kernel.org \
    --cc=rostedt@goodmis.org \
    --cc=ycaibb@gmail.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 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).