mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-12-14 17:16:41 +07:00
f82b77462b
Some macros required by tools/perf/trace/beauty/mmap.c is not support
for all architectures. For example, MAP_32BIT is defined on x86 only,
alpha doesn't define MADV_HWPOISON and MADV_SOFT_OFFLINE.
This patch regenerates mman.h for each arch, defines these missing
macros for perf. For missing MADV_*, fall back to asm-generic/mman-common
because they are in a 'case ...' statement. For flags, define it to 0.
Following is the script to generate this patch:
macros=`cat $0 | awk 'V==1 {print}; /^# start macro list/ {V=1}'`
rm `find ./tools/arch/ -name mman.h`
for arch in `ls tools/arch`
do
[ -d tools/arch/$arch/include/uapi/asm ] || mkdir -p tools/arch/$arch/include/uapi/asm
src=arch/$arch/include/uapi/asm/mman.h
target=tools/arch/$arch/include/uapi/asm/mman.h.tmp
real_target=tools/arch/$arch/include/uapi/asm/mman.h
guard="TOOLS_ARCH_"`echo $arch | awk '{print toupper($0)}'`_UAPI_ASM_MMAN_FIX_H
rm -f $target
[ -f $src ] &&
for m in $macros
do
if grep '#define[ \t]*'$m $src > /dev/null 2>&1
then
grep -h '#define[ \t]*'$m $src | sed 's/[ \t]*\/\*.*$//g' >> $target
fi
done
if [ -f $src ]
then
grep '#include <asm-generic' $src >> $target
else
echo "#include <asm-generic/mman.h>" >> $target
fi
touch $real_target
for m in $macros
do
if cat << EOF | gcc -Itools/arch/$arch/include -Itools/arch/$arch/include/uapi -Iinclude/ -Iinclude/uapi -E - | grep $m > /dev/null 2>&1
#include <uapi/asm/mman.h.tmp>
#include <uapi/linux/mman.h>
$m
EOF
then
echo "Fixing $m for $arch"
echo "/* $m is undefined on $arch, fix it for perf */" >> $target
if echo $m | grep '^MADV_' > /dev/null 2>&1
then
grep -h '#define[ \t]*'$m include/uapi/asm-generic/mman-common.h | sed 's/[ \t]*\/\*.*$//g' >> $target
else
echo "#define $m 0" >> $target
fi
fi
done
real_target=tools/arch/$arch/include/uapi/asm/mman.h
echo '#ifndef '$guard > $real_target
echo '#define '$guard >> $real_target
cat $target | sed 's|asm-generic|uapi/asm-generic|g' >> $real_target
echo '#endif' >> $real_target
rm $target
echo "$real_target"
done
exit 0
# Following macros are extracted from:
# tools/perf/trace/beauty/mmap.c
#
# start macro list
MADV_DODUMP
MADV_DOFORK
MADV_DONTDUMP
MADV_DONTFORK
MADV_DONTNEED
MADV_FREE
MADV_HUGEPAGE
MADV_HWPOISON
MADV_MERGEABLE
MADV_NOHUGEPAGE
MADV_NORMAL
MADV_RANDOM
MADV_REMOVE
MADV_SEQUENTIAL
MADV_SOFT_OFFLINE
MADV_UNMERGEABLE
MADV_WILLNEED
MAP_32BIT
MAP_ANONYMOUS
MAP_DENYWRITE
MAP_EXECUTABLE
MAP_FILE
MAP_FIXED
MAP_GROWSDOWN
MAP_HUGETLB
MAP_LOCKED
MAP_NONBLOCK
MAP_NORESERVE
MAP_POPULATE
MAP_PRIVATE
MAP_SHARED
MAP_STACK
MAP_UNINITIALIZED
MREMAP_FIXED
MREMAP_MAYMOVE
PROT_EXEC
PROT_GROWSDOWN
PROT_GROWSUP
PROT_NONE
PROT_READ
PROT_SEM
PROT_WRITE
Signed-off-by: Wang Nan <wangnan0@huawei.com>
Tested-by: Kim Phillips <kim.phillips@arm.com>
Tested-by: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
Cc: Ravi Bangoria <ravi.bangoria@linux.vnet.ibm.com>
Cc: Zefan Li <lizefan@huawei.com>
Cc: pi3orama@163.com
Fixes: 277cf08f3f
("perf trace beauty mmap: Fix defines for non !x86_64")
Link: http://lkml.kernel.org/r/1473850649-83389-3-git-send-email-wangnan0@huawei.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
48 lines
1.3 KiB
C
48 lines
1.3 KiB
C
#ifndef TOOLS_ARCH_ALPHA_UAPI_ASM_MMAN_FIX_H
|
|
#define TOOLS_ARCH_ALPHA_UAPI_ASM_MMAN_FIX_H
|
|
#define MADV_DODUMP 17
|
|
#define MADV_DOFORK 11
|
|
#define MADV_DONTDUMP 16
|
|
#define MADV_DONTFORK 10
|
|
#define MADV_DONTNEED 6
|
|
#define MADV_FREE 8
|
|
#define MADV_HUGEPAGE 14
|
|
#define MADV_MERGEABLE 12
|
|
#define MADV_NOHUGEPAGE 15
|
|
#define MADV_NORMAL 0
|
|
#define MADV_RANDOM 1
|
|
#define MADV_REMOVE 9
|
|
#define MADV_SEQUENTIAL 2
|
|
#define MADV_UNMERGEABLE 13
|
|
#define MADV_WILLNEED 3
|
|
#define MAP_ANONYMOUS 0x10
|
|
#define MAP_DENYWRITE 0x02000
|
|
#define MAP_EXECUTABLE 0x04000
|
|
#define MAP_FILE 0
|
|
#define MAP_FIXED 0x100
|
|
#define MAP_GROWSDOWN 0x01000
|
|
#define MAP_HUGETLB 0x100000
|
|
#define MAP_LOCKED 0x08000
|
|
#define MAP_NONBLOCK 0x40000
|
|
#define MAP_NORESERVE 0x10000
|
|
#define MAP_POPULATE 0x20000
|
|
#define MAP_PRIVATE 0x02
|
|
#define MAP_SHARED 0x01
|
|
#define MAP_STACK 0x80000
|
|
#define PROT_EXEC 0x4
|
|
#define PROT_GROWSDOWN 0x01000000
|
|
#define PROT_GROWSUP 0x02000000
|
|
#define PROT_NONE 0x0
|
|
#define PROT_READ 0x1
|
|
#define PROT_SEM 0x8
|
|
#define PROT_WRITE 0x2
|
|
/* MADV_HWPOISON is undefined on alpha, fix it for perf */
|
|
#define MADV_HWPOISON 100
|
|
/* MADV_SOFT_OFFLINE is undefined on alpha, fix it for perf */
|
|
#define MADV_SOFT_OFFLINE 101
|
|
/* MAP_32BIT is undefined on alpha, fix it for perf */
|
|
#define MAP_32BIT 0
|
|
/* MAP_UNINITIALIZED is undefined on alpha, fix it for perf */
|
|
#define MAP_UNINITIALIZED 0
|
|
#endif
|