From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ed1-x531.google.com (mail-ed1-x531.google.com [IPv6:2a00:1450:4864:20::531]) by sourceware.org (Postfix) with ESMTPS id C9B473858C2C for ; Wed, 22 Sep 2021 14:46:18 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org C9B473858C2C Received: by mail-ed1-x531.google.com with SMTP id c21so10773294edj.0 for ; Wed, 22 Sep 2021 07:46:18 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=nX96Tff/G/yFzyD4N/044kH6F+vWAi0tyeTkoAadY1Q=; b=CznF7m7FNg30T4dwID+u6fiMIyOB3QNb2qlQRRVDzM/It7uhtt6oFzUsusjWWs5pFl iABMefeq3QPMSPWoD022g35S78P4fyskdVsDAcogooLQUrQnEhIICOVti2W9WCN/70co 438DLqNNlLwU1fdWXD4v3m2VfkZcZk2ESBSjEH8vdazchYJouo1fD4y9fGuodu2ESoZV jY0atoxtAbDNMenvk9CbMTLL5CynryAUWY9BwZU7Swm76Ol8Ol6GjxPyF3uokHijFPGc 5RsMg7EAb1UByKXu+XqnaKE1qpvSXgIb2Nb7cMmAZvzK9zk2lIJu32d3FG1m/0Lwkn3E kXhw== X-Gm-Message-State: AOAM5321WPYnpNHWfVh0+lo46TiDaSArdcQ+WJJsNZRVSqtkuWauBPD2 nHoV2Y+t22VMxmkAjnZu3imtFPNa1Jg= X-Google-Smtp-Source: ABdhPJylXc3k0V9lXJdfEpsoaZ/qcvLZ1p6Du6y9FkBO1H2eg5S49yOxt7a/+dQtZltqenYMxgjOmw== X-Received: by 2002:a50:e0c7:: with SMTP id j7mr17052570edl.245.1632321973944; Wed, 22 Sep 2021 07:46:13 -0700 (PDT) Received: from sparse.. (93-172-32-151.bb.netvision.net.il. [93.172.32.151]) by smtp.gmail.com with ESMTPSA id c19sm1331462edt.50.2021.09.22.07.46.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Sep 2021 07:46:13 -0700 (PDT) From: Nir Soffer X-Google-Original-From: Nir Soffer To: systemtap@sourceware.org Cc: kwolf@redhat.com, wcohen@redhat.com, Nir Soffer Subject: [PATCH] Add traceaio example Date: Wed, 22 Sep 2021 17:45:59 +0300 Message-Id: <20210922144559.474891-1-nsoffer@redhat.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-10.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_BARRACUDACENTRAL, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, 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: Wed, 22 Sep 2021 14:46:20 -0000 Show how to trace arguments to io_submit. This is useful to debug EINVAL errors, for example when number of iovecs exceeds limits. Signed-off-by: Nir Soffer --- testsuite/systemtap.examples/io/traceaio.meta | 13 ++++++ testsuite/systemtap.examples/io/traceaio.stp | 43 ++++++++++++++++++ testsuite/systemtap.examples/io/traceaio.txt | 44 +++++++++++++++++++ 3 files changed, 100 insertions(+) create mode 100644 testsuite/systemtap.examples/io/traceaio.meta create mode 100755 testsuite/systemtap.examples/io/traceaio.stp create mode 100644 testsuite/systemtap.examples/io/traceaio.txt diff --git a/testsuite/systemtap.examples/io/traceaio.meta b/testsuite/systemtap.examples/io/traceaio.meta new file mode 100644 index 000000000..ea120f9be --- /dev/null +++ b/testsuite/systemtap.examples/io/traceaio.meta @@ -0,0 +1,13 @@ +title: Trace calls to io_submit +name: traceaio.stp +version: 1.0 +author: Nir Soffer +keywords: io +subsystem: io +status: production +exit: user-controlled +output: trace +scope: process +description: Trace calls to io_submit, logging iocbs and iovecs. +test_check: stap -p4 traceaio.stp -x 1 +test_installcheck: stap traceaio.stp -x 1 -T 1 diff --git a/testsuite/systemtap.examples/io/traceaio.stp b/testsuite/systemtap.examples/io/traceaio.stp new file mode 100755 index 000000000..126ea9c3c --- /dev/null +++ b/testsuite/systemtap.examples/io/traceaio.stp @@ -0,0 +1,43 @@ +#! /usr/bin/env stap +# +# Copyright (C) 2021 Red Hat, Inc. +# Written by Nir Soffer +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License version 2 as +# published by the Free Software Foundation. +# + +probe begin { + println("Tracing started"); +} + +probe syscall.io_submit +{ + if (pid() == target()) { + printf("[%s] io_submit(%s)\n", thread_indent(0), argstr); + + for (i = 0; i < nr; i++) { + iocbp = user_uint64(iocbpp_uaddr + i * 8) + fd = user_uint32(&@cast(iocbp, "iocb", "kernel")->aio_fildes) + opcode = user_uint16(&@cast(iocbp, "iocb", "kernel")->aio_lio_opcode) + offset = user_int64(&@cast(iocbp, "iocb", "kernel")->aio_offset) + nbytes = user_uint64(&@cast(iocbp, "iocb", "kernel")->aio_nbytes) + buf = user_uint64(&@cast(iocbp, "iocb", "kernel")->aio_buf) + 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) + } + } + } +} + +probe end { + println("Tracing stopped"); +} diff --git a/testsuite/systemtap.examples/io/traceaio.txt b/testsuite/systemtap.examples/io/traceaio.txt new file mode 100644 index 000000000..1d90dc592 --- /dev/null +++ b/testsuite/systemtap.examples/io/traceaio.txt @@ -0,0 +1,44 @@ +traceaio.stp - Trace io_submit calls + + Trace calls to io_submit(), logging iocbs and iovecs. When processing calls + with large number of iocbs and iovecs, you may need to increase MAXACTION. + +# stap -D MAXACTION=2000 traceaio.stp -x {pid} +Tracing started +[ 0 IO iothread1(21364):] io_submit(140719456722944, 1, 0x7ffbcf8b2410) + iocb[ 0]=0x7ffb1d9d98c0, fd=15, opcode=8, offset=0, nbytes=1, buf=0x7ffbc801b6a8 + iovec[ 0]=0x7ffbc801b6a8, base=0x7ffb4f9dc000, len=4096 +[ 0 IO iothread1(21364):] io_submit(140719456722944, 1, 0x7ffbcf8b2410) + iocb[ 0]=0x7ffb1d9d9920, fd=15, opcode=7, offset=0, nbytes=1, buf=0x7ffbc801b688 + iovec[ 0]=0x7ffbc801b688, base=0x7ffbb3d11000, len=4096 +[ 0 IO iothread1(21364):] io_submit(140719456722944, 4, 0x7ffbcf8b2410) + iocb[ 0]=0x7ffb1d9d9920, fd=15, opcode=7, offset=8192, nbytes=1, buf=0x7ffbc801b688 + iovec[ 0]=0x7ffbc801b688, base=0x7ffb9d82f000, len=4096 + iocb[ 1]=0x7ffb251dc920, fd=15, opcode=7, offset=20480, nbytes=2, buf=0x7ffbc80315f0 + iovec[ 0]=0x7ffbc80315f0, base=0x7ffbb3f69000, len=4096 + iovec[ 1]=0x7ffbc8031600, base=0x7ffb7dc48000, len=4096 + iocb[ 2]=0x7ffb19999920, fd=15, opcode=7, offset=36864, nbytes=6, buf=0x7ffbc8025320 + iovec[ 0]=0x7ffbc8025320, base=0x7ffb4f676000, len=4096 + iovec[ 1]=0x7ffbc8025330, base=0x7ffbb6f75000, len=4096 + iovec[ 2]=0x7ffbc8025340, base=0x7ffb9ddab000, len=4096 + iovec[ 3]=0x7ffbc8025350, base=0x7ffbbab7d000, len=4096 + iovec[ 4]=0x7ffbc8025360, base=0x7ffb7c3fb000, len=4096 + iovec[ 5]=0x7ffbc8025370, base=0x7ffb7cff5000, len=4096 + iocb[ 3]=0x7ffb16f6f920, fd=15, opcode=7, offset=69632, nbytes=15, buf=0x7ffbc80662b8 + iovec[ 0]=0x7ffbc80662b8, base=0x7ffbb3f44000, len=4096 + iovec[ 1]=0x7ffbc80662c8, base=0x7ffbb85cd000, len=4096 + iovec[ 2]=0x7ffbc80662d8, base=0x7ffbb81de000, len=4096 + iovec[ 3]=0x7ffbc80662e8, base=0x7ffbba3b7000, len=4096 + iovec[ 4]=0x7ffbc80662f8, base=0x7ffb7daf3000, len=4096 + iovec[ 5]=0x7ffbc8066308, base=0x7ffbb1ec3000, len=4096 + iovec[ 6]=0x7ffbc8066318, base=0x7ffbb1ece000, len=4096 + iovec[ 7]=0x7ffbc8066328, base=0x7ffb7cff7000, len=4096 + iovec[ 8]=0x7ffbc8066338, base=0x7ffb7cd60000, len=4096 + iovec[ 9]=0x7ffbc8066348, base=0x7ffbba865000, len=4096 + iovec[ 10]=0x7ffbc8066358, base=0x7ffbb80cc000, len=4096 + iovec[ 11]=0x7ffbc8066368, base=0x7ffbb826c000, len=4096 + iovec[ 12]=0x7ffbc8066378, base=0x7ffbbaa19000, len=4096 + iovec[ 13]=0x7ffbc8066388, base=0x7ffbb8230000, len=4096 + iovec[ 14]=0x7ffbc8066398, base=0x7ffbb6ed0000, len=4096 +... +^CTracing stopped -- 2.31.1