Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

[PATCH 1/3] perf record: support duration option to run during specified time

2 views
Skip to first unread message

Joonsoo Kim

unread,
Jun 18, 2013, 9:02:58 PM6/18/13
to Arnaldo Carvalho de Melo, Peter Zijlstra, Paul Mackerras, Ingo Molnar, linux-...@vger.kernel.org, Joonsoo Kim, Namhyung Kim
Currently, there is no method to quit at specified time later.
We are used to using 'sleep N' as command argument if we need it,
but explicitly supporting this feature maybe makes sense.

Cc: Namhyung Kim <namh...@kernel.org>
Signed-off-by: Joonsoo Kim <iamjoon...@lge.com>

diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
index cdf58ec..19c65b5 100644
--- a/tools/perf/builtin-record.c
+++ b/tools/perf/builtin-record.c
@@ -29,6 +29,7 @@
#include <sched.h>
#include <sys/mman.h>

+static unsigned int duration;
#ifndef HAVE_ON_EXIT
#ifndef ATEXIT_MAX
#define ATEXIT_MAX 32
@@ -194,7 +195,7 @@ static void perf_record__sig_exit(int exit_status __maybe_unused, void *arg)
psignal(WTERMSIG(status), rec->progname);
}

- if (signr == -1 || signr == SIGUSR1)
+ if (signr == -1 || signr == SIGUSR1 || signr == SIGALRM)
return;

signal(signr, SIG_DFL);
@@ -404,6 +405,7 @@ static int __cmd_record(struct perf_record *rec, int argc, const char **argv)
signal(SIGCHLD, sig_handler);
signal(SIGINT, sig_handler);
signal(SIGUSR1, sig_handler);
+ signal(SIGALRM, sig_handler);

if (!output_name) {
if (!fstat(STDOUT_FILENO, &st) && S_ISFIFO(st.st_mode))
@@ -471,6 +473,7 @@ static int __cmd_record(struct perf_record *rec, int argc, const char **argv)
goto out_delete_session;
}

