cluster-devel.redhat.com archive mirror
 help / color / mirror / Atom feed
From: Alexander Aring <aahringo@redhat.com>
To: cluster-devel.redhat.com
Subject: [Cluster-devel] [PATCH dlm-tool 8/8] dlm_controld: add time diff for state time intervals
Date: Mon, 30 Jan 2023 14:24:37 -0500	[thread overview]
Message-ID: <20230130192437.3330300-8-aahringo@redhat.com> (raw)
In-Reply-To: <20230130192437.3330300-1-aahringo@redhat.com>

This patch adds functionality to see how long a posix lock is alive or
is in waiting or pending state. It can be used to filter out interesting
locks which are stuck in e.g. waiting state to know that a user space
process probably has contention on it. The logging information will
printout additional lock information to do more search and find to get
more information about it's corosync or kernel communication.
---
 dlm_controld/plock.c | 48 ++++++++++++++++++++++++++++++--------------
 1 file changed, 33 insertions(+), 15 deletions(-)

diff --git a/dlm_controld/plock.c b/dlm_controld/plock.c
index d83a79d2..20c2a1e9 100644
--- a/dlm_controld/plock.c
+++ b/dlm_controld/plock.c
@@ -72,6 +72,7 @@ struct resource {
 
 struct posix_lock {
 	struct list_head	list;	   /* resource locks or waiters list */
+	struct timeval		list_time;
 	uint32_t		pid;
 	uint64_t		owner;
 	uint64_t		start;
@@ -83,6 +84,7 @@ struct posix_lock {
 
 struct lock_waiter {
 	struct list_head	list;
+	struct timeval		list_time;
 	uint32_t		flags;
 	struct dlm_plock_info	info;
 };
@@ -209,9 +211,11 @@ static uint64_t dt_usec(const struct timeval *start, const struct timeval *stop)
 }
 
 static void plock_print_lock_add_state(const struct lockspace *ls,
-				       const struct lock_waiter *w,
+				       struct lock_waiter *w,
 				       const char *state)
 {
+	gettimeofday(&w->list_time, NULL);
+
 	log_dlock(ls, "state: add %s %llx %llx-%llx %d/%u/%llx",
 		  state,
 		  (unsigned long long)w->info.number,
@@ -225,13 +229,20 @@ static void plock_print_lock_clear_state(const struct lockspace *ls,
 					 const struct lock_waiter *w,
 					 const char *state)
 {
-	log_dlock(ls, "state: clear %s %llx %llx-%llx %d/%u/%llx",
+	struct timeval now;
+	uint64_t usec;
+
+	gettimeofday(&now, NULL);
+	usec = dt_usec(&w->list_time, &now);
+
+	log_dlock(ls, "state: clear %s %llx %llx-%llx %d/%u/%llx %.3f",
 		  state,
 		  (unsigned long long)w->info.number,
 		  (unsigned long long)w->info.start,
 		  (unsigned long long)w->info.end,
 		  w->info.nodeid, w->info.pid,
-		  (unsigned long long)w->info.owner);
+		  (unsigned long long)w->info.owner,
+		  usec * 1.e-6);
 }
 
 #define plock_print_add_waiter(ls, w) \
@@ -245,23 +256,30 @@ static void plock_print_lock_clear_state(const struct lockspace *ls,
 	plock_print_lock_clear_state(ls, w, "pending")
 
 static void plock_print_add_plock(const struct lockspace *ls,
-				  const struct posix_lock *plock)
+				  struct posix_lock *po)
 {
-	log_dlock(ls, "state: add plock NA %llx-%llx %d/%u/%llx",
-		  (unsigned long long)plock->start,
-		  (unsigned long long)plock->end,
-		  plock->nodeid, plock->pid,
-		  (unsigned long long)plock->owner);
+	gettimeofday(&po->list_time, NULL);
+	log_dlock(ls, "state: add plock %llx-%llx %d/%u/%llx %.3f",
+		  (unsigned long long)po->start,
+		  (unsigned long long)po->end,
+		  po->nodeid, po->pid,
+		  (unsigned long long)po->owner);
 }
 
 static void plock_print_del_plock(const struct lockspace *ls,
-				  const struct posix_lock *plock)
+				  const struct posix_lock *po)
 {
-	log_dlock(ls, "state: del plock NA %llx-%llx %d/%u/%llx",
-		  (unsigned long long)plock->start,
-		  (unsigned long long)plock->end,
-		  plock->nodeid, plock->pid,
-		  (unsigned long long)plock->owner);
+	struct timeval now;
+	uint64_t usec;
+
+	gettimeofday(&now, NULL);
+	usec = dt_usec(&po->list_time, &now);
+	log_dlock(ls, "state: clear plock %llx-%llx %d/%u/%llx %.3f",
+		  (unsigned long long)po->start,
+		  (unsigned long long)po->end,
+		  po->nodeid, po->pid,
+		  (unsigned long long)po->owner,
+		  usec * 1.e-6);
 }
 
 static struct resource * rb_search_plock_resource(struct lockspace *ls, uint64_t number)
-- 
2.31.1


  parent reply	other threads:[~2023-01-30 19:24 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-30 19:24 [Cluster-devel] [PATCH dlm-tool 1/8] dlm_tool: add fail functionality if dump failed Alexander Aring
2023-01-30 19:24 ` [Cluster-devel] [PATCH dlm-tool 2/8] dlm_controld: always create logdir Alexander Aring
2023-01-30 19:24 ` [Cluster-devel] [PATCH dlm-tool 3/8] dlm_controld: add plock logfile Alexander Aring
2023-01-30 19:24 ` [Cluster-devel] [PATCH dlm-tool 4/8] dlm_controld: move processing of saved messages to plock level Alexander Aring
2023-01-30 19:24 ` [Cluster-devel] [PATCH dlm-tool 5/8] dlm_controld: remove ls parameter Alexander Aring
2023-01-30 19:24 ` [Cluster-devel] [PATCH dlm-tool 6/8] dlm_controld: log lock/pending/waiter state changes Alexander Aring
2023-01-30 21:26   ` Alexander Aring
2023-01-30 19:24 ` [Cluster-devel] [PATCH dlm-tool 7/8] dlm_controld: constify timeval of dt_usec() Alexander Aring
2023-01-30 19:24 ` Alexander Aring [this message]
2023-01-30 21:18   ` [Cluster-devel] [PATCH dlm-tool 8/8] dlm_controld: add time diff for state time intervals Alexander Aring

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=20230130192437.3330300-8-aahringo@redhat.com \
    --to=aahringo@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 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).