Hi,

Whilst analyzing the cleaner I added tracepoints called 'cleaner' and 
'bufcache_take' to
track its behaviour.

For the sake of symmetry I've added one in bufcache_release() too and moved the 
assignment
of 'pages' until after the KASSERT(), following the flow of bufcache_take().

Sample usage of these probes:

tracepoint:vfs:bufcache_take {
        printf("bcache_take:%d(%s) flags: 0x%x cache: %d pages: %d\n",
                tid, comm, arg0 , arg1, arg2);
}

tracepoint:vfs:bufcache_rel{
        printf("bcache_rel:%d(%s) flags: 0x%x cache: %d pages: %d\n",
                tid, comm, arg0, arg1, arg2);
}

tracepoint:vfs:cleaner{
        printf("cleaner:%d(%s) flags: 0x%x pushed: %d lodirtypages: %d, 
hidirtypages: %d\n",
                tid, comm, arg0, arg1, arg2, arg3);
}

OK to commit this?

Index: dev/dt/dt_prov_static.c
===================================================================
RCS file: /cvs/src/sys/dev/dt/dt_prov_static.c,v
retrieving revision 1.4
diff -u -p -r1.4 dt_prov_static.c
--- dev/dt/dt_prov_static.c     13 Sep 2020 14:55:08 -0000      1.4
+++ dev/dt/dt_prov_static.c     14 Sep 2020 10:43:43 -0000
@@ -58,6 +58,13 @@ DT_STATIC_PROBE3(uvm, map_insert, "vaddr
 DT_STATIC_PROBE3(uvm, map_remove, "vaddr_t", "vaddr_t", "vm_prot_t");
 
 /*
+ * VFS
+ */
+DT_STATIC_PROBE3(vfs, bufcache_rel, "long", "int", "int64_t");
+DT_STATIC_PROBE3(vfs, bufcache_take, "long", "int", "int64_t");
+DT_STATIC_PROBE4(vfs, cleaner, "long", "int", "long", "long");
+
+/*
  * List of all static probes
  */
 struct dt_probe *dtps_static[] = {
@@ -76,6 +83,10 @@ struct dt_probe *dtps_static[] = {
        &_DT_STATIC_P(uvm, fault),
        &_DT_STATIC_P(uvm, map_insert),
        &_DT_STATIC_P(uvm, map_remove),
+       /* VFS */
+       &_DT_STATIC_P(vfs, bufcache_rel),
+       &_DT_STATIC_P(vfs, bufcache_take),
+       &_DT_STATIC_P(vfs, cleaner),
 };
 
 int
Index: kern/vfs_bio.c
===================================================================
RCS file: /cvs/src/sys/kern/vfs_bio.c,v
retrieving revision 1.202
diff -u -p -r1.202 vfs_bio.c
--- kern/vfs_bio.c      12 Sep 2020 11:57:24 -0000      1.202
+++ kern/vfs_bio.c      14 Sep 2020 10:43:43 -0000
@@ -57,6 +57,7 @@
 #include <sys/conf.h>
 #include <sys/kernel.h>
 #include <sys/specdev.h>
+#include <sys/tracepoint.h>
 #include <uvm/uvm_extern.h>
 
 /* XXX Should really be in buf.h, but for uvm_constraint_range.. */
@@ -1209,6 +1210,9 @@ buf_daemon(void *arg)
                }
 
                while ((bp = bufcache_getdirtybuf())) {
+                       TRACEPOINT(vfs, cleaner, bp->b_flags, pushed,
+                           lodirtypages, hidirtypages);
+
                        if (UNCLEAN_PAGES < lodirtypages &&
                            bcstats.kvaslots_avail > 2 * RESERVE_SLOTS &&
                            pushed >= 16)
@@ -1693,6 +1697,9 @@ bufcache_take(struct buf *bp)
        KASSERT((bp->cache < NUM_CACHES));
 
        pages = atop(bp->b_bufsize);
+
+       TRACEPOINT(vfs, bufcache_take, bp->b_flags, bp->cache, pages);
+
        struct bufcache *cache = &cleancache[bp->cache];
        if (!ISSET(bp->b_flags, B_DELWRI)) {
                 if (ISSET(bp->b_flags, B_COLD)) {
@@ -1756,8 +1763,11 @@ bufcache_release(struct buf *bp)
        int64_t pages;
        struct bufcache *cache = &cleancache[bp->cache];
 
-       pages = atop(bp->b_bufsize);
        KASSERT(ISSET(bp->b_flags, B_BC));
+       pages = atop(bp->b_bufsize);
+
+       TRACEPOINT(vfs, bufcache_rel, bp->b_flags, bp->cache, pages);
+
        if (fliphigh) {
                if (ISSET(bp->b_flags, B_DMA) && bp->cache > 0)
                        panic("B_DMA buffer release from cache %d",
-- 
jasper

Reply via email to