mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: "Masami Hiramatsu (Google)" <mhiramat@kernel.org>,
	Steven Rostedt <rostedt@goodmis.org>,
	Sasha Levin <sashal@kernel.org>,
	linux-trace-kernel@vger.kernel.org
Subject: [PATCH AUTOSEL 6.6 21/23] tracing: probe-events: Add comments about entry data storing code
Date: Thu,  3 Apr 2025 15:18:14 -0400	[thread overview]
Message-ID: <20250403191816.2681439-21-sashal@kernel.org> (raw)
In-Reply-To: <20250403191816.2681439-1-sashal@kernel.org>

From: "Masami Hiramatsu (Google)" <mhiramat@kernel.org>

[ 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 <rostedt@goodmis.org>
Closes: https://lore.kernel.org/all/20250226102223.586d7119@gandalf.local.home/
Reviewed-by: Steven Rostedt (Google) <rostedt@goodmis.org>
Signed-off-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 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 8c73156a7eb94..606190239c877 100644
--- a/kernel/trace/trace_probe.c
+++ b/kernel/trace/trace_probe.c
@@ -769,6 +769,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;
@@ -792,6 +796,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) {
@@ -825,6 +843,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


  parent reply	other threads:[~2025-04-03 19:19 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-03 19:17 [PATCH AUTOSEL 6.6 01/23] drm: allow encoder mode_set even when connectors change for crtc Sasha Levin
2025-04-03 19:17 ` [PATCH AUTOSEL 6.6 02/23] drm/amd/display: Update Cursor request mode to the beginning prefetch always Sasha Levin
2025-04-03 19:17 ` [PATCH AUTOSEL 6.6 03/23] drm/amd/display: add workaround flag to link to force FFE preset Sasha Levin
2025-04-03 19:17 ` [PATCH AUTOSEL 6.6 04/23] drm: panel-orientation-quirks: Add support for AYANEO 2S Sasha Levin
2025-04-03 19:17 ` [PATCH AUTOSEL 6.6 05/23] drm: panel-orientation-quirks: Add quirks for AYA NEO Flip DS and KB Sasha Levin
2025-04-03 19:17 ` [PATCH AUTOSEL 6.6 06/23] drm: panel-orientation-quirks: Add quirk for AYA NEO Slide Sasha Levin
2025-04-03 19:18 ` [PATCH AUTOSEL 6.6 07/23] drm: panel-orientation-quirks: Add new quirk for GPD Win 2 Sasha Levin
2025-04-03 19:18 ` [PATCH AUTOSEL 6.6 08/23] drm: panel-orientation-quirks: Add quirk for OneXPlayer Mini (Intel) Sasha Levin
2025-04-03 19:18 ` [PATCH AUTOSEL 6.6 09/23] drm/bridge: panel: forbid initializing a panel with unknown connector type Sasha Levin
2025-04-03 19:18 ` [PATCH AUTOSEL 6.6 10/23] drivers: base: devres: Allow to release group on device release Sasha Levin
2025-04-03 19:18 ` [PATCH AUTOSEL 6.6 11/23] drm/amdkfd: clamp queue size to minimum Sasha Levin
2025-04-03 19:18 ` [PATCH AUTOSEL 6.6 12/23] drm/amdkfd: Fix mode1 reset crash issue Sasha Levin
2025-04-03 19:18 ` [PATCH AUTOSEL 6.6 13/23] drm/amdkfd: Fix pqm_destroy_queue race with GPU reset Sasha Levin
2025-04-03 19:18 ` [PATCH AUTOSEL 6.6 14/23] drm/amdkfd: debugfs hang_hws skip GPU with MES Sasha Levin
2025-04-03 19:18 ` [PATCH AUTOSEL 6.6 15/23] drm/mediatek: mtk_dpi: Move the input_2p_en bit to platform data Sasha Levin
2025-04-03 19:18 ` [PATCH AUTOSEL 6.6 16/23] drm/mediatek: mtk_dpi: Explicitly manage TVD clock in power on/off Sasha Levin
2025-04-03 19:18 ` [PATCH AUTOSEL 6.6 17/23] drm/amdgpu: handle amdgpu_cgs_create_device() errors in amd_powerplay_create() Sasha Levin
2025-04-03 19:18 ` [PATCH AUTOSEL 6.6 18/23] PCI: vmd: Make vmd_dev::cfg_lock a raw_spinlock_t type Sasha Levin
2025-04-03 19:18 ` [PATCH AUTOSEL 6.6 19/23] drm/amdgpu: grab an additional reference on the gang fence v2 Sasha Levin
2025-04-03 19:18 ` [PATCH AUTOSEL 6.6 20/23] fbdev: omapfb: Add 'plane' value check Sasha Levin
2025-04-03 19:18 ` Sasha Levin [this message]
2025-04-03 19:18 ` [PATCH AUTOSEL 6.6 22/23] ktest: Fix Test Failures Due to Missing LOG_FILE Directories Sasha Levin
2025-04-03 19:18 ` [PATCH AUTOSEL 6.6 23/23] tpm, tpm_tis: Workaround failed command reception on Infineon devices Sasha Levin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250403191816.2681439-21-sashal@kernel.org \
    --to=sashal@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-trace-kernel@vger.kernel.org \
    --cc=mhiramat@kernel.org \
    --cc=rostedt@goodmis.org \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®