Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp4378425pxj; Wed, 12 May 2021 04:28:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyqIfWkvicVKw0vcxNEkSc7hotq6+AiQTHYqipKitnSobIqsDVXme5uPbNon7Eh+PHDn6KP X-Received: by 2002:a02:cb0c:: with SMTP id j12mr31339605jap.92.1620818911180; Wed, 12 May 2021 04:28:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620818911; cv=none; d=google.com; s=arc-20160816; b=vXXPVKCIV8P1P9/xdmuDOsZc5o6gNtNAWUNxdfoXBUFS1r+jQmk895QGxPnAUpPv2h 7NrMbqdTMdZp8aTKgP1e+P+u+Q6LVc9HFNggpoGDiF2xi/JUHMNRmpkJ/5rBs4oPc0FE rk+hCEYMLdDCrjV/NP7MWAsBvs6/JwBCg1huI70V1PV0eL/S2wrRFk2HR07h17MIhvQA SLRVojjUuNPCXbEceajIrmYvcEPLryYjVRBlTPmAonO97iDpJNiwmP7L3fHZAWLwHTa2 lFUoJG4VsZlbAdZS5mJa5t7L83fm0E4H8A4gEnpGeYL8GhoWaAoPaUpALPSVP63qdgml MAQQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=wzGis5Sx19fZlq+QlTjQHAFtyeO93hUzkwbQWDFQ/eo=; b=gLUyFgnwPnacom+KPdpPU8xLRntuW6HulLqxuF6+osfBSx1Ur7DckwYnbhA8ujdkzT Pt24izM+if7sihwB4gYELQ/UqeaF0/GShPpMAIyNtKHKKtXm0GCcx0YoTPbj1GR9rwG6 VuJaR/OwVMjDPFHVqbAoQVB2ABdMs1vaPeF06//T896I6tqLt2K7zcqyu838Sj33HTjh rBSoQNRdob2BvLaRQWcmB026T6uLoznIA64H5bYFtnEQfzeO4ALnmTO9wj9apPKnhh06 ipxfdUVVgt9xMY+2C6f/LBWhLzKe5wBgPgwkL3hd3Nq1aBzmSh1TLkPrASS14Kv9FqOj oyew== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k11si21929256jap.38.2021.05.12.04.28.18; Wed, 12 May 2021 04:28:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230157AbhELL24 (ORCPT + 99 others); Wed, 12 May 2021 07:28:56 -0400 Received: from h4.fbrelay.privateemail.com ([131.153.2.45]:46253 "EHLO h4.fbrelay.privateemail.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230019AbhELL24 (ORCPT ); Wed, 12 May 2021 07:28:56 -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 Content-Transfer-Encoding: 8bit X-Virus-Scanned: ClamAV using ClamSMTP Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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 */ -- 2.31.1