lkml.org 
[lkml]   [2021]   [Aug]   [21]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[RFC PATCH v1 33/37] perf record: pin threads to monitored cpus if enough threads available
Date
This patch sets the affinity of the workqueue threads to pin them to
each monitored CPU in case the --threads option is set with enough
threads and evlist multithreading is enabled.

This yields a better performance for the evlist operations, since
affinity need not be sent by each thread everytime.

Signed-off-by: Riccardo Mancini <rickyman7@gmail.com>
---
tools/perf/builtin-record.c | 10 ++++++++++
1 file changed, 10 insertions(+)

diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
index 7802a0e25f631fac..e2d2445e05d7c07a 100644
--- a/tools/perf/builtin-record.c
+++ b/tools/perf/builtin-record.c
@@ -2945,6 +2945,16 @@ int cmd_record(int argc, const char **argv)
pr_err("setup_global_workqueue: %s\n", errbuf);
goto out;
}
+
+ if ((int)rec->opts.nr_threads >= rec->evlist->core.all_cpus->nr
+ && rec->opts.multithreaded_evlist) {
+ err = workqueue_set_affinities_cpu(global_wq, rec->evlist->core.all_cpus);
+ if (err) {
+ workqueue_strerror(global_wq, err, errbuf, sizeof(errbuf));
+ pr_err("workqueue_set_affinities_cpu: %s\n", errbuf);
+ goto out;
+ }
+ }
}

err = __cmd_record(&record, argc, argv);
--
2.31.1
\
 
 \ /
  Last update: 2021-08-21 11:23    [W:0.287 / U:0.480 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site