Patch "tracing/hwlat: Replace sched_setaffinity with set_cpus_allowed_ptr" has been added to the 5.15-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    tracing/hwlat: Replace sched_setaffinity with set_cpus_allowed_ptr

to the 5.15-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     tracing-hwlat-replace-sched_setaffinity-with-set_cpu.patch
and it can be found in the queue-5.15 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit d355159c20458aed159b8789555e755bbf8721a5
Author: Costa Shulyupin <costa.shul@xxxxxxxxxx>
Date:   Thu Mar 16 16:45:35 2023 +0200

    tracing/hwlat: Replace sched_setaffinity with set_cpus_allowed_ptr
    
    [ Upstream commit 71c7a30442b724717a30d5e7d1662ba4904eb3d4 ]
    
    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@xxxxxxxxxx
    
    Cc: Masami Hiramatsu <mhiramat@xxxxxxxxxx>
    Fixes: 0330f7aa8ee63 ("tracing: Have hwlat trace migrate across tracing_cpumask CPUs")
    Signed-off-by: Costa Shulyupin <costa.shul@xxxxxxxxxx>
    Acked-by: Daniel Bristot de Oliveira <bristot@xxxxxxxxxx>
    Signed-off-by: Steven Rostedt (Google) <rostedt@xxxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/kernel/trace/trace_hwlat.c b/kernel/trace/trace_hwlat.c
index 11f32e947c452..455f5edf008b8 100644
--- a/kernel/trace/trace_hwlat.c
+++ b/kernel/trace/trace_hwlat.c
@@ -339,7 +339,7 @@ static void move_to_next_cpu(void)
 	cpumask_clear(current_mask);
 	cpumask_set_cpu(next_cpu, current_mask);
 
-	sched_setaffinity(0, current_mask);
+	set_cpus_allowed_ptr(current, current_mask);
 	return;
 
  change_mode:
@@ -446,7 +446,7 @@ static int start_single_kthread(struct trace_array *tr)
 
 	}
 
-	sched_setaffinity(kthread->pid, current_mask);
+	set_cpus_allowed_ptr(kthread, current_mask);
 
 	kdata->kthread = kthread;
 	wake_up_process(kthread);



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux