From patchwork Wed May 12 11:26:57 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hamza Mahfooz X-Patchwork-Id: 437581 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7C247C433B4 for ; Wed, 12 May 2021 11:35:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 48C89613FB for ; Wed, 12 May 2021 11:35:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230037AbhELLg0 (ORCPT ); Wed, 12 May 2021 07:36:26 -0400 Received: from h4.fbrelay.privateemail.com ([131.153.2.45]:34549 "EHLO h4.fbrelay.privateemail.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230114AbhELLgZ (ORCPT ); Wed, 12 May 2021 07:36:25 -0400 Received: from MTA-07-4.privateemail.com (mta-07.privateemail.com [198.54.127.57]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by h3.fbrelay.privateemail.com (Postfix) with ESMTPS id 0FDCB8081D; Wed, 12 May 2021 07:27:48 -0400 (EDT) Received: from MTA-07.privateemail.com (localhost [127.0.0.1]) by MTA-07.privateemail.com (Postfix) with ESMTP id 177A26004D; Wed, 12 May 2021 07:27:47 -0400 (EDT) Received: from hal-station.. (unknown [10.20.151.208]) by MTA-07.privateemail.com (Postfix) with ESMTPA id 6551960051; Wed, 12 May 2021 07:27:46 -0400 (EDT) From: Hamza Mahfooz To: linux-kernel@vger.kernel.org Cc: Thomas Renninger , Shuah Khan , linux-pm@vger.kernel.org, Hamza Mahfooz , Janakarajan Natarajan Subject: [PATCH 1/2] cpupower: implement the multi-cpu monitoring of programs Date: Wed, 12 May 2021 07:26:57 -0400 Message-Id: <20210512112658.89965-1-someguy@effective-light.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 X-Virus-Scanned: ClamAV using ClamSMTP Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org 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 Signed-off-by: Hamza Mahfooz --- .../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 */ From patchwork Wed May 12 11:26:58 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hamza Mahfooz X-Patchwork-Id: 436003 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 66EDCC433ED for ; Wed, 12 May 2021 11:35:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2C37B613CF for ; Wed, 12 May 2021 11:35:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230267AbhELLgZ (ORCPT ); Wed, 12 May 2021 07:36:25 -0400 Received: from h4.fbrelay.privateemail.com ([131.153.2.45]:47819 "EHLO h4.fbrelay.privateemail.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230037AbhELLgZ (ORCPT ); Wed, 12 May 2021 07:36:25 -0400 X-Greylist: delayed 449 seconds by postgrey-1.27 at vger.kernel.org; Wed, 12 May 2021 07:36:25 EDT Received: from MTA-07-4.privateemail.com (mta-07.privateemail.com [198.54.127.57]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by h3.fbrelay.privateemail.com (Postfix) with ESMTPS id 8375A8081E; Wed, 12 May 2021 07:27:56 -0400 (EDT) Received: from MTA-07.privateemail.com (localhost [127.0.0.1]) by MTA-07.privateemail.com (Postfix) with ESMTP id 7BD4760058; Wed, 12 May 2021 07:27:55 -0400 (EDT) Received: from hal-station.. (unknown [10.20.151.208]) by MTA-07.privateemail.com (Postfix) with ESMTPA id D9FD46004D; Wed, 12 May 2021 07:27:54 -0400 (EDT) From: Hamza Mahfooz To: linux-kernel@vger.kernel.org Cc: Thomas Renninger , Shuah Khan , linux-pm@vger.kernel.org, Hamza Mahfooz Subject: [PATCH 2/2] cpupower: removed a completed task from the list Date: Wed, 12 May 2021 07:26:58 -0400 Message-Id: <20210512112658.89965-2-someguy@effective-light.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210512112658.89965-1-someguy@effective-light.com> References: <20210512112658.89965-1-someguy@effective-light.com> MIME-Version: 1.0 X-Virus-Scanned: ClamAV using ClamSMTP Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org 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 --- 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.