Skip to contentSkip to conversation

fs: dlm: tracepoint changes

PATCH New Alexander Aring 1 participant 4 messages Jun 1, 2022

Subsystems (2)
lore
Share & tools
lore

Alexander Aring

author maintainer
#0 lore raw

v2 cover fs: dlm: tracepoint changes

Hi,

this patch series contains some changes to the dlm tracepoint system. Now we can ask about if stable candidate or not, the dlm tracepoint system is relative new and I am doing some experiments right now and need those changes. It should be still backward compatible... may some small changes e.g. calling bast/ast tracepoint before calling callback which makes more sense as other way around... I think it's fine to put them in next as they are development tools anyway.

- Alex

changes since v2:
- remove the not working +1 terminated null in res_name field to provide a null terminated string, the user need to deal with it now.

Alexander Aring (3):
fs: change ast and bast trace order
fs: remove additional dereference of lkbsb
fs: dlm: add resource name to tracepoints

 fs/dlm/ast.c               |   4 +-
 fs/dlm/lock.c              |   4 +-
 include/trace/events/dlm.h | 118 ++++++++++++++++++++++++++++++-------
 3 files changed, 100 insertions(+), 26 deletions(-)
Signature · 1 line
2.31.1
author maintainer
#1 lore raw

PATCH v2 1/3 fs: change ast and bast trace order

This patch changes the order to call trace functionality before calling the traced callback. The intention is always to see at first that a dlm callback occurred and then optionally see dlm user traces in the ast or bast callback. Currently the behaviour is vice versa, the user sees that dlm ast or bast callback occurred after the dlm user callback for ast or bast was called.

---
 fs/dlm/ast.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
fs/dlm/ast.c +2 -2
index bfac462dd3e8..df25c3e785cf 100644
@@ -255,13 +255,13 @@ void dlm_callback_work(struct work_struct *work)
 		if (callbacks[i].flags & DLM_CB_SKIP) {
 			continue;
 		} else if (callbacks[i].flags & DLM_CB_BAST) {
-			bastfn(lkb->lkb_astparam, callbacks[i].mode);
 			trace_dlm_bast(ls, lkb, callbacks[i].mode);
+			bastfn(lkb->lkb_astparam, callbacks[i].mode);
 		} else if (callbacks[i].flags & DLM_CB_CAST) {
 			lkb->lkb_lksb->sb_status = callbacks[i].sb_status;
 			lkb->lkb_lksb->sb_flags = callbacks[i].sb_flags;
-			castfn(lkb->lkb_astparam);
 			trace_dlm_ast(ls, lkb, lkb->lkb_lksb);
+			castfn(lkb->lkb_astparam);
 		}
 	}
 
Signature · 1 line
2.31.1
author maintainer
#2 lore raw

PATCH v2 2/3 fs: remove additional dereference of lkbsb

In reply to Alexander Aring

This patch removes a dereference of lkbsb of lkb when calling ast tracepoint. First it reduces additional overhead, even if traces are not acitivated. Second we can deference it in TP_fast_assign over the already passed lkb parameter.

---
 fs/dlm/ast.c               | 2 +-
 include/trace/events/dlm.h | 8 ++++----
 2 files changed, 5 insertions(+), 5 deletions(-)
fs/dlm/ast.c +1 -1
index df25c3e785cf..19ef136f9e4f 100644
@@ -260,7 +260,7 @@ void dlm_callback_work(struct work_struct *work)
 		} else if (callbacks[i].flags & DLM_CB_CAST) {
 			lkb->lkb_lksb->sb_status = callbacks[i].sb_status;
 			lkb->lkb_lksb->sb_flags = callbacks[i].sb_flags;
-			trace_dlm_ast(ls, lkb, lkb->lkb_lksb);
+			trace_dlm_ast(ls, lkb);
 			castfn(lkb->lkb_astparam);
 		}
 	}
include/trace/events/dlm.h +4 -4
index 32088c603244..e333176ecfaf 100644
@@ -138,9 +138,9 @@ TRACE_EVENT(dlm_bast,
 
 TRACE_EVENT(dlm_ast,
 
-	TP_PROTO(struct dlm_ls *ls, struct dlm_lkb *lkb, struct dlm_lksb *lksb),
+	TP_PROTO(struct dlm_ls *ls, struct dlm_lkb *lkb),
 
-	TP_ARGS(ls, lkb, lksb),
+	TP_ARGS(ls, lkb),
 
 	TP_STRUCT__entry(
 		__field(__u32, ls_id)
@@ -152,8 +152,8 @@ TRACE_EVENT(dlm_ast,
 	TP_fast_assign(
 		__entry->ls_id = ls->ls_global_id;
 		__entry->lkb_id = lkb->lkb_id;
-		__entry->sb_flags = lksb->sb_flags;
-		__entry->sb_status = lksb->sb_status;
+		__entry->sb_flags = lkb->lkb_lksb->sb_flags;
+		__entry->sb_status = lkb->lkb_lksb->sb_status;
 	),
 
 	TP_printk("ls_id=%u lkb_id=%x sb_flags=%s sb_status=%d",
Signature · 1 line
2.31.1
author maintainer
#3 lore raw

PATCH v2 3/3 fs: dlm: add resource name to tracepoints

In reply to Alexander Aring

This patch adds the resource name to dlm tracepoints. In case of dlm_lock() we might end in a short time situation (if flags is not convert) that a lkb is not associated with a resource at the time when the tracepoint is called. Therefore we have a a prioritzation of getting the resource name. If the resource in a lkb isn't set we use the name and namelen passed as parameter as fallback.

It should be okay to access the lkb_resource and the res_name field at the time when the tracepoint is invoked. The resource is assigned to a lkb and it's reference is being hold during the tracepoint call. During this time the resource cannot be freed. Also a lkb will never switch it's assigned resource. The name of a dlm_rsb is assigned at creation time and should never be changed during runtime as well.

Sometimes the resource name e.g. gfs2 is ascii encoded but this isn't required by DLM itself. If it's ascii encoded please note that the resource name is not null-terminated.

The TP_printk() call uses always a hexadecimal string array representation for the resource name.

---
 fs/dlm/lock.c              |   4 +-
 include/trace/events/dlm.h | 110 +++++++++++++++++++++++++++++++------
 2 files changed, 94 insertions(+), 20 deletions(-)
fs/dlm/lock.c +2 -2
index 226822f49d30..e80d42ba64ae 100644
@@ -3472,7 +3472,7 @@ int dlm_lock(dlm_lockspace_t *lockspace,
 	if (error)
 		goto out;
 
-	trace_dlm_lock_start(ls, lkb, mode, flags);
+	trace_dlm_lock_start(ls, lkb, name, namelen, mode, flags);
 
 	error = set_lock_args(mode, lksb, flags, namelen, 0, ast,
 			      astarg, bast, &args);
@@ -3487,7 +3487,7 @@ int dlm_lock(dlm_lockspace_t *lockspace,
 	if (error == -EINPROGRESS)
 		error = 0;
  out_put:
-	trace_dlm_lock_end(ls, lkb, mode, flags, error);
+	trace_dlm_lock_end(ls, lkb, name, namelen, mode, flags, error);
 
 	if (convert || error)
 		__put_lkb(ls, lkb);
include/trace/events/dlm.h +92 -18

225 lines not on this page · raw message

Signature · 1 line
2.31.1