All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jin Yao <yao.jin@linux.intel.com>
To: acme@kernel.org, jolsa@kernel.org, peterz@infradead.org,
	mingo@redhat.com, alexander.shishkin@linux.intel.com
Cc: Linux-kernel@vger.kernel.org, ak@linux.intel.com,
	kan.liang@intel.com, yao.jin@intel.com,
	Jin Yao <yao.jin@linux.intel.com>
Subject: [PATCH v2 6/8] perf mem: Fix wrong verbose output for recording events
Date: Thu, 27 May 2021 08:16:08 +0800	[thread overview]
Message-ID: <20210527001610.10553-7-yao.jin@linux.intel.com> (raw)
In-Reply-To: <20210527001610.10553-1-yao.jin@linux.intel.com>

Current code:

for (j = 0; j < argc; j++, i++)
        rec_argv[i] = argv[j];

if (verbose > 0) {
        pr_debug("calling: record ");

        while (rec_argv[j]) {
                pr_debug("%s ", rec_argv[j]);
                j++;
        }
        pr_debug("\n");
}

The entries of argv[] are copied to the end of rec_argv[], not
copied to the beginning of rec_argv[]. So the index j at
rec_argv[] doesn't point to the first event.

Now we record the start index and end index for events in rec_argv[],
and print them if verbose is enabled.

Signed-off-by: Jin Yao <yao.jin@linux.intel.com>
---
v2:
 - New in v2.

 tools/perf/builtin-mem.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/tools/perf/builtin-mem.c b/tools/perf/builtin-mem.c
index 6b633df458c2..0fd2a74dbaca 100644
--- a/tools/perf/builtin-mem.c
+++ b/tools/perf/builtin-mem.c
@@ -65,6 +65,7 @@ static const char * const *record_mem_usage = __usage;
 static int __cmd_record(int argc, const char **argv, struct perf_mem *mem)
 {
 	int rec_argc, i = 0, j, tmp_nr = 0;
+	int start, end;
 	const char **rec_argv;
 	char **rec_tmp;
 	int ret;
@@ -144,9 +145,11 @@ static int __cmd_record(int argc, const char **argv, struct perf_mem *mem)
 	if (mem->data_page_size)
 		rec_argv[i++] = "--data-page-size";
 
+	start = i;
 	ret = perf_mem_events__record_args(rec_argv, &i, rec_tmp, &tmp_nr);
 	if (ret)
 		goto out;
+	end = i;
 
 	if (all_user)
 		rec_argv[i++] = "--all-user";
@@ -160,10 +163,9 @@ static int __cmd_record(int argc, const char **argv, struct perf_mem *mem)
 	if (verbose > 0) {
 		pr_debug("calling: record ");
 
-		while (rec_argv[j]) {
+		for (j = start; j < end; j++)
 			pr_debug("%s ", rec_argv[j]);
-			j++;
-		}
+
 		pr_debug("\n");
 	}
 
-- 
2.17.1


  parent reply	other threads:[~2021-05-27  7:56 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-27  0:16 [PATCH v2 0/8] perf: Support perf-mem/perf-c2c for AlderLake Jin Yao
2021-05-27  0:16 ` [PATCH v2 1/8] perf tools: Check mem-loads auxiliary event Jin Yao
2021-05-27  0:16 ` [PATCH v2 2/8] perf tools: Support pmu prefix for mem-load event Jin Yao
2021-05-27  0:16 ` [PATCH v2 3/8] perf tools: Support pmu prefix for mem-store event Jin Yao
2021-05-27  0:16 ` [PATCH v2 4/8] perf tools: Check if mem_events is supported for hybrid platform Jin Yao
2021-05-27  0:16 ` [PATCH v2 5/8] perf mem: Support record " Jin Yao
2021-05-27  0:16 ` Jin Yao [this message]
2021-05-31 22:42   ` [PATCH v2 6/8] perf mem: Fix wrong verbose output for recording events Jiri Olsa
2021-06-01  1:10     ` Jin, Yao
2021-05-27  0:16 ` [PATCH v2 7/8] perf mem: Disable 'mem-loads-aux' group before reporting Jin Yao
2021-05-27  0:16 ` [PATCH v2 8/8] perf c2c: Support record for hybrid platform Jin Yao
2021-05-31 22:49 ` [PATCH v2 0/8] perf: Support perf-mem/perf-c2c for AlderLake Jiri Olsa
2021-06-01 14:09   ` Arnaldo Carvalho de Melo

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=20210527001610.10553-7-yao.jin@linux.intel.com \
    --to=yao.jin@linux.intel.com \
    --cc=Linux-kernel@vger.kernel.org \
    --cc=acme@kernel.org \
    --cc=ak@linux.intel.com \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=jolsa@kernel.org \
    --cc=kan.liang@intel.com \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=yao.jin@intel.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.