Patch "tools/power turbostat: Fix trailing '\n' parsing" has been added to the 6.12-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

    tools/power turbostat: Fix trailing '\n' parsing

to the 6.12-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:
     tools-power-turbostat-fix-trailing-n-parsing.patch
and it can be found in the queue-6.12 subdirectory.

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



commit 934f83de84c02f788ffb32cf5bd01c4871aa4576
Author: Zhang Rui <rui.zhang@xxxxxxxxx>
Date:   Tue Aug 27 13:07:51 2024 +0800

    tools/power turbostat: Fix trailing '\n' parsing
    
    [ Upstream commit fed8511cc8996989178823052dc0200643e1389a ]
    
    parse_cpu_string() parses the string input either from command line or
    from /sys/fs/cgroup/cpuset.cpus.effective to get a list of CPUs that
    turbostat can run with.
    
    The cpu string returned by /sys/fs/cgroup/cpuset.cpus.effective contains
    a trailing '\n', but strtoul() fails to treat this as an error.
    
    That says, for the code below
            val = ("\n", NULL, 10);
    val returns 0, and errno is also not set.
    
    As a result, CPU0 is erroneously considered as allowed CPU and this
    causes failures when turbostat tries to run on CPU0.
    
     get_counters: Could not migrate to CPU 0
     ...
     turbostat: re-initialized with num_cpus 8, allowed_cpus 5
     get_counters: Could not migrate to CPU 0
    
    Add a check to return immediately if '\n' or '\0' is detected.
    
    Fixes: 8c3dd2c9e542 ("tools/power/turbostat: Abstrct function for parsing cpu string")
    Signed-off-by: Zhang Rui <rui.zhang@xxxxxxxxx>
    Signed-off-by: Len Brown <len.brown@xxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/tools/power/x86/turbostat/turbostat.c b/tools/power/x86/turbostat/turbostat.c
index 089220aaa5c92..aa9200319d0ea 100644
--- a/tools/power/x86/turbostat/turbostat.c
+++ b/tools/power/x86/turbostat/turbostat.c
@@ -5385,6 +5385,9 @@ static int parse_cpu_str(char *cpu_str, cpu_set_t *cpu_set, int cpu_set_size)
 		if (*next == '-')	/* no negative cpu numbers */
 			return 1;
 
+		if (*next == '\0' || *next == '\n')
+			break;
+
 		start = strtoul(next, &next, 10);
 
 		if (start >= CPU_SUBSET_MAXCPUS)




[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