public inbox for systemtap@sourceware.org
 help / color / mirror / Atom feed
From: Nir Soffer <nsoffer@redhat.com>
To: systemtap@sourceware.org
Cc: fche@redhat.com, teigland@redhat.com, Nir Soffer <nsoffer@redhat.com>
Subject: [PATCH v2] Fix traceaio with IO_CMD_{PREAD,PWRITE}
Date: Wed, 29 Sep 2021 12:03:11 +0300	[thread overview]
Message-ID: <20210929090311.1075181-1-nsoffer@redhat.com> (raw)

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 | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)

diff --git a/testsuite/systemtap.examples/io/traceaio.stp b/testsuite/systemtap.examples/io/traceaio.stp
index 126ea9c3c..dd123858e 100755
--- a/testsuite/systemtap.examples/io/traceaio.stp
+++ b/testsuite/systemtap.examples/io/traceaio.stp
@@ -8,6 +8,10 @@
 # published by the Free Software Foundation.
 #
 
+# From <linux/aio_abi.h>
+global IOCB_CMD_PREADV = 7
+global IOCB_CMD_PWRITEV = 8
+
 probe begin {
     println("Tracing started");
 }
@@ -27,12 +31,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 == IOCB_CMD_PREADV || opcode == IOCB_CMD_PWRITEV) {
+                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)
+                }
             }
         }
     }
-- 
2.31.1


                 reply	other threads:[~2021-09-29  9:03 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20210929090311.1075181-1-nsoffer@redhat.com \
    --to=nsoffer@redhat.com \
    --cc=fche@redhat.com \
    --cc=systemtap@sourceware.org \
    --cc=teigland@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 read-only IMAP folder(s) and NNTP newsgroup(s).