Messages in this thread |  | | | Subject | Re: [patch] trace: Add user-space event tracing/injection | | From | Peter Zijlstra <> | | Date | Wed, 17 Nov 2010 13:37:14 +0100 |
| |
On Wed, 2010-11-17 at 13:29 +0100, Peter Zijlstra wrote: > > + case PR_TASK_PERF_USER_TRACE: > > + { > > + void __user *uevent_ptr = (void *)arg2; > > + char kstring[MAX_USER_TRACE_SIZE+1]; > > + unsigned long uevent_len = arg3; > > + > > + if (uevent_len > MAX_USER_TRACE_SIZE) > > + return -EINVAL; > > + if (copy_from_user(kstring, uevent_ptr, uevent_len)) > > + return -EFAULT; > > + kstring[uevent_len] = 0; > > + > > + trace_user(kstring); > > + return 0; > > + }
That implementation can be improved upon, no need to actually do the copy_from_user() when the tracepoint isn't enabled.
Also, do we really need a max size here? I know ftrace (and the perf tracepoint interface) are currently limited to 1 page of trace data but that can be fixed (although not trivially).
Also, -EINVAL isn't really a helpful error code in that case, -EMSGSIZE seems like a good candidate.
And the uevent name is already taken for something else, re-using it here might cause confusion.
|  |