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 21D053857C52 for ; Thu, 23 Sep 2021 22:21:43 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 21D053857C52 Received: from mail-oo1-f71.google.com (mail-oo1-f71.google.com [209.85.161.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-215-pM61BBKzM_282gE1oNHHMA-1; Thu, 23 Sep 2021 18:21:41 -0400 X-MC-Unique: pM61BBKzM_282gE1oNHHMA-1 Received: by mail-oo1-f71.google.com with SMTP id x23-20020a4a3957000000b0029aff3ae536so5786268oog.0 for ; Thu, 23 Sep 2021 15:21:41 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=xncVPPY182I8rJZqxUsIDfZFL5ISHj0O00lVjqQYW98=; b=gw/eVKahxqEKbB/eW3UkASdN+8ZFeoIO/y0R00e2XLc47oe7zv2tF/2AcTrVauKEfq DLmf6J+uIP5cEv11lvDxFZENRX+7XZGuTa/xovt7O7dmxSN/XS2L9OtEWvaVyc/JbUs3 T10IISgZKwdqptWTlqguasAik1gsKy80g3RJlRR3mjdNx4JuMRYK2QLR7mBMa9EMvyis Ho9ZeRKAZ2nNzJDUFO1wSSVa+SVqAJ+5mEpRUR2Y8Aw3R6/TT12+BU0FKAUHJ3uhwuFF OQGNp6DvGGXU+IznTYlWttddtVJ7rbo88RjoDuYqBeplN+QEZMXHiJx1H7fFJV9FeL2j XrIg== X-Gm-Message-State: AOAM530I1j1VwWxEPx17ZQJriD8Tj6ciTcyca6VvgLyuQDXEPb2nm7IZ s1UW72oV1WI5zUx7ZJ4Fn4UY1kiw4iIga8ul/KF3ydjadYVpHGriSY8RmGfXmhRR7G3Cf15DXk0 A298c+lbyrN3KvuRYnuLH0VJCgbpaa9jrP0I= X-Received: by 2002:a4a:ded2:: with SMTP id w18mr5860519oou.77.1632435700667; Thu, 23 Sep 2021 15:21:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzfbwbYvZ9a9h/AoVjvVgSfNlgB+jt6XYWJXijsxR3AT9FY+9q/rMjJBpa3CV4O//AwPYdUCNxYf1jU8vO/378= X-Received: by 2002:a4a:ded2:: with SMTP id w18mr5860501oou.77.1632435700398; Thu, 23 Sep 2021 15:21:40 -0700 (PDT) MIME-Version: 1.0 References: <20210923174903.605613-1-nsoffer@redhat.com> In-Reply-To: <20210923174903.605613-1-nsoffer@redhat.com> From: Nir Soffer Date: Fri, 24 Sep 2021 01:21:24 +0300 Message-ID: Subject: Re: [PATCH] Fix traceaio with IO_CMD_{PREAD,PWRITE} To: systemtap@sourceware.org Cc: David Teigland , fche@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-14.7 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 22:21:44 -0000 On Thu, Sep 23, 2021 at 8:49 PM Nir Soffer wrote: > > 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 %) Unfortunately this does not work. I tested this before adding these "constants". This works: global IO_CMD_PREADV = 7 global IO_CMD_PWRITEV = 8 Do we have a better way to handle this? > + > 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 >