Re: [PATCH 0/1] arm64: defconfig: Add Coresight as module

Catalin Marinas
2022-09-21T15:08:42Z

On Wed, Sep 21, 2022 at 03:05:34PM +0100, James Clark wrote:
> As suggested by Catalin here's the change to add Coresight to defconfig.
>
> Unfortunately I don't think we should add CONFIG_CORESIGHT_SOURCE_ETM4X
> which builds a few files until [1] is merged because of the overhead
> of CONFIG_PID_IN_CONTEXTIDR.
>
> [1]: https://lore.kernel.org/lkml/20211021134530.206216-1-leo.yan@linaro.org/T/

I thought the overhead wasn't the problem, it's mostly negligible. We
can probably save a few more cycles on the __switch_to() path by
replacing several isb()s in those functions with a single one just
before cpu_switch_to().

IIRC the issue is that unless a process runs in the root pid namespace,
the actual pid written to contextidr is meaningless.

Now that you reminded me of that thread, I see three options (sorry, not
entirely related to the defconfig updates):

1. Remove CONFIG_PID_IN_CONTEXTIDR and corresponding code completely,
find other events to correlate the task with the trace.

2. Always on CONFIG_PID_IN_CONTEXTIDR (we might as well remove the
Kconfig entry). This would write the root pid namespace value
(task_pid_nr()).

3. Similar to (2) but instead write task_pid_nr_ns(). An alternative
here is to write -1 if the task is not in the root pid namespace.

Strong preference for (1).

--
Catalin