lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Thu, 2 May 2013 15:38:49 +0200
From:	Peter Zijlstra <peterz@...radead.org>
To:	Jiri Olsa <jolsa@...hat.com>
Cc:	linux-kernel@...r.kernel.org,
	Arnaldo Carvalho de Melo <acme@...stprotocols.net>,
	Peter Zijlstra <a.p.zijlstra@...llo.nl>,
	Ingo Molnar <mingo@...e.hu>, Paul Mackerras <paulus@...ba.org>,
	Corey Ashford <cjashfor@...ux.vnet.ibm.com>,
	Frederic Weisbecker <fweisbec@...il.com>,
	Namhyung Kim <namhyung@...nel.org>
Subject: Re: [PATCH 02/11] perf: Add PERF_EVENT_IOC_ID ioctl to return
 event ID

On Mon, Feb 04, 2013 at 01:32:56PM +0100, Jiri Olsa wrote:
> From: "jolsa@...hat.com" <jolsa@...hat.com>
> 
> The only way to get the event ID is by reading the event fd,
> followed by parsing the ID value out of the returned data.
> 
> While this is ok for current read format used by perf tool,
> it is not ok when we use PERF_FORMAT_GROUP format.
> 
> With this format the data are returned for the whole group
> and there's no way to find out what ID belongs to our fd
> (if we are not group leader event).
> 
> Adding a simple ioctl that returns event primary ID for given fd.
> 
> Signed-off-by: Jiri Olsa <jolsa@...hat.com>
> Cc: Arnaldo Carvalho de Melo <acme@...stprotocols.net>

Acked-by: Peter Zijlstra <a.p.zijlstra@...llo.nl>

> Cc: Ingo Molnar <mingo@...e.hu>
> Cc: Paul Mackerras <paulus@...ba.org>
> Cc: Corey Ashford <cjashfor@...ux.vnet.ibm.com>
> Cc: Frederic Weisbecker <fweisbec@...il.com>
> Cc: Namhyung Kim <namhyung@...nel.org>
> ---
>  include/uapi/linux/perf_event.h | 1 +
>  kernel/events/core.c            | 9 +++++++++
>  2 files changed, 10 insertions(+)
> 
> diff --git a/include/uapi/linux/perf_event.h b/include/uapi/linux/perf_event.h
> index 9fa9c62..b4ea8ed 100644
> --- a/include/uapi/linux/perf_event.h
> +++ b/include/uapi/linux/perf_event.h
> @@ -316,6 +316,7 @@ struct perf_event_attr {
>  #define PERF_EVENT_IOC_PERIOD		_IOW('$', 4, __u64)
>  #define PERF_EVENT_IOC_SET_OUTPUT	_IO ('$', 5)
>  #define PERF_EVENT_IOC_SET_FILTER	_IOW('$', 6, char *)
> +#define PERF_EVENT_IOC_ID		_IOR('$', 7, u64 *)
>  
>  enum perf_event_ioc_flags {
>  	PERF_IOC_FLAG_GROUP		= 1U << 0,
> diff --git a/kernel/events/core.c b/kernel/events/core.c
> index 301079d..4081261 100644
> --- a/kernel/events/core.c
> +++ b/kernel/events/core.c
> @@ -3277,6 +3277,15 @@ static long perf_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
>  	case PERF_EVENT_IOC_PERIOD:
>  		return perf_event_period(event, (u64 __user *)arg);
>  
> +	case PERF_EVENT_IOC_ID:
> +	{
> +		u64 id = primary_event_id(event);
> +
> +		if (copy_to_user((void __user *)arg, &id, sizeof(id)))
> +			return -EFAULT;
> +		return 0;
> +	}
> +
>  	case PERF_EVENT_IOC_SET_OUTPUT:
>  	{
>  		int ret;
> -- 
> 1.7.11.7
> 
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