[v3,0/3] perf: add new option '--workload-attr' to set workload sched_policy/priority/mask
Message ID | 20230718033355.2960912-1-changbin.du@huawei.com |
---|---|
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c923:0:b0:3e4:2afc:c1 with SMTP id j3csp1496236vqt; Mon, 17 Jul 2023 21:13:15 -0700 (PDT) X-Google-Smtp-Source: APBJJlGFLDEjhVBdA2R+1jEeEUI+ioKutWvXLW39EKYRd1eDUmNsOG3dTbAZrLtTMg2JFcRvwGhe X-Received: by 2002:a17:906:a2d5:b0:991:37d2:c9f0 with SMTP id by21-20020a170906a2d500b0099137d2c9f0mr10306116ejb.68.1689653595070; Mon, 17 Jul 2023 21:13:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689653595; cv=none; d=google.com; s=arc-20160816; b=pbhsilJFiV/scIvrSYqil6a6trENhjsMJXX4ejuSlEc67+ooRaam1ifX5ExuR080ih /bxmadAKx3yYIsngR82Uli1lO809McDiypyuIuKJP1GkHoPmPl/+2fUheRYbT1K/K08U 0gTwoQzqhoV9AJBLcntxvhjF7rcXRXDHi05Nv32gKwL+aq19IRAlZYUd9Bzz6IZ0frj4 AaU+wIWxVaz+LhX6rUBsuhFuy9q3Y6f2Jo9W6cWCdFQnjU6a7SXtRimajx4W5/4Z0fg+ 7hVS3p8VCOa3XmSg1CFd28rf9PUMYarT2h+zoiFItyQe3wY2nP3QVms1FRZGZRTpedPl HmZg== 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=diZLP4e0QiGCYWf9y0QMV1fIBTXLcMvP10T0oEUDFUc=; fh=ApeLdK2xurAeWAFDrmxfomKJVPpeLi5+JFM/i5kBxGg=; b=eP8YlJiA0EFPnnbufYVAPb/+/X8Pyvi9sYj2Ztdw+tdIVeoRnhYJH1sVP9klre0b3n YHNjKkyr2P911uh8ujlaxEk+ur3lKSqEeY0B5NekG7Kd0C9MhMlrQGZ7QOeUylOfpGzC 4ogN/DUuIzQoaW0TshTE3UaDTqWaj3hdxx0OfbqHcHsd45nvuHUPLkGhQbmgw9mNFdwf BMDCv1ovdnJm/u/Sr1ui0kGMvQakAYVgI8VAp5v2MSnCOH1DgzrbdvM1WQmsX08JCjil H3tnCmqGkH5Xx7mH6MK9oWwF9pYESVRzj2Pm49JuBcnFleEaLYkF/99T8unPkhcr13nE k6ZA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t27-20020a1709063e5b00b009945340230esi599841eji.174.2023.07.17.21.12.51; Mon, 17 Jul 2023 21:13:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229872AbjGRDeY (ORCPT <rfc822;daweilics@gmail.com> + 99 others); Mon, 17 Jul 2023 23:34:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38820 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229608AbjGRDeV (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Mon, 17 Jul 2023 23:34:21 -0400 Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3FFF7B5; Mon, 17 Jul 2023 20:34:19 -0700 (PDT) Received: from kwepemi500013.china.huawei.com (unknown [172.30.72.54]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4R4kyZ6mv0zLnn2; Tue, 18 Jul 2023 11:31:50 +0800 (CST) Received: from M910t.huawei.com (10.110.54.157) by kwepemi500013.china.huawei.com (7.221.188.120) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Tue, 18 Jul 2023 11:34:16 +0800 From: Changbin Du <changbin.du@huawei.com> To: Peter Zijlstra <peterz@infradead.org>, Ingo Molnar <mingo@redhat.com>, Arnaldo Carvalho de Melo <acme@kernel.org> CC: Mark Rutland <mark.rutland@arm.com>, Alexander Shishkin <alexander.shishkin@linux.intel.com>, Jiri Olsa <jolsa@kernel.org>, Namhyung Kim <namhyung@kernel.org>, Ian Rogers <irogers@google.com>, Adrian Hunter <adrian.hunter@intel.com>, <linux-perf-users@vger.kernel.org>, <linux-kernel@vger.kernel.org>, Hui Wang <hw.huiwang@huawei.com>, Changbin Du <changbin.du@huawei.com> Subject: [PATCH v3 0/3] perf: add new option '--workload-attr' to set workload sched_policy/priority/mask Date: Tue, 18 Jul 2023 11:33:52 +0800 Message-ID: <20230718033355.2960912-1-changbin.du@huawei.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.110.54.157] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To kwepemi500013.china.huawei.com (7.221.188.120) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1771728384907488952 X-GMAIL-MSGID: 1771730207811156395 |
Series |
perf: add new option '--workload-attr' to set workload sched_policy/priority/mask
|
|
Message
Changbin Du
July 18, 2023, 3:33 a.m. UTC
This adds a new option '--workload-attr' to set the sched_policy/priority/mask of the workload to reduce system noise. $ sudo perf stat --workload-attr fifo,40,0-3:7 -- ls Please see patch 1/2 for more details. v3: - replace taskset with --workload-attr option in documents and tests. v2: - Use cpu list spec instead of cpu mask number. - Update documents. Changbin Du (3): perf cpumap: Add __perf_cpu_map__new and perf_cpu_map__2_cpuset perf: add new option '--workload-attr' to set workload sched_policy/priority/mask perf: replace taskset with --workload-attr option tools/lib/perf/cpumap.c | 45 ++++++- tools/lib/perf/include/perf/cpumap.h | 4 + tools/lib/perf/libperf.map | 2 + tools/perf/Documentation/intel-hybrid.txt | 2 +- tools/perf/Documentation/perf-record.txt | 7 ++ tools/perf/Documentation/perf-stat.txt | 8 +- tools/perf/builtin-record.c | 26 ++++ tools/perf/builtin-stat.c | 18 +++ tools/perf/tests/cpumap.c | 23 ++++ .../tests/shell/stat_bpf_counters_cgrp.sh | 2 +- tools/perf/tests/shell/test_arm_coresight.sh | 2 +- tools/perf/tests/shell/test_data_symbol.sh | 2 +- tools/perf/tests/shell/test_intel_pt.sh | 2 +- tools/perf/util/evlist.c | 117 ++++++++++++++++++ tools/perf/util/evlist.h | 3 + tools/perf/util/target.h | 9 ++ 16 files changed, 263 insertions(+), 9 deletions(-)
Comments
On 18/07/23 06:33, Changbin Du wrote: > This adds a new option '--workload-attr' to set the sched_policy/priority/mask > of the workload to reduce system noise. > > $ sudo perf stat --workload-attr fifo,40,0-3:7 -- ls Not really sold on the need for this, but maybe it could be simpler. What about just adding a hook for a command (e.g. script) to run before exec'ing the workload e.g. --configure-workload=blah.sh results in perf doing system("blah.sh 12345") where 12345 is the workload PID. Then maybe you could do: --configure-workload="taskset -p 0x3" > > Please see patch 1/2 for more details. > > v3: > - replace taskset with --workload-attr option in documents and tests. > v2: > - Use cpu list spec instead of cpu mask number. > - Update documents. > > Changbin Du (3): > perf cpumap: Add __perf_cpu_map__new and perf_cpu_map__2_cpuset > perf: add new option '--workload-attr' to set workload > sched_policy/priority/mask > perf: replace taskset with --workload-attr option > > tools/lib/perf/cpumap.c | 45 ++++++- > tools/lib/perf/include/perf/cpumap.h | 4 + > tools/lib/perf/libperf.map | 2 + > tools/perf/Documentation/intel-hybrid.txt | 2 +- > tools/perf/Documentation/perf-record.txt | 7 ++ > tools/perf/Documentation/perf-stat.txt | 8 +- > tools/perf/builtin-record.c | 26 ++++ > tools/perf/builtin-stat.c | 18 +++ > tools/perf/tests/cpumap.c | 23 ++++ > .../tests/shell/stat_bpf_counters_cgrp.sh | 2 +- > tools/perf/tests/shell/test_arm_coresight.sh | 2 +- > tools/perf/tests/shell/test_data_symbol.sh | 2 +- > tools/perf/tests/shell/test_intel_pt.sh | 2 +- > tools/perf/util/evlist.c | 117 ++++++++++++++++++ > tools/perf/util/evlist.h | 3 + > tools/perf/util/target.h | 9 ++ > 16 files changed, 263 insertions(+), 9 deletions(-) >
On Thu, Jul 20, 2023 at 01:00:58PM +0300, Adrian Hunter wrote: > On 18/07/23 06:33, Changbin Du wrote: > > This adds a new option '--workload-attr' to set the sched_policy/priority/mask > > of the workload to reduce system noise. > > > > $ sudo perf stat --workload-attr fifo,40,0-3:7 -- ls > > Not really sold on the need for this, but maybe it could be > simpler. > What about just adding a hook for a command (e.g. script) to > run before exec'ing the workload e.g. > > --configure-workload=blah.sh > > results in perf doing system("blah.sh 12345") where 12345 > is the workload PID. > > Then maybe you could do: > > --configure-workload="taskset -p 0x3" > Acctually, we already have such option for perf-stat. --post <command> command to run after to the measured command --pre <command> command to run prior to the measured command By involving a shell script we can do more complex setup. But sometimes I just need to set sched attributes. For example, to investigate the impact of various compiler optimizations. In this case, I don't want a script. This is the original purpose I try to add this new option. > > > > > Please see patch 1/2 for more details. > > > > v3: > > - replace taskset with --workload-attr option in documents and tests. > > v2: > > - Use cpu list spec instead of cpu mask number. > > - Update documents. > > > > Changbin Du (3): > > perf cpumap: Add __perf_cpu_map__new and perf_cpu_map__2_cpuset > > perf: add new option '--workload-attr' to set workload > > sched_policy/priority/mask > > perf: replace taskset with --workload-attr option > > > > tools/lib/perf/cpumap.c | 45 ++++++- > > tools/lib/perf/include/perf/cpumap.h | 4 + > > tools/lib/perf/libperf.map | 2 + > > tools/perf/Documentation/intel-hybrid.txt | 2 +- > > tools/perf/Documentation/perf-record.txt | 7 ++ > > tools/perf/Documentation/perf-stat.txt | 8 +- > > tools/perf/builtin-record.c | 26 ++++ > > tools/perf/builtin-stat.c | 18 +++ > > tools/perf/tests/cpumap.c | 23 ++++ > > .../tests/shell/stat_bpf_counters_cgrp.sh | 2 +- > > tools/perf/tests/shell/test_arm_coresight.sh | 2 +- > > tools/perf/tests/shell/test_data_symbol.sh | 2 +- > > tools/perf/tests/shell/test_intel_pt.sh | 2 +- > > tools/perf/util/evlist.c | 117 ++++++++++++++++++ > > tools/perf/util/evlist.h | 3 + > > tools/perf/util/target.h | 9 ++ > > 16 files changed, 263 insertions(+), 9 deletions(-) > > >
On 24/07/23 07:02, Changbin Du wrote: > On Thu, Jul 20, 2023 at 01:00:58PM +0300, Adrian Hunter wrote: >> On 18/07/23 06:33, Changbin Du wrote: >>> This adds a new option '--workload-attr' to set the sched_policy/priority/mask >>> of the workload to reduce system noise. >>> >>> $ sudo perf stat --workload-attr fifo,40,0-3:7 -- ls >> >> Not really sold on the need for this, but maybe it could be >> simpler. >> What about just adding a hook for a command (e.g. script) to >> run before exec'ing the workload e.g. >> >> --configure-workload=blah.sh >> >> results in perf doing system("blah.sh 12345") where 12345 >> is the workload PID. >> >> Then maybe you could do: >> >> --configure-workload="taskset -p 0x3" >> > Acctually, we already have such option for perf-stat. > > --post <command> command to run after to the measured command > --pre <command> command to run prior to the measured command > > By involving a shell script we can do more complex setup. But sometimes I just > need to set sched attributes. For example, to investigate the impact of > various compiler optimizations. In this case, I don't want a script. This is the > original purpose I try to add this new option. There is also command schedtool, but what exactly is the problem with a script? > >> >>> >>> Please see patch 1/2 for more details. >>> >>> v3: >>> - replace taskset with --workload-attr option in documents and tests. >>> v2: >>> - Use cpu list spec instead of cpu mask number. >>> - Update documents. >>> >>> Changbin Du (3): >>> perf cpumap: Add __perf_cpu_map__new and perf_cpu_map__2_cpuset >>> perf: add new option '--workload-attr' to set workload >>> sched_policy/priority/mask >>> perf: replace taskset with --workload-attr option >>> >>> tools/lib/perf/cpumap.c | 45 ++++++- >>> tools/lib/perf/include/perf/cpumap.h | 4 + >>> tools/lib/perf/libperf.map | 2 + >>> tools/perf/Documentation/intel-hybrid.txt | 2 +- >>> tools/perf/Documentation/perf-record.txt | 7 ++ >>> tools/perf/Documentation/perf-stat.txt | 8 +- >>> tools/perf/builtin-record.c | 26 ++++ >>> tools/perf/builtin-stat.c | 18 +++ >>> tools/perf/tests/cpumap.c | 23 ++++ >>> .../tests/shell/stat_bpf_counters_cgrp.sh | 2 +- >>> tools/perf/tests/shell/test_arm_coresight.sh | 2 +- >>> tools/perf/tests/shell/test_data_symbol.sh | 2 +- >>> tools/perf/tests/shell/test_intel_pt.sh | 2 +- >>> tools/perf/util/evlist.c | 117 ++++++++++++++++++ >>> tools/perf/util/evlist.h | 3 + >>> tools/perf/util/target.h | 9 ++ >>> 16 files changed, 263 insertions(+), 9 deletions(-) >>> >> >
On Mon, Jul 24, 2023 at 08:44:12AM +0300, Adrian Hunter wrote: > On 24/07/23 07:02, Changbin Du wrote: > > On Thu, Jul 20, 2023 at 01:00:58PM +0300, Adrian Hunter wrote: > >> On 18/07/23 06:33, Changbin Du wrote: > >>> This adds a new option '--workload-attr' to set the sched_policy/priority/mask > >>> of the workload to reduce system noise. > >>> > >>> $ sudo perf stat --workload-attr fifo,40,0-3:7 -- ls > >> > >> Not really sold on the need for this, but maybe it could be > >> simpler. > >> What about just adding a hook for a command (e.g. script) to > >> run before exec'ing the workload e.g. > >> > >> --configure-workload=blah.sh > >> > >> results in perf doing system("blah.sh 12345") where 12345 > >> is the workload PID. > >> > >> Then maybe you could do: > >> > >> --configure-workload="taskset -p 0x3" > >> > > Acctually, we already have such option for perf-stat. > > > > --post <command> command to run after to the measured command > > --pre <command> command to run prior to the measured command > > > > By involving a shell script we can do more complex setup. But sometimes I just > > need to set sched attributes. For example, to investigate the impact of > > various compiler optimizations. In this case, I don't want a script. This is the > > original purpose I try to add this new option. > > There is also command schedtool, but what exactly is the problem > with a script? > > > There is no problem with a script, just a shortcut for convenience. When I want to share perf investigation with somebody, I just need to share a single commandline. Anyway nothing bad, right? :)
On 24/07/23 12:34, Changbin Du wrote: > On Mon, Jul 24, 2023 at 08:44:12AM +0300, Adrian Hunter wrote: >> On 24/07/23 07:02, Changbin Du wrote: >>> On Thu, Jul 20, 2023 at 01:00:58PM +0300, Adrian Hunter wrote: >>>> On 18/07/23 06:33, Changbin Du wrote: >>>>> This adds a new option '--workload-attr' to set the sched_policy/priority/mask >>>>> of the workload to reduce system noise. >>>>> >>>>> $ sudo perf stat --workload-attr fifo,40,0-3:7 -- ls >>>> >>>> Not really sold on the need for this, but maybe it could be >>>> simpler. >>>> What about just adding a hook for a command (e.g. script) to >>>> run before exec'ing the workload e.g. >>>> >>>> --configure-workload=blah.sh >>>> >>>> results in perf doing system("blah.sh 12345") where 12345 >>>> is the workload PID. >>>> >>>> Then maybe you could do: >>>> >>>> --configure-workload="taskset -p 0x3" >>>> >>> Acctually, we already have such option for perf-stat. >>> >>> --post <command> command to run after to the measured command >>> --pre <command> command to run prior to the measured command >>> >>> By involving a shell script we can do more complex setup. But sometimes I just >>> need to set sched attributes. For example, to investigate the impact of >>> various compiler optimizations. In this case, I don't want a script. This is the >>> original purpose I try to add this new option. >> >> There is also command schedtool, but what exactly is the problem >> with a script? >> >>> > There is no problem with a script, just a shortcut for convenience. When I want > to share perf investigation with somebody, I just need to share a single commandline. > Anyway nothing bad, right? :) Also depends on what you call a single commandline, since you could always create the script and run perf in one long line :-) I would still go for the simpler option: easier to maintain and potentially more flexible.