[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <5531be0b-a421-fc92-9798-afdb58fc9336@huawei.com>
Date: Tue, 13 Jun 2023 10:03:41 +0800
From: Yang Jihong <yangjihong1@...wei.com>
To: Arnaldo Carvalho de Melo <acme@...nel.org>
CC: Peter Zijlstra <peterz@...radead.org>,
Ingo Molnar <mingo@...hat.com>,
Mark Rutland <mark.rutland@....com>,
Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
Jiri Olsa <jolsa@...nel.org>,
Namhyung Kim <namhyung@...nel.org>,
Ian Rogers <irogers@...gle.com>,
Adrian Hunter <adrian.hunter@...el.com>,
linux-perf-users <linux-perf-users@...r.kernel.org>,
linux-kernel <linux-kernel@...r.kernel.org>
Subject: Re: [RFC] Adding support for setting the affinity of the recording
process
Hello,
Sorry, I forgot to add another recipient in the last email. Send it again.
On 2023/6/12 22:24, Arnaldo Carvalho de Melo wrote:
> Em Mon, Jun 12, 2023 at 06:26:10PM +0800, Yang Jihong escreveu:
>> Hello everyone,
>>
>> Currently, perf-record supports profiling an existing process, thread, or a
>> specified command.
>>
>> Sometimes we may need to set CPU affinity of the target process before
>> recording:
>>
>> # taskset -pc <cpus> <pid>
>> # perf record -p <pid> -- sleep 10
>>
>> or:
>>
>> # perf record -- `taskset -c <cpus> COMMAND`
>>
>> I'm thinking about getting perf to support setting the affinity of the
>> recording process, for example:
>
> not of the 'recording process' but the 'observed process', right?
>
Yes, it's the process of being observed.
>> 1. set the CPU affinity of the <pid1> process to <cpus1>, <pid2> process to
>> <cpus2>, and record:
>>
>> # perf record -p <pid1>/<cpus1>:<pid2>/<cpus2> -- sleep 10
>
> but what would be the semantic for what is being observed? Would this
> result in it recording events on that CPU or just for that process (that
> now runs just on that CPU)?
>
just for the process running on a specific CPU.
> Without affinity setting that could mean: observe just that process when
> it runs on that CPU.
>
> But could you please spell out the use case, why do you need this, is
> this so common (for you) that you repeatedly need to first taskset, then
> perf, etc?
As Peter said, big.LITTLE is a common scenario where a process may
behave differently on different CPUs.
There are other scenarios. For example, if I run a server and a client
and do not set affinity for them, they may sometimes run on the same
NUMA node or on different NUMA nodes due to scheduling reasons.
In this case, the performance may fluctuate due to reasons such as cache
miss. When analyzing performance problems, we sometimes care about
stability.
>
>> and
>>
>> 2. set CPU affinity of the COMMAND and record:
>>
>> # perf record --taskset-command <cpus> COMMAND
>>
>> In doing so, perf, as an observer, actually changes some of the properties
>> of the target process, which may be contrary to the purpose of perf tool.
>
> Up for discussion, but I don't think this is that much a problem if it
> streamlines common observability sessions/experimentations.
If the perf is used to set the affinity of the observed process, it
actually interferes with some behavior of the target process (such as
affecting scheduling).
In this scenario, the perf is not just a simple observer. Therefore, I
am not sure whether this behavior is acceptable.
Thank you for your reply.
Thanks,
Yang.
Powered by blists - more mailing lists