From patchwork Wed Feb 14 13:22:14 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: 20373 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:bc8a:b0:106:860b:bbdd with SMTP id dn10csp1207397dyb; Wed, 14 Feb 2024 05:22:53 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUd7DfV5bE5ddcdjapnDi0nxWVDgBf4CcY3lsJJUdyu/4fh5H8uMOI6Ori92+5ha1PDdCkTO57NY6Sm2Pos9b98p8T2nw== X-Google-Smtp-Source: AGHT+IF/vL7fVDKU+Zk0nJPpeoWMMND+nRneiyl+GdcJpAsbPR7OK0AmYgb1OmCRW3xdYdWewaVo X-Received: by 2002:a05:6402:88c:b0:561:e8c:791e with SMTP id e12-20020a056402088c00b005610e8c791emr2278763edy.38.1707916973284; Wed, 14 Feb 2024 05:22:53 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707916973; cv=pass; d=google.com; s=arc-20160816; b=cbV8CgfO2stq+622MD0e9K9BHNkumQVVS3WLd+YI5FW2sSW32xr+haZiLc2JmFPWh9 bOnZf8GNltrh8PnALfeLxh5aOvFLvEmgyMuL8gpKpmZX+QWsZ6eBps/Vmk5A7mjnvodt pOe69MKCZVv/p8yl60QMeCN6DChOCRd2YayHspHMYxCgsgRTERdA/2XGuU8ZKGz7+4vn vhM/0WNJ8WGT2n9l6P7pla2mcviV0A1koUZET34vj4FqQhHaGrlWXcqktr7jyZHMDJKX l8e/xjM+OzojQ06HioG23taJ2P6QI8p2p4Q8wjOf8oX5uo+SC6F28NnFTLYDYBxBFruj 2WdQ== 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=WvjmQOjZ/aFgolkGp64UwYFwNPvrbxY+q/4LMdLNcuE=; fh=csPhxj2mcv+iNTyXRUlYdFGkIp20IG/hEgiAc0kmd4E=; b=Ptk0LOvc5J8AjBff+pHcOVLjw0WaUc09sNejWBVQmHjUhynZcJ5+CNiRJ8/egvX/zS hnRmBbTsnf1lPb7wapUzDibArKxjfxWOwQMLV/B9KhsL6QHuc95ahkRm8p7drfs+7O9P nIFrIMpxLpHtRRZb67r9ZIs5LYdP2UcUjF7+RoNvmCISmGNxbYcZ5hI0dxQ6WQlrJ/MO pht1fV8PQKa2WrVmJmd4AwN9G+pLXEM0P7PN0dEW1jSOzrweOllNtFPrKbGJDscDtmBM +lzperM67QSRphDqHVLyteAwp2hutobsDEiBtoD8NlAc1LwE8QNvNUEac97/d+m6wCw4 tllA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=bIP2z1ZO; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-65266-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-65266-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Forwarded-Encrypted: i=2; AJvYcCUG+UNPdIPfs8C3fi6H14kjcJiiCWBERGJJ0rtCcgAh5paK4BTbM1Nk0yQajiLZX5I2fsOzUsim29APMib6HWyZiVUW8w== Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id a4-20020aa7d904000000b00560a8b102cbsi4789359edr.299.2024.02.14.05.22.53 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 05:22:53 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-65266-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=bIP2z1ZO; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-65266-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-65266-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 4ECB11F22466 for ; Wed, 14 Feb 2024 13:22:38 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4FB0754BD8; Wed, 14 Feb 2024 13:22:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="bIP2z1ZO" 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 C9F4654670; Wed, 14 Feb 2024 13:22:18 +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=1707916938; cv=none; b=AwrpfOA+BZv/ArCWE3qNyIFcDbv0nFyIJRBFnYU6SRJ5Ce6s8flvAdC4TmQm7FW3tBy29wx4oBbnfg8GUCgM6ZDNyC7Uw++o6j6XO2ZkKWRBkshu9TBklP/mAAovKO3ymDPsle/fOh+M7byjs/VDPsjYysQvdz9dnWs3QT0xiJE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707916938; c=relaxed/simple; bh=bBRoDlO2YKY1ltZI6iH4y3v5GP17SnYkawVDUuqF5FA=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version:Content-Type; b=bzL3w++1NrRKjC0m3w9HjT5PYsEDQVh1XML4ACuww11aCxgmpvhjAJdDX/3bEafeJywVCBZcTe95qBuH3AO/xAcbZ2I2/U2Wq6Z49Ca39llDUG1RVDJqMe5aHdS1mKZEdzsgOxnwFUZxKOCASB0uTN9AQHYltU1qKSgjS+9jgnw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=bIP2z1ZO; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3E154C433C7; Wed, 14 Feb 2024 13:22:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1707916938; bh=bBRoDlO2YKY1ltZI6iH4y3v5GP17SnYkawVDUuqF5FA=; h=From:To:Cc:Subject:Date:From; b=bIP2z1ZOkTF1YgpwaFaEpnlpasFryQboSHsOUKZGk+dpmRsNq/FL6pBiOb66gZG8W 9YlM2MnLYEc9jkznARRMQ+2qH9r9320YErVQbCDMrAFuMSNNNKu+AlMKdskS+UysSq 4R+Qz3YH46sDlXaYwtpaAdmp3kCxpHp9NcDtg/32luoxIygIo3gDQ1x5dT4pRYO8El 0N5Lb/Z7K+UY5WbGLsDeiHUdqoaDmHeJffYQUCPZsVB/pYb+rAJz16hivsB4UrCk+O lnCqd38DXsd+rE7l0KhAWEcaPtvAeHzZW5xDLZT2gMoPVCZH0ZOM67imDLSpjdYc7N P5lxb0eQRIy0A== From: "Masami Hiramatsu (Google)" To: linux-trace-kernel@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Steven Rostedt , mhiramat@kernel.org Subject: [PATCH RFC 0/5] tracing/probes: Support function parameter access from return probe Date: Wed, 14 Feb 2024 22:22:14 +0900 Message-Id: <170791693437.389532.6816883363982512874.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: 1790880748101531765 X-GMAIL-MSGID: 1790880748101531765 Hi, Here is a series of patches to support accessing function entry data from function *return* probes (including kretprobe and fprobe-exit event). 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. TODO: - update README file - add/update ftracetest - update documents Thank you, --- Masami Hiramatsu (Google) (5): tracing/probes: Fix to search structure fields correctly 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/probes: Support $argN in return probe (kprobe and fprobe) kernel/trace/trace_btf.c | 4 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 + 8 files changed, 433 insertions(+), 167 deletions(-) -- Masami Hiramatsu (Google)