* [PATCH v3] perf sched replay: Fix -r/--repeat command line option for infinity
@ 2024-06-28 7:18 Madadi Vineeth Reddy
2024-07-02 18:44 ` Namhyung Kim
0 siblings, 1 reply; 2+ messages in thread
From: Madadi Vineeth Reddy @ 2024-06-28 7:18 UTC (permalink / raw)
To: Arnaldo Carvalho de Melo, Namhyung Kim, Ian Rogers, Athira Rajeev,
James Clark
Cc: Peter Zijlstra, Ingo Molnar, Mark Rutland, Alexander Shishkin,
Jiri Olsa, Adrian Hunter, Kan Liang, acme, linux-perf-users, LKML,
Madadi Vineeth Reddy
Currently, the -r/--repeat option accepts values from 0 and complains
for -1. The help section specifies:
-r, --repeat <n> repeat the workload replay N times (-1: infinite)
The -r -1 option raises an error because replay_repeat is defined as
an unsigned int.
In the current implementation, the workload is repeated n times when
-r <n> is used, except when n is 0.
When -r is set to 0, the workload is also repeated once. This happens
because when -r=0, the run_one_test function is not called. (Note that
mutex unlocking, which is essential for child threads spawned to emulate
the workload, happens in run_one_test.) However, mutex unlocking is
still performed in the destroy_tasks function. Thus, -r=0 results in the
workload running once coincidentally.
To clarify and maintain the existing logic for -r >= 1 (which runs the
workload the specified number of times) and to fix the issue with infinite
runs, make -r=0 perform an infinite run.
Reviewed-by: James Clark <james.clark@arm.com>
Signed-off-by: Madadi Vineeth Reddy <vineethr@linux.ibm.com>
---
Changes in v3:
- Used UINT_MAX for replay_repeat to maintain the original intent
of an indefinite loop. (Namhyung Kim)
- Rebase against perf-tools-next commit e8b86f0311a4 ("perf test
stat_bpf_counter.sh: Stabilize the test results")
- Link to v2: https://lore.kernel.org/all/20240621171909.24119-1-vineethr@linux.ibm.com/
Changes in v2:
- Kept the existing 'for' loop and added a condition for infinite
looping. (James Clark)
- Add Reviewed-by tag from James Clark.
- Rebase against perf-tools-next commit 788c5160526a ("perf vendor
events: Add westmereex counter information")
- Link to v1: https://lore.kernel.org/all/20240618112907.15131-1-vineethr@linux.ibm.com/
tools/perf/Documentation/perf-sched.txt | 7 +++++++
tools/perf/builtin-sched.c | 5 ++++-
2 files changed, 11 insertions(+), 1 deletion(-)
diff --git a/tools/perf/Documentation/perf-sched.txt b/tools/perf/Documentation/perf-sched.txt
index 74c812f7a4a4..f0e5617f6652 100644
--- a/tools/perf/Documentation/perf-sched.txt
+++ b/tools/perf/Documentation/perf-sched.txt
@@ -202,6 +202,13 @@ OPTIONS for 'perf sched timehist'
--state::
Show task state when it switched out.
+OPTIONS for 'perf sched replay'
+------------------------------
+
+-r::
+--repeat <n>::
+ repeat the workload n times (0: infinite). Default is 10.
+
SEE ALSO
--------
linkperf:perf-record[1]
diff --git a/tools/perf/builtin-sched.c b/tools/perf/builtin-sched.c
index aa59f763ca46..24e9d83c7bb6 100644
--- a/tools/perf/builtin-sched.c
+++ b/tools/perf/builtin-sched.c
@@ -3386,6 +3386,9 @@ static int perf_sched__replay(struct perf_sched *sched)
sched->thread_funcs_exit = false;
create_tasks(sched);
printf("------------------------------------------------------------\n");
+ if (sched->replay_repeat == 0)
+ sched->replay_repeat = UINT_MAX;
+
for (i = 0; i < sched->replay_repeat; i++)
run_one_test(sched);
@@ -3551,7 +3554,7 @@ int cmd_sched(int argc, const char **argv)
};
const struct option replay_options[] = {
OPT_UINTEGER('r', "repeat", &sched.replay_repeat,
- "repeat the workload replay N times (-1: infinite)"),
+ "repeat the workload replay N times (0: infinite)"),
OPT_PARENT(sched_options)
};
const struct option map_options[] = {
--
2.31.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v3] perf sched replay: Fix -r/--repeat command line option for infinity
2024-06-28 7:18 [PATCH v3] perf sched replay: Fix -r/--repeat command line option for infinity Madadi Vineeth Reddy
@ 2024-07-02 18:44 ` Namhyung Kim
0 siblings, 0 replies; 2+ messages in thread
From: Namhyung Kim @ 2024-07-02 18:44 UTC (permalink / raw)
To: Arnaldo Carvalho de Melo, Ian Rogers, Athira Rajeev, James Clark,
Madadi Vineeth Reddy
Cc: Peter Zijlstra, Ingo Molnar, Mark Rutland, Alexander Shishkin,
Jiri Olsa, Adrian Hunter, Kan Liang, acme, linux-perf-users, LKML
On Fri, 28 Jun 2024 12:48:21 +0530, Madadi Vineeth Reddy wrote:
> Currently, the -r/--repeat option accepts values from 0 and complains
> for -1. The help section specifies:
> -r, --repeat <n> repeat the workload replay N times (-1: infinite)
>
> The -r -1 option raises an error because replay_repeat is defined as
> an unsigned int.
>
> [...]
Applied to perf-tools-next, thanks!
Best regards,
Namhyung
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-07-02 18:44 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-06-28 7:18 [PATCH v3] perf sched replay: Fix -r/--repeat command line option for infinity Madadi Vineeth Reddy
2024-07-02 18:44 ` Namhyung Kim
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).