Costa Shulyupin 71c7a30442 tracing/hwlat: Replace sched_setaffinity with set_cpus_allowed_ptr
There is a problem with the behavior of hwlat in a container,
resulting in incorrect output. A warning message is generated:
"cpumask changed while in round-robin mode, switching to mode none",
and the tracing_cpumask is ignored. This issue arises because
the kernel thread, hwlatd, is not a part of the container, and
the function sched_setaffinity is unable to locate it using its PID.
Additionally, the task_struct of hwlatd is already known.
Ultimately, the function set_cpus_allowed_ptr achieves
the same outcome as sched_setaffinity, but employs task_struct
instead of PID.

Test case:

  # cd /sys/kernel/tracing
  # echo 0 > tracing_on
  # echo round-robin > hwlat_detector/mode
  # echo hwlat > current_tracer
  # unshare --fork --pid bash -c 'echo 1 > tracing_on'
  # dmesg -c

Actual behavior:

[573502.809060] hwlat_detector: cpumask changed while in round-robin mode, switching to mode none

Link: https://lore.kernel.org/linux-trace-kernel/20230316144535.1004952-1-costa.shul@redhat.com

Cc: Masami Hiramatsu <mhiramat@kernel.org>
Fixes: 0330f7aa8ee63 ("tracing: Have hwlat trace migrate across tracing_cpumask CPUs")
Signed-off-by: Costa Shulyupin <costa.shul@redhat.com>
Acked-by: Daniel Bristot de Oliveira <bristot@kernel.org>
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
2023-03-19 13:23:22 -04:00
..
2022-12-13 19:29:45 -08:00
2022-12-02 11:25:00 +01:00
2022-12-21 14:31:52 -08:00
2022-12-13 14:05:39 -08:00
2022-12-19 07:13:33 -06:00
2022-12-21 07:59:57 -08:00
2022-08-29 19:47:03 -04:00
2022-01-11 13:08:21 -08:00
2022-09-26 10:13:13 -07:00
2022-12-17 14:06:53 -06:00
2022-11-15 00:42:02 -08:00
2022-12-23 12:00:24 -08:00
2022-12-19 12:33:32 -06:00
2022-12-23 12:00:24 -08:00
2022-12-16 03:54:54 -08:00
2022-06-29 13:07:16 +02:00
2022-12-16 03:54:54 -08:00
2022-12-14 12:20:00 -08:00
2022-10-10 12:49:34 -07:00
2022-02-25 09:36:06 +01:00
2022-12-13 19:29:45 -08:00
2022-08-06 16:38:17 -07:00