+ alarm(duration);
if (forks) {
err = perf_evlist__prepare_workload(evsel_list, &opts->target,
argv, opts->pipe_output,
@@ -955,6 +958,7 @@ const struct option record_options[] = {
parse_branch_stack),
OPT_BOOLEAN('W', "weight", &record.opts.sample_weight,
"sample by weight (on special events only)"),
+ OPT_UINTEGER(0, "duration", &duration, "run during specified seconds"),
OPT_END()
};

--
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majo...@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

Joonsoo Kim

unread,
Jun 18, 2013, 9:02:59 PM6/18/13
to Arnaldo Carvalho de Melo, Peter Zijlstra, Paul Mackerras, Ingo Molnar, linux-...@vger.kernel.org, Joonsoo Kim, Namhyung Kim
Currently, lib lk doesn't use CROSS_COMPILE environment variable,
so cross build is always failed. This is a quick fix for this problem.

Cc: Namhyung Kim <namh...@kernel.org>
Signed-off-by: Joonsoo Kim <iamjoon...@lge.com>

diff --git a/tools/lib/lk/Makefile b/tools/lib/lk/Makefile
index 926cbf3..91e5174 100644
--- a/tools/lib/lk/Makefile
+++ b/tools/lib/lk/Makefile
@@ -1,5 +1,20 @@
include ../../scripts/Makefile.include

+# Makefiles suck: This macro sets a default value of $(2) for the
+# variable named by $(1), unless the variable has been set by
+# environment or command line. This is necessary for CC and AR
+# because make sets default values, so the simpler ?= approach
+# won't work as expected.
+define allow-override
+ $(if $(or $(findstring environment,$(origin $(1))),\
+ $(findstring command line,$(origin $(1)))),,\
+ $(eval $(1) = $(2)))
+endef
+
+# Allow setting CC and AR, or setting CROSS_COMPILE as a prefix.
+$(call allow-override,CC,$(CROSS_COMPILE)gcc)
+$(call allow-override,AR,$(CROSS_COMPILE)ar)
+
# guard against environment variables
LIB_H=
LIB_OBJS=

Joonsoo Kim

unread,
Jun 18, 2013, 9:04:21 PM6/18/13
to Arnaldo Carvalho de Melo, Peter Zijlstra, Paul Mackerras, Ingo Molnar, linux-...@vger.kernel.org, Joonsoo Kim, David Ahern, Namhyung Kim
Building perf for android is failed, because it can't find definition of
struct winsize. This definition is in termios.h, so I add this header
to util.h to solve the problem. It is missed by commit '2c803e52' which
moves get_term_dimensions() from builtin-top.c to util.c, but, missed to
move termios.h header.

Cc: David Ahern <dsa...@gmail.com>
Cc: Namhyung Kim <namh...@kernel.org>
Signed-off-by: Joonsoo Kim <iamjoon...@lge.com>

diff --git a/tools/perf/util/util.h b/tools/perf/util/util.h
index a45710b..f2c6483 100644
--- a/tools/perf/util/util.h
+++ b/tools/perf/util/util.h
@@ -72,6 +72,7 @@
#include "types.h"
#include <sys/ttydefaults.h>
#include <lk/debugfs.h>
+#include <termios.h>

extern const char *graph_line;
extern const char *graph_dotted_line;
@@ -274,6 +275,5 @@ void dump_stack(void);

extern unsigned int page_size;

-struct winsize;
void get_term_dimensions(struct winsize *ws);
#endif /* GIT_COMPAT_UTIL_H */

Ingo Molnar

unread,
Jun 19, 2013, 7:33:40 AM6/19/13
to Joonsoo Kim, Arnaldo Carvalho de Melo, Peter Zijlstra, Paul Mackerras, Ingo Molnar, linux-...@vger.kernel.org, David Ahern, Namhyung Kim

* Joonsoo Kim <iamjoon...@lge.com> wrote:

> Building perf for android is failed, because it can't find definition of
> struct winsize. This definition is in termios.h, so I add this header
> to util.h to solve the problem. It is missed by commit '2c803e52' which
> moves get_term_dimensions() from builtin-top.c to util.c, but, missed to
> move termios.h header.
>
> Cc: David Ahern <dsa...@gmail.com>
> Cc: Namhyung Kim <namh...@kernel.org>
> Signed-off-by: Joonsoo Kim <iamjoon...@lge.com>

Is this something we need for v3.10 as well?

Thanks,

Ingo

Namhyung Kim

unread,
Jun 19, 2013, 8:16:49 AM6/19/13
to Ingo Molnar, Joonsoo Kim, Arnaldo Carvalho de Melo, Peter Zijlstra, Paul Mackerras, Ingo Molnar, linux-...@vger.kernel.org, David Ahern
Hi Ingo,

On Wed, Jun 19, 2013 at 8:33 PM, Ingo Molnar <mi...@kernel.org> wrote:
>
> * Joonsoo Kim <iamjoon...@lge.com> wrote:
>
>> Building perf for android is failed, because it can't find definition of
>> struct winsize. This definition is in termios.h, so I add this header
>> to util.h to solve the problem. It is missed by commit '2c803e52' which
>> moves get_term_dimensions() from builtin-top.c to util.c, but, missed to
>> move termios.h header.
>>
>> Cc: David Ahern <dsa...@gmail.com>
>> Cc: Namhyung Kim <namh...@kernel.org>
>> Signed-off-by: Joonsoo Kim <iamjoon...@lge.com>
>
> Is this something we need for v3.10 as well?
>
> Thanks,
>
> Ingo

I think it's good to go to v3.10 and even v3.9 as well:

$ git name-rev --tags --refs=refs/tags/v3.* 2c803e52
2c803e52 tags/v3.9-rc1~173^2~13^2~22

--
Thanks,
Namhyung

David Ahern

unread,
Jun 19, 2013, 10:52:18 AM6/19/13
to Joonsoo Kim, Arnaldo Carvalho de Melo, Peter Zijlstra, Paul Mackerras, Ingo Molnar, linux-...@vger.kernel.org, Namhyung Kim
On 6/18/13 7:02 PM, Joonsoo Kim wrote:
> Building perf for android is failed, because it can't find definition of
> struct winsize. This definition is in termios.h, so I add this header
> to util.h to solve the problem. It is missed by commit '2c803e52' which
> moves get_term_dimensions() from builtin-top.c to util.c, but, missed to
> move termios.h header.

Thank you for fixing this.

David

>
> Cc: David Ahern <dsa...@gmail.com>
> Cc: Namhyung Kim <namh...@kernel.org>
> Signed-off-by: Joonsoo Kim <iamjoon...@lge.com>
>
> diff --git a/tools/perf/util/util.h b/tools/perf/util/util.h
> index a45710b..f2c6483 100644
> --- a/tools/perf/util/util.h
> +++ b/tools/perf/util/util.h
> @@ -72,6 +72,7 @@
> #include "types.h"
> #include <sys/ttydefaults.h>
> #include <lk/debugfs.h>
> +#include <termios.h>
>
> extern const char *graph_line;
> extern const char *graph_dotted_line;
> @@ -274,6 +275,5 @@ void dump_stack(void);
>
> extern unsigned int page_size;
>
> -struct winsize;
> void get_term_dimensions(struct winsize *ws);
> #endif /* GIT_COMPAT_UTIL_H */
>

--

Joonsoo Kim

unread,
Jun 19, 2013, 9:45:24 PM6/19/13
to Namhyung Kim, Ingo Molnar, Arnaldo Carvalho de Melo, Peter Zijlstra, Paul Mackerras, Ingo Molnar, linux-...@vger.kernel.org, David Ahern
On Wed, Jun 19, 2013 at 09:16:20PM +0900, Namhyung Kim wrote:
> Hi Ingo,
>
> On Wed, Jun 19, 2013 at 8:33 PM, Ingo Molnar <mi...@kernel.org> wrote:
> >
> > * Joonsoo Kim <iamjoon...@lge.com> wrote:
> >
> >> Building perf for android is failed, because it can't find definition of
> >> struct winsize. This definition is in termios.h, so I add this header
> >> to util.h to solve the problem. It is missed by commit '2c803e52' which
> >> moves get_term_dimensions() from builtin-top.c to util.c, but, missed to
> >> move termios.h header.
> >>
> >> Cc: David Ahern <dsa...@gmail.com>
> >> Cc: Namhyung Kim <namh...@kernel.org>
> >> Signed-off-by: Joonsoo Kim <iamjoon...@lge.com>
> >
> > Is this something we need for v3.10 as well?
> >
> > Thanks,
> >
> > Ingo
>
> I think it's good to go to v3.10 and even v3.9 as well:
>
> $ git name-rev --tags --refs=refs/tags/v3.* 2c803e52
> 2c803e52 tags/v3.9-rc1~173^2~13^2~22

Agreed.

Sukadev Bhattiprolu

unread,
Jun 28, 2013, 8:28:02 PM6/28/13
to Joonsoo Kim, Arnaldo Carvalho de Melo, Peter Zijlstra, Paul Mackerras, Ingo Molnar, linux-...@vger.kernel.org, Namhyung Kim
nit: A slight ambiguity in the help text. Would you mind changing it to:

"run for specified duration (seconds)" ?

Sukadev

Joonsoo Kim

unread,
Jul 1, 2013, 1:46:46 AM7/1/13
to Sukadev Bhattiprolu, Arnaldo Carvalho de Melo, Peter Zijlstra, Paul Mackerras, Ingo Molnar, linux-...@vger.kernel.org, Namhyung Kim
Hello, Sukadev.
Okay.

Here goes v2 with your suggestion.
---------------->8------------------------------
From b65e29b33cb250d4a4be103ce5afae29f6bdc11a Mon Sep 17 00:00:00 2001
From: Joonsoo Kim <iamjoon...@lge.com>
Date: Thu, 13 Jun 2013 18:06:21 +0900
Subject: [PATCH v2] perf, tools: support duration option to run during specified
time

Currently, there is no method to quit at specified time later.
We are used to using 'sleep N' as command argument if we need it,
but explicitly supporting this feature maybe makes sense.

Signed-off-by: Joonsoo Kim <iamjoon...@lge.com>

diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
index cdf58ec..1384118 100644
@@ -955,6 +958,8 @@ const struct option record_options[] = {
parse_branch_stack),
OPT_BOOLEAN('W', "weight", &record.opts.sample_weight,
"sample by weight (on special events only)"),
+ OPT_UINTEGER(0, "duration", &duration,
+ "run for specified duration (seconds)"),
OPT_END()
};

