]> sourceware.org Git - systemtap.git/commitdiff
Fix traceaio with IO_CMD_{PREAD,PWRITE}
authorNir Soffer <nsoffer@redhat.com>
Wed, 29 Sep 2021 08:06:53 +0000 (04:06 -0400)
committerFrank Ch. Eigler <fche@redhat.com>
Wed, 29 Sep 2021 08:06:53 +0000 (04:06 -0400)
When using IO_CMD_{PREAD,PWRITE} aio_nbytes is the size of a single
buffer aio_buf.

Previously the script logged unrelated memory contents from userspace:

[     0 sanlock(8214):] io_submit(140589225578496, 1, 0x7fdd5fefc718)
    iocb[   0]=0x7fdd58000b70, fd=16, opcode=0, offset=0, nbytes=1048576, buf=0x7fdd5c5f6000
        iovec[   0]=0x7fdd5c5f6000, base=0x3000412212010, len=16
        iovec[   1]=0x7fdd5c5f6010, base=0x0, len=1
        iovec[   2]=0x7fdd5c5f6020, base=0x1, len=16
        ...

Now we trace iovecs only when using IO_CMD_{PREADV,PWITEV}:

[     0 sanlock(8397):] io_submit(140589225566208, 1, 0x7fdd5e6f9718)
    iocb[   0]=0x7fdd48000b70, fd=19, opcode=0, offset=0, nbytes=1048576, buf=0x7fdd5c3f2000
[     0 sanlock(8397):] io_submit(140589225566208, 1, 0x7fdd5e6f9718)
    iocb[   0]=0x7fdd48000b70, fd=19, opcode=1, offset=512, nbytes=512, buf=0x7fdd4810a000

Signed-off-by: Nir Soffer <nsoffer@redhat.com>
testsuite/systemtap.examples/io/traceaio.stp

index 126ea9c3ca960bd4e9655aa1e3f339ed178ef7b3..903d65526dda03096e213cef848e302e1ac05058 100755 (executable)
@@ -8,6 +8,9 @@
 # published by the Free Software Foundation.
 #
 
+@define IO_CMD_PREADV   %( 7 %)
+@define IO_CMD_PWRITEV  %( 8 %)
+
 probe begin {
     println("Tracing started");
 }
@@ -27,12 +30,14 @@ probe syscall.io_submit
             printf("    iocb[%4d]=%p, fd=%d, opcode=%d, offset=%d, nbytes=%d, buf=%p\n",
                    i, iocbp, fd, opcode, offset, nbytes, buf)
 
-            for (j = 0; j < nbytes; j++) {
-                iovecp = &@cast(buf, "iovec", "kernel")[j]
-                base = user_uint64(&@cast(iovecp, "iovec", "kernel")->iov_base)
-                len = user_uint32(&@cast(iovecp, "iovec", "kernel")->iov_len)
-                printf("        iovec[%4d]=%p, base=%p, len=%d\n",
-                       j, iovecp, base, len)
+            if (opcode == @IO_CMD_PREADV || opcode == @IO_CMD_PREADV) {
+                for (j = 0; j < nbytes; j++) {
+                    iovecp = &@cast(buf, "iovec", "kernel")[j]
+                    base = user_uint64(&@cast(iovecp, "iovec", "kernel")->iov_base)
+                    len = user_uint32(&@cast(iovecp, "iovec", "kernel")->iov_len)
+                    printf("        iovec[%4d]=%p, base=%p, len=%d\n",
+                           j, iovecp, base, len)
+                }
             }
         }
     }
This page took 0.028562 seconds and 5 git commands to generate.