linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] cpupower: implement the multi-cpu monitoring of programs
@ 2021-05-12 11:26 Hamza Mahfooz
  2021-05-12 11:26 ` [PATCH 2/2] cpupower: removed a completed task from the list Hamza Mahfooz
  2021-05-12 14:44 ` [PATCH 1/2] cpupower: implement the multi-cpu monitoring of programs Shuah Khan
  0 siblings, 2 replies; 5+ messages in thread
From: Hamza Mahfooz @ 2021-05-12 11:26 UTC (permalink / raw)
  To: linux-kernel
  Cc: Thomas Renninger, Shuah Khan, linux-pm, Hamza Mahfooz,
	Janakarajan Natarajan

If we look inside cpupower/ToDo, the current 6th point makes mention of
a method to implement multi-cpu monitoring without introducing noise to
the tested program itself.

Suggested-by: Janakarajan Natarajan <Janakarajan.Natarajan@amd.com>
Signed-off-by: Hamza Mahfooz <someguy@effective-light.com>
---
 .../utils/idle_monitor/cpupower-monitor.c     | 28 +++++++++++++------
 1 file changed, 20 insertions(+), 8 deletions(-)

diff --git a/tools/power/cpupower/utils/idle_monitor/cpupower-monitor.c b/tools/power/cpupower/utils/idle_monitor/cpupower-monitor.c
index 7c77045fef52..5fc9b38be4e5 100644
--- a/tools/power/cpupower/utils/idle_monitor/cpupower-monitor.c
+++ b/tools/power/cpupower/utils/idle_monitor/cpupower-monitor.c
@@ -278,7 +278,7 @@ void list_monitors(void)
 	}
 }
 
-int fork_it(char **argv)
+int fork_it(int cpu, char **argv)
 {
 	int status;
 	unsigned int num;
@@ -315,9 +315,9 @@ int fork_it(char **argv)
 
 	timediff = timespec_diff_us(start, end);
 	if (WIFEXITED(status))
-		printf(_("%s took %.5f seconds and exited with status %d\n"),
-			argv[0], timediff / (1000.0 * 1000),
-			WEXITSTATUS(status));
+		printf(_("cpu %d: %s took %.5f seconds and exited with status %d\n"),
+			cpu, argv[0],
+			timediff / (1000.0 * 1000), WEXITSTATUS(status));
 	return 0;
 }
 
@@ -388,7 +388,8 @@ int cmd_monitor(int argc, char **argv)
 {
 	unsigned int num;
 	struct cpuidle_monitor *test_mon;
-	int cpu;
+	int cpu, status;
+	pid_t child_pid;
 
 	cmdline(argc, argv);
 	cpu_count = get_cpu_topology(&cpu_top);
@@ -440,10 +441,21 @@ int cmd_monitor(int argc, char **argv)
 	/*
 	 * if any params left, it must be a command to fork
 	 */
-	if (argc - optind)
-		fork_it(argv + optind);
-	else
+	if (argc - optind) {
+		for (cpu = 0; cpu < cpu_count; cpu++) {
+			child_pid = fork();
+			if (!child_pid) {
+				bind_cpu(cpu);
+				fork_it(cpu, argv + optind);
+				exit(EXIT_SUCCESS);
+			} else if (waitpid(child_pid, &status, 0) == -1) {
+				perror("waitpid");
+				exit(EXIT_FAILURE);
+			}
+		}
+	} else {
 		do_interval_measure(interval);
+	}
 
 	/* ToDo: Topology parsing needs fixing first to do
 	   this more generically */
-- 
2.31.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 2/2] cpupower: removed a completed task from the list
  2021-05-12 11:26 [PATCH 1/2] cpupower: implement the multi-cpu monitoring of programs Hamza Mahfooz