--
1.7.9.5

tip-bot for Joonsoo Kim

unread,
Jul 12, 2013, 4:50:33 AM7/12/13
to linux-ti...@vger.kernel.org, ac...@redhat.com, linux-...@vger.kernel.org, pau...@samba.org, mi...@redhat.com, h...@zytor.com, mi...@kernel.org, a.p.zi...@chello.nl, namh...@kernel.org, dsa...@gmail.com, tg...@linutronix.de, iamjoon...@lge.com
Commit-ID: 756bbc84e30b57ca1010b550ea30594fd0b0494f
Gitweb: http://git.kernel.org/tip/756bbc84e30b57ca1010b550ea30594fd0b0494f
Author: Joonsoo Kim <iamjoon...@lge.com>
AuthorDate: Wed, 19 Jun 2013 10:02:30 +0900
Committer: Arnaldo Carvalho de Melo <ac...@redhat.com>
CommitDate: Mon, 8 Jul 2013 17:36:05 -0300

perf tools: Include termios.h explicitly

Building perf for android fails because it can't find the definition of
struct winsize.

This definition is in termios.h, so I add this header to util.h to solve
the problem.

It is missed by commit '2c803e52' which moves get_term_dimensions() from
builtin-top.c to util.c, but missed to move termios.h header.

