All of lore.kernel.org
 help / color / mirror / Atom feed
* [Powertop] [PATCH 1/2] perf: Pass 0 as a third argument to ioctl on perf_fd
@ 2012-09-16 14:17 Namhyung Kim
  0 siblings, 0 replies; 3+ messages in thread
From: Namhyung Kim @ 2012-09-16 14:17 UTC (permalink / raw)
  To: powertop

[-- Attachment #1: Type: text/plain, Size: 1063 bytes --]

The third argument of PERF_EVENT_IOC_{ENABLE,DISABLE} ioctl is a flag
to determine whether the command should be applied to group members.
Since the powertop doesn't use the event grouping feature, it'd better
passing 0 as a third argument explicitly.

Signed-off-by: Namhyung Kim <namhyung(a)gmail.com>
---
 src/perf/perf.cpp |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/perf/perf.cpp b/src/perf/perf.cpp
index 69f1da3..c8ba7a8 100644
--- a/src/perf/perf.cpp
+++ b/src/perf/perf.cpp
@@ -128,7 +128,7 @@ void perf_event::create_perf_event(char *eventname, int _cpu)
 		return;
 	}
 
-	ret = ioctl(perf_fd, PERF_EVENT_IOC_ENABLE);
+	ret = ioctl(perf_fd, PERF_EVENT_IOC_ENABLE, 0);
 
 	if (ret < 0) {
 		fprintf(stderr, "failed to enable perf \n");
@@ -210,7 +210,7 @@ void perf_event::start(void)
 void perf_event::stop(void)
 {
 	int ret;
-	ret = ioctl(perf_fd, PERF_EVENT_IOC_DISABLE);
+	ret = ioctl(perf_fd, PERF_EVENT_IOC_DISABLE, 0);
 	if (ret)
 		cout << "stop failing\n";
 }
-- 
1.7.9.2


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [Powertop] [PATCH 1/2] perf: Pass 0 as a third argument to ioctl on perf_fd
@ 2012-09-16 23:17 Sergey Senozhatsky
  0 siblings, 0 replies; 3+ messages in thread
From: Sergey Senozhatsky @ 2012-09-16 23:17 UTC (permalink / raw)
  To: powertop

[-- Attachment #1: Type: text/plain, Size: 1667 bytes --]

On (09/16/12 23:17), Namhyung Kim wrote:
> The third argument of PERF_EVENT_IOC_{ENABLE,DISABLE} ioctl is a flag
> to determine whether the command should be applied to group members.
> Since the powertop doesn't use the event grouping feature, it'd better
> passing 0 as a third argument explicitly.
>

[..]
   <+629>:	mov    -0x88(%rbp),%rax
   <+636>:	mov    0x8(%rax),%eax
   <+639>:	mov    $0x2400,%esi
   <+644>:	mov    %eax,%edi
   <+646>:	mov    $0x0,%eax
   <+651>:	callq  0x404460 <ioctl(a)plt>
[..]

agree, let's pass 0 explicitly to perf_ioctl():

3307
3308         if (flags & PERF_IOC_FLAG_GROUP)
3309                 perf_event_for_each(event, func);
3310         else
3311                 perf_event_for_each_child(event, func);
3312 



good catch, thank you!


	-ss

 
> Signed-off-by: Namhyung Kim <namhyung(a)gmail.com>
> ---
>  src/perf/perf.cpp |    4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/src/perf/perf.cpp b/src/perf/perf.cpp
> index 69f1da3..c8ba7a8 100644
> --- a/src/perf/perf.cpp
> +++ b/src/perf/perf.cpp
> @@ -128,7 +128,7 @@ void perf_event::create_perf_event(char *eventname, int _cpu)
>  		return;
>  	}
>  
> -	ret = ioctl(perf_fd, PERF_EVENT_IOC_ENABLE);
> +	ret = ioctl(perf_fd, PERF_EVENT_IOC_ENABLE, 0);
>  
>  	if (ret < 0) {
>  		fprintf(stderr, "failed to enable perf \n");
> @@ -210,7 +210,7 @@ void perf_event::start(void)
>  void perf_event::stop(void)
>  {
>  	int ret;
> -	ret = ioctl(perf_fd, PERF_EVENT_IOC_DISABLE);
> +	ret = ioctl(perf_fd, PERF_EVENT_IOC_DISABLE, 0);
>  	if (ret)
>  		cout << "stop failing\n";
>  }
> 

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Powertop] [PATCH 1/2] perf: Pass 0 as a third argument to ioctl on perf_fd
@ 2012-09-17 15:21 Chris Ferron
  0 siblings, 0 replies; 3+ messages in thread
From: Chris Ferron @ 2012-09-17 15:21 UTC (permalink / raw)
  To: powertop

[-- Attachment #1: Type: text/plain, Size: 1213 bytes --]

On 09/16/2012 07:17 AM, Namhyung Kim wrote:
> The third argument of PERF_EVENT_IOC_{ENABLE,DISABLE} ioctl is a flag
> to determine whether the command should be applied to group members.
> Since the powertop doesn't use the event grouping feature, it'd better
> passing 0 as a third argument explicitly.
>
> Signed-off-by: Namhyung Kim <namhyung(a)gmail.com>
> ---
>   src/perf/perf.cpp |    4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/src/perf/perf.cpp b/src/perf/perf.cpp
> index 69f1da3..c8ba7a8 100644
> --- a/src/perf/perf.cpp
> +++ b/src/perf/perf.cpp
> @@ -128,7 +128,7 @@ void perf_event::create_perf_event(char *eventname, int _cpu)
>   		return;
>   	}
>   
> -	ret = ioctl(perf_fd, PERF_EVENT_IOC_ENABLE);
> +	ret = ioctl(perf_fd, PERF_EVENT_IOC_ENABLE, 0);
>   
>   	if (ret < 0) {
>   		fprintf(stderr, "failed to enable perf \n");
> @@ -210,7 +210,7 @@ void perf_event::start(void)
>   void perf_event::stop(void)
>   {
>   	int ret;
> -	ret = ioctl(perf_fd, PERF_EVENT_IOC_DISABLE);
> +	ret = ioctl(perf_fd, PERF_EVENT_IOC_DISABLE, 0);
>   	if (ret)
>   		cout << "stop failing\n";
>   }
Your patch as been merged.
Thank You
-C


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2012-09-17 15:21 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-09-17 15:21 [Powertop] [PATCH 1/2] perf: Pass 0 as a third argument to ioctl on perf_fd Chris Ferron
  -- strict thread matches above, loose matches on Subject: below --
2012-09-16 23:17 Sergey Senozhatsky
2012-09-16 14:17 Namhyung Kim

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.