From mboxrd@z Thu Jan 1 00:00:00 1970 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 E0A41226527; Thu, 3 Apr 2025 19:18:11 +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=1743707892; cv=none; b=cT654L4OwvIjLY/ed3u+S02WRbtcSNoCXvKzZVFf/9/SUUTw/55ZP2bMctgi8rl2yDG1OZOphc1JYFsQD7VqvS/zK/Uzx1jIlV+mTBoZWUbXbAvyqxCRpyWWCmwmD+lV2zvnTvxvNVoXL06tBdG4mFNo8H357ldYPxXSz+vHkUc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743707892; c=relaxed/simple; bh=4Z0q3Xs/H9AZcmWQTqJHE7x55UJuKGQjIQM0FFvzNiQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=NECM8iTnYMVN/o/sY+2/kVtIc65SlhSNmkVOub64qWoQ96FTsxBiU23KME6e1X6fD315ej5Rw4jUyW+9zBOHLD369/w9LC81KvtQ4DS+X/6FpzratHLGkWOVl6nBfjBEMORCbqGohr+feaeVpinvDXsLnyRGctxv7j1ct0PrjmM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=GfxGs8qW; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="GfxGs8qW" Received: by smtp.kernel.org (Postfix) with ESMTPSA id AB541C4CEE8; Thu, 3 Apr 2025 19:18:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1743707891; bh=4Z0q3Xs/H9AZcmWQTqJHE7x55UJuKGQjIQM0FFvzNiQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GfxGs8qWSAGt+Jlwg+MxSmvQfBM56bLfvZBsT6bcaqNEH62g6gBCq7H+mwyl9R2B8 Bgsudy38bKe+oBZ4RbhUeSNqeDjliXsj4WkaK7UbE+jkHajX/S/3wBcqKu2AnhNmQa PKxcTjlGLXqCaNTtxStdFLxoZx7wx/IbYuFXVBp5+v5qp/wo/+trCLOzG1tEvEI7b6 7XVYpdx0KB1OYyvgcb/ytvjCwuEiGk4+iKDRphzKqhhRXXGujreUz0Dh1ufvmhYHLX po3d5lLVQ97WCo//p+oaEb4P1/e3sPGF6gvVwzI1StbS8ox9nhWt/cJVtr7Cnthaqi 27oCkHzogaBng== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: "Masami Hiramatsu (Google)" , Steven Rostedt , Sasha Levin , linux-trace-kernel@vger.kernel.org Subject: [PATCH AUTOSEL 6.12 30/33] tracing: probe-events: Add comments about entry data storing code Date: Thu, 3 Apr 2025 15:16:53 -0400 Message-Id: <20250403191656.2680995-30-sashal@kernel.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250403191656.2680995-1-sashal@kernel.org> References: <20250403191656.2680995-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-trace-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore X-stable-base: Linux 6.12.21 Content-Transfer-Encoding: 8bit From: "Masami Hiramatsu (Google)" [ Upstream commit bb9c6020f4c3a07a90dc36826cb5fbe83f09efd5 ] Add comments about entry data storing code to __store_entry_arg() and traceprobe_get_entry_data_size(). These are a bit complicated because of building the entry data storing code and scanning it. This just add comments, no behavior change. Link: https://lore.kernel.org/all/174061715004.501424.333819546601401102.stgit@devnote2/ Reported-by: Steven Rostedt Closes: https://lore.kernel.org/all/20250226102223.586d7119@gandalf.local.home/ Reviewed-by: Steven Rostedt (Google) Signed-off-by: Masami Hiramatsu (Google) Signed-off-by: Sasha Levin --- kernel/trace/trace_probe.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/kernel/trace/trace_probe.c b/kernel/trace/trace_probe.c index 16a5e368e7b77..578919962e5df 100644 --- a/kernel/trace/trace_probe.c +++ b/kernel/trace/trace_probe.c @@ -770,6 +770,10 @@ static int check_prepare_btf_string_fetch(char *typename, #ifdef CONFIG_HAVE_FUNCTION_ARG_ACCESS_API +/* + * Add the entry code to store the 'argnum'th parameter and return the offset + * in the entry data buffer where the data will be stored. + */ static int __store_entry_arg(struct trace_probe *tp, int argnum) { struct probe_entry_arg *earg = tp->entry_arg; @@ -793,6 +797,20 @@ static int __store_entry_arg(struct trace_probe *tp, int argnum) tp->entry_arg = earg; } + /* + * The entry code array is repeating the pair of + * [FETCH_OP_ARG(argnum)][FETCH_OP_ST_EDATA(offset of entry data buffer)] + * and the rest of entries are filled with [FETCH_OP_END]. + * + * To reduce the redundant function parameter fetching, we scan the entry + * code array to find the FETCH_OP_ARG which already fetches the 'argnum' + * parameter. If it doesn't match, update 'offset' to find the last + * offset. + * If we find the FETCH_OP_END without matching FETCH_OP_ARG entry, we + * will save the entry with FETCH_OP_ARG and FETCH_OP_ST_EDATA, and + * return data offset so that caller can find the data offset in the entry + * data buffer. + */ offset = 0; for (i = 0; i < earg->size - 1; i++) { switch (earg->code[i].op) { @@ -826,6 +844,16 @@ int traceprobe_get_entry_data_size(struct trace_probe *tp) if (!earg) return 0; + /* + * earg->code[] array has an operation sequence which is run in + * the entry handler. + * The sequence stopped by FETCH_OP_END and each data stored in + * the entry data buffer by FETCH_OP_ST_EDATA. The FETCH_OP_ST_EDATA + * stores the data at the data buffer + its offset, and all data are + * "unsigned long" size. The offset must be increased when a data is + * stored. Thus we need to find the last FETCH_OP_ST_EDATA in the + * code array. + */ for (i = 0; i < earg->size; i++) { switch (earg->code[i].op) { case FETCH_OP_END: -- 2.39.5