Signed-off-by: Joonsoo Kim <iamjoon...@lge.com>
Acked-by: David Ahern <dsa...@gmail.com>
Cc: David Ahern <dsa...@gmail.com>
Cc: Ingo Molnar <mi...@redhat.com>
Cc: Namhyung Kim <namh...@kernel.org>
Cc: Paul Mackerras <pau...@samba.org>
Cc: Peter Zijlstra <a.p.zi...@chello.nl>
Link: http://lkml.kernel.org/r/1371603750-15053-3-git-s...@lge.com
Signed-off-by: Arnaldo Carvalho de Melo <ac...@redhat.com>
---
tools/perf/util/util.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/perf/util/util.h b/tools/perf/util/util.h
index 7a484c9..2732fad 100644
--- a/tools/perf/util/util.h
+++ b/tools/perf/util/util.h
@@ -72,6 +72,7 @@
#include "types.h"
#include <sys/ttydefaults.h>
#include <lk/debugfs.h>
+#include <termios.h>

extern const char *graph_line;
extern const char *graph_dotted_line;
@@ -274,6 +275,5 @@ void dump_stack(void);

extern unsigned int page_size;

-struct winsize;
void get_term_dimensions(struct winsize *ws);
#endif /* GIT_COMPAT_UTIL_H */
--

tip-bot for Joonsoo Kim

unread,
Jul 12, 2013, 4:57:44 AM7/12/13
to linux-ti...@vger.kernel.org, ac...@redhat.com, linux-...@vger.kernel.org, pau...@samba.org, mi...@redhat.com, h...@zytor.com, mi...@kernel.org, a.p.zi...@chello.nl, namh...@kernel.org, tg...@linutronix.de, iamjoon...@lge.com
Commit-ID: 079787f209416416383c74ea5d5044be2d586f5e
Gitweb: http://git.kernel.org/tip/079787f209416416383c74ea5d5044be2d586f5e
Author: Joonsoo Kim <iamjoon...@lge.com>
AuthorDate: Wed, 19 Jun 2013 10:02:29 +0900
Committer: Arnaldo Carvalho de Melo <ac...@redhat.com>
CommitDate: Mon, 8 Jul 2013 17:36:17 -0300

tools lib lk: Fix for cross build

Currently, lib lk doesn't use CROSS_COMPILE environment variable, so
cross build always fails.

This is a quick fix for this problem.

Signed-off-by: Joonsoo Kim <iamjoon...@lge.com>
Cc: Ingo Molnar <mi...@redhat.com>
Cc: Namhyung Kim <namh...@kernel.org>
Cc: Paul Mackerras <pau...@samba.org>
Cc: Peter Zijlstra <a.p.zi...@chello.nl>
Link: http://lkml.kernel.org/r/1371603750-15053-2-git-s...@lge.com
Signed-off-by: Arnaldo Carvalho de Melo <ac...@redhat.com>
---
tools/lib/lk/Makefile | 15 +++++++++++++++
1 file changed, 15 insertions(+)

diff --git a/tools/lib/lk/Makefile b/tools/lib/lk/Makefile
index 2c5a197..f0ecc0a 100644
--- a/tools/lib/lk/Makefile
+++ b/tools/lib/lk/Makefile
@@ -3,6 +3,21 @@ include ../../scripts/Makefile.include
CC = $(CROSS_COMPILE)gcc
AR = $(CROSS_COMPILE)ar

+# Makefiles suck: This macro sets a default value of $(2) for the
+# variable named by $(1), unless the variable has been set by
+# environment or command line. This is necessary for CC and AR
+# because make sets default values, so the simpler ?= approach
+# won't work as expected.
+define allow-override
+ $(if $(or $(findstring environment,$(origin $(1))),\
+ $(findstring command line,$(origin $(1)))),,\
+ $(eval $(1) = $(2)))
+endef
+
+# Allow setting CC and AR, or setting CROSS_COMPILE as a prefix.
+$(call allow-override,CC,$(CROSS_COMPILE)gcc)
+$(call allow-override,AR,$(CROSS_COMPILE)ar)
+
# guard against environment variables
LIB_H=
LIB_OBJS=
--
0 new messages