From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by sourceware.org (Postfix) with ESMTP id 0ECDE3858D29 for ; Thu, 23 Sep 2021 17:49:12 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 0ECDE3858D29 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-489-kpJ1liMzPVy5EW6Yq0Omgg-1; Thu, 23 Sep 2021 13:49:10 -0400 X-MC-Unique: kpJ1liMzPVy5EW6Yq0Omgg-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 37F12100C660 for ; Thu, 23 Sep 2021 17:49:09 +0000 (UTC) Received: from sparse.redhat.com (unknown [10.35.206.41]) by smtp.corp.redhat.com (Postfix) with ESMTP id CC745652A2; Thu, 23 Sep 2021 17:49:04 +0000 (UTC) From: Nir Soffer To: systemtap@sourceware.org Cc: teigland@redhat.com, fche@redhat.com, Nir Soffer Subject: [PATCH] Fix traceaio with IO_CMD_{PREAD,PWRITE} Date: Thu, 23 Sep 2021 20:49:03 +0300 Message-Id: <20210923174903.605613-1-nsoffer@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII" X-Spam-Status: No, score=-15.9 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: systemtap@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Systemtap mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 23 Sep 2021 17:49:13 -0000 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 --- testsuite/systemtap.examples/io/traceaio.stp | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/testsuite/systemtap.examples/io/traceaio.stp b/testsuite/systemtap.examples/io/traceaio.stp index 126ea9c3c..903d65526 100755 --- a/testsuite/systemtap.examples/io/traceaio.stp +++ b/testsuite/systemtap.examples/io/traceaio.stp @@ -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) + } } } } -- 2.31.1