Re: [PATCH v11 13/24] perf record: Extend --threads command line option

From: Jiri Olsa
Date: Sun Sep 12 2021 - 17:02:12 EST


On Tue, Aug 17, 2021 at 11:23:16AM +0300, Alexey Bayduraev wrote:
> Extend --threads option in perf record command line interface.
> The option can have a value in the form of masks that specify
> cpus to be monitored with data streaming threads and its layout
> in system topology. The masks can be filtered using cpu mask
> provided via -C option.
>
> The specification value can be user defined list of masks. Masks
> separated by colon define cpus to be monitored by one thread and
> affinity mask of that thread is separated by slash. For example:
> <cpus mask 1>/<affinity mask 1>:<cpu mask 2>/<affinity mask 2>
> specifies parallel threads layout that consists of two threads
> with corresponding assigned cpus to be monitored.
>
> The specification value can be a string e.g. "cpu", "core" or
> "socket" meaning creation of data streaming thread for every
> cpu or core or socket to monitor distinct cpus or cpus grouped
> by core or socket.
>
> The option provided with no or empty value defaults to per-cpu
> parallel threads layout creating data streaming thread for every
> cpu being monitored.
>
> Document --threads option syntax and parallel data streaming modes
> in Documentation/perf-record.txt.
>
> Feature design and implementation are based on prototypes [1], [2].
>
> [1] git clone https://git.kernel.org/pub/scm/linux/kernel/git/jolsa/perf.git -b perf/record_threads
> [2] https://lore.kernel.org/lkml/20180913125450.21342-1-jolsa@xxxxxxxxxx/
>
> Suggested-by: Jiri Olsa <jolsa@xxxxxxxxxx>
> Suggested-by: Namhyung Kim <namhyung@xxxxxxxxxx>
> Acked-by: Andi Kleen <ak@xxxxxxxxxxxxxxx>
> Acked-by: Namhyung Kim <namhyung@xxxxxxxxx>
> Reviewed-by: Riccardo Mancini <rickyman7@xxxxxxxxx>
> Tested-by: Riccardo Mancini <rickyman7@xxxxxxxxx>
> Signed-off-by: Alexey Bayduraev <alexey.v.bayduraev@xxxxxxxxxxxxxxx>
> ---
> tools/perf/Documentation/perf-record.txt | 30 ++-
> tools/perf/builtin-record.c | 314 ++++++++++++++++++++++-
> tools/perf/util/record.h | 1 +
> 3 files changed, 340 insertions(+), 5 deletions(-)
>
> diff --git a/tools/perf/Documentation/perf-record.txt b/tools/perf/Documentation/perf-record.txt
> index 0408e677c117..4bbdc813e2e9 100644
> --- a/tools/perf/Documentation/perf-record.txt
> +++ b/tools/perf/Documentation/perf-record.txt
> @@ -695,9 +695,35 @@ measurements:
> wait -n ${perf_pid}
> exit $?
>
> ---threads::
> +--threads=<spec>::
> Write collected trace data into several data files using parallel threads.
> -The option creates a data streaming thread for each cpu in the system.
> +<spec> value can be user defined list of masks. Masks separated by colon
> +define cpus to be monitored by a thread and affinity mask of that thread
> +is separated by slash:
> +
> + <cpus mask 1>/<affinity mask 1>:<cpus mask 2>/<affinity mask 2>:...
> +
> +For example user specification like the following:
> +
> + 0,2-4/2-4:1,5-7/5-7

is this special case?

[root@krava perf]# ./perf record --threads=1/1

[root@krava perf]# ps -ef | grep perf
root 132071 130979 9 22:59 pts/6 00:00:00 ./perf record --threads=1/1

[root@krava perf]# cat /proc/131798/task/*/status | grep Cpus_allowed
cat: '/proc/131798/task/*/status': No such file or directory
[root@krava perf]# cat /proc/132071/task/*/status | grep Cpus_allowed
Cpus_allowed: ff
Cpus_allowed_list: 0-7
Cpus_allowed: ff
Cpus_allowed_list: 0-7

looks like the affinity was not set

thanks,
jirka