summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMark Hatle <mark.hatle@amd.com>2024-01-13 08:56:47 -0700
committerMark Hatle <mark.hatle@amd.com>2024-01-16 08:53:11 -0600
commitea11906ff5a86873771ce10ec528845486a07372 (patch)
tree4762d41f66f7387d18f7112c7c96a18c787a6239
parentef691fd9558e536984295cad2dbb91148a8c60b2 (diff)
downloadmeta-xilinx-ea11906ff5a86873771ce10ec528845486a07372.tar.gz
perf: Update perf to work with Linux 6.6
Update perf to match Yocto project master. This requires both libtraceevent and the updated perf integration. This version was taking from Poky master commit: 61182659c212db24e52cdbcdbb043c7b0de86094 Signed-off-by: Mark Hatle <mark.hatle@amd.com>
-rw-r--r--meta-xilinx-core/recipes-kernel/libtraceevent/libtraceevent/meson.patch74
-rw-r--r--meta-xilinx-core/recipes-kernel/libtraceevent/libtraceevent_1.7.3.bb23
-rw-r--r--meta-xilinx-core/recipes-kernel/perf/perf-perl.inc11
-rw-r--r--meta-xilinx-core/recipes-kernel/perf/perf.bb414
-rwxr-xr-xmeta-xilinx-core/recipes-kernel/perf/perf/sort-pmuevents.py100
5 files changed, 622 insertions, 0 deletions
diff --git a/meta-xilinx-core/recipes-kernel/libtraceevent/libtraceevent/meson.patch b/meta-xilinx-core/recipes-kernel/libtraceevent/libtraceevent/meson.patch
new file mode 100644
index 00000000..38b61071
--- /dev/null
+++ b/meta-xilinx-core/recipes-kernel/libtraceevent/libtraceevent/meson.patch
@@ -0,0 +1,74 @@
1Fixes for the Meson build of libtraceevent:
2
3- Make the plugin directory the same as the Makefiles
4- Install the plugins as modules not static and versioned shared libraries
5- Add an option to disable building the documentation (needs asciidoc and xmlto)
6
7Upstream-Status: Pending
8Signed-off-by: Ross Burton <ross.burton@arm.com>
9
10diff --git a/meson.build b/meson.build
11index b61c873..4bba4d8 100644
12--- a/meson.build
13+++ b/meson.build
14@@ -25,7 +25,7 @@ htmldir = join_paths(prefixdir, get_option('htmldir'))
15 libdir = join_paths(prefixdir, get_option('libdir'))
16 plugindir = get_option('plugindir')
17 if plugindir == ''
18- plugindir = join_paths(libdir, 'libtraceevent/plugins')
19+ plugindir = join_paths(libdir, 'traceevent/plugins')
20 endif
21
22 add_project_arguments(
23@@ -45,10 +45,13 @@ if cunit_dep.found()
24 subdir('utest')
25 endif
26 subdir('samples')
27-subdir('Documentation')
28
29-custom_target(
30- 'docs',
31- output: 'docs',
32- depends: [html, man],
33- command: ['echo'])
34+if get_option('docs')
35+ subdir('Documentation')
36+
37+ custom_target(
38+ 'docs',
39+ output: 'docs',
40+ depends: [html, man],
41+ command: ['echo'])
42+endif
43diff --git a/meson_options.txt b/meson_options.txt
44index b2294f6..0611216 100644
45--- a/meson_options.txt
46+++ b/meson_options.txt
47@@ -4,6 +4,10 @@
48
49 option('plugindir', type : 'string',
50 description : 'set the plugin dir')
51+
52+option('docs', type : 'boolean', value: true,
53+ description : 'build documentation')
54+
55 option('htmldir', type : 'string', value : 'share/doc/libtraceevent-doc',
56 description : 'directory for HTML documentation')
57 option('asciidoctor', type : 'boolean', value: false,
58diff --git a/plugins/meson.build b/plugins/meson.build
59index 74ad664..4919be4 100644
60--- a/plugins/meson.build
61+++ b/plugins/meson.build
62@@ -19,11 +19,10 @@ plugins = [
63
64 pdeps = []
65 foreach plugin : plugins
66- pdeps += library(
67+ pdeps += shared_module(
68 plugin.replace('.c', ''),
69 plugin,
70 name_prefix: '',
71- version: library_version,
72 dependencies: [libtraceevent_dep],
73 include_directories: [incdir],
74 install: true,
diff --git a/meta-xilinx-core/recipes-kernel/libtraceevent/libtraceevent_1.7.3.bb b/meta-xilinx-core/recipes-kernel/libtraceevent/libtraceevent_1.7.3.bb
new file mode 100644
index 00000000..bee78918
--- /dev/null
+++ b/meta-xilinx-core/recipes-kernel/libtraceevent/libtraceevent_1.7.3.bb
@@ -0,0 +1,23 @@
1# Copyright (C) 2022 Khem Raj <raj.khem@gmail.com>
2# Released under the MIT license (see COPYING.MIT for the terms)
3
4SUMMARY = "API to access the kernel tracefs directory"
5HOMEPAGE = "https://git.kernel.org/pub/scm/libs/libtrace/libtracefs.git/"
6LICENSE = "GPL-2.0-or-later & LGPL-2.1-or-later"
7LIC_FILES_CHKSUM = "file://LICENSES/GPL-2.0;md5=e6a75371ba4d16749254a51215d13f97 \
8 file://LICENSES/LGPL-2.1;md5=b370887980db5dd40659b50909238dbd"
9SECTION = "libs"
10
11SRCREV = "dd148189b74da3e2f45c7e536319fec97cb71213"
12SRC_URI = "git://git.kernel.org/pub/scm/libs/libtrace/libtraceevent.git;branch=${BPN};protocol=https \
13 file://meson.patch"
14
15S = "${WORKDIR}/git"
16
17inherit meson pkgconfig
18
19EXTRA_OEMESON = "-Ddocs=false"
20
21PACKAGES += "${PN}-plugins"
22
23FILES:${PN}-plugins += "${libdir}/traceevent/plugins"
diff --git a/meta-xilinx-core/recipes-kernel/perf/perf-perl.inc b/meta-xilinx-core/recipes-kernel/perf/perf-perl.inc
new file mode 100644
index 00000000..491f54c3
--- /dev/null
+++ b/meta-xilinx-core/recipes-kernel/perf/perf-perl.inc
@@ -0,0 +1,11 @@
1inherit perlnative cpan-base
2
3# Env var which tells perl if it should use host (no) or target (yes) settings
4export PERLCONFIGTARGET = "${@is_target(d)}"
5export PERL_INC = "${STAGING_LIBDIR}${PERL_OWN_DIR}/perl5/${@get_perl_version(d)}/${@get_perl_arch(d)}/CORE"
6export PERL_LIB = "${STAGING_LIBDIR}${PERL_OWN_DIR}/perl5/${@get_perl_version(d)}"
7export PERL_ARCHLIB = "${STAGING_LIBDIR}${PERL_OWN_DIR}/perl5/${@get_perl_version(d)}/${@get_perl_arch(d)}"
8
9# The perl symbols CPPSTDIN and CPPRUN embed the sysroot into the
10# binaries, work needed to remove this
11INSANE_SKIP:${PN}-dbg += "buildpaths"
diff --git a/meta-xilinx-core/recipes-kernel/perf/perf.bb b/meta-xilinx-core/recipes-kernel/perf/perf.bb
new file mode 100644
index 00000000..9164d93a
--- /dev/null
+++ b/meta-xilinx-core/recipes-kernel/perf/perf.bb
@@ -0,0 +1,414 @@
1SUMMARY = "Performance analysis tools for Linux"
2DESCRIPTION = "Performance counters for Linux are a new kernel-based \
3subsystem that provide a framework for all things \
4performance analysis. It covers hardware level \
5(CPU/PMU, Performance Monitoring Unit) features \
6and software features (software counters, tracepoints) \
7as well."
8HOMEPAGE = "https://perf.wiki.kernel.org/index.php/Main_Page"
9
10LICENSE = "GPL-2.0-only"
11
12PE = '1'
13
14PACKAGECONFIG ??= "python tui libunwind libtraceevent"
15PACKAGECONFIG[dwarf] = ",NO_DWARF=1"
16PACKAGECONFIG[perl] = ",NO_LIBPERL=1,perl"
17PACKAGECONFIG[python] = ",NO_LIBPYTHON=1,python3 python3-setuptools-native"
18# gui support was added with kernel 3.6.35
19# since 3.10 libnewt was replaced by slang
20# to cover a wide range of kernel we add both dependencies
21PACKAGECONFIG[tui] = ",NO_NEWT=1,libnewt slang"
22PACKAGECONFIG[libunwind] = ",NO_LIBUNWIND=1 NO_LIBDW_DWARF_UNWIND=1,libunwind"
23PACKAGECONFIG[libnuma] = ",NO_LIBNUMA=1"
24PACKAGECONFIG[bfd] = ",NO_LIBBFD=1"
25PACKAGECONFIG[systemtap] = ",NO_SDT=1,systemtap"
26PACKAGECONFIG[jvmti] = ",NO_JVMTI=1"
27# libaudit support would need scripting to be enabled
28PACKAGECONFIG[audit] = ",NO_LIBAUDIT=1,audit"
29PACKAGECONFIG[manpages] = ",,xmlto-native asciidoc-native"
30PACKAGECONFIG[cap] = ",,libcap"
31PACKAGECONFIG[libtraceevent] = ",NO_LIBTRACEEVENT=1,libtraceevent"
32# jevents requires host python for generating a .c file, but is
33# unrelated to the python item.
34PACKAGECONFIG[jevents] = ",NO_JEVENTS=1,python3-native"
35# Arm CoreSight
36PACKAGECONFIG[coresight] = "CORESIGHT=1,,opencsd"
37PACKAGECONFIG[pfm4] = ",NO_LIBPFM4=1,libpfm4"
38PACKAGECONFIG[babeltrace] = ",NO_LIBBABELTRACE=1,babeltrace"
39
40# libunwind is not yet ported for some architectures
41PACKAGECONFIG:remove:arc = "libunwind"
42PACKAGECONFIG:remove:riscv32 = "libunwind"
43
44DEPENDS = " \
45 virtual/${MLPREFIX}libc \
46 ${MLPREFIX}elfutils \
47 ${MLPREFIX}binutils \
48 bison-native flex-native xz \
49"
50
51do_configure[depends] += "virtual/kernel:do_shared_workdir"
52
53PROVIDES = "virtual/perf"
54
55inherit linux-kernel-base kernel-arch manpages
56
57# needed for building the tools/perf Python bindings
58inherit ${@bb.utils.contains('PACKAGECONFIG', 'python', 'python3targetconfig', '', d)}
59inherit python3-dir
60export PYTHON_SITEPACKAGES_DIR
61
62#kernel 3.1+ supports WERROR to disable warnings as errors
63export WERROR = "0"
64
65do_populate_lic[depends] += "virtual/kernel:do_shared_workdir"
66
67# needed for building the tools/perf Perl binding
68include ${@bb.utils.contains('PACKAGECONFIG', 'perl', 'perf-perl.inc', '', d)}
69
70inherit kernelsrc
71
72S = "${WORKDIR}/${BP}"
73SPDX_S = "${S}/tools/perf"
74
75# The LDFLAGS is required or some old kernels fails due missing
76# symbols and this is preferred than requiring patches to every old
77# supported kernel.
78LDFLAGS="-ldl -lutil"
79
80# Perf's build system adds its own optimization flags for most TUs,
81# overriding the flags included here. But for some, perf does not add
82# any -O option, so ensure the distro's chosen optimization gets used
83# for those. Since ${SELECTED_OPTIMIZATION} always includes
84# ${DEBUG_FLAGS} which in turn includes ${DEBUG_PREFIX_MAP}, this also
85# ensures perf is built with appropriate -f*-prefix-map options,
86# avoiding the 'buildpaths' QA warning.
87TARGET_CC_ARCH += "${SELECTED_OPTIMIZATION}"
88
89EXTRA_OEMAKE = '\
90 V=1 \
91 VF=1 \
92 -C ${S}/tools/perf \
93 O=${B} \
94 CROSS_COMPILE=${TARGET_PREFIX} \
95 ARCH=${ARCH} \
96 CC="${CC}" \
97 CCLD="${CC}" \
98 LDSHARED="${CC} -shared" \
99 AR="${AR}" \
100 LD="${LD}" \
101 EXTRA_CFLAGS="-ldw -I${S}" \
102 YFLAGS='-y --file-prefix-map=${WORKDIR}=${TARGET_DBGSRC_DIR}' \
103 EXTRA_LDFLAGS="${PERF_EXTRA_LDFLAGS}" \
104 perfexecdir=${libexecdir} \
105 NO_GTK2=1 \
106 ${PACKAGECONFIG_CONFARGS} \
107 PKG_CONFIG=pkg-config \
108 TMPDIR="${B}" \
109 LIBUNWIND_DIR=${STAGING_EXECPREFIXDIR} \
110'
111
112EXTRA_OEMAKE += "\
113 'DESTDIR=${D}' \
114 'prefix=${prefix}' \
115 'bindir=${bindir}' \
116 'sharedir=${datadir}' \
117 'sysconfdir=${sysconfdir}' \
118 'perfexecdir=${libexecdir}/perf-core' \
119 'ETC_PERFCONFIG=${@os.path.relpath(sysconfdir, prefix)}' \
120 'sharedir=${@os.path.relpath(datadir, prefix)}' \
121 'mandir=${@os.path.relpath(mandir, prefix)}' \
122 'infodir=${@os.path.relpath(infodir, prefix)}' \
123 ${@bb.utils.contains('PACKAGECONFIG', 'python', 'PYTHON=python3 PYTHON_CONFIG=python3-config', '', d)} \
124"
125
126# During do_configure, we might run a 'make clean'. That often breaks
127# when done in parallel, so disable parallelism for do_configure. Note
128# that it has to be done this way rather than by passing -j1, since
129# perf's build system by default ignores any -j argument, but does
130# honour a JOBS variable.
131EXTRA_OEMAKE:append:task-configure = " JOBS=1"
132
133PERF_SRC ?= "Makefile \
134 tools/arch \
135 tools/build \
136 tools/include \
137 tools/lib \
138 tools/Makefile \
139 tools/perf \
140 tools/scripts \
141 scripts/ \
142 arch/arm64/tools \
143 arch/${ARCH}/Makefile \
144"
145
146PERF_EXTRA_LDFLAGS = ""
147
148# MIPS N32/N64
149PERF_EXTRA_LDFLAGS:mipsarchn32eb = "-m elf32btsmipn32"
150PERF_EXTRA_LDFLAGS:mipsarchn32el = "-m elf32ltsmipn32"
151PERF_EXTRA_LDFLAGS:mipsarchn64eb = "-m elf64btsmip"
152PERF_EXTRA_LDFLAGS:mipsarchn64el = "-m elf64ltsmip"
153
154do_compile() {
155 # Linux kernel build system is expected to do the right thing
156 unset CFLAGS
157 test -e ${S}/tools/lib/traceevent/plugins/Makefile && \
158 sed -i -e 's|\$(libdir)/traceevent/plugins|\$(libdir)/traceevent_${KERNEL_VERSION}/plugins|g' ${S}/tools/lib/traceevent/plugins/Makefile
159 test -e ${S}/tools/perf/Makefile.config && \
160 sed -i -e 's|\$(libdir)/traceevent/plugins|\$(libdir)/traceevent_${KERNEL_VERSION}/plugins|g' ${S}/tools/perf/Makefile.config
161 oe_runmake all
162}
163
164do_install() {
165 # Linux kernel build system is expected to do the right thing
166 unset CFLAGS
167 oe_runmake install
168 # we are checking for this make target to be compatible with older perf versions
169 if ${@bb.utils.contains('PACKAGECONFIG', 'python', 'true', 'false', d)} && grep -q install-python_ext ${S}/tools/perf/Makefile*; then
170 oe_runmake DESTDIR=${D} install-python_ext
171 if [ -e ${D}${libdir}/python*/site-packages/perf-*/SOURCES.txt ]; then
172 sed -i -e 's#${WORKDIR}##g' ${D}${libdir}/python*/site-packages/perf-*/SOURCES.txt
173 fi
174 fi
175}
176
177do_configure[prefuncs] += "copy_perf_source_from_kernel"
178python copy_perf_source_from_kernel() {
179 sources = (d.getVar("PERF_SRC") or "").split()
180 src_dir = d.getVar("STAGING_KERNEL_DIR")
181 dest_dir = d.getVar("S")
182 bb.utils.mkdirhier(dest_dir)
183 bb.utils.prunedir(dest_dir)
184 for s in sources:
185 src = oe.path.join(src_dir, s)
186 dest = oe.path.join(dest_dir, s)
187 if not os.path.exists(src):
188 bb.warn("Path does not exist: %s. Maybe PERF_SRC lists more files than what your kernel version provides and needs." % src)
189 continue
190 if os.path.isdir(src):
191 oe.path.copyhardlinktree(src, dest)
192 else:
193 src_path = os.path.dirname(s)
194 os.makedirs(os.path.join(dest_dir,src_path),exist_ok=True)
195 bb.utils.copyfile(src, dest)
196}
197
198do_configure:prepend () {
199 # If building a multlib based perf, the incorrect library path will be
200 # detected by perf, since it triggers via: ifeq ($(ARCH),x86_64). In a 32 bit
201 # build, with a 64 bit multilib, the arch won't match and the detection of a
202 # 64 bit build (and library) are not exected. To ensure that libraries are
203 # installed to the correct location, we can use the weak assignment in the
204 # config/Makefile.
205 #
206 # Also need to relocate .config-detected to $(OUTPUT)/config-detected
207 # for kernel sources that do not already do this
208 # as two builds (e.g. perf and lib32-perf from mutlilib can conflict
209 # with each other if its in the shared source directory
210 #
211 if [ -e "${S}/tools/perf/config/Makefile" ]; then
212 perfconfig="${S}/tools/perf/config/Makefile"
213 fi
214 if [ -e "${S}/tools/perf/Makefile.config" ]; then
215 perfconfig="${S}/tools/perf/Makefile.config"
216 fi
217 if [ -n "${perfconfig}" ]; then
218 # Match $(prefix)/$(lib) and $(prefix)/lib
219 sed -i -e 's,^libdir = \($(prefix)/.*lib\),libdir ?= \1,' \
220 -e 's,^perfexecdir = \(.*\),perfexecdir ?= \1,' \
221 -e 's,\ .config-detected, $(OUTPUT)/config-detected,g' \
222 ${perfconfig}
223 fi
224 # The man pages installation is "$(INSTALL) -d -m 755 $(DESTDIR)$(man1dir)"
225 # in ${S}/tools/perf/Documentation/Makefile, if the mandir set to '?=', it
226 # will use the relative path 'share/man', in the way it will resulting in
227 # incorrect installation for man pages.
228 if [ -e "${S}/tools/perf/Documentation/Makefile" ]; then
229 sed -i 's,^mandir?=,mandir:=,' ${S}/tools/perf/Documentation/Makefile
230 fi
231 if [ -e "${S}/tools/perf/Makefile.perf" ]; then
232 sed -i -e 's,\ .config-detected, $(OUTPUT)/config-detected,g' \
233 ${S}/tools/perf/Makefile.perf
234 sed -i -e "s,prefix='\$(DESTDIR_SQ)/usr'$,prefix='\$(DESTDIR_SQ)/usr' --install-lib='\$(PYTHON_SITEPACKAGES_DIR)' --root='\$(DESTDIR)',g" \
235 ${S}/tools/perf/Makefile.perf
236 # backport https://github.com/torvalds/linux/commit/e4ffd066ff440a57097e9140fa9e16ceef905de8
237 sed -i -e 's,\($(Q)$(SHELL) .$(arch_errno_tbl).\) $(CC) $(arch_errno_hdr_dir),\1 $(firstword $(CC)) $(arch_errno_hdr_dir),g' \
238 ${S}/tools/perf/Makefile.perf
239 fi
240 sed -i -e "s,--root='/\$(DESTDIR_SQ)',--prefix='\$(DESTDIR_SQ)/usr' --install-lib='\$(DESTDIR)\$(PYTHON_SITEPACKAGES_DIR)',g" \
241 ${S}/tools/perf/Makefile*
242
243 if [ -e "${S}/tools/build/Makefile.build" ]; then
244 sed -i -e 's,\ .config-detected, $(OUTPUT)/config-detected,g' \
245 ${S}/tools/build/Makefile.build
246 fi
247
248 # start reproducibility substitutions
249 if [ -e "${S}/tools/perf/Makefile.config" ]; then
250 # The following line in the Makefle:
251 # override PYTHON := $(call get-executable-or-default,PYTHON,$(PYTHON_AUTO))
252 # "PYTHON" / "PYTHON_AUTO" have the full path as part of the variable. We've
253 # ensure that the environment is setup and we do not need the full path to be
254 # captured, since the symbol gets built into the executable, making it not
255 # reproducible.
256 sed -i -e 's,$(call get-executable-or-default\,PYTHON\,$(PYTHON_AUTO)),$(notdir $(call get-executable-or-default\,PYTHON\,$(PYTHON_AUTO))),g' \
257 ${S}/tools/perf/Makefile.config
258 # The same line is in older releases, but looking explicitly for Python 2
259 sed -i -e 's,$(call get-executable-or-default\,PYTHON\,$(PYTHON2)),$(notdir $(call get-executable-or-default\,PYTHON\,$(PYTHON2))),g' \
260 ${S}/tools/perf/Makefile.config
261
262 # likewise with this substitution. Kernels with commit 18f2967418d031a39
263 # [perf tools: Use Python devtools for version autodetection rather than runtime]
264 # need this substitution for reproducibility.
265 sed -i -e 's,$(call get-executable-or-default\,PYTHON\,$(subst -config\,\,$(PYTHON_AUTO))),$(notdir $(call get-executable-or-default\,PYTHON\,$(subst -config\,\,$(PYTHON_AUTO)))),g' \
266 ${S}/tools/perf/Makefile.config
267
268 # The following line:
269 # srcdir_SQ = $(patsubst %tools/perf,tools/perf,$(subst ','\'',$(srcdir))),
270 # Captures the full src path of perf, which of course makes it not
271 # reproducible. We really only need the relative location 'tools/perf', so we
272 # change the Makefile line to remove everything before 'tools/perf'
273 sed -i -e "s%srcdir_SQ = \$(subst ','\\\'',\$(srcdir))%srcdir_SQ = \$(patsubst \%tools/perf,tools/perf,\$(subst ','\\\'',\$(srcdir)))%g" \
274 ${S}/tools/perf/Makefile.config
275 # Avoid hardcoded path to python-native
276 sed -i -e 's#\(PYTHON_WORD := \)$(call shell-wordify,$(PYTHON))#\1 python3#g' \
277 ${S}/tools/perf/Makefile.config
278 fi
279 if [ -e "${S}/tools/perf/tests/Build" ]; then
280 # OUTPUT is the full path, we have python on the path so we remove it from the
281 # definition. This is captured in the perf binary, so breaks reproducibility
282 sed -i -e 's,PYTHONPATH="BUILD_STR($(OUTPUT)python)",PYTHONPATH="BUILD_STR(python)",g' \
283 ${S}/tools/perf/tests/Build
284 fi
285 if [ -e "${S}/tools/perf/util/Build" ]; then
286 # To avoid bison generating #ifdefs that have captured paths, we make sure
287 # all the calls have YFLAGS, which contains prefix mapping information.
288 sed -i -e 's,$(BISON),$(BISON) $(YFLAGS),g' ${S}/tools/perf/util/Build
289 fi
290 if [ -e "${S}/scripts/Makefile.host" ]; then
291 # To avoid yacc (bison) generating #ifdefs that have captured paths, we make sure
292 # all the calls have YFLAGS, which contains prefix mapping information.
293 sed -i -e 's,$(YACC),$(YACC) $(YFLAGS),g' ${S}/scripts/Makefile.host
294 fi
295 if [ -e "${S}/tools/perf/pmu-events/Build" ]; then
296 target='$(OUTPUT)pmu-events/pmu-events.c $(V)'
297 replacement1='$(OUTPUT)pmu-events/pmu-events.c $(V)\n'
298 replacement2='\t$(srctree)/sort-pmuevents.py $(OUTPUT)pmu-events/pmu-events.c $(OUTPUT)pmu-events/pmu-events.c.new\n'
299 replacement3='\tcp $(OUTPUT)pmu-events/pmu-events.c.new $(OUTPUT)pmu-events/pmu-events.c'
300 sed -i -e "s,$target,$replacement1$replacement2$replacement3,g" \
301 "${S}/tools/perf/pmu-events/Build"
302 fi
303 if [ -e "${S}/tools/perf/pmu-events/jevents.py" ]; then
304 sed -i -e "s#os.scandir(path)#sorted(os.scandir(path), key=lambda e: e.name)#g" \
305 "${S}/tools/perf/pmu-events/jevents.py"
306 fi
307 if [ -e "${S}/tools/perf/arch/arm64/Makefile" ]; then
308 sed -i 's,sysdef := $(srctree)/,sysdef := ,' ${S}/tools/perf/arch/arm64/Makefile
309 sed -i 's,$(incpath) $(sysdef),$(incpath) $(srctree)/$(sysdef) $(sysdef),' ${S}/tools/perf/arch/arm64/Makefile
310 fi
311 if [ -e "${S}/tools/perf/arch/arm64/entry/syscalls/mksyscalltbl" ]; then
312 if ! grep -q input_rel ${S}/tools/perf/arch/arm64/entry/syscalls/mksyscalltbl; then
313 sed -i 's,input=$4,input=$4\ninput_rel=$5,' ${S}/tools/perf/arch/arm64/entry/syscalls/mksyscalltbl
314 fi
315 sed -i 's,#include \\"\$input\\",#include \\"\$input_rel\\",' ${S}/tools/perf/arch/arm64/entry/syscalls/mksyscalltbl
316 fi
317 # end reproducibility substitutions
318
319 # We need to ensure the --sysroot option in CC is preserved
320 if [ -e "${S}/tools/perf/Makefile.perf" ]; then
321 sed -i 's,CC = $(CROSS_COMPILE)gcc,#CC,' ${S}/tools/perf/Makefile.perf
322 sed -i 's,AR = $(CROSS_COMPILE)ar,#AR,' ${S}/tools/perf/Makefile.perf
323 sed -i 's,LD = $(CROSS_COMPILE)ld,#LD,' ${S}/tools/perf/Makefile.perf
324 sed -i 's,PKG_CONFIG = $(CROSS_COMPILE)pkg-config,#PKG_CONFIG,' ${S}/tools/perf/Makefile.perf
325 fi
326 if [ -e "${S}/tools/lib/api/Makefile" ]; then
327 sed -i 's,CC = $(CROSS_COMPILE)gcc,#CC,' ${S}/tools/lib/api/Makefile
328 sed -i 's,AR = $(CROSS_COMPILE)ar,#AR,' ${S}/tools/lib/api/Makefile
329 sed -i 's,LD = $(CROSS_COMPILE)ld,#LD,' ${S}/tools/lib/api/Makefile
330 fi
331 if [ -e "${S}/tools/lib/subcmd/Makefile" ]; then
332 sed -i 's,CC = $(CROSS_COMPILE)gcc,#CC,' ${S}/tools/lib/subcmd/Makefile
333 sed -i 's,AR = $(CROSS_COMPILE)ar,#AR,' ${S}/tools/lib/subcmd/Makefile
334 fi
335 if [ -e "${S}/tools/perf/config/feature-checks/Makefile" ]; then
336 sed -i 's,CC := $(CROSS_COMPILE)gcc -MD,CC += -MD,' ${S}/tools/perf/config/feature-checks/Makefile
337 fi
338 if [ -e "${S}/tools/build/Makefile.feature" ]; then
339 sed -i 's,CFLAGS=,CC="\$(CC)" CFLAGS=,' ${S}/tools/build/Makefile.feature
340 fi
341 # The libperl feature check produces fatal warnings due to -Werror being
342 # used, silence enough errors that the check passes.
343 sed -i 's/\(FLAGS_PERL_EMBED=.*\)/\1 -Wno-error=unused-function -Wno-error=attributes/' ${S}/tools/build/feature/Makefile
344
345 # 3.17-rc1+ has a include issue for arm/powerpc. Temporarily sed in the appropriate include
346 if [ -e "${S}/tools/perf/arch/$ARCH/util/skip-callchain-idx.c" ]; then
347 sed -i 's,#include "util/callchain.h",#include "util/callchain.h"\n#include "util/debug.h",' ${S}/tools/perf/arch/$ARCH/util/skip-callchain-idx.c
348 fi
349 if [ -e "${S}/tools/perf/arch/arm/util/unwind-libunwind.c" ] && [ -e "${S}/tools/perf/arch/arm/tests/dwarf-unwind.c" ]; then
350 sed -i 's,#include "tests/tests.h",#include "tests/tests.h"\n#include "util/debug.h",' ${S}/tools/perf/arch/arm/tests/dwarf-unwind.c
351 sed -i 's,#include "perf_regs.h",#include "perf_regs.h"\n#include "util/debug.h",' ${S}/tools/perf/arch/arm/util/unwind-libunwind.c
352 fi
353
354 # use /usr/bin/env instead of version specific python
355 for s in `find ${S}/tools/perf/ -name '*.py'` `find ${S}/scripts/ -name 'bpf_helpers_doc.py'`; do
356 sed -i -e "s,#!.*python.*,#!${USRBINPATH}/env python3," ${s}
357 done
358
359 # unistd.h can be out of sync between libc-headers and the captured version in the perf source
360 # so we copy it from the sysroot unistd.h to the perf unistd.h
361 install -D -m0644 ${STAGING_INCDIR}/asm-generic/unistd.h ${S}/tools/include/uapi/asm-generic/unistd.h
362 install -D -m0644 ${STAGING_INCDIR}/asm-generic/unistd.h ${S}/include/uapi/asm-generic/unistd.h
363
364 # the fetcher is inhibited by the 'inherit kernelsrc', so we do a quick check and
365 # copy for a helper script we need
366 for p in $(echo ${FILESPATH} | tr ':' '\n'); do
367 if [ -e $p/sort-pmuevents.py ]; then
368 cp $p/sort-pmuevents.py ${S}
369 fi
370 done
371}
372
373python do_package:prepend() {
374 d.setVar('PKGV', d.getVar("KERNEL_VERSION").split("-")[0])
375}
376
377PACKAGE_ARCH = "${MACHINE_ARCH}"
378
379
380PACKAGES =+ "${PN}-archive ${PN}-tests ${PN}-perl ${PN}-python"
381
382RDEPENDS:${PN} += "elfutils bash"
383RDEPENDS:${PN}-archive =+ "bash"
384RDEPENDS:${PN}-python =+ "bash python3 python3-modules ${@bb.utils.contains('PACKAGECONFIG', 'audit', 'audit-python', '', d)}"
385RDEPENDS:${PN}-perl =+ "bash perl perl-modules"
386RDEPENDS:${PN}-tests =+ "python3 bash"
387
388RSUGGESTS:${PN} += "${PN}-archive ${PN}-tests \
389 ${@bb.utils.contains('PACKAGECONFIG', 'perl', '${PN}-perl', '', d)} \
390 ${@bb.utils.contains('PACKAGECONFIG', 'python', '${PN}-python', '', d)} \
391 "
392FILES_SOLIBSDEV = ""
393FILES:${PN} += "${libexecdir}/perf-core ${exec_prefix}/libexec/perf-core ${libdir}/traceevent* ${libdir}/libperf-jvmti.so"
394FILES:${PN}-archive = "${libdir}/perf/perf-core/perf-archive"
395FILES:${PN}-tests = "${libdir}/perf/perf-core/tests ${libexecdir}/perf-core/tests"
396FILES:${PN}-python = " \
397 ${PYTHON_SITEPACKAGES_DIR} \
398 ${libexecdir}/perf-core/scripts/python \
399 "
400FILES:${PN}-perl = "${libexecdir}/perf-core/scripts/perl"
401
402DEBUG_OPTIMIZATION:append = " -Wno-error=maybe-uninitialized"
403
404PACKAGESPLITFUNCS =+ "perf_fix_sources"
405
406perf_fix_sources () {
407 for f in util/parse-events-flex.h util/parse-events-flex.c util/pmu-flex.c \
408 util/pmu-flex.h util/expr-flex.h util/expr-flex.c; do
409 f=${PKGD}${TARGET_DBGSRC_DIR}/$f
410 if [ -e $f ]; then
411 sed -i -e 's#${S}/##g' $f
412 fi
413 done
414}
diff --git a/meta-xilinx-core/recipes-kernel/perf/perf/sort-pmuevents.py b/meta-xilinx-core/recipes-kernel/perf/perf/sort-pmuevents.py
new file mode 100755
index 00000000..0362f2d8
--- /dev/null
+++ b/meta-xilinx-core/recipes-kernel/perf/perf/sort-pmuevents.py
@@ -0,0 +1,100 @@
1#!/usr/bin/env python3
2
3# perf pmu-events sorting tool
4#
5# Copyright (C) 2021 Bruce Ashfield
6#
7# SPDX-License-Identifier: MIT
8#
9
10import sys
11import os
12import re
13from collections import OrderedDict
14
15if len(sys.argv) < 2:
16 print( "[ERROR]: input and output pmu files missing" )
17 sys.exit(1)
18
19if len(sys.argv) < 3:
20 print( "[ERROR]: output pmu file missing" )
21 sys.exit(1)
22
23infile = sys.argv[1]
24outfile = sys.argv[2]
25
26if not os.path.exists(infile):
27 print( "ERROR. input file does not exist: %s" % infile )
28 sys.exit(1)
29
30if os.path.exists(outfile):
31 print( "WARNING. output file will be overwritten: %s" % infile )
32
33with open(infile, 'r') as file:
34 data = file.read()
35
36preamble_regex = re.compile( '^(.*?)^(struct|const struct|static struct|static const struct)', re.MULTILINE | re.DOTALL )
37
38preamble = re.search( preamble_regex, data )
39struct_block_regex = re.compile( '^(struct|const struct|static struct|static const struct).*?(\w+) (.*?)\[\] = {(.*?)^};', re.MULTILINE | re.DOTALL )
40field_regex = re.compile( '{.*?},', re.MULTILINE | re.DOTALL )
41cpuid_regex = re.compile( '\.cpuid = (.*?),', re.MULTILINE | re.DOTALL )
42name_regex = re.compile( '\.name = (.*?),', re.MULTILINE | re.DOTALL )
43
44# create a dictionary structure to store all the structs, their
45# types and then their fields.
46entry_dict = {}
47for struct in re.findall( struct_block_regex, data ):
48 # print( "struct: %s %s %s" % (struct[0],struct[1],struct[2]) )
49 entry_dict[struct[2]] = {}
50 entry_dict[struct[2]]['type_prefix'] = struct[0]
51 entry_dict[struct[2]]['type'] = struct[1]
52 entry_dict[struct[2]]['fields'] = {}
53 for entry in re.findall( field_regex, struct[3] ):
54 #print( " entry: %s" % entry )
55 cpuid = re.search( cpuid_regex, entry )
56 if cpuid:
57 #print( " cpuid found: %s" % cpuid.group(1) )
58 entry_dict[struct[2]]['fields'][cpuid.group(1)] = entry
59
60 name = re.search( name_regex, entry )
61 if name:
62 #print( " name found: %s" % name.group(1) )
63 entry_dict[struct[2]]['fields'][name.group(1)] = entry
64
65 # unmatched entries are most likely array terminators and
66 # should end up as the last element in the sorted list, which
67 # is achieved by using '0' as the key
68 if not cpuid and not name:
69 entry_dict[struct[2]]['fields']['0'] = entry
70
71# created ordered dictionaries from the captured values. These are ordered by
72# a sorted() iteration of the keys. We don't care about the order we read
73# things, just the sorted order. Hency why we couldn't create these during
74# reading.
75#
76# yes, there's a more concise way to do this, but our nested dictionaries of
77# fields make it complex enough that it becomes unreadable.
78entry_dict_sorted = OrderedDict()
79for i in sorted(entry_dict.keys()):
80 entry_dict_sorted[i] = {}
81 entry_dict_sorted[i]['type_prefix'] = entry_dict[i]['type_prefix']
82 entry_dict_sorted[i]['type'] = entry_dict[i]['type']
83 entry_dict_sorted[i]['fields'] = {}
84 for f in sorted(entry_dict[i]['fields'].keys()):
85 entry_dict_sorted[i]['fields'][f] = entry_dict[i]['fields'][f]
86
87# dump the sorted elements to the outfile
88outf = open( outfile, 'w' )
89
90print( preamble.group(1) )
91outf.write( preamble.group(1) )
92for d in entry_dict_sorted:
93 outf.write( "%s %s %s[] = {\n" % (entry_dict_sorted[d]['type_prefix'], entry_dict_sorted[d]['type'],d) )
94 for f in entry_dict_sorted[d]['fields']:
95 outf.write( entry_dict_sorted[d]['fields'][f] + '\n' )
96
97 outf.write( "};\n" )
98
99outf.close()
100