Skip to content

Commit 89cd2fd

Browse files
tracing/osnoise: Allow arbitrarily long CPU string
JIRA: https://issues.redhat.com/browse/RHEL-86520 commit 17f8910 Author: Tomas Glozar <tglozar@redhat.com> Date: Fri Apr 25 11:18:39 2025 +0200 tracing/osnoise: Allow arbitrarily long CPU string Allocate kernel memory for processing CPU string (/sys/kernel/tracing/osnoise/cpus) also in osnoise_cpus_write to allow the writing of a CPU string of an arbitrary length. This replaces the 256-byte buffer, which is insufficient with the rising number of CPUs. For example, if I wanted to measure on every even CPU on a system with 256 CPUs, the string would be 456 characters long. Cc: Masami Hiramatsu <mhiramat@kernel.org> Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com> Link: https://lore.kernel.org/20250425091839.343289-1-tglozar@redhat.com Signed-off-by: Tomas Glozar <tglozar@redhat.com> Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org> Signed-off-by: Tomas Glozar <tglozar@redhat.com>
1 parent 64c58bb commit 89cd2fd

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

kernel/trace/trace_osnoise.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2315,7 +2315,7 @@ osnoise_cpus_read(struct file *filp, char __user *ubuf, size_t count,
23152315
* osnoise_cpus_write - Write function for "cpus" entry
23162316
* @filp: The active open file structure
23172317
* @ubuf: The user buffer that contains the value to write
2318-
* @cnt: The maximum number of bytes to write to "file"
2318+
* @count: The maximum number of bytes to write to "file"
23192319
* @ppos: The current position in @file
23202320
*
23212321
* This function provides a write implementation for the "cpus"
@@ -2333,10 +2333,11 @@ osnoise_cpus_write(struct file *filp, const char __user *ubuf, size_t count,
23332333
{
23342334
cpumask_var_t osnoise_cpumask_new;
23352335
int running, err;
2336-
char buf[256];
2336+
char *buf __free(kfree) = NULL;
23372337

2338-
if (count >= 256)
2339-
return -EINVAL;
2338+
buf = kmalloc(count, GFP_KERNEL);
2339+
if (!buf)
2340+
return -ENOMEM;
23402341

23412342
if (copy_from_user(buf, ubuf, count))
23422343
return -EFAULT;

0 commit comments

Comments
 (0)