mirror of
				https://github.com/torvalds/linux.git
				synced 2025-11-04 02:30:34 +02:00 
			
		
		
		
	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>
This commit is contained in:
		
							parent
							
								
									a54665ab7c
								
							
						
					
					
						commit
						17f89102fe
					
				
					 1 changed files with 5 additions and 4 deletions
				
			
		| 
						 | 
					@ -2302,7 +2302,7 @@ osnoise_cpus_read(struct file *filp, char __user *ubuf, size_t count,
 | 
				
			||||||
 * osnoise_cpus_write - Write function for "cpus" entry
 | 
					 * osnoise_cpus_write - Write function for "cpus" entry
 | 
				
			||||||
 * @filp: The active open file structure
 | 
					 * @filp: The active open file structure
 | 
				
			||||||
 * @ubuf: The user buffer that contains the value to write
 | 
					 * @ubuf: The user buffer that contains the value to write
 | 
				
			||||||
 * @cnt: The maximum number of bytes to write to "file"
 | 
					 * @count: The maximum number of bytes to write to "file"
 | 
				
			||||||
 * @ppos: The current position in @file
 | 
					 * @ppos: The current position in @file
 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
 * This function provides a write implementation for the "cpus"
 | 
					 * 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,
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	cpumask_var_t osnoise_cpumask_new;
 | 
						cpumask_var_t osnoise_cpumask_new;
 | 
				
			||||||
	int running, err;
 | 
						int running, err;
 | 
				
			||||||
	char buf[256];
 | 
						char *buf __free(kfree) = NULL;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (count >= 256)
 | 
						buf = kmalloc(count, GFP_KERNEL);
 | 
				
			||||||
		return -EINVAL;
 | 
						if (!buf)
 | 
				
			||||||
 | 
							return -ENOMEM;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (copy_from_user(buf, ubuf, count))
 | 
						if (copy_from_user(buf, ubuf, count))
 | 
				
			||||||
		return -EFAULT;
 | 
							return -EFAULT;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue