perf tools: perf.h cleanups
Jiri Olsa
reviewercover perf tools: perf.h cleanups
hi,
moving syscall function and arch related defines into new header 'perf-sys.h' as requested by Peter in:
http://lkml.kernel.org/r/[email protected]
While at it I did some clean ups in perf.h header.
Hopefully I did not brake anyone's usage of perf.h .. let me know ;-)
Also available in here:
git://git.kernel.org/pub/scm/linux/kernel/git/jolsa/perf.git
perf/header_1
thanks,
jirka
---
Jiri Olsa (10):
perf tools: Remove MAX_COUNTERS define from perf.h perf tools: Remove unlikely define from perf.h
perf tools: Remove min define from perf.h
perf tools: Remove asmlinkage define from perf.h perf tools: Remove PR_TASK_PERF_EVENTS_* from perf.h perf tools: Move sample data structures from perf.h perf tools: Move perf_call_graph_mode enum from perf.h perf tools: Move syscall and arch specific defines from perf.h perf tools: Move sys_perf_event_open function from perf.h perf tools: Move ACCESS_ONCE from perf.h header
tools/perf/perf-sys.h | 190 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ tools/perf/perf.h | 250 ++++--------------------------------------------------------------------------------------------------- tools/perf/util/callchain.h | 7 +++ tools/perf/util/event.h | 24 ++++++++++ tools/perf/util/evlist.h | 2 + tools/perf/util/symbol.h | 1 + 6 files changed, 232 insertions(+), 242 deletions(-) create mode 100644 tools/perf/perf-sys.h
Jiri Olsa
reviewerPATCH 1/10 perf tools: Remove MAX_COUNTERS define from perf.h
As it's no longer used.
--- tools/perf/perf.h | 1 - 1 file changed, 1 deletion(-)
tools/perf/perf.h +0 -1
@@ -231,7 +231,6 @@ sys_perf_event_open(struct perf_event_attr *attr,return fd; } -#define MAX_COUNTERS 256#define MAX_NR_CPUS 256struct ip_callchain {
Signature · 1 line
1.8.3.1
tip-bot for Jiri Olsa
merge bot[tip:perf/core] perf tools: Remove MAX_COUNTERS define from perf.h
perf tools: Remove MAX_COUNTERS define from perf.h
Commit-ID: 3dd422b4a5009e7654846534d535758d4cc985db Gitweb: http://git.kernel.org/tip/3dd422b4a5009e7654846534d535758d4cc985db Author: Jiri Olsa <[email protected]> AuthorDate: Mon, 5 May 2014 12:26:14 +0200 Committer: Jiri Olsa <[email protected]> CommitDate: Mon, 5 May 2014 17:45:20 +0200
perf tools: Remove MAX_COUNTERS define from perf.h
As it's no longer used.
--- tools/perf/perf.h | 1 - 1 file changed, 1 deletion(-)
tools/perf/perf.h +0 -1
@@ -231,7 +231,6 @@ sys_perf_event_open(struct perf_event_attr *attr,return fd; } -#define MAX_COUNTERS 256#define MAX_NR_CPUS 256struct ip_callchain {
Jiri Olsa
reviewerPATCH 2/10 perf tools: Remove unlikely define from perf.h
In reply to Jiri OlsaIt's defined in tools/include/linux/compiler.h header.
--- tools/perf/perf.h | 1 - 1 file changed, 1 deletion(-)
tools/perf/perf.h +0 -1
@@ -203,7 +203,6 @@ static inline unsigned long long rdclock(void)*/ #define asmlinkage -#define unlikely (x) __builtin_expect(!!(x), 0)#define min (x, y) ({ \ typeof(x) _min1 = (x); \ typeof(y) _min2 = (y); \
Signature · 1 line
1.8.3.1
tip-bot for Jiri Olsa
merge bot[tip:perf/core] perf tools: Remove unlikely define from perf.h
perf tools: Remove unlikely define from perf.h
Commit-ID: 8be26c539f0d4c77a798b20515ad6404d72de74d Gitweb: http://git.kernel.org/tip/8be26c539f0d4c77a798b20515ad6404d72de74d Author: Jiri Olsa <[email protected]> AuthorDate: Mon, 5 May 2014 12:32:05 +0200 Committer: Jiri Olsa <[email protected]> CommitDate: Mon, 5 May 2014 17:46:10 +0200
perf tools: Remove unlikely define from perf.h
It's defined in tools/include/linux/compiler.h header.
--- tools/perf/perf.h | 1 - 1 file changed, 1 deletion(-)
tools/perf/perf.h +0 -1
@@ -203,7 +203,6 @@ static inline unsigned long long rdclock(void)*/ #define asmlinkage -#define unlikely (x) __builtin_expect(!!(x), 0)#define min (x, y) ({ \ typeof(x) _min1 = (x); \ typeof(y) _min2 = (y); \
Jiri Olsa
reviewerPATCH 3/10 perf tools: Remove min define from perf.h
In reply to Jiri OlsaIt's defined in tools/perf/util/include/linux/kernel.h header.
--- tools/perf/perf.h | 6 ------ 1 file changed, 6 deletions(-)
tools/perf/perf.h +0 -6
@@ -203,12 +203,6 @@ static inline unsigned long long rdclock(void)*/ #define asmlinkage -#define min (x, y) ({ \ - typeof(x) _min1 = (x); \ - typeof(y) _min2 = (y); \ - (void) (&_min1 == &_min2); \ - _min1 < _min2 ? _min1 : _min2; }) -extern bool test_attr__enabled;void test_attr__init (void ); void test_attr__open(struct perf_event_attr *attr, pid_t pid, int cpu,
Signature · 1 line
1.8.3.1
tip-bot for Jiri Olsa
merge bot[tip:perf/core] perf tools: Remove min define from perf.h
perf tools: Remove min define from perf.h
Commit-ID: 1b7ae1c941af21ec386ea7c7e812ba430652731c Gitweb: http://git.kernel.org/tip/1b7ae1c941af21ec386ea7c7e812ba430652731c Author: Jiri Olsa <[email protected]> AuthorDate: Mon, 5 May 2014 12:34:12 +0200 Committer: Jiri Olsa <[email protected]> CommitDate: Mon, 5 May 2014 17:46:41 +0200
perf tools: Remove min define from perf.h
It's defined in tools/perf/util/include/linux/kernel.h header.
--- tools/perf/perf.h | 6 ------ 1 file changed, 6 deletions(-)
tools/perf/perf.h +0 -6
@@ -203,12 +203,6 @@ static inline unsigned long long rdclock(void)*/ #define asmlinkage -#define min (x, y) ({ \ - typeof(x) _min1 = (x); \ - typeof(y) _min2 = (y); \ - (void) (&_min1 == &_min2); \ - _min1 < _min2 ? _min1 : _min2; }) -extern bool test_attr__enabled;void test_attr__init (void ); void test_attr__open(struct perf_event_attr *attr, pid_t pid, int cpu,
Jiri Olsa
reviewerPATCH 4/10 perf tools: Remove asmlinkage define from perf.h
In reply to Jiri OlsaAs it's no longer used.
--- tools/perf/perf.h | 5 ----- 1 file changed, 5 deletions(-)
tools/perf/perf.h +0 -5
@@ -198,11 +198,6 @@ static inline unsigned long long rdclock(void)return ts.tv_sec *1000000000ULL + ts.tv_nsec; } -/* -* Pick up some kernel type conventions: -*/ -#define asmlinkage -extern bool test_attr__enabled;void test_attr__init (void ); void test_attr__open(struct perf_event_attr *attr, pid_t pid, int cpu,
Signature · 1 line
1.8.3.1
tip-bot for Jiri Olsa
merge bot[tip:perf/core] perf tools: Remove asmlinkage define from perf.h
perf tools: Remove asmlinkage define from perf.h
Commit-ID: 273a0a734cd780f9ab3c3aac1851b2d15bb9638d Gitweb: http://git.kernel.org/tip/273a0a734cd780f9ab3c3aac1851b2d15bb9638d Author: Jiri Olsa <[email protected]> AuthorDate: Mon, 5 May 2014 12:36:38 +0200 Committer: Jiri Olsa <[email protected]> CommitDate: Mon, 5 May 2014 17:47:06 +0200
perf tools: Remove asmlinkage define from perf.h
As it's no longer used.
--- tools/perf/perf.h | 5 ----- 1 file changed, 5 deletions(-)
tools/perf/perf.h +0 -5
@@ -198,11 +198,6 @@ static inline unsigned long long rdclock(void)return ts.tv_sec *1000000000ULL + ts.tv_nsec; } -/* -* Pick up some kernel type conventions: -*/ -#define asmlinkage -extern bool test_attr__enabled;void test_attr__init (void ); void test_attr__open(struct perf_event_attr *attr, pid_t pid, int cpu,
Jiri Olsa
reviewerPATCH 5/10 perf tools: Remove PR_TASK_PERF_EVENTS_* from perf.h
In reply to Jiri OlsaIt's defined in include/uapi/linux/prctl.h header. Also it was never used in perf tool.
--- tools/perf/perf.h | 7 ------- 1 file changed, 7 deletions(-)
tools/perf/perf.h +0 -7
@@ -176,13 +176,6 @@#include <linux/types.h> #include <linux/perf_event.h> -/* -* prctl(PR_TASK_PERF_EVENTS_DISABLE) will (cheaply) disable all -* counters in the current task. -*/ -#define PR_TASK_PERF_EVENTS_DISABLE 31 -#define PR_TASK_PERF_EVENTS_ENABLE 32 -#ifndef NSEC_PER_SEC # define NSEC_PER_SEC 1000000000ULL#endif
Signature · 1 line
1.8.3.1
tip-bot for Jiri Olsa
merge bot[tip:perf/core] perf tools: Remove PR_TASK_PERF_EVENTS_* from perf.h
perf tools: Remove PR_TASK_PERF_EVENTS_* from perf.h
Commit-ID: 36446f4bfe613ad1da00f06081d410d62c07d334 Gitweb: http://git.kernel.org/tip/36446f4bfe613ad1da00f06081d410d62c07d334 Author: Jiri Olsa <[email protected]> AuthorDate: Mon, 5 May 2014 12:37:05 +0200 Committer: Jiri Olsa <[email protected]> CommitDate: Mon, 5 May 2014 17:47:25 +0200
perf tools: Remove PR_TASK_PERF_EVENTS_* from perf.h
It's defined in include/uapi/linux/prctl.h header. Also it was never used in perf tool.
--- tools/perf/perf.h | 7 ------- 1 file changed, 7 deletions(-)
tools/perf/perf.h +0 -7
@@ -176,13 +176,6 @@#include <linux/types.h> #include <linux/perf_event.h> -/* -* prctl(PR_TASK_PERF_EVENTS_DISABLE) will (cheaply) disable all -* counters in the current task. -*/ -#define PR_TASK_PERF_EVENTS_DISABLE 31 -#define PR_TASK_PERF_EVENTS_ENABLE 32 -#ifndef NSEC_PER_SEC # define NSEC_PER_SEC 1000000000ULL#endif
Jiri Olsa
reviewerPATCH 6/10 perf tools: Move sample data structures from perf.h
In reply to Jiri OlsaInto util/event.h header where all sample data structures are defined.
--- tools/perf/perf.h | 24 ------------------------ tools/perf/util/event.h | 24 ++++++++++++++++++++++++ tools/perf/util/symbol.h | 1 + 3 files changed, 25 insertions(+), 24 deletions(-)
tools/perf/perf.h +0 -24
@@ -214,30 +214,6 @@ sys_perf_event_open(struct perf_event_attr *attr,#define MAX_NR_CPUS 256 -struct ip_callchain { -u64 nr; -u64 ips[0 ]; -}; - -struct branch_flags { -u64 mispred:1 ; -u64 predicted:1 ; -u64 in_tx:1 ; -u64 abort:1 ; -u64 reserved:60 ; -}; - -struct branch_entry { -u64 from; -u64 to; -struct branch_flags flags; -}; - -struct branch_stack { -u64 nr; -struct branch_entry entries[0 ]; -}; -extern const char *input_name;extern bool perf_host, perf_guest;extern const char perf_version_string[];
tools/perf/util/event.h +24 -0
@@ -112,6 +112,30 @@ struct sample_read { }; }; +struct ip_callchain { +u64 nr; +u64 ips[0 ]; +}; + +struct branch_flags { +u64 mispred:1 ; +u64 predicted:1 ; +u64 in_tx:1 ; +u64 abort:1 ; +u64 reserved:60 ; +}; + +struct branch_entry { +u64 from; +u64 to; +struct branch_flags flags; +}; + +struct branch_stack { +u64 nr; +struct branch_entry entries[0 ]; +}; +struct perf_sample {u64 ip;u32 pid, tid;
tools/perf/util/symbol.h +1 -0
@@ -12,6 +12,7 @@#include <byteswap.h> #include <libgen.h> #include "build-id.h" +#include "event.h" #ifdef HAVE_LIBELF_SUPPORT #include <libelf.h>
Signature · 1 line
1.8.3.1
tip-bot for Jiri Olsa
merge bot[tip:perf/core] perf tools: Move sample data structures from perf.h
perf tools: Move sample data structures from perf.h
Commit-ID: 0776eb59354f8b848e5738a612c272d8f48de9bf Gitweb: http://git.kernel.org/tip/0776eb59354f8b848e5738a612c272d8f48de9bf Author: Jiri Olsa <[email protected]> AuthorDate: Mon, 5 May 2014 12:41:45 +0200 Committer: Jiri Olsa <[email protected]> CommitDate: Mon, 5 May 2014 17:47:40 +0200
perf tools: Move sample data structures from perf.h
Into util/event.h header where all sample data structures are defined.
--- tools/perf/perf.h | 24 ------------------------ tools/perf/util/event.h | 24 ++++++++++++++++++++++++ tools/perf/util/symbol.h | 1 + 3 files changed, 25 insertions(+), 24 deletions(-)
tools/perf/perf.h +0 -24
@@ -214,30 +214,6 @@ sys_perf_event_open(struct perf_event_attr *attr,#define MAX_NR_CPUS 256 -struct ip_callchain { -u64 nr; -u64 ips[0 ]; -}; - -struct branch_flags { -u64 mispred:1 ; -u64 predicted:1 ; -u64 in_tx:1 ; -u64 abort:1 ; -u64 reserved:60 ; -}; - -struct branch_entry { -u64 from; -u64 to; -struct branch_flags flags; -}; - -struct branch_stack { -u64 nr; -struct branch_entry entries[0 ]; -}; -extern const char *input_name;extern bool perf_host, perf_guest;extern const char perf_version_string[];
tools/perf/util/event.h +24 -0
@@ -112,6 +112,30 @@ struct sample_read { }; }; +struct ip_callchain { +u64 nr; +u64 ips[0 ]; +}; + +struct branch_flags { +u64 mispred:1 ; +u64 predicted:1 ; +u64 in_tx:1 ; +u64 abort:1 ; +u64 reserved:60 ; +}; + +struct branch_entry { +u64 from; +u64 to; +struct branch_flags flags; +}; + +struct branch_stack { +u64 nr; +struct branch_entry entries[0 ]; +}; +struct perf_sample {u64 ip;u32 pid, tid;
tools/perf/util/symbol.h +1 -0
@@ -12,6 +12,7 @@#include <byteswap.h> #include <libgen.h> #include "build-id.h" +#include "event.h" #ifdef HAVE_LIBELF_SUPPORT #include <libelf.h>
Jiri Olsa
reviewerPATCH 7/10 perf tools: Move perf_call_graph_mode enum from perf.h
In reply to Jiri OlsaInto util/callchain.h header where all callchain related structures should be.
--- tools/perf/perf.h | 7 ------- tools/perf/util/callchain.h | 7 +++++++ 2 files changed, 7 insertions(+), 7 deletions(-)
tools/perf/perf.h +0 -7
@@ -222,13 +222,6 @@ void pthread__unblock_sigwinch(void);#include "util/target.h" -enum perf_call_graph_mode { -CALLCHAIN_NONE , -CALLCHAIN_FP , -CALLCHAIN_DWARF , -CALLCHAIN_MAX -}; -struct record_opts {struct target target;int call_graph;
tools/perf/util/callchain.h +7 -0
@@ -7,6 +7,13 @@#include "event.h" #include "symbol.h" +enum perf_call_graph_mode { +CALLCHAIN_NONE , +CALLCHAIN_FP , +CALLCHAIN_DWARF , +CALLCHAIN_MAX +}; +enum chain_mode {CHAIN_NONE ,CHAIN_FLAT ,
Signature · 1 line
1.8.3.1
tip-bot for Jiri Olsa
merge bot[tip:perf/core] perf tools: Move perf_call_graph_mode enum from perf.h
perf tools: Move perf_call_graph_mode enum from perf.h
Commit-ID: 2c83bc08e305e135b954d82596864b7d024fc7fd Gitweb: http://git.kernel.org/tip/2c83bc08e305e135b954d82596864b7d024fc7fd Author: Jiri Olsa <[email protected]> AuthorDate: Mon, 5 May 2014 12:46:17 +0200 Committer: Jiri Olsa <[email protected]> CommitDate: Mon, 5 May 2014 17:48:10 +0200
perf tools: Move perf_call_graph_mode enum from perf.h
Into util/callchain.h header where all callchain related structures should be.
--- tools/perf/perf.h | 7 ------- tools/perf/util/callchain.h | 7 +++++++ 2 files changed, 7 insertions(+), 7 deletions(-)
tools/perf/perf.h +0 -7
@@ -222,13 +222,6 @@ void pthread__unblock_sigwinch(void);#include "util/target.h" -enum perf_call_graph_mode { -CALLCHAIN_NONE , -CALLCHAIN_FP , -CALLCHAIN_DWARF , -CALLCHAIN_MAX -}; -struct record_opts {struct target target;int call_graph;
tools/perf/util/callchain.h +7 -0
@@ -7,6 +7,13 @@#include "event.h" #include "symbol.h" +enum perf_call_graph_mode { +CALLCHAIN_NONE , +CALLCHAIN_FP , +CALLCHAIN_DWARF , +CALLCHAIN_MAX +}; +enum chain_mode {CHAIN_NONE ,CHAIN_FLAT ,
Jiri Olsa
reviewerPATCH 8/10 perf tools: Move syscall and arch specific defines from perf.h
In reply to Jiri OlsaInto new perf-sys.h header.
The main reason is to separate system specific perf data from perf tool stuff, so it could be used in small test programs, as requested Peter:
http://lkml.kernel.org/r/[email protected]
This separation makes the perf.h header more clear.
--- tools/perf/perf-sys.h | 168 ++++++++++++++++++++++++++++++++++++++++++++++++++ tools/perf/perf.h | 165 +------------------------------------------------ 2 files changed, 169 insertions(+), 164 deletions(-) create mode 100644 tools/perf/perf-sys.h
tools/perf/perf-sys.h new file +168 -0
@@ -0,0 +1,168 @@ +#ifndef _PERF_SYS_H +#define _PERF_SYS_H + +#include <asm/unistd.h> + +#if defined(__i386__) +#define mb () asm volatile("lock; addl $0,0(%%esp)" ::: "memory") +#define wmb () asm volatile("lock; addl $0,0(%%esp)" ::: "memory") +#define rmb () asm volatile("lock; addl $0,0(%%esp)" ::: "memory") +#define cpu_relax () asm volatile("rep; nop" ::: "memory"); +#define CPUINFO_PROC "model name" +#ifndef __NR_perf_event_open +# define __NR_perf_event_open 336 +#endif +#ifndef __NR_futex +# define __NR_futex 240 +#endif +#ifndef __NR_gettid +# define __NR_gettid 224 +#endif +#endif + +#if defined(__x86_64__) +#define mb () asm volatile("mfence" ::: "memory") +#define wmb () asm volatile("sfence" ::: "memory") +#define rmb () asm volatile("lfence" ::: "memory") +#define cpu_relax () asm volatile("rep; nop" ::: "memory"); +#define CPUINFO_PROC "model name" +#ifndef __NR_perf_event_open +# define __NR_perf_event_open 298 +#endif +#ifndef __NR_futex +# define __NR_futex 202 +#endif +#ifndef __NR_gettid +# define __NR_gettid 186 +#endif +#endif + +#ifdef __powerpc__ +#include "../../arch/powerpc/include/uapi/asm/unistd.h" +#define mb () asm volatile ("sync" ::: "memory") +#define wmb () asm volatile ("sync" ::: "memory") +#define rmb () asm volatile ("sync" ::: "memory") +#define CPUINFO_PROC "cpu" +#endif + +#ifdef __s390__ +#define mb () asm volatile("bcr 15,0" ::: "memory") +#define wmb () asm volatile("bcr 15,0" ::: "memory") +#define rmb () asm volatile("bcr 15,0" ::: "memory") +#endif + +#ifdef __sh__ +#if defined(__SH4A__) || defined(__SH5__) +# define mb () asm volatile("synco" ::: "memory") +# define wmb () asm volatile("synco" ::: "memory") +# define rmb () asm volatile("synco" ::: "memory") +#else +# define mb () asm volatile("" ::: "memory") +# define wmb () asm volatile("" ::: "memory") +# define rmb () asm volatile("" ::: "memory") +#endif +#define CPUINFO_PROC "cpu type" +#endif + +#ifdef __hppa__ +#define mb () asm volatile("" ::: "memory") +#define wmb () asm volatile("" ::: "memory") +#define rmb () asm volatile("" ::: "memory") +#define CPUINFO_PROC "cpu" +#endif + +#ifdef __sparc__ +#ifdef __LP64__ +#define mb () asm volatile("ba,pt %%xcc, 1f\n" \ + "membar #StoreLoad\n" \ + "1:\n":::"memory") +#else +#define mb () asm volatile("":::"memory") +#endif +#define wmb () asm volatile("":::"memory") +#define rmb () asm volatile("":::"memory") +#define CPUINFO_PROC "cpu" +#endif + +#ifdef __alpha__ +#define mb () asm volatile("mb" ::: "memory") +#define wmb () asm volatile("wmb" ::: "memory") +#define rmb () asm volatile("mb" ::: "memory") +#define CPUINFO_PROC "cpu model" +#endif + +#ifdef __ia64__ +#define mb () asm volatile ("mf" ::: "memory") +#define wmb () asm volatile ("mf" ::: "memory") +#define rmb () asm volatile ("mf" ::: "memory") +#define cpu_relax () asm volatile ("hint @pause" ::: "memory") +#define CPUINFO_PROC "model name" +#endif + +#ifdef __arm__ +/* +* Use the __kuser_memory_barrier helper in the CPU helper page. See +* arch/arm/kernel/entry-armv.S in the kernel source for details. +*/ +#define mb () ((void(*)(void))0xffff0fa0)() +#define wmb () ((void(*)(void))0xffff0fa0)() +#define rmb () ((void(*)(void))0xffff0fa0)() +#define CPUINFO_PROC "Processor" +#endif + +#ifdef __aarch64__ +#define mb () asm volatile("dmb ish" ::: "memory") +#define wmb () asm volatile("dmb ishst" ::: "memory") +#define rmb () asm volatile("dmb ishld" ::: "memory") +#define cpu_relax () asm volatile("yield" ::: "memory") +#endif + +#ifdef __mips__ +#define mb() asm volatile( \ + ".set mips2\n\t" \ + "sync\n\t" \ + ".set mips0" \ + : /* no output */ \ + : /* no input */ \ + : "memory") +#define wmb () mb() +#define rmb () mb() +#define CPUINFO_PROC "cpu model" +#endif + +#ifdef __arc__ +#define mb () asm volatile("" ::: "memory") +#define wmb () asm volatile("" ::: "memory") +#define rmb () asm volatile("" ::: "memory") +#define CPUINFO_PROC "Processor" +#endif + +#ifdef __metag__ +#define mb () asm volatile("" ::: "memory") +#define wmb () asm volatile("" ::: "memory") +#define rmb () asm volatile("" ::: "memory") +#define CPUINFO_PROC "CPU" +#endif + +#ifdef __xtensa__ +#define mb () asm volatile("memw" ::: "memory") +#define wmb () asm volatile("memw" ::: "memory") +#define rmb () asm volatile("" ::: "memory") +#define CPUINFO_PROC "core ID" +#endif + +#ifdef __tile__ +#define mb () asm volatile ("mf" ::: "memory") +#define wmb () asm volatile ("mf" ::: "memory") +#define rmb () asm volatile ("mf" ::: "memory") +#define cpu_relax () asm volatile ("mfspr zero, PASS" ::: "memory") +#define CPUINFO_PROC "model name" +#endif + +#define barrier () asm volatile ("" ::: "memory") + +#ifndef cpu_relax +#define cpu_relax () barrier() +#endif + +#endif /* _PERF_SYS_H */
tools/perf/perf.h +1 -164
174 lines not on this page · raw message
Signature · 1 line
1.8.3.1
tip-bot for Jiri Olsa
merge bot[tip:perf/core] perf tools: Move syscall and arch specific defines from perf.h
perf tools: Move syscall and arch specific defines from perf.h
Commit-ID: 43599d1f7adffbbf990b00716ba22974ec1487be Gitweb: http://git.kernel.org/tip/43599d1f7adffbbf990b00716ba22974ec1487be Author: Jiri Olsa <[email protected]> AuthorDate: Mon, 5 May 2014 12:53:20 +0200 Committer: Jiri Olsa <[email protected]> CommitDate: Mon, 5 May 2014 17:48:28 +0200
perf tools: Move syscall and arch specific defines from perf.h
Into new perf-sys.h header.
The main reason is to separate system specific perf data from perf tool stuff, so it could be used in small test programs, as requested Peter:
http://lkml.kernel.org/r/[email protected]
This separation makes the perf.h header more clear.
---
tools/perf/{perf.h => perf-sys.h} | 89 +-------------------
tools/perf/perf.h | 165 +-------------------------------------
2 files changed, 4 insertions(+), 250 deletions(-)tools/perf/perf-sys.h renamed from tools/perf/perf.h +3 -86
@@ -1,5 +1,5 @@ -#ifndef _PERF_PERF_H -#define _PERF_PERF_H +#ifndef _PERF_SYS_H +#define _PERF_SYS_H#include <asm/unistd.h>
@@ -165,87 +165,4 @@#define cpu_relax () barrier()#endif -#define ACCESS_ONCE (x) (*(volatile typeof(x) *)&(x)) - - -#include <time.h> -#include <unistd.h> -#include <sys/types.h> -#include <sys/syscall.h> - -#include <linux/types.h> -#include <linux/perf_event.h> - -#ifndef NSEC_PER_SEC -# define NSEC_PER_SEC 1000000000ULL -#endif -#ifndef NSEC_PER_USEC -# define NSEC_PER_USEC 1000ULL -#endif - -static inline unsigned long long rdclock (void ) -{ -struct timespec ts; - -clock_gettime (CLOCK_MONOTONIC , &ts); -return ts.tv_sec *1000000000ULL + ts.tv_nsec; -} - -extern bool test_attr__enabled; -void test_attr__init (void ); -void test_attr__open (struct perf_event_attr *attr,pid_t pid,int cpu, -int fd,int group_fd,unsigned long flags); - -static inline int -sys_perf_event_open (struct perf_event_attr *attr, -pid_t pid,int cpu,int group_fd, -unsigned long flags) -{ -int fd; - - fd =syscall (__NR_perf_event_open, attr, pid, cpu, - group_fd, flags); - -if (unlikely (test_attr__enabled)) -test_attr__open (attr, pid, cpu, fd, group_fd, flags); - -return fd; -} - -#define MAX_NR_CPUS 256 - -extern const char *input_name; -extern bool perf_host, perf_guest; -extern const char perf_version_string[]; - -void pthread__unblock_sigwinch (void ); - -#include "util/target.h" - -struct record_opts { -struct target target; -int call_graph; -bool call_graph_enabled; -bool group; -bool inherit_stat; -bool no_buffering; -bool no_inherit; -bool no_inherit_set; -bool no_samples; -bool raw_samples; -bool sample_address; -bool sample_weight; -bool sample_time; -bool period; -unsigned int freq; -unsigned int mmap_pages; -unsigned int user_freq; -u64 branch_stack; -u64 default_interval; -u64 user_interval; -u16 stack_dump_size; -bool sample_transaction; -unsigned initial_delay; -}; - -#endif +#endif /* _PERF_SYS_H */
tools/perf/perf.h +1 -164
174 lines not on this page · raw message
Jiri Olsa
reviewerPATCH 9/10 perf tools: Move sys_perf_event_open function from perf.h
In reply to Jiri OlsaInto perf-sys.h header, as requested by Peter:
http://lkml.kernel.org/r/[email protected]
Adding HAVE_ATTR_TEST define to turn off/on the attribute test code in the sys_perf_event_open function.
--- tools/perf/perf-sys.h | 22 ++++++++++++++++++++++ tools/perf/perf.h | 40 +++++++++++----------------------------- 2 files changed, 33 insertions(+), 29 deletions(-)
tools/perf/perf-sys.h +22 -0
@@ -1,6 +1,11 @@#ifndef _PERF_SYS_H#define _PERF_SYS_H +#include <unistd.h> +#include <sys/types.h> +#include <sys/syscall.h> +#include <linux/types.h> +#include <linux/perf_event.h> #include <asm/unistd.h> #if defined(__i386__)
@@ -165,4 +170,21 @@#define cpu_relax () barrier()#endif +static inline int +sys_perf_event_open (struct perf_event_attr *attr, +pid_t pid,int cpu,int group_fd, +unsigned long flags) +{ +int fd; + + fd =syscall (__NR_perf_event_open, attr, pid, cpu, + group_fd, flags); + +#ifdef HAVE_ATTR_TEST +if (unlikely (test_attr__enabled)) +test_attr__open (attr, pid, cpu, fd, group_fd, flags); +#endif +return fd; +} +#endif /* _PERF_SYS_H */
tools/perf/perf.h +11 -29
@@ -1,18 +1,21 @@#ifndef _PERF_PERF_H#define _PERF_PERF_H -#include "perf-sys.h" - -#define ACCESS_ONCE (x) (*(volatile typeof(x) *)&(x)) -#include <time.h> -#include <unistd.h> -#include <sys/types.h> -#include <sys/syscall.h> - +#include <stdbool.h> #include <linux/types.h> #include <linux/perf_event.h> +extern bool test_attr__enabled; +void test_attr__init (void ); +void test_attr__open (struct perf_event_attr *attr,pid_t pid,int cpu, +int fd,int group_fd,unsigned long flags); + +#define HAVE_ATTR_TEST +#include "perf-sys.h" + +#define ACCESS_ONCE (x) (*(volatile typeof(x) *)&(x)) +#ifndef NSEC_PER_SEC # define NSEC_PER_SEC 1000000000ULL#endif
@@ -28,27 +31,6 @@ static inline unsigned long long rdclock(void)return ts.tv_sec *1000000000ULL + ts.tv_nsec; } -extern bool test_attr__enabled; -void test_attr__init (void ); -void test_attr__open (struct perf_event_attr *attr,pid_t pid,int cpu, -int fd,int group_fd,unsigned long flags); - -static inline int -sys_perf_event_open (struct perf_event_attr *attr, -pid_t pid,int cpu,int group_fd, -unsigned long flags) -{ -int fd; - - fd =syscall (__NR_perf_event_open, attr, pid, cpu, - group_fd, flags); - -if (unlikely (test_attr__enabled)) -test_attr__open (attr, pid, cpu, fd, group_fd, flags); - -return fd; -} -#define MAX_NR_CPUS 256extern const char *input_name;
Signature · 1 line
1.8.3.1
tip-bot for Jiri Olsa
merge bot[tip:perf/core] perf tools: Move sys_perf_event_open function from perf.h
perf tools: Move sys_perf_event_open function from perf.h
Commit-ID: 82baa0eb46c15b749723d0c801470fea044657d7 Gitweb: http://git.kernel.org/tip/82baa0eb46c15b749723d0c801470fea044657d7 Author: Jiri Olsa <[email protected]> AuthorDate: Mon, 5 May 2014 12:58:31 +0200 Committer: Jiri Olsa <[email protected]> CommitDate: Mon, 5 May 2014 17:48:51 +0200
perf tools: Move sys_perf_event_open function from perf.h
Into perf-sys.h header, as requested by Peter:
http://lkml.kernel.org/r/[email protected]
Adding HAVE_ATTR_TEST define to turn off/on the attribute test code in the sys_perf_event_open function.
--- tools/perf/perf-sys.h | 22 ++++++++++++++++++++++ tools/perf/perf.h | 40 +++++++++++----------------------------- 2 files changed, 33 insertions(+), 29 deletions(-)
tools/perf/perf-sys.h +22 -0
@@ -1,6 +1,11 @@#ifndef _PERF_SYS_H#define _PERF_SYS_H +#include <unistd.h> +#include <sys/types.h> +#include <sys/syscall.h> +#include <linux/types.h> +#include <linux/perf_event.h> #include <asm/unistd.h> #if defined(__i386__)
@@ -165,4 +170,21 @@#define cpu_relax () barrier()#endif +static inline int +sys_perf_event_open (struct perf_event_attr *attr, +pid_t pid,int cpu,int group_fd, +unsigned long flags) +{ +int fd; + + fd =syscall (__NR_perf_event_open, attr, pid, cpu, + group_fd, flags); + +#ifdef HAVE_ATTR_TEST +if (unlikely (test_attr__enabled)) +test_attr__open (attr, pid, cpu, fd, group_fd, flags); +#endif +return fd; +} +#endif /* _PERF_SYS_H */
tools/perf/perf.h +11 -29
@@ -1,18 +1,21 @@#ifndef _PERF_PERF_H#define _PERF_PERF_H -#include "perf-sys.h" - -#define ACCESS_ONCE (x) (*(volatile typeof(x) *)&(x)) -#include <time.h> -#include <unistd.h> -#include <sys/types.h> -#include <sys/syscall.h> - +#include <stdbool.h> #include <linux/types.h> #include <linux/perf_event.h> +extern bool test_attr__enabled; +void test_attr__init (void ); +void test_attr__open (struct perf_event_attr *attr,pid_t pid,int cpu, +int fd,int group_fd,unsigned long flags); + +#define HAVE_ATTR_TEST +#include "perf-sys.h" + +#define ACCESS_ONCE (x) (*(volatile typeof(x) *)&(x)) +#ifndef NSEC_PER_SEC # define NSEC_PER_SEC 1000000000ULL#endif
@@ -28,27 +31,6 @@ static inline unsigned long long rdclock(void)return ts.tv_sec *1000000000ULL + ts.tv_nsec; } -extern bool test_attr__enabled; -void test_attr__init (void ); -void test_attr__open (struct perf_event_attr *attr,pid_t pid,int cpu, -int fd,int group_fd,unsigned long flags); - -static inline int -sys_perf_event_open (struct perf_event_attr *attr, -pid_t pid,int cpu,int group_fd, -unsigned long flags) -{ -int fd; - - fd =syscall (__NR_perf_event_open, attr, pid, cpu, - group_fd, flags); - -if (unlikely (test_attr__enabled)) -test_attr__open (attr, pid, cpu, fd, group_fd, flags); - -return fd; -} -#define MAX_NR_CPUS 256extern const char *input_name;
Jiri Olsa
reviewerPATCH 10/10 perf tools: Move ACCESS_ONCE from perf.h header
In reply to Jiri OlsaInto util/evlist.h header as it's the only user of this define.
--- tools/perf/perf.h | 2 -- tools/perf/util/evlist.h | 2 ++ 2 files changed, 2 insertions(+), 2 deletions(-)
tools/perf/perf.h +0 -2
@@ -14,8 +14,6 @@ void test_attr__open(struct perf_event_attr *attr, pid_t pid, int cpu,#define HAVE_ATTR_TEST #include "perf-sys.h" -#define ACCESS_ONCE (x) (*(volatile typeof(x) *)&(x)) -#ifndef NSEC_PER_SEC # define NSEC_PER_SEC 1000000000ULL#endif
tools/perf/util/evlist.h +2 -0
@@ -17,6 +17,8 @@ struct record_opts;#define PERF_EVLIST__HLIST_BITS 8#define PERF_EVLIST__HLIST_SIZE (1 << PERF_EVLIST__HLIST_BITS) +#define ACCESS_ONCE (x) (*(volatile typeof(x) *)&(x)) +struct perf_mmap {void *base;int mask;
Signature · 1 line
1.8.3.1
Peter Zijlstra
maintainerRe: [PATCH 10/10] perf tools: Move ACCESS_ONCE from perf.h header
Quoted 2 lines · Jiri Olsa
Into
util/evlist.hheader as it's the only user
of this define.
One could argue its part of the barrier muck, but sure.
Re: [PATCH 10/10] perf tools: Move ACCESS_ONCE from perf.h header
Quoted 1 line · Peter Zijlstra
One could argue its part of the barrier muck, but sure.
Yeah, it might be prudent to put stuff like that in the most fitting headers from the get-go as it causes trouble otherwise. And for ACCESS_ONCE, in particular, we have tools/include/linux/compiler.h which is a subset of include/linux/compiler.h so maybe it should go there.
Btw, why aren't we simply including include/linux/compiler.h in tools/include/linux/compiler.h and be done with the whole compiler-related stuff?
Signature · 5 lines
Regards/Gruss,
Boris.
Sent from a fat crate under my desk. Formatting is fine.
--Re: [PATCH 10/10] perf tools: Move ACCESS_ONCE from perf.h header
Quoted 7 lines · Borislav Petkov
Quoted 1 line · Peter Zijlstra
One could argue its part of the barrier muck, but sure.
Yeah, it might be prudent to put stuff like that in the most fitting headers from the get-go as it causes trouble otherwise. And for
ACCESS_ONCE, in particular, we havetools/include/linux/compiler.hwhich is a subset ofinclude/linux/compiler.hso maybe it should go there.
right, that sounds like better place, I'll put it there
thanks,
jirka
Quoted 9 lines · Jiri Olsa
hi,
moving syscall function and arch related defines into new header 'perf-sys.h' as requested by Peter in:
http://lkml.kernel.org/r/[email protected]While at it I did some clean ups in
perf.hheader.Hopefully I did not brake anyone's usage of
perf.h.. let me know ;-)
break, brake is to slow down, also possibly appropriate ;-)
Thanks!
Em Mon, May 05, 2014 at 02:33:29PM +0200, Jiri Olsa escreveu:
Quoted 5 lines
hi,
moving syscall function and arch related defines into new header 'perf-sys.h' as requested by Peter in:
http://lkml.kernel.org/r/[email protected]
Quoted 8 lines
While at it I did some clean ups in
perf.hheader.Hopefully I did not brake anyone's usage of
perf.h.. let me know ;-)Also available in here:
git://git.kernel.org/pub/scm/linux/kernel/git/jolsa/perf.git
perf/header_1
With that ACCESS_ONCE comments made addressed:
- Arnaldo
Quoted 11 lines · Arnaldo Carvalho de Melo
Em Mon, May 05, 2014 at 02:33:29PM +0200, Jiri Olsa escreveu:
Quoted 10 lines
hi,
moving syscall function and arch related defines into new header 'perf-sys.h' as requested by Peter in:
http://lkml.kernel.org/r/[email protected]While at it I did some clean ups in
perf.hheader.Hopefully I did not brake anyone's usage of
perf.h.. let me know ;-)
Quoted 7 lines
Quoted 3 lines
Also available in here:
git://git.kernel.org/pub/scm/linux/kernel/git/jolsa/perf.git
perf/header_1With that
ACCESS_ONCEcomments made addressed:
eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeey ;-)
welcome back!!!
jirka