Re: [PATCH 2/2] perf: Userspace software event and ioctl

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Sep 18, 2014 at 03:34:33PM +0100, Pawel Moll wrote:
> This patch adds a PERF_COUNT_SW_USERSPACE_EVENT type,
> which can be generated by user with PERF_EVENT_IOC_ENTRY
> ioctl command, which injects an event of said type into
> the perf buffer.
> 
> The ioctl takes a pointer to struct perf_event_userspace
> as an argument. The structure begins with a 64-bit
> integer type value, which determines meaning of the
> following content (size/data pair). Type 0 are defined
> as zero-terminated strings, other types are defined by
> userspace (the perf tool will contain a list of
> known values with reference implementation of data
> content parsers).
> 
> Possible use cases for this feature:
> 
> - "perf_printf" like mechanism to add logging messages
>   to one's perf session; an example implementation:
> 
> 	int perf_printf(int perf_fd, const char *fmt, ...)
> 	{
> 	        struct perf_event_userspace *event;
> 	        int size;
> 	        va_list ap;
> 	        int err;
> 
> 	        va_start(ap, fmt);
> 
> 	        size = vsnprintf(NULL, 0, fmt, ap) + 1;
> 	        event = malloc(sizeof(*event) + size);
> 	        if (!event) {
> 	                va_end(ap);
> 	                return -1;
> 	        }
> 
> 	        event->type = 0;
> 	        event->size = size;
> 	        vsnprintf(event->data, size, fmt, ap);
> 
> 	        va_end(ap);
> 
> 	        err = ioctl(perf_fd, PERF_EVENT_IOC_USERSPACE, event);
> 
> 	        free(event);
> 
> 	        return err < 0 ? err : size - 1;
> 	}
> 
> - "perf_printf" used by for perf trace tool,
>   where certain traced process' calls are intercepted
>   (eg. using LD_PRELOAD) and treated as logging
>   requests, with it output redirected into the
>   perf buffer
> 
> - synchronisation of performance data generated in
>   user space with the perf stream coming from the kernel.
>   For example, the marker can be inserted by a JIT engine
>   after it generated portion of the code, but before the
>   code is executed for the first time, allowing the
>   post-processor to pick the correct debugging
>   information.
> 
> - other example is a system profiling tool taking data
>   from other sources than just perf, which generates a marker
>   at the beginning at at the end of the session
>   (also possibly periodically during the session) to
>   synchronise kernel timestamps with clock values
>   obtained in userspace (gtod or raw_monotonic).


Feel free to use up to 70 chars wide text in Changelogs. Most editors
have support for reflowing text. No need to keep it this narrow.

Also none of the many words above describe
PERF_SAMPLE_USERSPACE_EVENT(), wth is that about?

--
To unsubscribe from this list: send the line "unsubscribe linux-api" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux