Index | Thread | Search

From:
Alexander Bluhm <bluhm@openbsd.org>
Subject:
refcnt and rwlock dt(4) trace documentation
To:
tech@openbsd.org
Date:
Thu, 31 Jul 2025 18:20:09 +0200

Download raw body.

Thread
  • Alexander Bluhm:

    refcnt and rwlock dt(4) trace documentation

Hi,

refcnt_init_trace(9) and rw_init_flags_trace(9) can create trace
points for dt(4).  Documentation was a bit inconsistent.

ok?

bluhm

Index: sys/kern/kern_synch.c
===================================================================
RCS file: /data/mirror/openbsd/cvs/src/sys/kern/kern_synch.c,v
diff -u -p -r1.230 kern_synch.c
--- sys/kern/kern_synch.c	28 Jul 2025 05:08:35 -0000	1.230
+++ sys/kern/kern_synch.c	31 Jul 2025 15:52:23 -0000
@@ -900,9 +900,9 @@ refcnt_init(struct refcnt *r)
 }
 
 void
-refcnt_init_trace(struct refcnt *r, int idx)
+refcnt_init_trace(struct refcnt *r, int trace)
 {
-	r->r_traceidx = idx;
+	r->r_traceidx = trace;
 	atomic_store_int(&r->r_refs, 1);
 	TRACEINDEX(refcnt, r->r_traceidx, r, 0, +1);
 }
Index: sys/sys/refcnt.h
===================================================================
RCS file: /data/mirror/openbsd/cvs/src/sys/sys/refcnt.h,v
diff -u -p -r1.15 refcnt.h
--- sys/sys/refcnt.h	14 Jul 2025 08:47:15 -0000	1.15
+++ sys/sys/refcnt.h	31 Jul 2025 15:52:23 -0000
@@ -35,7 +35,7 @@ struct refcnt {
 #ifdef _KERNEL
 
 void	refcnt_init(struct refcnt *);
-void	refcnt_init_trace(struct refcnt *, int id);
+void	refcnt_init_trace(struct refcnt *, int);
 void	refcnt_take(struct refcnt *);
 int	refcnt_rele(struct refcnt *);
 void	refcnt_rele_wake(struct refcnt *);
Index: share/man/man9/refcnt_init.9
===================================================================
RCS file: /data/mirror/openbsd/cvs/src/share/man/man9/refcnt_init.9,v
diff -u -p -r1.7 refcnt_init.9
--- share/man/man9/refcnt_init.9	14 Jul 2025 08:47:15 -0000	1.7
+++ share/man/man9/refcnt_init.9	21 Jul 2025 22:12:32 -0000
@@ -33,7 +33,7 @@
 .Ft void
 .Fn "refcnt_init" "struct refcnt *r"
 .Ft void
-.Fn "refcnt_init_trace" "struct refcnt *r" "int idx"
+.Fn "refcnt_init_trace" "struct refcnt *r" "int trace"
 .Ft void
 .Fn "refcnt_take" "struct refcnt *r"
 .Ft int
Index: share/man/man9/rwlock.9
===================================================================
RCS file: /data/mirror/openbsd/cvs/src/share/man/man9/rwlock.9,v
diff -u -p -r1.28 rwlock.9
--- share/man/man9/rwlock.9	18 May 2025 00:13:57 -0000	1.28
+++ share/man/man9/rwlock.9	31 Jul 2025 16:08:38 -0000
@@ -22,6 +22,7 @@
 .Nm rwlock ,
 .Nm rw_init ,
 .Nm rw_init_flags ,
+.Nm rw_init_flags_trace ,
 .Nm rw_enter ,
 .Nm rw_exit ,
 .Nm rw_enter_read ,
@@ -34,6 +35,7 @@
 .Nm rw_assert_unlocked ,
 .Nm rw_status ,
 .Nm RWLOCK_INITIALIZER ,
+.Nm RWLOCK_INITIALIZER_TRACE ,
 .Nm rrw_init ,
 .Nm rrw_init_flags ,
 .Nm rrw_enter ,
@@ -46,6 +48,7 @@
 .Fn rw_init "struct rwlock *rwl" "const char *name"
 .Ft void
 .Fn rw_init_flags "struct rwlock *rwl" "const char *name" "int flags"
+.Fn rw_init_flags_trace "struct rwlock *rwl" "const char *name" "int flags" "int trace"
 .Ft int
 .Fn rw_enter "struct rwlock *rwl" "int flags"
 .Ft void
@@ -69,6 +72,7 @@
 .Ft int
 .Fn rw_status "struct rwlock *rwl"
 .Fn RWLOCK_INITIALIZER "const char *name"
+.Fn RWLOCK_INITIALIZER_TRACE "const char *name" "int trace"
 .Ft void
 .Fn rrw_init "struct rrwlock *rrwl" "const char *name"
 .Ft void
@@ -121,6 +125,8 @@ Instructs
 .Xr witness 4
 to ignore this lock.
 .El
+.Fn rw_init_flags_trace
+additionally accepts a dt(4) static probe index.
 .Pp
 The
 .Fn rw_enter
@@ -197,6 +203,8 @@ The
 .Fa name
 argument specifies the name of the lock, which is used as the wait message
 if the thread needs to sleep.
+.Fn RWLOCK_INITIALIZER_TRACE
+additionally accepts a dt(4) static probe index.
 .Pp
 The
 .Nm rrwlock
@@ -205,6 +213,7 @@ They otherwise behave the same as their 
 .Sh CONTEXT
 .Fn rw_init ,
 .Fn rw_init_flags ,
+.Fn rw_init_flags_trace ,
 .Fn rrw_init
 and
 .Fn rrw_init_flags