Skip to content

Commit 17f8910

Browse files
lenticularis39rostedt
authored andcommitted
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 <[email protected]> Cc: Mathieu Desnoyers <[email protected]> Link: https://lore.kernel.org/[email protected] Signed-off-by: Tomas Glozar <[email protected]> Signed-off-by: Steven Rostedt (Google) <[email protected]>
1 parent a54665a commit 17f8910

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
@@ -2302,7 +2302,7 @@ osnoise_cpus_read(struct file *filp, char __user *ubuf, size_t count,
23022302
* osnoise_cpus_write - Write function for "cpus" entry
23032303
* @filp: The active open file structure
23042304
* @ubuf: The user buffer that contains the value to write
2305-
* @cnt: The maximum number of bytes to write to "file"
2305+
* @count: The maximum number of bytes to write to "file"
23062306
* @ppos: The current position in @file
23072307
*
23082308
* This function provides a write implementation for the "cpus"
@@ -2320,10 +2320,11 @@ osnoise_cpus_write(struct file *filp, const char __user *ubuf, size_t count,
23202320
{
23212321
cpumask_var_t osnoise_cpumask_new;
23222322
int running, err;
2323-
char buf[256];
2323+
char *buf __free(kfree) = NULL;
23242324

2325-
if (count >= 256)
2326-
return -EINVAL;
2325+
buf = kmalloc(count, GFP_KERNEL);
2326+
if (!buf)
2327+
return -ENOMEM;
23272328

23282329
if (copy_from_user(buf, ubuf, count))
23292330
return -EFAULT;

0 commit comments

Comments
 (0)