@ 2021-05-12 11:26 ` Hamza Mahfooz
  2021-05-12 14:45   ` Shuah Khan
  2021-05-12 14:44 ` [PATCH 1/2] cpupower: implement the multi-cpu monitoring of programs Shuah Khan
  1 sibling, 1 reply; 5+ messages in thread
From: Hamza Mahfooz @ 2021-05-12 11:26 UTC (permalink / raw)
  To: linux-kernel; +Cc: Thomas Renninger, Shuah Khan, linux-pm, Hamza Mahfooz

Since this task has been completed, cpupower/ToDo should be updated so
that others know not to attempt this task as well.

Signed-off-by: Hamza Mahfooz <someguy@effective-light.com>
---
 tools/power/cpupower/ToDo | 10 ----------
 1 file changed, 10 deletions(-)

diff --git a/tools/power/cpupower/ToDo b/tools/power/cpupower/ToDo
index b196a139a3e4..39c870ea83e6 100644
--- a/tools/power/cpupower/ToDo
+++ b/tools/power/cpupower/ToDo
@@ -12,13 +12,3 @@ ToDos sorted by priority:
   -> This is to move the per_cpu logic from inside the
      monitor to outside it. This can be given higher
      priority in fork_it.
-- Fork as many processes as there are CPUs in case the
-  per_cpu_schedule flag is set.
-  -> Bind forked process to each cpu.
-  -> Execute start measures via the forked processes on
-     each cpu.
-  -> Run test executable in a forked process.
-  -> Execute stop measures via the forked processes on
-     each cpu.
-  This would be ideal as it will not introduce noise in the
-  tested executable.
-- 
2.31.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH 1/2] cpupower: implement the multi-cpu monitoring of programs
  2021-05-12 11:26 [PATCH 1/2] cpupower: implement the multi-cpu monitoring of programs Hamza Mahfooz
  2021-05-12 11:26 ` [PATCH 2/2] cpupower: removed a completed task from the list Hamza Mahfooz
@ 2021-05-12 14:44 ` Shuah Khan
  1 sibling, 0 replies; 5+ messages in thread
From: Shuah Khan @ 2021-05-12 14:44 UTC (permalink / raw)
  To: Hamza Mahfooz, linux-kernel
  Cc: Thomas Renninger, Shuah Khan, linux-pm, Janakarajan Natarajan,
	Shuah Khan

On 5/12/21 5:26 AM, Hamza Mahfooz wrote:
> If we look inside cpupower/ToDo, the current 6th point makes mention of
> a method to implement multi-cpu monitoring without introducing noise to
> the tested program itself.
> 
> Suggested-by: Janakarajan Natarajan <Janakarajan.Natarajan@amd.com>
> Signed-off-by: Hamza Mahfooz <someguy@effective-light.com>

You have to use real name/address in you signed-off-by. Is this how
you sign your legal documents?

Please refer to:
https://www.kernel.org/doc/html/latest/process/submitting-patches.html

thanks,
-- Shuah

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 2/2] cpupower: removed a completed task from the list
  2021-05-12 11:26 ` [PATCH 2/2] cpupower: removed a completed task from the list Hamza Mahfooz
@ 2021-05-12 14:45   ` Shuah Khan
  2021-05-12 20:30     ` Hamza Mahfooz
  0 siblings, 1 reply; 5+ messages in thread
From: Shuah Khan @ 2021-05-12 14:45 UTC (permalink / raw)
  To: Hamza Mahfooz, linux-kernel
  Cc: Thomas Renninger, Shuah Khan, linux-pm, Shuah Khan

On 5/12/21 5:26 AM, Hamza Mahfooz wrote:
> Since this task has been completed, cpupower/ToDo should be updated so
> that others know not to attempt this task as well.
> 
> Signed-off-by: Hamza Mahfooz <someguy@effective-light.com>


You have to use real name/address in you signed-off-by. Is this how
you sign your legal documents?

Please refer to:
https://www.kernel.org/doc/html/latest/process/submitting-patches.html

thanks,
-- Shuah

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 2/2] cpupower: removed a completed task from the list
  2021-05-12 14:45   ` Shuah Khan
@ 2021-05-12 20:30     ` Hamza Mahfooz
  0 siblings, 0 replies; 5+ messages in thread
From: Hamza Mahfooz @ 2021-05-12 20:30 UTC (permalink / raw)
  To: Shuah Khan; +Cc: linux-kernel, Thomas Renninger, Shuah Khan, linux-pm



On Wed, May 12 2021 at 08:45:49 AM -0600, Shuah Khan 
<skhan@linuxfoundation.org> wrote:
> You have to use real name/address in you signed-off-by.

I have used my real name and email address btw.



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-05-12 20:51 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-12 11:26 [PATCH 1/2] cpupower: implement the multi-cpu monitoring of programs Hamza Mahfooz
2021-05-12 11:26 ` [PATCH 2/2] cpupower: removed a completed task from the list Hamza Mahfooz
2021-05-12 14:45   ` Shuah Khan
2021-05-12 20:30     ` Hamza Mahfooz
2021-05-12 14:44 ` [PATCH 1/2] cpupower: implement the multi-cpu monitoring of programs Shuah Khan

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).