From patchwork Mon Feb 26 03:57:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Masami Hiramatsu (Google)" X-Patchwork-Id: 20946 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp1860032dyb; Sun, 25 Feb 2024 20:12:49 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCW4LRvTxqmRzu2zXcVSKV2dPpy0ZynY4FSzI7qD9ekdQ+MEjB98oUhF2pPmNWToBHIBTyuWxaNoby5ggz01L4L2kxsZcg== X-Google-Smtp-Source: AGHT+IHTTTpFraShbrWVSUBMhnY55XyO8i8MOHi8vgjsrmvFvDk08V+wlCXLooJSpOGvNNVXmUeS X-Received: by 2002:a05:6402:3456:b0:564:3b2e:2a2e with SMTP id l22-20020a056402345600b005643b2e2a2emr3634086edc.9.1708920769363; Sun, 25 Feb 2024 20:12:49 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708920769; cv=pass; d=google.com; s=arc-20160816; b=Jpd8jD+kcu6/Vmw1ngJ5zs2mjb/JydYBvEkXIQVx5iZFBSz0lVwIy/wg3B8zKTpRm2 lb+EbpWIJSojYzRO/6qz22ws2b26WsuBYIAu6/nLNTb0m8qWLUTtasbsVCF6B2Q2hAxu ec6664AQlO5dTaTiQsnOws8JSYG5YZSddJ3Seypds2yc4vJg3hg9Ly79XGysV3xVNfid BE00uL5jR+CRibs6nsytFFhPrF1kLADR8iv/8Fs4iSjUILDxfScp8oD1JYLUO6q/PZcQ 0+0W9gYg01dbDm6XaMM2bUwuIjPW5OFvG+MVjzS2VqaZiaOx+E16+kk8Sp0ZKDbuH7im wKnQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:user-agent:message-id:date :subject:cc:to:from:dkim-signature; bh=stoYIKwLis9v9dHRaQyvN4EH/HYzkEJyHNGhFejMoCs=; fh=+uEoxECwu+GZPXA+yzsV/ZJCsf7WyFzcH+9RxOmv8OU=; b=myFnZjV+0WCCu3Bq6Ho+G/d4SBs4Yi1gdd4VnmLtXNSmeM9uB3L2oQrqa79XyoCA2k iOLbCSngIVu4jyVThJ8lDkVvyOLXUu1qCUGEYxR/yFk5TeDnRQEd4XMlvuwIw5XiQN7F vrncjoFsM0LVZP1nFxwL/I5mZvnRFaHXZYkkrVa8KdwtMFJQmI3ZKHZ+nbS2VBxKsWOD 7HVe1mqujlU+SRvPQygtDZTG3QAnQHg7r3O1EYKS2LBcng4pgQ2BNOWlMcZ6eTH0mY4F u5LE5X4kLC+jJfzMRn7jruJm9ENyi12mbu2K/d/MZLJU1SN+44DuD3VtU5zjIvKugDjg Gtmg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Ynq5945f; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-80503-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-80503-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id u10-20020a50eaca000000b00565dcc278fasi796021edp.540.2024.02.25.20.12.49 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 25 Feb 2024 20:12:49 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-80503-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Ynq5945f; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-80503-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-80503-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 7F8ED1F24FB7 for ; Mon, 26 Feb 2024 04:02:10 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 852CE1B800; Mon, 26 Feb 2024 03:58:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Ynq5945f" 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 CDFC11B7E3; Mon, 26 Feb 2024 03:57:58 +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=1708919878; cv=none; b=hwPaNzACZTnd663q+jIbZepmjRA6osRIcMKBzv9EoTisp4iNqaxOS7WX9uF/kwXj+9BLpJSVpmnpJ3wPnmAnN4ZMVqDvNwyxdwwLvW532xhlTz/IRLu02CGWCDt/mwpQeZcdPnljPF1vi1WSVk9OCqR94He3+2W5KZyTbvAK6FI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708919878; c=relaxed/simple; bh=6eV/0foyMhUCesPp4RUIfzVdUPTf/g2H7EDQ8aK/UiE=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version:Content-Type; b=WHD+RRuwZzg3rZMfFmW32rFkeio2pZE1Bw0Q2oKNoRedek0NLP0vl1/wCjQJSqfaIszNaf2GfeFzrPC3h9CI036ZvLSjlZaLEEcLHlYBa04FXhRzb6TZ5K/r9U69fXv9nXsKWqRngOFIZ5+LbUZDJihBU8THUd4g6MgYZBjEh7Q= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Ynq5945f; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7FD4FC433C7; Mon, 26 Feb 2024 03:57:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1708919878; bh=6eV/0foyMhUCesPp4RUIfzVdUPTf/g2H7EDQ8aK/UiE=; h=From:To:Cc:Subject:Date:From; b=Ynq5945f9Uj1pO+1l/G/qFbWR1EvKH6IbKRxedbgP32P/t1GzHI7ghH1y7slQ3xri 6u+7NYV8bF9RqPNxErTFQoXS6IjcJO4iMBFfRUolghRQoxcC19OE1RZsMni1JzlhDP K7B4smpOv8wJSbsiorRH60apN3rck2o+KFH9CsckA8lg9S9oAh25q1n886AqSztetP IP+yssUSnoS/E2mC+NBGgirFBBaATSxCsOa+qoK/gqBfBFZ+lHP9u8MLSB5hMmaxlX kY0ByORlK6EY3tV4anD8fDiXE/w2SJyEXmxvcE1XOMpAIJzjAA6R4wmZexuLfduvtu /j4kysTdW2NNg== From: "Masami Hiramatsu (Google)" To: Steven Rostedt , Jiri Olsa Cc: linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, mhiramat@kernel.org, linux-doc@vger.kernel.org, linux-kselftest@vger.kernel.org Subject: [PATCH v2 0/7] tracing/probes: Support function parameter access from return probe Date: Mon, 26 Feb 2024 12:57:53 +0900 Message-Id: <170891987362.609861.6767830614537418260.stgit@devnote2> X-Mailer: git-send-email 2.34.1 User-Agent: StGit/0.19 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791933304628472102 X-GMAIL-MSGID: 1791933304628472102 Hi, Here is version 2 series of patches to support accessing function entry data from function *return* probes (including kretprobe and fprobe-exit event). In this version, I added another cleanup [4/7], updated README[5/7], added testcases[6/7] and updated document[7/7]. This allows us to access the results of some functions, which returns the error code and its results are passed via function parameter, such as an structure-initialization function. For example, vfs_open() will link the file structure to the inode and update mode. Thus we can trace that changes. # echo 'f vfs_open mode=file->f_mode:x32 inode=file->f_inode:x64' >> dynamic_events # echo 'f vfs_open%return mode=file->f_mode:x32 inode=file->f_inode:x64' >> dynamic_events # echo 1 > events/fprobes/enable # cat trace sh-131 [006] ...1. 1945.714346: vfs_open__entry: (vfs_open+0x4/0x40) mode=0x2 inode=0x0 sh-131 [006] ...1. 1945.714358: vfs_open__exit: (do_open+0x274/0x3d0 <- vfs_open) mode=0x4d801e inode=0xffff888008470168 cat-143 [007] ...1. 1945.717949: vfs_open__entry: (vfs_open+0x4/0x40) mode=0x1 inode=0x0 cat-143 [007] ...1. 1945.717956: vfs_open__exit: (do_open+0x274/0x3d0 <- vfs_open) mode=0x4a801d inode=0xffff888005f78d28 cat-143 [007] ...1. 1945.720616: vfs_open__entry: (vfs_open+0x4/0x40) mode=0x1 inode=0x0 cat-143 [007] ...1. 1945.728263: vfs_open__exit: (do_open+0x274/0x3d0 <- vfs_open) mode=0xa800d inode=0xffff888004ada8d8 So as you can see those fields are initialized at exit. This series is based on v6.8-rc5 kernel or you can checkout from https://git.kernel.org/pub/scm/linux/kernel/git/mhiramat/linux.git/log/?h=topic/entry-data Thank you, --- Masami Hiramatsu (Google) (7): tracing/fprobe-event: cleanup: Fix a wrong comment in fprobe event tracing/probes: Cleanup probe argument parser tracing/probes: cleanup: Set trace_probe::nr_args at trace_probe_init tracing: Remove redundant #else block for BTF args from README tracing/probes: Support $argN in return probe (kprobe and fprobe) selftests/ftrace: Add test cases for entry args at function exit Documentation: tracing: Add entry argument access at function exit Documentation/trace/fprobetrace.rst | 7 Documentation/trace/kprobetrace.rst | 7 kernel/trace/trace.c | 5 kernel/trace/trace_eprobe.c | 8 kernel/trace/trace_fprobe.c | 59 ++- kernel/trace/trace_kprobe.c | 58 ++- kernel/trace/trace_probe.c | 417 ++++++++++++++------ kernel/trace/trace_probe.h | 30 + kernel/trace/trace_probe_tmpl.h | 10 kernel/trace/trace_uprobe.c | 14 - .../ftrace/test.d/dynevent/fprobe_entry_arg.tc | 18 + .../ftrace/test.d/kprobe/kretprobe_entry_arg.tc | 18 + 12 files changed, 483 insertions(+), 168 deletions(-) create mode 100644 tools/testing/selftests/ftrace/test.d/dynevent/fprobe_entry_arg.tc create mode 100644 tools/testing/selftests/ftrace/test.d/kprobe/kretprobe_entry_arg.tc -- Masami Hiramatsu (Google)