Linux Audio

Check our new training course

Loading...
v4.6
 
  1#ifndef _PERF_SYS_H
  2#define _PERF_SYS_H
  3
  4#include <unistd.h>
  5#include <sys/types.h>
  6#include <sys/syscall.h>
  7#include <linux/types.h>
  8#include <linux/perf_event.h>
  9#include <asm/barrier.h>
 10
 11#if defined(__i386__)
 12#define cpu_relax()	asm volatile("rep; nop" ::: "memory");
 13#define CPUINFO_PROC	{"model name"}
 14#ifndef __NR_perf_event_open
 15# define __NR_perf_event_open 336
 16#endif
 17#ifndef __NR_futex
 18# define __NR_futex 240
 19#endif
 20#ifndef __NR_gettid
 21# define __NR_gettid 224
 22#endif
 23#endif
 24
 25#if defined(__x86_64__)
 26#define cpu_relax()	asm volatile("rep; nop" ::: "memory");
 27#define CPUINFO_PROC	{"model name"}
 28#ifndef __NR_perf_event_open
 29# define __NR_perf_event_open 298
 30#endif
 31#ifndef __NR_futex
 32# define __NR_futex 202
 33#endif
 34#ifndef __NR_gettid
 35# define __NR_gettid 186
 36#endif
 37#endif
 38
 39#ifdef __powerpc__
 40#include "../../arch/powerpc/include/uapi/asm/unistd.h"
 41#define CPUINFO_PROC	{"cpu"}
 42#endif
 43
 44#ifdef __s390__
 45#define CPUINFO_PROC	{"vendor_id"}
 46#endif
 47
 48#ifdef __sh__
 49#define CPUINFO_PROC	{"cpu type"}
 50#endif
 51
 52#ifdef __hppa__
 53#define CPUINFO_PROC	{"cpu"}
 54#endif
 55
 56#ifdef __sparc__
 57#define CPUINFO_PROC	{"cpu"}
 58#endif
 59
 60#ifdef __alpha__
 61#define CPUINFO_PROC	{"cpu model"}
 62#endif
 63
 64#ifdef __ia64__
 65#define cpu_relax()	asm volatile ("hint @pause" ::: "memory")
 66#define CPUINFO_PROC	{"model name"}
 67#endif
 68
 69#ifdef __arm__
 70#define CPUINFO_PROC	{"model name", "Processor"}
 71#endif
 72
 73#ifdef __aarch64__
 74#define cpu_relax()	asm volatile("yield" ::: "memory")
 75#endif
 76
 77#ifdef __mips__
 78#define CPUINFO_PROC	{"cpu model"}
 79#endif
 80
 81#ifdef __arc__
 82#define CPUINFO_PROC	{"Processor"}
 83#endif
 84
 85#ifdef __metag__
 86#define CPUINFO_PROC	{"CPU"}
 87#endif
 88
 89#ifdef __xtensa__
 90#define CPUINFO_PROC	{"core ID"}
 91#endif
 92
 93#ifdef __tile__
 94#define cpu_relax()	asm volatile ("mfspr zero, PASS" ::: "memory")
 95#define CPUINFO_PROC    {"model name"}
 96#endif
 97
 98#ifndef cpu_relax
 99#define cpu_relax() barrier()
100#endif
101
102static inline int
103sys_perf_event_open(struct perf_event_attr *attr,
104		      pid_t pid, int cpu, int group_fd,
105		      unsigned long flags)
106{
107	int fd;
108
109	fd = syscall(__NR_perf_event_open, attr, pid, cpu,
110		     group_fd, flags);
111
112#ifdef HAVE_ATTR_TEST
113	if (unlikely(test_attr__enabled))
114		test_attr__open(attr, pid, cpu, fd, group_fd, flags);
115#endif
116	return fd;
117}
118
119#endif /* _PERF_SYS_H */
v5.4
 1/* SPDX-License-Identifier: GPL-2.0 */
 2#ifndef _PERF_SYS_H
 3#define _PERF_SYS_H
 4
 5#include <unistd.h>
 6#include <sys/types.h>
 7#include <sys/syscall.h>
 8#include <linux/compiler.h>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 9
10struct perf_event_attr;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11
12extern bool test_attr__enabled;
13void test_attr__ready(void);
14void test_attr__init(void);
15void test_attr__open(struct perf_event_attr *attr, pid_t pid, int cpu,
16		     int fd, int group_fd, unsigned long flags);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
17
18#ifndef HAVE_ATTR_TEST
19#define HAVE_ATTR_TEST 1
20#endif
21
22static inline int
23sys_perf_event_open(struct perf_event_attr *attr,
24		      pid_t pid, int cpu, int group_fd,
25		      unsigned long flags)
26{
27	int fd;
28
29	fd = syscall(__NR_perf_event_open, attr, pid, cpu,
30		     group_fd, flags);
31
32#if HAVE_ATTR_TEST
33	if (unlikely(test_attr__enabled))
34		test_attr__open(attr, pid, cpu, fd, group_fd, flags);
35#endif
36	return fd;
37}
38
39#endif /* _PERF_SYS_H */