Message ID | ZdYtJs8nWt6ALprh@x1 |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel+bounces-75159-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:693c:2685:b0:108:e6aa:91d0 with SMTP id mn5csp1168971dyc; Wed, 21 Feb 2024 09:05:36 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWkVtMixzkXCs+rNJqk2ujCLtvEKn89PghAUgbmuXL/IPpVhMCUoLTDHUKuDmfLRemeE8xYwHMMLr6e8ozP99/45NZy9Q== X-Google-Smtp-Source: AGHT+IFRNBWbc7CIZdorTluzDwPgnjIDN06Vm43asU+Z6ujiTKUOoSYFaFZYIcyDrP+cJ9gj/NUU X-Received: by 2002:a17:90b:b0b:b0:299:2240:43e with SMTP id bf11-20020a17090b0b0b00b002992240043emr14123749pjb.35.1708535136298; Wed, 21 Feb 2024 09:05:36 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708535136; cv=pass; d=google.com; s=arc-20160816; b=nGqtJsilUXYxixABdzuN8ZJLnNZW7bMKwAgniCk9QzXqMQv/6szpgHNrhTo6B+MAl4 y3fQlCJvBWwF2rgEa6kRxoPkUYUHs1bNfwcxinfpJIG8/gBoqurZSRpLfg1yE2dGLTrK ti7jiyB2qXID9t3hbdT98QntpJ+QN0db8BMN6HLVHOyoIl+HjuqKqpTjhCbywdhAOnFq KXNuEC8vMJe4tptoqiH65WqfOPyGkW3iVMab3QciXCTrL3LsFrPTTeJUADkf3RqxUJ+Z rxWnbSVisvv4YUd1bfP7yDHAkpYOhTUlWUpcko6kVpd9n6DLgzJeSOxjfYlIBzDPFT6D PUfw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-disposition:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:message-id:subject:cc:to:from:date :dkim-signature; bh=O9TaUuipdCSWR/JqJvLWLyY0mCREW7veRM6GlWhA6iU=; fh=LHoRBkCV7YFtute1bxRvAv2KoY1+DE4brpr3wmlFNFk=; b=xt1FBSZ8naIzB7CHZykRbyp18Y1I+w/vY1EF5aQt/zhNZFKXXM0pPaVYdrfTl49QO+ rplWy/l4N/G045Ru8gChX4l3NHWQSC9F7Rk7ocnSWs+RpWmGaL1FnhAMXAoPc5PqYTW5 S+4HUOrgqhPtPxfp2PZTcZr7bjTdsMoJfQZtaIlxs4oxwFQREKE7GGsAUAvsYPp6wTVM VHhtNr04iTCJGhZIeTOv0yToiuIzGJIGx3NS/kHH+WFoL6qzJhuo/XSe+iNEi9QelqTq rjQ6zsvffJJYwCrDu8xm/dggi+gWu628xsTqDSmCF73RjO2SoG939cy/xnZ0xRNkTSVP +SYg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=nOD15bXa; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-75159-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-75159-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id v6-20020a17090a6b0600b00299491faa0bsi8609596pjj.137.2024.02.21.09.05.35 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Feb 2024 09:05:36 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-75159-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=nOD15bXa; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-75159-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-75159-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 70D02B20BF4 for <ouuuleilei@gmail.com>; Wed, 21 Feb 2024 17:05:08 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B8BC583CB7; Wed, 21 Feb 2024 17:04:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="nOD15bXa" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 977B5839E0; Wed, 21 Feb 2024 17:04:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708535083; cv=none; b=ZzIr8hGqR8YOIiD30DuOmPHidnPTS/j4zUrdRsIkg+dAUkxyS0LFrt0ySSYfCBkXoFk+4/ABVrcyZjxJNOnIjpAlx2/CoXisWTdb66mcztB1SNvMu+ogB3oVWDkFRmsrveuswdapw6K2lsbs0Zg3Dq7UtrZa08fPAU4Xe1ai+z0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708535083; c=relaxed/simple; bh=7qKbGwaEKrIs5CEKuJzoB1E1+PJ1uNtIk55d8WvXuWg=; h=Date:From:To:Cc:Subject:Message-ID:MIME-Version:Content-Type: Content-Disposition; b=tRe/Hs6X44oePkeLLKEFcMCWmvsCFjxSfl5RvaA9jBs7jNMnmvfdZlew9/ZI9s38h4X4pn582b5AFAxlI2m0J08+4FYzGm1aRSBMJV00+nFvRX7lLXqW+a5RDioPvsqxfI3dO1IpdmzjQ2C/3IGh2DRphuVQJR3Msg+Ohn45vJI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=nOD15bXa; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5E802C433C7; Wed, 21 Feb 2024 17:04:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1708535083; bh=7qKbGwaEKrIs5CEKuJzoB1E1+PJ1uNtIk55d8WvXuWg=; h=Date:From:To:Cc:Subject:From; b=nOD15bXa7Csn7bTVsgw2dPxCBjVqJFWuLJjfyMjCmSuf6w78iwxId925yJ7IFcV7y vXl3We1TGQMGF3J26yXbxQZPHzjiflMw3gKKTP3esJp5449Lrw0G5yZPDrGS+HlCrN IufQLHdMl8Py1sSHMjid1HJLRbAE+1zmcPcLz7PJvJCxXGoOpvDw7aOzV7v7J9GluI s0xslSwpOTNO4NQ13jt2hocaJF3999b3QphL0uY3GHVKLqsxaD1EBvgRTYkVY2uj3S 2gXq+KZxGWMSU6Tn0HRJliQfaCzFiPXcgBYHNJT2pF9XN3x1kY617ak4cnwzZlupIx YFdZt83PycAMQ== Date: Wed, 21 Feb 2024 14:04:38 -0300 From: Arnaldo Carvalho de Melo <acme@kernel.org> To: Namhyung Kim <namhyung@kernel.org> Cc: Adrian Hunter <adrian.hunter@intel.com>, Ian Rogers <irogers@google.com>, Jiri Olsa <jolsa@kernel.org>, Linux Kernel Mailing List <linux-kernel@vger.kernel.org>, linux-perf-users@vger.kernel.org Subject: [PATCH 1/1] perf trace: Collect sys_nanosleep first argument Message-ID: <ZdYtJs8nWt6ALprh@x1> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791528939359866764 X-GMAIL-MSGID: 1791528939359866764 |
Series |
[1/1] perf trace: Collect sys_nanosleep first argument
|
|
Commit Message
Arnaldo Carvalho de Melo
Feb. 21, 2024, 5:04 p.m. UTC
That is a 'struct timespec' passed from userspace to the kernel as we
can see with a system wide syscall tracing:
root@number:~# perf trace -e nanosleep
0.000 (10.102 ms): podman/9150 nanosleep(rqtp: { .tv_sec: 0, .tv_nsec: 10000000 }) = 0
38.924 (10.077 ms): podman/2195174 nanosleep(rqtp: { .tv_sec: 0, .tv_nsec: 10000000 }) = 0
100.177 (10.107 ms): podman/9150 nanosleep(rqtp: { .tv_sec: 0, .tv_nsec: 10000000 }) = 0
139.171 (10.063 ms): podman/2195174 nanosleep(rqtp: { .tv_sec: 0, .tv_nsec: 10000000 }) = 0
200.603 (10.105 ms): podman/9150 nanosleep(rqtp: { .tv_sec: 0, .tv_nsec: 10000000 }) = 0
239.399 (10.064 ms): podman/2195174 nanosleep(rqtp: { .tv_sec: 0, .tv_nsec: 10000000 }) = 0
300.994 (10.096 ms): podman/9150 nanosleep(rqtp: { .tv_sec: 0, .tv_nsec: 10000000 }) = 0
339.584 (10.067 ms): podman/2195174 nanosleep(rqtp: { .tv_sec: 0, .tv_nsec: 10000000 }) = 0
401.335 (10.057 ms): podman/9150 nanosleep(rqtp: { .tv_sec: 0, .tv_nsec: 10000000 }) = 0
439.758 (10.166 ms): podman/2195174 nanosleep(rqtp: { .tv_sec: 0, .tv_nsec: 10000000 }) = 0
501.814 (10.110 ms): podman/9150 nanosleep(rqtp: { .tv_sec: 0, .tv_nsec: 10000000 }) = 0
539.983 (10.227 ms): podman/2195174 nanosleep(rqtp: { .tv_sec: 0, .tv_nsec: 10000000 }) = 0
602.284 (10.199 ms): podman/9150 nanosleep(rqtp: { .tv_sec: 0, .tv_nsec: 10000000 }) = 0
640.208 (10.105 ms): podman/2195174 nanosleep(rqtp: { .tv_sec: 0, .tv_nsec: 10000000 }) = 0
702.662 (10.163 ms): podman/9150 nanosleep(rqtp: { .tv_sec: 0, .tv_nsec: 10000000 }) = 0
740.440 (10.107 ms): podman/2195174 nanosleep(rqtp: { .tv_sec: 0, .tv_nsec: 10000000 }) = 0
802.993 (10.159 ms): podman/9150 nanosleep(rqtp: { .tv_sec: 0, .tv_nsec: 10000000 }) = 0
^Croot@number:~# strace -p 9150 -e nanosleep
If we then use the ptrace method to look at that podman process:
root@number:~# strace -p 9150 -e nanosleep
strace: Process 9150 attached
nanosleep({tv_sec=0, tv_nsec=10000000}, NULL) = 0
nanosleep({tv_sec=0, tv_nsec=10000000}, NULL) = 0
nanosleep({tv_sec=0, tv_nsec=10000000}, NULL) = 0
nanosleep({tv_sec=0, tv_nsec=10000000}, NULL) = 0
nanosleep({tv_sec=0, tv_nsec=10000000}, NULL) = 0
nanosleep({tv_sec=0, tv_nsec=10000000}, NULL) = 0
nanosleep({tv_sec=0, tv_nsec=10000000}, NULL) = 0
^Cstrace: Process 9150 detached
root@number:~#
With some changes we can get something closer to the strace output,
still in system wide mode:
root@number:~# perf config trace.show_arg_names=false
root@number:~# perf config trace.show_duration=false
root@number:~# perf config trace.show_timestamp=false
root@number:~# perf config trace.show_zeros=true
root@number:~# perf config trace.args_alignment=0
root@number:~# perf trace -e nanosleep --max-events=10
podman/2195174 nanosleep({ .tv_sec: 0, .tv_nsec: 10000000 }, NULL) = 0
podman/9150 nanosleep({ .tv_sec: 0, .tv_nsec: 10000000 }, NULL) = 0
podman/2195174 nanosleep({ .tv_sec: 0, .tv_nsec: 10000000 }, NULL) = 0
podman/9150 nanosleep({ .tv_sec: 0, .tv_nsec: 10000000 }, NULL) = 0
podman/2195174 nanosleep({ .tv_sec: 0, .tv_nsec: 10000000 }, NULL) = 0
podman/9150 nanosleep({ .tv_sec: 0, .tv_nsec: 10000000 }, NULL) = 0
podman/2195174 nanosleep({ .tv_sec: 0, .tv_nsec: 10000000 }, NULL) = 0
podman/9150 nanosleep({ .tv_sec: 0, .tv_nsec: 10000000 }, NULL) = 0
podman/2195174 nanosleep({ .tv_sec: 0, .tv_nsec: 10000000 }, NULL) = 0
podman/9150 nanosleep({ .tv_sec: 0, .tv_nsec: 10000000 }, NULL) = 0
root@number:~#
root@number:~# perf config
trace.show_arg_names=false
trace.show_duration=false
trace.show_timestamp=false
trace.show_zeros=true
trace.args_alignment=0
root@number:~# cat ~/.perfconfig
# this file is auto-generated.
[trace]
show_arg_names = false
show_duration = false
show_timestamp = false
show_zeros = true
args_alignment = 0
root@number:~#
This will not get reused by any other syscall as nanosleep is the only
one to have as its first argument a 'struct timespec" pointer argument
passed from userspace to the kernel:
root@number:~# grep timespec /sys/kernel/tracing/events/syscalls/sys_enter_*/format | grep offset:16
/sys/kernel/tracing/events/syscalls/sys_enter_nanosleep/format: field:struct __kernel_timespec * rqtp; offset:16; size:8; signed:0;
root@number:~#
BTF based pretty printing will simplify all this, but then lets just get
the low hanging fruits first.
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Ian Rogers <irogers@google.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/perf/builtin-trace.c | 2 ++
.../bpf_skel/augmented_raw_syscalls.bpf.c | 21 +++++++++++++++++++
2 files changed, 23 insertions(+)
Comments
On Wed, Feb 21, 2024 at 9:04 AM Arnaldo Carvalho de Melo <acme@kernel.org> wrote: > > That is a 'struct timespec' passed from userspace to the kernel as we > can see with a system wide syscall tracing: > > root@number:~# perf trace -e nanosleep > 0.000 (10.102 ms): podman/9150 nanosleep(rqtp: { .tv_sec: 0, .tv_nsec: 10000000 }) = 0 > 38.924 (10.077 ms): podman/2195174 nanosleep(rqtp: { .tv_sec: 0, .tv_nsec: 10000000 }) = 0 > 100.177 (10.107 ms): podman/9150 nanosleep(rqtp: { .tv_sec: 0, .tv_nsec: 10000000 }) = 0 > 139.171 (10.063 ms): podman/2195174 nanosleep(rqtp: { .tv_sec: 0, .tv_nsec: 10000000 }) = 0 > 200.603 (10.105 ms): podman/9150 nanosleep(rqtp: { .tv_sec: 0, .tv_nsec: 10000000 }) = 0 > 239.399 (10.064 ms): podman/2195174 nanosleep(rqtp: { .tv_sec: 0, .tv_nsec: 10000000 }) = 0 > 300.994 (10.096 ms): podman/9150 nanosleep(rqtp: { .tv_sec: 0, .tv_nsec: 10000000 }) = 0 > 339.584 (10.067 ms): podman/2195174 nanosleep(rqtp: { .tv_sec: 0, .tv_nsec: 10000000 }) = 0 > 401.335 (10.057 ms): podman/9150 nanosleep(rqtp: { .tv_sec: 0, .tv_nsec: 10000000 }) = 0 > 439.758 (10.166 ms): podman/2195174 nanosleep(rqtp: { .tv_sec: 0, .tv_nsec: 10000000 }) = 0 > 501.814 (10.110 ms): podman/9150 nanosleep(rqtp: { .tv_sec: 0, .tv_nsec: 10000000 }) = 0 > 539.983 (10.227 ms): podman/2195174 nanosleep(rqtp: { .tv_sec: 0, .tv_nsec: 10000000 }) = 0 > 602.284 (10.199 ms): podman/9150 nanosleep(rqtp: { .tv_sec: 0, .tv_nsec: 10000000 }) = 0 > 640.208 (10.105 ms): podman/2195174 nanosleep(rqtp: { .tv_sec: 0, .tv_nsec: 10000000 }) = 0 > 702.662 (10.163 ms): podman/9150 nanosleep(rqtp: { .tv_sec: 0, .tv_nsec: 10000000 }) = 0 > 740.440 (10.107 ms): podman/2195174 nanosleep(rqtp: { .tv_sec: 0, .tv_nsec: 10000000 }) = 0 > 802.993 (10.159 ms): podman/9150 nanosleep(rqtp: { .tv_sec: 0, .tv_nsec: 10000000 }) = 0 > ^Croot@number:~# strace -p 9150 -e nanosleep > > If we then use the ptrace method to look at that podman process: > > root@number:~# strace -p 9150 -e nanosleep > strace: Process 9150 attached > nanosleep({tv_sec=0, tv_nsec=10000000}, NULL) = 0 > nanosleep({tv_sec=0, tv_nsec=10000000}, NULL) = 0 > nanosleep({tv_sec=0, tv_nsec=10000000}, NULL) = 0 > nanosleep({tv_sec=0, tv_nsec=10000000}, NULL) = 0 > nanosleep({tv_sec=0, tv_nsec=10000000}, NULL) = 0 > nanosleep({tv_sec=0, tv_nsec=10000000}, NULL) = 0 > nanosleep({tv_sec=0, tv_nsec=10000000}, NULL) = 0 > ^Cstrace: Process 9150 detached > root@number:~# > > With some changes we can get something closer to the strace output, > still in system wide mode: > > root@number:~# perf config trace.show_arg_names=false > root@number:~# perf config trace.show_duration=false > root@number:~# perf config trace.show_timestamp=false > root@number:~# perf config trace.show_zeros=true > root@number:~# perf config trace.args_alignment=0 > root@number:~# perf trace -e nanosleep --max-events=10 > podman/2195174 nanosleep({ .tv_sec: 0, .tv_nsec: 10000000 }, NULL) = 0 > podman/9150 nanosleep({ .tv_sec: 0, .tv_nsec: 10000000 }, NULL) = 0 > podman/2195174 nanosleep({ .tv_sec: 0, .tv_nsec: 10000000 }, NULL) = 0 > podman/9150 nanosleep({ .tv_sec: 0, .tv_nsec: 10000000 }, NULL) = 0 > podman/2195174 nanosleep({ .tv_sec: 0, .tv_nsec: 10000000 }, NULL) = 0 > podman/9150 nanosleep({ .tv_sec: 0, .tv_nsec: 10000000 }, NULL) = 0 > podman/2195174 nanosleep({ .tv_sec: 0, .tv_nsec: 10000000 }, NULL) = 0 > podman/9150 nanosleep({ .tv_sec: 0, .tv_nsec: 10000000 }, NULL) = 0 > podman/2195174 nanosleep({ .tv_sec: 0, .tv_nsec: 10000000 }, NULL) = 0 > podman/9150 nanosleep({ .tv_sec: 0, .tv_nsec: 10000000 }, NULL) = 0 > root@number:~# > root@number:~# perf config > trace.show_arg_names=false > trace.show_duration=false > trace.show_timestamp=false > trace.show_zeros=true > trace.args_alignment=0 > root@number:~# cat ~/.perfconfig > # this file is auto-generated. > [trace] > show_arg_names = false > show_duration = false > show_timestamp = false > show_zeros = true > args_alignment = 0 > root@number:~# > > This will not get reused by any other syscall as nanosleep is the only > one to have as its first argument a 'struct timespec" pointer argument > passed from userspace to the kernel: > > root@number:~# grep timespec /sys/kernel/tracing/events/syscalls/sys_enter_*/format | grep offset:16 > /sys/kernel/tracing/events/syscalls/sys_enter_nanosleep/format: field:struct __kernel_timespec * rqtp; offset:16; size:8; signed:0; > root@number:~# > > BTF based pretty printing will simplify all this, but then lets just get > the low hanging fruits first. > > Cc: Adrian Hunter <adrian.hunter@intel.com> > Cc: Ian Rogers <irogers@google.com> > Cc: Jiri Olsa <jolsa@kernel.org> > Cc: Namhyung Kim <namhyung@kernel.org> > Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com> v2? https://lore.kernel.org/lkml/Zbq72dJRpOlfRWnf@kernel.org/ Thanks, Ian
On Wed, Feb 21, 2024 at 09:15:01AM -0800, Ian Rogers wrote: > On Wed, Feb 21, 2024 at 9:04 AM Arnaldo Carvalho de Melo > <acme@kernel.org> wrote: > > > > That is a 'struct timespec' passed from userspace to the kernel as we > > can see with a system wide syscall tracing: > > > > root@number:~# perf trace -e nanosleep > > 0.000 (10.102 ms): podman/9150 nanosleep(rqtp: { .tv_sec: 0, .tv_nsec: 10000000 }) = 0 > > 38.924 (10.077 ms): podman/2195174 nanosleep(rqtp: { .tv_sec: 0, .tv_nsec: 10000000 }) = 0 > > 100.177 (10.107 ms): podman/9150 nanosleep(rqtp: { .tv_sec: 0, .tv_nsec: 10000000 }) = 0 > > 139.171 (10.063 ms): podman/2195174 nanosleep(rqtp: { .tv_sec: 0, .tv_nsec: 10000000 }) = 0 > > 200.603 (10.105 ms): podman/9150 nanosleep(rqtp: { .tv_sec: 0, .tv_nsec: 10000000 }) = 0 > > 239.399 (10.064 ms): podman/2195174 nanosleep(rqtp: { .tv_sec: 0, .tv_nsec: 10000000 }) = 0 > > 300.994 (10.096 ms): podman/9150 nanosleep(rqtp: { .tv_sec: 0, .tv_nsec: 10000000 }) = 0 > > 339.584 (10.067 ms): podman/2195174 nanosleep(rqtp: { .tv_sec: 0, .tv_nsec: 10000000 }) = 0 > > 401.335 (10.057 ms): podman/9150 nanosleep(rqtp: { .tv_sec: 0, .tv_nsec: 10000000 }) = 0 > > 439.758 (10.166 ms): podman/2195174 nanosleep(rqtp: { .tv_sec: 0, .tv_nsec: 10000000 }) = 0 > > 501.814 (10.110 ms): podman/9150 nanosleep(rqtp: { .tv_sec: 0, .tv_nsec: 10000000 }) = 0 > > 539.983 (10.227 ms): podman/2195174 nanosleep(rqtp: { .tv_sec: 0, .tv_nsec: 10000000 }) = 0 > > 602.284 (10.199 ms): podman/9150 nanosleep(rqtp: { .tv_sec: 0, .tv_nsec: 10000000 }) = 0 > > 640.208 (10.105 ms): podman/2195174 nanosleep(rqtp: { .tv_sec: 0, .tv_nsec: 10000000 }) = 0 > > 702.662 (10.163 ms): podman/9150 nanosleep(rqtp: { .tv_sec: 0, .tv_nsec: 10000000 }) = 0 > > 740.440 (10.107 ms): podman/2195174 nanosleep(rqtp: { .tv_sec: 0, .tv_nsec: 10000000 }) = 0 > > 802.993 (10.159 ms): podman/9150 nanosleep(rqtp: { .tv_sec: 0, .tv_nsec: 10000000 }) = 0 > > ^Croot@number:~# strace -p 9150 -e nanosleep > > > > If we then use the ptrace method to look at that podman process: > > > > root@number:~# strace -p 9150 -e nanosleep > > strace: Process 9150 attached > > nanosleep({tv_sec=0, tv_nsec=10000000}, NULL) = 0 > > nanosleep({tv_sec=0, tv_nsec=10000000}, NULL) = 0 > > nanosleep({tv_sec=0, tv_nsec=10000000}, NULL) = 0 > > nanosleep({tv_sec=0, tv_nsec=10000000}, NULL) = 0 > > nanosleep({tv_sec=0, tv_nsec=10000000}, NULL) = 0 > > nanosleep({tv_sec=0, tv_nsec=10000000}, NULL) = 0 > > nanosleep({tv_sec=0, tv_nsec=10000000}, NULL) = 0 > > ^Cstrace: Process 9150 detached > > root@number:~# > > > > With some changes we can get something closer to the strace output, > > still in system wide mode: > > > > root@number:~# perf config trace.show_arg_names=false > > root@number:~# perf config trace.show_duration=false > > root@number:~# perf config trace.show_timestamp=false > > root@number:~# perf config trace.show_zeros=true > > root@number:~# perf config trace.args_alignment=0 > > root@number:~# perf trace -e nanosleep --max-events=10 > > podman/2195174 nanosleep({ .tv_sec: 0, .tv_nsec: 10000000 }, NULL) = 0 > > podman/9150 nanosleep({ .tv_sec: 0, .tv_nsec: 10000000 }, NULL) = 0 > > podman/2195174 nanosleep({ .tv_sec: 0, .tv_nsec: 10000000 }, NULL) = 0 > > podman/9150 nanosleep({ .tv_sec: 0, .tv_nsec: 10000000 }, NULL) = 0 > > podman/2195174 nanosleep({ .tv_sec: 0, .tv_nsec: 10000000 }, NULL) = 0 > > podman/9150 nanosleep({ .tv_sec: 0, .tv_nsec: 10000000 }, NULL) = 0 > > podman/2195174 nanosleep({ .tv_sec: 0, .tv_nsec: 10000000 }, NULL) = 0 > > podman/9150 nanosleep({ .tv_sec: 0, .tv_nsec: 10000000 }, NULL) = 0 > > podman/2195174 nanosleep({ .tv_sec: 0, .tv_nsec: 10000000 }, NULL) = 0 > > podman/9150 nanosleep({ .tv_sec: 0, .tv_nsec: 10000000 }, NULL) = 0 > > root@number:~# > > root@number:~# perf config > > trace.show_arg_names=false > > trace.show_duration=false > > trace.show_timestamp=false > > trace.show_zeros=true > > trace.args_alignment=0 > > root@number:~# cat ~/.perfconfig > > # this file is auto-generated. > > [trace] > > show_arg_names = false > > show_duration = false > > show_timestamp = false > > show_zeros = true > > args_alignment = 0 > > root@number:~# > > > > This will not get reused by any other syscall as nanosleep is the only > > one to have as its first argument a 'struct timespec" pointer argument > > passed from userspace to the kernel: > > > > root@number:~# grep timespec /sys/kernel/tracing/events/syscalls/sys_enter_*/format | grep offset:16 > > /sys/kernel/tracing/events/syscalls/sys_enter_nanosleep/format: field:struct __kernel_timespec * rqtp; offset:16; size:8; signed:0; > > root@number:~# > > > > BTF based pretty printing will simplify all this, but then lets just get > > the low hanging fruits first. > > > > Cc: Adrian Hunter <adrian.hunter@intel.com> > > Cc: Ian Rogers <irogers@google.com> > > Cc: Jiri Olsa <jolsa@kernel.org> > > Cc: Namhyung Kim <namhyung@kernel.org> > > Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com> > > v2? https://lore.kernel.org/lkml/Zbq72dJRpOlfRWnf@kernel.org/ Nope, I thought I hadn't submitted and when doing a git rebase perf-tools-next/perf-tools-next It was rebased, so I thought I really hadn't submitted it and sent it. - Arnaldo
diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c index 109b8e64fe69ae32..6abe280dc38f1921 100644 --- a/tools/perf/builtin-trace.c +++ b/tools/perf/builtin-trace.c @@ -1048,6 +1048,8 @@ static const struct syscall_fmt syscall_fmts[] = { .arg = { [3] = { .scnprintf = SCA_MREMAP_FLAGS, /* flags */ }, }, }, { .name = "name_to_handle_at", .arg = { [0] = { .scnprintf = SCA_FDAT, /* dfd */ }, }, }, + { .name = "nanosleep", + .arg = { [0] = { .scnprintf = SCA_TIMESPEC, /* req */ }, }, }, { .name = "newfstatat", .arg = { [0] = { .scnprintf = SCA_FDAT, /* dfd */ }, }, }, { .name = "open", diff --git a/tools/perf/util/bpf_skel/augmented_raw_syscalls.bpf.c b/tools/perf/util/bpf_skel/augmented_raw_syscalls.bpf.c index 2872f9bc07850bd7..0acbd74e8c760956 100644 --- a/tools/perf/util/bpf_skel/augmented_raw_syscalls.bpf.c +++ b/tools/perf/util/bpf_skel/augmented_raw_syscalls.bpf.c @@ -341,6 +341,27 @@ int sys_enter_clock_nanosleep(struct syscall_enter_args *args) return 1; /* Failure: don't filter */ } +SEC("tp/syscalls/sys_enter_nanosleep") +int sys_enter_nanosleep(struct syscall_enter_args *args) +{ + struct augmented_args_payload *augmented_args = augmented_args_payload(); + const void *req_arg = (const void *)args->args[0]; + unsigned int len = sizeof(augmented_args->args); + __u32 size = sizeof(struct timespec64); + + if (augmented_args == NULL) + goto failure; + + if (size > sizeof(augmented_args->__data)) + goto failure; + + bpf_probe_read_user(&augmented_args->__data, size, req_arg); + + return augmented__output(args, augmented_args, len + size); +failure: + return 1; /* Failure: don't filter */ +} + static pid_t getpid(void) { return bpf_get_current_pid_tgid();