diff mbox

[1/2] perf tools: Introduce memory mapping macros in mman-fix.h

Message ID 1473140932-143524-2-git-send-email-wangnan0@huawei.com
State New
Headers show

Commit Message

Wang Nan Sept. 6, 2016, 5:48 a.m. UTC
tools/perf/trace/beauty/mmap.c, tools/perf/util/event.c and
tools/perf/util/map.c depend on several macros in mman.h, which
are lost on old systems like ubuntu 12.04. They are architecture
dependened macros. Importing ./arch/*/include/uapi/asm/mman.h
into tools/ is not easy because mman.h for some unusual archs
(like tile) have extra dependencies.

This patch introduces only required macros into mman-fix.h.
Macros list is gotten from tools/perf/trace/beauty/mmap.c.

This patch is gnerated using following bash script:

 #!/bin/bash

 function begin_mman_fix_header()
 {
   echo "#ifndef $1" >  $2
   echo "#define $1" >> $2
   echo "#include <sys/mman.h>" >> $2
 }

 function finish_mman_fix_header()
 {
   echo "#endif // $1" >> $2
   echo "Finish writing $2"
 }

 function build_mman_fix_header()
 {
   guard=$1
   shift
   target=$1
   shift
   begin_mman_fix_header $guard $target
   for src in $@
   do
     if [ -f $src ]
     then
       for macro in $macros
       do
         if grep '#define[ \t]*'$macro $src > /dev/null 2>&1
         then
           echo "#ifndef $macro" >> $target
           grep '#define[ \t]*'$macro $src | sed 's/[ \t]*\/\*.*$//g' >> $target
           echo "#endif" >> $target
         fi
       done
     fi
   done
 }

 macros=`grep ifndef tools/perf/trace/beauty/mmap.c | awk '{print $2}'`

 baseheader=tools/include/uapi/asm-generic/mman-fix.h
 build_mman_fix_header __TOOLS_UAPI_ASM_MMAN_FIX_H $baseheader include/uapi/asm-generic/mman*
 echo "#ifndef MAP_UNINITIALIZED" >> $baseheader
 echo "#define MAP_UNINITIALIZED 0x4000000" >> $baseheader
 echo "#endif" >> $baseheader
 finish_mman_fix_header __TOOLS_UAPI_ASM_MMAN_FIX_H $baseheader

 archs=`ls tools/arch`
 for arch in $archs
 do
   archheader=tools/arch/$arch/include/uapi/asm/mman-fix.h
   if [ ! -d tools/arch/$arch/include/uapi/asm ]
   then
     mkdir -p tools/arch/$arch/include/uapi/asm
   fi
   uppercase=`echo $arch | awk '{print toupper($0)}'`
   build_mman_fix_header TOOLS_ARCH_${uppercase}_UAPI_ASM_MMAN_FIX_H $archheader arch/$arch/include/uapi/asm/mman.h
   echo "#include <asm-generic/mman-fix.h>" >> $archheader
   finish_mman_fix_header TOOLS_ARCH_${uppercase}_UAPI_ASM_MMAN_FIX_H $archheader
 done

Signed-off-by: Wang Nan <wangnan0@huawei.com>

Cc: Nilay Vaish <nilayvaish@gmail.com>
Cc: Hou Pengyang <houpengyang@huawei.com>
Cc: He Kuang <hekuang@huawei.com>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/arch/alpha/include/uapi/asm/mman-fix.h      | 38 +++++++++++++++++++
 tools/arch/arm/include/uapi/asm/mman-fix.h        |  5 +++
 tools/arch/arm64/include/uapi/asm/mman-fix.h      |  5 +++
 tools/arch/frv/include/uapi/asm/mman-fix.h        |  5 +++
 tools/arch/h8300/include/uapi/asm/mman-fix.h      |  5 +++
 tools/arch/hexagon/include/uapi/asm/mman-fix.h    |  5 +++
 tools/arch/ia64/include/uapi/asm/mman-fix.h       |  5 +++
 tools/arch/m32r/include/uapi/asm/mman-fix.h       |  5 +++
 tools/arch/microblaze/include/uapi/asm/mman-fix.h |  5 +++
 tools/arch/mips/include/uapi/asm/mman-fix.h       | 41 ++++++++++++++++++++
 tools/arch/mn10300/include/uapi/asm/mman-fix.h    |  5 +++
 tools/arch/parisc/include/uapi/asm/mman-fix.h     | 38 +++++++++++++++++++
 tools/arch/powerpc/include/uapi/asm/mman-fix.h    | 11 ++++++
 tools/arch/s390/include/uapi/asm/mman-fix.h       |  5 +++
 tools/arch/score/include/uapi/asm/mman-fix.h      |  5 +++
 tools/arch/sh/include/uapi/asm/mman-fix.h         |  5 +++
 tools/arch/sparc/include/uapi/asm/mman-fix.h      | 11 ++++++
 tools/arch/tile/include/uapi/asm/mman-fix.h       | 11 ++++++
 tools/arch/x86/include/uapi/asm/mman-fix.h        |  8 ++++
 tools/arch/xtensa/include/uapi/asm/mman-fix.h     | 38 +++++++++++++++++++
 tools/include/uapi/asm-generic/mman-fix.h         | 46 +++++++++++++++++++++++
 tools/perf/MANIFEST                               |  2 +
 22 files changed, 304 insertions(+)
 create mode 100644 tools/arch/alpha/include/uapi/asm/mman-fix.h
 create mode 100644 tools/arch/arm/include/uapi/asm/mman-fix.h
 create mode 100644 tools/arch/arm64/include/uapi/asm/mman-fix.h
 create mode 100644 tools/arch/frv/include/uapi/asm/mman-fix.h
 create mode 100644 tools/arch/h8300/include/uapi/asm/mman-fix.h
 create mode 100644 tools/arch/hexagon/include/uapi/asm/mman-fix.h
 create mode 100644 tools/arch/ia64/include/uapi/asm/mman-fix.h
 create mode 100644 tools/arch/m32r/include/uapi/asm/mman-fix.h
 create mode 100644 tools/arch/microblaze/include/uapi/asm/mman-fix.h
 create mode 100644 tools/arch/mips/include/uapi/asm/mman-fix.h
 create mode 100644 tools/arch/mn10300/include/uapi/asm/mman-fix.h
 create mode 100644 tools/arch/parisc/include/uapi/asm/mman-fix.h
 create mode 100644 tools/arch/powerpc/include/uapi/asm/mman-fix.h
 create mode 100644 tools/arch/s390/include/uapi/asm/mman-fix.h
 create mode 100644 tools/arch/score/include/uapi/asm/mman-fix.h
 create mode 100644 tools/arch/sh/include/uapi/asm/mman-fix.h
 create mode 100644 tools/arch/sparc/include/uapi/asm/mman-fix.h
 create mode 100644 tools/arch/tile/include/uapi/asm/mman-fix.h
 create mode 100644 tools/arch/x86/include/uapi/asm/mman-fix.h
 create mode 100644 tools/arch/xtensa/include/uapi/asm/mman-fix.h
 create mode 100644 tools/include/uapi/asm-generic/mman-fix.h

-- 
1.8.3.4

Comments

Wang Nan Sept. 6, 2016, 1:25 p.m. UTC | #1
On 2016/9/6 20:59, Arnaldo Carvalho de Melo wrote:
> Em Tue, Sep 06, 2016 at 05:48:51AM +0000, Wang Nan escreveu:

>> tools/perf/trace/beauty/mmap.c, tools/perf/util/event.c and

>> tools/perf/util/map.c depend on several macros in mman.h, which

>> are lost on old systems like ubuntu 12.04. They are architecture

> Not "lost on old systems", changing that to "not present on old systems"

>

>> dependened macros. Importing ./arch/*/include/uapi/asm/mman.h

>> into tools/ is not easy because mman.h for some unusual archs

>> (like tile) have extra dependencies.

>> This patch introduces only required macros into mman-fix.h.

>> Macros list is gotten from tools/perf/trace/beauty/mmap.c.

> ok, I'll try keeping the  include/uapi/asm-generic/mman.h and

> arch/alpha/include/uapi/asm/mman.h with just what you added, so that at

> least the .c files appears as using the headers were those things are

> defined in the kernel sources.

>

> Ah, and good eyes in realizing this is not the same value for all

> arches!


This is why we have to define these macros for each archs.
Your solution in tools/perf/trace/beauty/mmap.c works for
x86 only.

However, I don't like this patchset because we add 300+
lines of code and 22 new files for less than 15 macros,
and only one of them I really concern. Moreover, futhre
code require more symbols in uapi and we have to add new
headers, finally we will clone the whole uapi. We have
to stop doing this...

For the hugetlb problem, I think you can take the v2 patch
without this 2 patches:

http://lkml.kernel.org/r/1473137909-142064-1-git-send-email-wangnan0@huawei.com

so old system can compile without hugetlb support.

This is the reason why I separated into 2 patch series.

Thank you.

> - Arnaldo

>   

>> This patch is gnerated using following bash script:

>>

>>   #!/bin/bash

>>

>>   function begin_mman_fix_header()

>>   {

>>     echo "#ifndef $1" >  $2

>>     echo "#define $1" >> $2

>>     echo "#include <sys/mman.h>" >> $2

>>   }

>>

>>   function finish_mman_fix_header()

>>   {

>>     echo "#endif // $1" >> $2

>>     echo "Finish writing $2"

>>   }

>>

>>   function build_mman_fix_header()

>>   {

>>     guard=$1

>>     shift

>>     target=$1

>>     shift

>>     begin_mman_fix_header $guard $target

>>     for src in $@

>>     do

>>       if [ -f $src ]

>>       then

>>         for macro in $macros

>>         do

>>           if grep '#define[ \t]*'$macro $src > /dev/null 2>&1

>>           then

>>             echo "#ifndef $macro" >> $target

>>             grep '#define[ \t]*'$macro $src | sed 's/[ \t]*\/\*.*$//g' >> $target

>>             echo "#endif" >> $target

>>           fi

>>         done

>>       fi

>>     done

>>   }

>>

>>   macros=`grep ifndef tools/perf/trace/beauty/mmap.c | awk '{print $2}'`

>>

>>   baseheader=tools/include/uapi/asm-generic/mman-fix.h

>>   build_mman_fix_header __TOOLS_UAPI_ASM_MMAN_FIX_H $baseheader include/uapi/asm-generic/mman*

>>   echo "#ifndef MAP_UNINITIALIZED" >> $baseheader

>>   echo "#define MAP_UNINITIALIZED 0x4000000" >> $baseheader

>>   echo "#endif" >> $baseheader

>>   finish_mman_fix_header __TOOLS_UAPI_ASM_MMAN_FIX_H $baseheader

>>

>>   archs=`ls tools/arch`

>>   for arch in $archs

>>   do

>>     archheader=tools/arch/$arch/include/uapi/asm/mman-fix.h

>>     if [ ! -d tools/arch/$arch/include/uapi/asm ]

>>     then

>>       mkdir -p tools/arch/$arch/include/uapi/asm

>>     fi

>>     uppercase=`echo $arch | awk '{print toupper($0)}'`

>>     build_mman_fix_header TOOLS_ARCH_${uppercase}_UAPI_ASM_MMAN_FIX_H $archheader arch/$arch/include/uapi/asm/mman.h

>>     echo "#include <asm-generic/mman-fix.h>" >> $archheader

>>     finish_mman_fix_header TOOLS_ARCH_${uppercase}_UAPI_ASM_MMAN_FIX_H $archheader

>>   done

>>

>> Signed-off-by: Wang Nan <wangnan0@huawei.com>

>> Cc: Nilay Vaish <nilayvaish@gmail.com>

>> Cc: Hou Pengyang <houpengyang@huawei.com>

>> Cc: He Kuang <hekuang@huawei.com>

>> Cc: Arnaldo Carvalho de Melo <acme@redhat.com>

>> ---

>>   tools/arch/alpha/include/uapi/asm/mman-fix.h      | 38 +++++++++++++++++++

>>   tools/arch/arm/include/uapi/asm/mman-fix.h        |  5 +++

>>   tools/arch/arm64/include/uapi/asm/mman-fix.h      |  5 +++

>>   tools/arch/frv/include/uapi/asm/mman-fix.h        |  5 +++

>>   tools/arch/h8300/include/uapi/asm/mman-fix.h      |  5 +++

>>   tools/arch/hexagon/include/uapi/asm/mman-fix.h    |  5 +++

>>   tools/arch/ia64/include/uapi/asm/mman-fix.h       |  5 +++

>>   tools/arch/m32r/include/uapi/asm/mman-fix.h       |  5 +++

>>   tools/arch/microblaze/include/uapi/asm/mman-fix.h |  5 +++

>>   tools/arch/mips/include/uapi/asm/mman-fix.h       | 41 ++++++++++++++++++++

>>   tools/arch/mn10300/include/uapi/asm/mman-fix.h    |  5 +++

>>   tools/arch/parisc/include/uapi/asm/mman-fix.h     | 38 +++++++++++++++++++

>>   tools/arch/powerpc/include/uapi/asm/mman-fix.h    | 11 ++++++

>>   tools/arch/s390/include/uapi/asm/mman-fix.h       |  5 +++

>>   tools/arch/score/include/uapi/asm/mman-fix.h      |  5 +++

>>   tools/arch/sh/include/uapi/asm/mman-fix.h         |  5 +++

>>   tools/arch/sparc/include/uapi/asm/mman-fix.h      | 11 ++++++

>>   tools/arch/tile/include/uapi/asm/mman-fix.h       | 11 ++++++

>>   tools/arch/x86/include/uapi/asm/mman-fix.h        |  8 ++++

>>   tools/arch/xtensa/include/uapi/asm/mman-fix.h     | 38 +++++++++++++++++++

>>   tools/include/uapi/asm-generic/mman-fix.h         | 46 +++++++++++++++++++++++

>>   tools/perf/MANIFEST                               |  2 +

>>   22 files changed, 304 insertions(+)

>>   create mode 100644 tools/arch/alpha/include/uapi/asm/mman-fix.h

>>   create mode 100644 tools/arch/arm/include/uapi/asm/mman-fix.h

>>   create mode 100644 tools/arch/arm64/include/uapi/asm/mman-fix.h

>>   create mode 100644 tools/arch/frv/include/uapi/asm/mman-fix.h

>>   create mode 100644 tools/arch/h8300/include/uapi/asm/mman-fix.h

>>   create mode 100644 tools/arch/hexagon/include/uapi/asm/mman-fix.h

>>   create mode 100644 tools/arch/ia64/include/uapi/asm/mman-fix.h

>>   create mode 100644 tools/arch/m32r/include/uapi/asm/mman-fix.h

>>   create mode 100644 tools/arch/microblaze/include/uapi/asm/mman-fix.h

>>   create mode 100644 tools/arch/mips/include/uapi/asm/mman-fix.h

>>   create mode 100644 tools/arch/mn10300/include/uapi/asm/mman-fix.h

>>   create mode 100644 tools/arch/parisc/include/uapi/asm/mman-fix.h

>>   create mode 100644 tools/arch/powerpc/include/uapi/asm/mman-fix.h

>>   create mode 100644 tools/arch/s390/include/uapi/asm/mman-fix.h

>>   create mode 100644 tools/arch/score/include/uapi/asm/mman-fix.h

>>   create mode 100644 tools/arch/sh/include/uapi/asm/mman-fix.h

>>   create mode 100644 tools/arch/sparc/include/uapi/asm/mman-fix.h

>>   create mode 100644 tools/arch/tile/include/uapi/asm/mman-fix.h

>>   create mode 100644 tools/arch/x86/include/uapi/asm/mman-fix.h

>>   create mode 100644 tools/arch/xtensa/include/uapi/asm/mman-fix.h

>>   create mode 100644 tools/include/uapi/asm-generic/mman-fix.h

>>

>> diff --git a/tools/arch/alpha/include/uapi/asm/mman-fix.h b/tools/arch/alpha/include/uapi/asm/mman-fix.h

>> new file mode 100644

>> index 0000000..f807a71

>> --- /dev/null

>> +++ b/tools/arch/alpha/include/uapi/asm/mman-fix.h

>> @@ -0,0 +1,38 @@

>> +#ifndef TOOLS_ARCH_ALPHA_UAPI_ASM_MMAN_FIX_H

>> +#define TOOLS_ARCH_ALPHA_UAPI_ASM_MMAN_FIX_H

>> +#include <sys/mman.h>

>> +#ifndef PROT_SEM

>> +#define PROT_SEM	0x8

>> +#endif

>> +#ifndef MAP_FIXED

>> +#define MAP_FIXED	0x100

>> +#endif

>> +#ifndef MAP_ANONYMOUS

>> +#define MAP_ANONYMOUS	0x10

>> +#endif

>> +#ifndef MAP_STACK

>> +#define MAP_STACK	0x80000

>> +#endif

>> +#ifndef MAP_HUGETLB

>> +#define MAP_HUGETLB	0x100000

>> +#endif

>> +#ifndef MADV_MERGEABLE

>> +#define MADV_MERGEABLE   12

>> +#endif

>> +#ifndef MADV_UNMERGEABLE

>> +#define MADV_UNMERGEABLE 13

>> +#endif

>> +#ifndef MADV_HUGEPAGE

>> +#define MADV_HUGEPAGE	14

>> +#endif

>> +#ifndef MADV_NOHUGEPAGE

>> +#define MADV_NOHUGEPAGE	15

>> +#endif

>> +#ifndef MADV_DONTDUMP

>> +#define MADV_DONTDUMP   16

>> +#endif

>> +#ifndef MADV_DODUMP

>> +#define MADV_DODUMP	17

>> +#endif

>> +#include <asm-generic/mman-fix.h>

>> +#endif // TOOLS_ARCH_ALPHA_UAPI_ASM_MMAN_FIX_H

>> diff --git a/tools/arch/arm/include/uapi/asm/mman-fix.h b/tools/arch/arm/include/uapi/asm/mman-fix.h

>> new file mode 100644

>> index 0000000..a29dae1

>> --- /dev/null

>> +++ b/tools/arch/arm/include/uapi/asm/mman-fix.h

>> @@ -0,0 +1,5 @@

>> +#ifndef TOOLS_ARCH_ARM_UAPI_ASM_MMAN_FIX_H

>> +#define TOOLS_ARCH_ARM_UAPI_ASM_MMAN_FIX_H

>> +#include <sys/mman.h>

>> +#include <asm-generic/mman-fix.h>

>> +#endif // TOOLS_ARCH_ARM_UAPI_ASM_MMAN_FIX_H

>> diff --git a/tools/arch/arm64/include/uapi/asm/mman-fix.h b/tools/arch/arm64/include/uapi/asm/mman-fix.h

>> new file mode 100644

>> index 0000000..e50c0d1

>> --- /dev/null

>> +++ b/tools/arch/arm64/include/uapi/asm/mman-fix.h

>> @@ -0,0 +1,5 @@

>> +#ifndef TOOLS_ARCH_ARM64_UAPI_ASM_MMAN_FIX_H

>> +#define TOOLS_ARCH_ARM64_UAPI_ASM_MMAN_FIX_H

>> +#include <sys/mman.h>

>> +#include <asm-generic/mman-fix.h>

>> +#endif // TOOLS_ARCH_ARM64_UAPI_ASM_MMAN_FIX_H

>> diff --git a/tools/arch/frv/include/uapi/asm/mman-fix.h b/tools/arch/frv/include/uapi/asm/mman-fix.h

>> new file mode 100644

>> index 0000000..8c2eb44

>> --- /dev/null

>> +++ b/tools/arch/frv/include/uapi/asm/mman-fix.h

>> @@ -0,0 +1,5 @@

>> +#ifndef TOOLS_ARCH_FRV_UAPI_ASM_MMAN_FIX_H

>> +#define TOOLS_ARCH_FRV_UAPI_ASM_MMAN_FIX_H

>> +#include <sys/mman.h>

>> +#include <asm-generic/mman-fix.h>

>> +#endif // TOOLS_ARCH_FRV_UAPI_ASM_MMAN_FIX_H

>> diff --git a/tools/arch/h8300/include/uapi/asm/mman-fix.h b/tools/arch/h8300/include/uapi/asm/mman-fix.h

>> new file mode 100644

>> index 0000000..e639fe6

>> --- /dev/null

>> +++ b/tools/arch/h8300/include/uapi/asm/mman-fix.h

>> @@ -0,0 +1,5 @@

>> +#ifndef TOOLS_ARCH_H8300_UAPI_ASM_MMAN_FIX_H

>> +#define TOOLS_ARCH_H8300_UAPI_ASM_MMAN_FIX_H

>> +#include <sys/mman.h>

>> +#include <asm-generic/mman-fix.h>

>> +#endif // TOOLS_ARCH_H8300_UAPI_ASM_MMAN_FIX_H

>> diff --git a/tools/arch/hexagon/include/uapi/asm/mman-fix.h b/tools/arch/hexagon/include/uapi/asm/mman-fix.h

>> new file mode 100644

>> index 0000000..dda9359

>> --- /dev/null

>> +++ b/tools/arch/hexagon/include/uapi/asm/mman-fix.h

>> @@ -0,0 +1,5 @@

>> +#ifndef TOOLS_ARCH_HEXAGON_UAPI_ASM_MMAN_FIX_H

>> +#define TOOLS_ARCH_HEXAGON_UAPI_ASM_MMAN_FIX_H

>> +#include <sys/mman.h>

>> +#include <asm-generic/mman-fix.h>

>> +#endif // TOOLS_ARCH_HEXAGON_UAPI_ASM_MMAN_FIX_H

>> diff --git a/tools/arch/ia64/include/uapi/asm/mman-fix.h b/tools/arch/ia64/include/uapi/asm/mman-fix.h

>> new file mode 100644

>> index 0000000..1e98f36

>> --- /dev/null

>> +++ b/tools/arch/ia64/include/uapi/asm/mman-fix.h

>> @@ -0,0 +1,5 @@

>> +#ifndef TOOLS_ARCH_IA64_UAPI_ASM_MMAN_FIX_H

>> +#define TOOLS_ARCH_IA64_UAPI_ASM_MMAN_FIX_H

>> +#include <sys/mman.h>

>> +#include <asm-generic/mman-fix.h>

>> +#endif // TOOLS_ARCH_IA64_UAPI_ASM_MMAN_FIX_H

>> diff --git a/tools/arch/m32r/include/uapi/asm/mman-fix.h b/tools/arch/m32r/include/uapi/asm/mman-fix.h

>> new file mode 100644

>> index 0000000..74aa94d

>> --- /dev/null

>> +++ b/tools/arch/m32r/include/uapi/asm/mman-fix.h

>> @@ -0,0 +1,5 @@

>> +#ifndef TOOLS_ARCH_M32R_UAPI_ASM_MMAN_FIX_H

>> +#define TOOLS_ARCH_M32R_UAPI_ASM_MMAN_FIX_H

>> +#include <sys/mman.h>

>> +#include <asm-generic/mman-fix.h>

>> +#endif // TOOLS_ARCH_M32R_UAPI_ASM_MMAN_FIX_H

>> diff --git a/tools/arch/microblaze/include/uapi/asm/mman-fix.h b/tools/arch/microblaze/include/uapi/asm/mman-fix.h

>> new file mode 100644

>> index 0000000..90b7a53

>> --- /dev/null

>> +++ b/tools/arch/microblaze/include/uapi/asm/mman-fix.h

>> @@ -0,0 +1,5 @@

>> +#ifndef TOOLS_ARCH_MICROBLAZE_UAPI_ASM_MMAN_FIX_H

>> +#define TOOLS_ARCH_MICROBLAZE_UAPI_ASM_MMAN_FIX_H

>> +#include <sys/mman.h>

>> +#include <asm-generic/mman-fix.h>

>> +#endif // TOOLS_ARCH_MICROBLAZE_UAPI_ASM_MMAN_FIX_H

>> diff --git a/tools/arch/mips/include/uapi/asm/mman-fix.h b/tools/arch/mips/include/uapi/asm/mman-fix.h

>> new file mode 100644

>> index 0000000..ef58cd7

>> --- /dev/null

>> +++ b/tools/arch/mips/include/uapi/asm/mman-fix.h

>> @@ -0,0 +1,41 @@

>> +#ifndef TOOLS_ARCH_MIPS_UAPI_ASM_MMAN_FIX_H

>> +#define TOOLS_ARCH_MIPS_UAPI_ASM_MMAN_FIX_H

>> +#include <sys/mman.h>

>> +#ifndef PROT_SEM

>> +#define PROT_SEM	0x10

>> +#endif

>> +#ifndef MAP_FIXED

>> +#define MAP_FIXED	0x010

>> +#endif

>> +#ifndef MAP_ANONYMOUS

>> +#define MAP_ANONYMOUS	0x0800

>> +#endif

>> +#ifndef MAP_STACK

>> +#define MAP_STACK	0x40000

>> +#endif

>> +#ifndef MAP_HUGETLB

>> +#define MAP_HUGETLB	0x80000

>> +#endif

>> +#ifndef MADV_HWPOISON

>> +#define MADV_HWPOISON	 100

>> +#endif

>> +#ifndef MADV_MERGEABLE

>> +#define MADV_MERGEABLE	 12

>> +#endif

>> +#ifndef MADV_UNMERGEABLE

>> +#define MADV_UNMERGEABLE 13

>> +#endif

>> +#ifndef MADV_HUGEPAGE

>> +#define MADV_HUGEPAGE	14

>> +#endif

>> +#ifndef MADV_NOHUGEPAGE

>> +#define MADV_NOHUGEPAGE 15

>> +#endif

>> +#ifndef MADV_DONTDUMP

>> +#define MADV_DONTDUMP	16

>> +#endif

>> +#ifndef MADV_DODUMP

>> +#define MADV_DODUMP	17

>> +#endif

>> +#include <asm-generic/mman-fix.h>

>> +#endif // TOOLS_ARCH_MIPS_UAPI_ASM_MMAN_FIX_H

>> diff --git a/tools/arch/mn10300/include/uapi/asm/mman-fix.h b/tools/arch/mn10300/include/uapi/asm/mman-fix.h

>> new file mode 100644

>> index 0000000..86a2903

>> --- /dev/null

>> +++ b/tools/arch/mn10300/include/uapi/asm/mman-fix.h

>> @@ -0,0 +1,5 @@

>> +#ifndef TOOLS_ARCH_MN10300_UAPI_ASM_MMAN_FIX_H

>> +#define TOOLS_ARCH_MN10300_UAPI_ASM_MMAN_FIX_H

>> +#include <sys/mman.h>

>> +#include <asm-generic/mman-fix.h>

>> +#endif // TOOLS_ARCH_MN10300_UAPI_ASM_MMAN_FIX_H

>> diff --git a/tools/arch/parisc/include/uapi/asm/mman-fix.h b/tools/arch/parisc/include/uapi/asm/mman-fix.h

>> new file mode 100644

>> index 0000000..c157a03

>> --- /dev/null

>> +++ b/tools/arch/parisc/include/uapi/asm/mman-fix.h

>> @@ -0,0 +1,38 @@

>> +#ifndef TOOLS_ARCH_PARISC_UAPI_ASM_MMAN_FIX_H

>> +#define TOOLS_ARCH_PARISC_UAPI_ASM_MMAN_FIX_H

>> +#include <sys/mman.h>

>> +#ifndef PROT_SEM

>> +#define PROT_SEM	0x8

>> +#endif

>> +#ifndef MAP_FIXED

>> +#define MAP_FIXED	0x04

>> +#endif

>> +#ifndef MAP_ANONYMOUS

>> +#define MAP_ANONYMOUS	0x10

>> +#endif

>> +#ifndef MAP_STACK

>> +#define MAP_STACK	0x40000

>> +#endif

>> +#ifndef MAP_HUGETLB

>> +#define MAP_HUGETLB	0x80000

>> +#endif

>> +#ifndef MADV_MERGEABLE

>> +#define MADV_MERGEABLE   65

>> +#endif

>> +#ifndef MADV_UNMERGEABLE

>> +#define MADV_UNMERGEABLE 66

>> +#endif

>> +#ifndef MADV_HUGEPAGE

>> +#define MADV_HUGEPAGE	67

>> +#endif

>> +#ifndef MADV_NOHUGEPAGE

>> +#define MADV_NOHUGEPAGE	68

>> +#endif

>> +#ifndef MADV_DONTDUMP

>> +#define MADV_DONTDUMP   69

>> +#endif

>> +#ifndef MADV_DODUMP

>> +#define MADV_DODUMP	70

>> +#endif

>> +#include <asm-generic/mman-fix.h>

>> +#endif // TOOLS_ARCH_PARISC_UAPI_ASM_MMAN_FIX_H

>> diff --git a/tools/arch/powerpc/include/uapi/asm/mman-fix.h b/tools/arch/powerpc/include/uapi/asm/mman-fix.h

>> new file mode 100644

>> index 0000000..4b552fa

>> --- /dev/null

>> +++ b/tools/arch/powerpc/include/uapi/asm/mman-fix.h

>> @@ -0,0 +1,11 @@

>> +#ifndef TOOLS_ARCH_POWERPC_UAPI_ASM_MMAN_FIX_H

>> +#define TOOLS_ARCH_POWERPC_UAPI_ASM_MMAN_FIX_H

>> +#include <sys/mman.h>

>> +#ifndef MAP_STACK

>> +#define MAP_STACK	0x20000

>> +#endif

>> +#ifndef MAP_HUGETLB

>> +#define MAP_HUGETLB	0x40000

>> +#endif

>> +#include <asm-generic/mman-fix.h>

>> +#endif // TOOLS_ARCH_POWERPC_UAPI_ASM_MMAN_FIX_H

>> diff --git a/tools/arch/s390/include/uapi/asm/mman-fix.h b/tools/arch/s390/include/uapi/asm/mman-fix.h

>> new file mode 100644

>> index 0000000..d7755dd

>> --- /dev/null

>> +++ b/tools/arch/s390/include/uapi/asm/mman-fix.h

>> @@ -0,0 +1,5 @@

>> +#ifndef TOOLS_ARCH_S390_UAPI_ASM_MMAN_FIX_H

>> +#define TOOLS_ARCH_S390_UAPI_ASM_MMAN_FIX_H

>> +#include <sys/mman.h>

>> +#include <asm-generic/mman-fix.h>

>> +#endif // TOOLS_ARCH_S390_UAPI_ASM_MMAN_FIX_H

>> diff --git a/tools/arch/score/include/uapi/asm/mman-fix.h b/tools/arch/score/include/uapi/asm/mman-fix.h

>> new file mode 100644

>> index 0000000..97ad192

>> --- /dev/null

>> +++ b/tools/arch/score/include/uapi/asm/mman-fix.h

>> @@ -0,0 +1,5 @@

>> +#ifndef TOOLS_ARCH_SCORE_UAPI_ASM_MMAN_FIX_H

>> +#define TOOLS_ARCH_SCORE_UAPI_ASM_MMAN_FIX_H

>> +#include <sys/mman.h>

>> +#include <asm-generic/mman-fix.h>

>> +#endif // TOOLS_ARCH_SCORE_UAPI_ASM_MMAN_FIX_H

>> diff --git a/tools/arch/sh/include/uapi/asm/mman-fix.h b/tools/arch/sh/include/uapi/asm/mman-fix.h

>> new file mode 100644

>> index 0000000..d17bca8

>> --- /dev/null

>> +++ b/tools/arch/sh/include/uapi/asm/mman-fix.h

>> @@ -0,0 +1,5 @@

>> +#ifndef TOOLS_ARCH_SH_UAPI_ASM_MMAN_FIX_H

>> +#define TOOLS_ARCH_SH_UAPI_ASM_MMAN_FIX_H

>> +#include <sys/mman.h>

>> +#include <asm-generic/mman-fix.h>

>> +#endif // TOOLS_ARCH_SH_UAPI_ASM_MMAN_FIX_H

>> diff --git a/tools/arch/sparc/include/uapi/asm/mman-fix.h b/tools/arch/sparc/include/uapi/asm/mman-fix.h

>> new file mode 100644

>> index 0000000..3ac4ba0

>> --- /dev/null

>> +++ b/tools/arch/sparc/include/uapi/asm/mman-fix.h

>> @@ -0,0 +1,11 @@

>> +#ifndef TOOLS_ARCH_SPARC_UAPI_ASM_MMAN_FIX_H

>> +#define TOOLS_ARCH_SPARC_UAPI_ASM_MMAN_FIX_H

>> +#include <sys/mman.h>

>> +#ifndef MAP_STACK

>> +#define MAP_STACK	0x20000

>> +#endif

>> +#ifndef MAP_HUGETLB

>> +#define MAP_HUGETLB	0x40000

>> +#endif

>> +#include <asm-generic/mman-fix.h>

>> +#endif // TOOLS_ARCH_SPARC_UAPI_ASM_MMAN_FIX_H

>> diff --git a/tools/arch/tile/include/uapi/asm/mman-fix.h b/tools/arch/tile/include/uapi/asm/mman-fix.h

>> new file mode 100644

>> index 0000000..105a3b0e

>> --- /dev/null

>> +++ b/tools/arch/tile/include/uapi/asm/mman-fix.h

>> @@ -0,0 +1,11 @@

>> +#ifndef TOOLS_ARCH_TILE_UAPI_ASM_MMAN_FIX_H

>> +#define TOOLS_ARCH_TILE_UAPI_ASM_MMAN_FIX_H

>> +#include <sys/mman.h>

>> +#ifndef MAP_STACK

>> +#define MAP_STACK	MAP_GROWSDOWN

>> +#endif

>> +#ifndef MAP_HUGETLB

>> +#define MAP_HUGETLB	0x4000

>> +#endif

>> +#include <asm-generic/mman-fix.h>

>> +#endif // TOOLS_ARCH_TILE_UAPI_ASM_MMAN_FIX_H

>> diff --git a/tools/arch/x86/include/uapi/asm/mman-fix.h b/tools/arch/x86/include/uapi/asm/mman-fix.h

>> new file mode 100644

>> index 0000000..0cda2bf

>> --- /dev/null

>> +++ b/tools/arch/x86/include/uapi/asm/mman-fix.h

>> @@ -0,0 +1,8 @@

>> +#ifndef TOOLS_ARCH_X86_UAPI_ASM_MMAN_FIX_H

>> +#define TOOLS_ARCH_X86_UAPI_ASM_MMAN_FIX_H

>> +#include <sys/mman.h>

>> +#ifndef MAP_32BIT

>> +#define MAP_32BIT	0x40

>> +#endif

>> +#include <asm-generic/mman-fix.h>

>> +#endif // TOOLS_ARCH_X86_UAPI_ASM_MMAN_FIX_H

>> diff --git a/tools/arch/xtensa/include/uapi/asm/mman-fix.h b/tools/arch/xtensa/include/uapi/asm/mman-fix.h

>> new file mode 100644

>> index 0000000..9ec9051

>> --- /dev/null

>> +++ b/tools/arch/xtensa/include/uapi/asm/mman-fix.h

>> @@ -0,0 +1,38 @@

>> +#ifndef TOOLS_ARCH_XTENSA_UAPI_ASM_MMAN_FIX_H

>> +#define TOOLS_ARCH_XTENSA_UAPI_ASM_MMAN_FIX_H

>> +#include <sys/mman.h>

>> +#ifndef PROT_SEM

>> +#define PROT_SEM	0x10

>> +#endif

>> +#ifndef MAP_FIXED

>> +#define MAP_FIXED	0x010

>> +#endif

>> +#ifndef MAP_ANONYMOUS

>> +#define MAP_ANONYMOUS	0x0800

>> +#endif

>> +#ifndef MAP_STACK

>> +#define MAP_STACK	0x40000

>> +#endif

>> +#ifndef MAP_HUGETLB

>> +#define MAP_HUGETLB	0x80000

>> +#endif

>> +#ifndef MADV_MERGEABLE

>> +#define MADV_MERGEABLE   12

>> +#endif

>> +#ifndef MADV_UNMERGEABLE

>> +#define MADV_UNMERGEABLE 13

>> +#endif

>> +#ifndef MADV_HUGEPAGE

>> +#define MADV_HUGEPAGE	14

>> +#endif

>> +#ifndef MADV_NOHUGEPAGE

>> +#define MADV_NOHUGEPAGE	15

>> +#endif

>> +#ifndef MADV_DONTDUMP

>> +#define MADV_DONTDUMP   16

>> +#endif

>> +#ifndef MADV_DODUMP

>> +#define MADV_DODUMP	17

>> +#endif

>> +#include <asm-generic/mman-fix.h>

>> +#endif // TOOLS_ARCH_XTENSA_UAPI_ASM_MMAN_FIX_H

>> diff --git a/tools/include/uapi/asm-generic/mman-fix.h b/tools/include/uapi/asm-generic/mman-fix.h

>> new file mode 100644

>> index 0000000..f47eb4c

>> --- /dev/null

>> +++ b/tools/include/uapi/asm-generic/mman-fix.h

>> @@ -0,0 +1,46 @@

>> +#ifndef __TOOLS_UAPI_ASM_MMAN_FIX_H

>> +#define __TOOLS_UAPI_ASM_MMAN_FIX_H

>> +#include <sys/mman.h>

>> +#ifndef PROT_SEM

>> +#define PROT_SEM	0x8

>> +#endif

>> +#ifndef MAP_FIXED

>> +#define MAP_FIXED	0x10

>> +#endif

>> +#ifndef MAP_ANONYMOUS

>> +#define MAP_ANONYMOUS	0x20

>> +#endif

>> +#ifndef MADV_HWPOISON

>> +#define MADV_HWPOISON	100

>> +#endif

>> +#ifndef MADV_SOFT_OFFLINE

>> +#define MADV_SOFT_OFFLINE 101

>> +#endif

>> +#ifndef MADV_MERGEABLE

>> +#define MADV_MERGEABLE   12

>> +#endif

>> +#ifndef MADV_UNMERGEABLE

>> +#define MADV_UNMERGEABLE 13

>> +#endif

>> +#ifndef MADV_HUGEPAGE

>> +#define MADV_HUGEPAGE	14

>> +#endif

>> +#ifndef MADV_NOHUGEPAGE

>> +#define MADV_NOHUGEPAGE	15

>> +#endif

>> +#ifndef MADV_DONTDUMP

>> +#define MADV_DONTDUMP   16

>> +#endif

>> +#ifndef MADV_DODUMP

>> +#define MADV_DODUMP	17

>> +#endif

>> +#ifndef MAP_STACK

>> +#define MAP_STACK	0x20000

>> +#endif

>> +#ifndef MAP_HUGETLB

>> +#define MAP_HUGETLB	0x40000

>> +#endif

>> +#ifndef MAP_UNINITIALIZED

>> +#define MAP_UNINITIALIZED 0x4000000

>> +#endif

>> +#endif // __TOOLS_UAPI_ASM_MMAN_FIX_H

>> diff --git a/tools/perf/MANIFEST b/tools/perf/MANIFEST

>> index ff200c6..56ac24f 100644

>> --- a/tools/perf/MANIFEST

>> +++ b/tools/perf/MANIFEST

>> @@ -66,6 +66,7 @@ tools/include/linux/hash.h

>>   tools/include/linux/kernel.h

>>   tools/include/linux/list.h

>>   tools/include/linux/log2.h

>> +tools/include/uapi/asm-generic/mman-fix.h

>>   tools/include/uapi/linux/bpf.h

>>   tools/include/uapi/linux/bpf_common.h

>>   tools/include/uapi/linux/hw_breakpoint.h

>> @@ -80,3 +81,4 @@ tools/include/linux/err.h

>>   tools/include/linux/bitmap.h

>>   tools/include/linux/time64.h

>>   tools/arch/*/include/uapi/asm/perf_regs.h

>> +tools/arch/*/include/uapi/asm/mman-fix.h

>> -- 

>> 1.8.3.4
Wang Nan Sept. 6, 2016, 3:28 p.m. UTC | #2
On 2016/9/6 21:39, Arnaldo Carvalho de Melo wrote:
> Em Tue, Sep 06, 2016 at 09:25:47PM +0800, Wangnan (F) escreveu:

>>

>> On 2016/9/6 20:59, Arnaldo Carvalho de Melo wrote:

>>> Em Tue, Sep 06, 2016 at 05:48:51AM +0000, Wang Nan escreveu:

>>>> tools/perf/trace/beauty/mmap.c, tools/perf/util/event.c and

>>>> tools/perf/util/map.c depend on several macros in mman.h, which

>>>> are lost on old systems like ubuntu 12.04. They are architecture

>>> Not "lost on old systems", changing that to "not present on old systems"

>>>

>>>> dependened macros. Importing ./arch/*/include/uapi/asm/mman.h

>>>> into tools/ is not easy because mman.h for some unusual archs

>>>> (like tile) have extra dependencies.

>>>> This patch introduces only required macros into mman-fix.h.

>>>> Macros list is gotten from tools/perf/trace/beauty/mmap.c.

>>> ok, I'll try keeping the  include/uapi/asm-generic/mman.h and

>>> arch/alpha/include/uapi/asm/mman.h with just what you added, so that at

>>> least the .c files appears as using the headers were those things are

>>> defined in the kernel sources.

>>>

>>> Ah, and good eyes in realizing this is not the same value for all

>>> arches!

>> This is why we have to define these macros for each archs.

>> Your solution in tools/perf/trace/beauty/mmap.c works for

>> x86 only.

>>

>> However, I don't like this patchset because we add 300+

>> lines of code and 22 new files for less than 15 macros,

>> and only one of them I really concern. Moreover, futhre

>> code require more symbols in uapi and we have to add new

>> headers, finally we will clone the whole uapi. We have

>> to stop doing this...

> Why? If we want to support older newer kernels running on older distros,

> which is a valid goal, or recent tool source code on older distros,

> where fallbacks will take place with their older kernels, and if we have

> the build automated for that (I have) then why not keep the tools

> building on as many different userspaces as possible?


Your automated building checker is great. I mean we have
to find a way to stop pulling kernel headers to tools/include.

But since we haven't find such a way, I'll continously improve
this mman.h stuff. As your suggestion, I'll try to put them
in uapi/mman.h, not mman-fix.h. This require a building check
for each arch.

Thank you.
diff mbox

Patch

diff --git a/tools/arch/alpha/include/uapi/asm/mman-fix.h b/tools/arch/alpha/include/uapi/asm/mman-fix.h
new file mode 100644
index 0000000..f807a71
--- /dev/null
+++ b/tools/arch/alpha/include/uapi/asm/mman-fix.h
@@ -0,0 +1,38 @@ 
+#ifndef TOOLS_ARCH_ALPHA_UAPI_ASM_MMAN_FIX_H
+#define TOOLS_ARCH_ALPHA_UAPI_ASM_MMAN_FIX_H
+#include <sys/mman.h>
+#ifndef PROT_SEM
+#define PROT_SEM	0x8
+#endif
+#ifndef MAP_FIXED
+#define MAP_FIXED	0x100
+#endif
+#ifndef MAP_ANONYMOUS
+#define MAP_ANONYMOUS	0x10
+#endif
+#ifndef MAP_STACK
+#define MAP_STACK	0x80000
+#endif
+#ifndef MAP_HUGETLB
+#define MAP_HUGETLB	0x100000
+#endif
+#ifndef MADV_MERGEABLE
+#define MADV_MERGEABLE   12
+#endif
+#ifndef MADV_UNMERGEABLE
+#define MADV_UNMERGEABLE 13
+#endif
+#ifndef MADV_HUGEPAGE
+#define MADV_HUGEPAGE	14
+#endif
+#ifndef MADV_NOHUGEPAGE
+#define MADV_NOHUGEPAGE	15
+#endif
+#ifndef MADV_DONTDUMP
+#define MADV_DONTDUMP   16
+#endif
+#ifndef MADV_DODUMP
+#define MADV_DODUMP	17
+#endif
+#include <asm-generic/mman-fix.h>
+#endif // TOOLS_ARCH_ALPHA_UAPI_ASM_MMAN_FIX_H
diff --git a/tools/arch/arm/include/uapi/asm/mman-fix.h b/tools/arch/arm/include/uapi/asm/mman-fix.h
new file mode 100644
index 0000000..a29dae1
--- /dev/null
+++ b/tools/arch/arm/include/uapi/asm/mman-fix.h
@@ -0,0 +1,5 @@ 
+#ifndef TOOLS_ARCH_ARM_UAPI_ASM_MMAN_FIX_H
+#define TOOLS_ARCH_ARM_UAPI_ASM_MMAN_FIX_H
+#include <sys/mman.h>
+#include <asm-generic/mman-fix.h>
+#endif // TOOLS_ARCH_ARM_UAPI_ASM_MMAN_FIX_H
diff --git a/tools/arch/arm64/include/uapi/asm/mman-fix.h b/tools/arch/arm64/include/uapi/asm/mman-fix.h
new file mode 100644
index 0000000..e50c0d1
--- /dev/null
+++ b/tools/arch/arm64/include/uapi/asm/mman-fix.h
@@ -0,0 +1,5 @@ 
+#ifndef TOOLS_ARCH_ARM64_UAPI_ASM_MMAN_FIX_H
+#define TOOLS_ARCH_ARM64_UAPI_ASM_MMAN_FIX_H
+#include <sys/mman.h>
+#include <asm-generic/mman-fix.h>
+#endif // TOOLS_ARCH_ARM64_UAPI_ASM_MMAN_FIX_H
diff --git a/tools/arch/frv/include/uapi/asm/mman-fix.h b/tools/arch/frv/include/uapi/asm/mman-fix.h
new file mode 100644
index 0000000..8c2eb44
--- /dev/null
+++ b/tools/arch/frv/include/uapi/asm/mman-fix.h
@@ -0,0 +1,5 @@ 
+#ifndef TOOLS_ARCH_FRV_UAPI_ASM_MMAN_FIX_H
+#define TOOLS_ARCH_FRV_UAPI_ASM_MMAN_FIX_H
+#include <sys/mman.h>
+#include <asm-generic/mman-fix.h>
+#endif // TOOLS_ARCH_FRV_UAPI_ASM_MMAN_FIX_H
diff --git a/tools/arch/h8300/include/uapi/asm/mman-fix.h b/tools/arch/h8300/include/uapi/asm/mman-fix.h
new file mode 100644
index 0000000..e639fe6
--- /dev/null
+++ b/tools/arch/h8300/include/uapi/asm/mman-fix.h
@@ -0,0 +1,5 @@ 
+#ifndef TOOLS_ARCH_H8300_UAPI_ASM_MMAN_FIX_H
+#define TOOLS_ARCH_H8300_UAPI_ASM_MMAN_FIX_H
+#include <sys/mman.h>
+#include <asm-generic/mman-fix.h>
+#endif // TOOLS_ARCH_H8300_UAPI_ASM_MMAN_FIX_H
diff --git a/tools/arch/hexagon/include/uapi/asm/mman-fix.h b/tools/arch/hexagon/include/uapi/asm/mman-fix.h
new file mode 100644
index 0000000..dda9359
--- /dev/null
+++ b/tools/arch/hexagon/include/uapi/asm/mman-fix.h
@@ -0,0 +1,5 @@ 
+#ifndef TOOLS_ARCH_HEXAGON_UAPI_ASM_MMAN_FIX_H
+#define TOOLS_ARCH_HEXAGON_UAPI_ASM_MMAN_FIX_H
+#include <sys/mman.h>
+#include <asm-generic/mman-fix.h>
+#endif // TOOLS_ARCH_HEXAGON_UAPI_ASM_MMAN_FIX_H
diff --git a/tools/arch/ia64/include/uapi/asm/mman-fix.h b/tools/arch/ia64/include/uapi/asm/mman-fix.h
new file mode 100644
index 0000000..1e98f36
--- /dev/null
+++ b/tools/arch/ia64/include/uapi/asm/mman-fix.h
@@ -0,0 +1,5 @@ 
+#ifndef TOOLS_ARCH_IA64_UAPI_ASM_MMAN_FIX_H
+#define TOOLS_ARCH_IA64_UAPI_ASM_MMAN_FIX_H
+#include <sys/mman.h>
+#include <asm-generic/mman-fix.h>
+#endif // TOOLS_ARCH_IA64_UAPI_ASM_MMAN_FIX_H
diff --git a/tools/arch/m32r/include/uapi/asm/mman-fix.h b/tools/arch/m32r/include/uapi/asm/mman-fix.h
new file mode 100644
index 0000000..74aa94d
--- /dev/null
+++ b/tools/arch/m32r/include/uapi/asm/mman-fix.h
@@ -0,0 +1,5 @@ 
+#ifndef TOOLS_ARCH_M32R_UAPI_ASM_MMAN_FIX_H
+#define TOOLS_ARCH_M32R_UAPI_ASM_MMAN_FIX_H
+#include <sys/mman.h>
+#include <asm-generic/mman-fix.h>
+#endif // TOOLS_ARCH_M32R_UAPI_ASM_MMAN_FIX_H
diff --git a/tools/arch/microblaze/include/uapi/asm/mman-fix.h b/tools/arch/microblaze/include/uapi/asm/mman-fix.h
new file mode 100644
index 0000000..90b7a53
--- /dev/null
+++ b/tools/arch/microblaze/include/uapi/asm/mman-fix.h
@@ -0,0 +1,5 @@ 
+#ifndef TOOLS_ARCH_MICROBLAZE_UAPI_ASM_MMAN_FIX_H
+#define TOOLS_ARCH_MICROBLAZE_UAPI_ASM_MMAN_FIX_H
+#include <sys/mman.h>
+#include <asm-generic/mman-fix.h>
+#endif // TOOLS_ARCH_MICROBLAZE_UAPI_ASM_MMAN_FIX_H
diff --git a/tools/arch/mips/include/uapi/asm/mman-fix.h b/tools/arch/mips/include/uapi/asm/mman-fix.h
new file mode 100644
index 0000000..ef58cd7
--- /dev/null
+++ b/tools/arch/mips/include/uapi/asm/mman-fix.h
@@ -0,0 +1,41 @@ 
+#ifndef TOOLS_ARCH_MIPS_UAPI_ASM_MMAN_FIX_H
+#define TOOLS_ARCH_MIPS_UAPI_ASM_MMAN_FIX_H
+#include <sys/mman.h>
+#ifndef PROT_SEM
+#define PROT_SEM	0x10
+#endif
+#ifndef MAP_FIXED
+#define MAP_FIXED	0x010
+#endif
+#ifndef MAP_ANONYMOUS
+#define MAP_ANONYMOUS	0x0800
+#endif
+#ifndef MAP_STACK
+#define MAP_STACK	0x40000
+#endif
+#ifndef MAP_HUGETLB
+#define MAP_HUGETLB	0x80000
+#endif
+#ifndef MADV_HWPOISON
+#define MADV_HWPOISON	 100
+#endif
+#ifndef MADV_MERGEABLE
+#define MADV_MERGEABLE	 12
+#endif
+#ifndef MADV_UNMERGEABLE
+#define MADV_UNMERGEABLE 13
+#endif
+#ifndef MADV_HUGEPAGE
+#define MADV_HUGEPAGE	14
+#endif
+#ifndef MADV_NOHUGEPAGE
+#define MADV_NOHUGEPAGE 15
+#endif
+#ifndef MADV_DONTDUMP
+#define MADV_DONTDUMP	16
+#endif
+#ifndef MADV_DODUMP
+#define MADV_DODUMP	17
+#endif
+#include <asm-generic/mman-fix.h>
+#endif // TOOLS_ARCH_MIPS_UAPI_ASM_MMAN_FIX_H
diff --git a/tools/arch/mn10300/include/uapi/asm/mman-fix.h b/tools/arch/mn10300/include/uapi/asm/mman-fix.h
new file mode 100644
index 0000000..86a2903
--- /dev/null
+++ b/tools/arch/mn10300/include/uapi/asm/mman-fix.h
@@ -0,0 +1,5 @@ 
+#ifndef TOOLS_ARCH_MN10300_UAPI_ASM_MMAN_FIX_H
+#define TOOLS_ARCH_MN10300_UAPI_ASM_MMAN_FIX_H
+#include <sys/mman.h>
+#include <asm-generic/mman-fix.h>
+#endif // TOOLS_ARCH_MN10300_UAPI_ASM_MMAN_FIX_H
diff --git a/tools/arch/parisc/include/uapi/asm/mman-fix.h b/tools/arch/parisc/include/uapi/asm/mman-fix.h
new file mode 100644
index 0000000..c157a03
--- /dev/null
+++ b/tools/arch/parisc/include/uapi/asm/mman-fix.h
@@ -0,0 +1,38 @@ 
+#ifndef TOOLS_ARCH_PARISC_UAPI_ASM_MMAN_FIX_H
+#define TOOLS_ARCH_PARISC_UAPI_ASM_MMAN_FIX_H
+#include <sys/mman.h>
+#ifndef PROT_SEM
+#define PROT_SEM	0x8
+#endif
+#ifndef MAP_FIXED
+#define MAP_FIXED	0x04
+#endif
+#ifndef MAP_ANONYMOUS
+#define MAP_ANONYMOUS	0x10
+#endif
+#ifndef MAP_STACK
+#define MAP_STACK	0x40000
+#endif
+#ifndef MAP_HUGETLB
+#define MAP_HUGETLB	0x80000
+#endif
+#ifndef MADV_MERGEABLE
+#define MADV_MERGEABLE   65
+#endif
+#ifndef MADV_UNMERGEABLE
+#define MADV_UNMERGEABLE 66
+#endif
+#ifndef MADV_HUGEPAGE
+#define MADV_HUGEPAGE	67
+#endif
+#ifndef MADV_NOHUGEPAGE
+#define MADV_NOHUGEPAGE	68
+#endif
+#ifndef MADV_DONTDUMP
+#define MADV_DONTDUMP   69
+#endif
+#ifndef MADV_DODUMP
+#define MADV_DODUMP	70
+#endif
+#include <asm-generic/mman-fix.h>
+#endif // TOOLS_ARCH_PARISC_UAPI_ASM_MMAN_FIX_H
diff --git a/tools/arch/powerpc/include/uapi/asm/mman-fix.h b/tools/arch/powerpc/include/uapi/asm/mman-fix.h
new file mode 100644
index 0000000..4b552fa
--- /dev/null
+++ b/tools/arch/powerpc/include/uapi/asm/mman-fix.h
@@ -0,0 +1,11 @@ 
+#ifndef TOOLS_ARCH_POWERPC_UAPI_ASM_MMAN_FIX_H
+#define TOOLS_ARCH_POWERPC_UAPI_ASM_MMAN_FIX_H
+#include <sys/mman.h>
+#ifndef MAP_STACK
+#define MAP_STACK	0x20000
+#endif
+#ifndef MAP_HUGETLB
+#define MAP_HUGETLB	0x40000
+#endif
+#include <asm-generic/mman-fix.h>
+#endif // TOOLS_ARCH_POWERPC_UAPI_ASM_MMAN_FIX_H
diff --git a/tools/arch/s390/include/uapi/asm/mman-fix.h b/tools/arch/s390/include/uapi/asm/mman-fix.h
new file mode 100644
index 0000000..d7755dd
--- /dev/null
+++ b/tools/arch/s390/include/uapi/asm/mman-fix.h
@@ -0,0 +1,5 @@ 
+#ifndef TOOLS_ARCH_S390_UAPI_ASM_MMAN_FIX_H
+#define TOOLS_ARCH_S390_UAPI_ASM_MMAN_FIX_H
+#include <sys/mman.h>
+#include <asm-generic/mman-fix.h>
+#endif // TOOLS_ARCH_S390_UAPI_ASM_MMAN_FIX_H
diff --git a/tools/arch/score/include/uapi/asm/mman-fix.h b/tools/arch/score/include/uapi/asm/mman-fix.h
new file mode 100644
index 0000000..97ad192
--- /dev/null
+++ b/tools/arch/score/include/uapi/asm/mman-fix.h
@@ -0,0 +1,5 @@ 
+#ifndef TOOLS_ARCH_SCORE_UAPI_ASM_MMAN_FIX_H
+#define TOOLS_ARCH_SCORE_UAPI_ASM_MMAN_FIX_H
+#include <sys/mman.h>
+#include <asm-generic/mman-fix.h>
+#endif // TOOLS_ARCH_SCORE_UAPI_ASM_MMAN_FIX_H
diff --git a/tools/arch/sh/include/uapi/asm/mman-fix.h b/tools/arch/sh/include/uapi/asm/mman-fix.h
new file mode 100644
index 0000000..d17bca8
--- /dev/null
+++ b/tools/arch/sh/include/uapi/asm/mman-fix.h
@@ -0,0 +1,5 @@ 
+#ifndef TOOLS_ARCH_SH_UAPI_ASM_MMAN_FIX_H
+#define TOOLS_ARCH_SH_UAPI_ASM_MMAN_FIX_H
+#include <sys/mman.h>
+#include <asm-generic/mman-fix.h>
+#endif // TOOLS_ARCH_SH_UAPI_ASM_MMAN_FIX_H
diff --git a/tools/arch/sparc/include/uapi/asm/mman-fix.h b/tools/arch/sparc/include/uapi/asm/mman-fix.h
new file mode 100644
index 0000000..3ac4ba0
--- /dev/null
+++ b/tools/arch/sparc/include/uapi/asm/mman-fix.h
@@ -0,0 +1,11 @@ 
+#ifndef TOOLS_ARCH_SPARC_UAPI_ASM_MMAN_FIX_H
+#define TOOLS_ARCH_SPARC_UAPI_ASM_MMAN_FIX_H
+#include <sys/mman.h>
+#ifndef MAP_STACK
+#define MAP_STACK	0x20000
+#endif
+#ifndef MAP_HUGETLB
+#define MAP_HUGETLB	0x40000
+#endif
+#include <asm-generic/mman-fix.h>
+#endif // TOOLS_ARCH_SPARC_UAPI_ASM_MMAN_FIX_H
diff --git a/tools/arch/tile/include/uapi/asm/mman-fix.h b/tools/arch/tile/include/uapi/asm/mman-fix.h
new file mode 100644
index 0000000..105a3b0e
--- /dev/null
+++ b/tools/arch/tile/include/uapi/asm/mman-fix.h
@@ -0,0 +1,11 @@ 
+#ifndef TOOLS_ARCH_TILE_UAPI_ASM_MMAN_FIX_H
+#define TOOLS_ARCH_TILE_UAPI_ASM_MMAN_FIX_H
+#include <sys/mman.h>
+#ifndef MAP_STACK
+#define MAP_STACK	MAP_GROWSDOWN
+#endif
+#ifndef MAP_HUGETLB
+#define MAP_HUGETLB	0x4000
+#endif
+#include <asm-generic/mman-fix.h>
+#endif // TOOLS_ARCH_TILE_UAPI_ASM_MMAN_FIX_H
diff --git a/tools/arch/x86/include/uapi/asm/mman-fix.h b/tools/arch/x86/include/uapi/asm/mman-fix.h
new file mode 100644
index 0000000..0cda2bf
--- /dev/null
+++ b/tools/arch/x86/include/uapi/asm/mman-fix.h
@@ -0,0 +1,8 @@ 
+#ifndef TOOLS_ARCH_X86_UAPI_ASM_MMAN_FIX_H
+#define TOOLS_ARCH_X86_UAPI_ASM_MMAN_FIX_H
+#include <sys/mman.h>
+#ifndef MAP_32BIT
+#define MAP_32BIT	0x40
+#endif
+#include <asm-generic/mman-fix.h>
+#endif // TOOLS_ARCH_X86_UAPI_ASM_MMAN_FIX_H
diff --git a/tools/arch/xtensa/include/uapi/asm/mman-fix.h b/tools/arch/xtensa/include/uapi/asm/mman-fix.h
new file mode 100644
index 0000000..9ec9051
--- /dev/null
+++ b/tools/arch/xtensa/include/uapi/asm/mman-fix.h
@@ -0,0 +1,38 @@ 
+#ifndef TOOLS_ARCH_XTENSA_UAPI_ASM_MMAN_FIX_H
+#define TOOLS_ARCH_XTENSA_UAPI_ASM_MMAN_FIX_H
+#include <sys/mman.h>
+#ifndef PROT_SEM
+#define PROT_SEM	0x10
+#endif
+#ifndef MAP_FIXED
+#define MAP_FIXED	0x010
+#endif
+#ifndef MAP_ANONYMOUS
+#define MAP_ANONYMOUS	0x0800
+#endif
+#ifndef MAP_STACK
+#define MAP_STACK	0x40000
+#endif
+#ifndef MAP_HUGETLB
+#define MAP_HUGETLB	0x80000
+#endif
+#ifndef MADV_MERGEABLE
+#define MADV_MERGEABLE   12
+#endif
+#ifndef MADV_UNMERGEABLE
+#define MADV_UNMERGEABLE 13
+#endif
+#ifndef MADV_HUGEPAGE
+#define MADV_HUGEPAGE	14
+#endif
+#ifndef MADV_NOHUGEPAGE
+#define MADV_NOHUGEPAGE	15
+#endif
+#ifndef MADV_DONTDUMP
+#define MADV_DONTDUMP   16
+#endif
+#ifndef MADV_DODUMP
+#define MADV_DODUMP	17
+#endif
+#include <asm-generic/mman-fix.h>
+#endif // TOOLS_ARCH_XTENSA_UAPI_ASM_MMAN_FIX_H
diff --git a/tools/include/uapi/asm-generic/mman-fix.h b/tools/include/uapi/asm-generic/mman-fix.h
new file mode 100644
index 0000000..f47eb4c
--- /dev/null
+++ b/tools/include/uapi/asm-generic/mman-fix.h
@@ -0,0 +1,46 @@ 
+#ifndef __TOOLS_UAPI_ASM_MMAN_FIX_H
+#define __TOOLS_UAPI_ASM_MMAN_FIX_H
+#include <sys/mman.h>
+#ifndef PROT_SEM
+#define PROT_SEM	0x8
+#endif
+#ifndef MAP_FIXED
+#define MAP_FIXED	0x10
+#endif
+#ifndef MAP_ANONYMOUS
+#define MAP_ANONYMOUS	0x20
+#endif
+#ifndef MADV_HWPOISON
+#define MADV_HWPOISON	100
+#endif
+#ifndef MADV_SOFT_OFFLINE
+#define MADV_SOFT_OFFLINE 101
+#endif
+#ifndef MADV_MERGEABLE
+#define MADV_MERGEABLE   12
+#endif
+#ifndef MADV_UNMERGEABLE
+#define MADV_UNMERGEABLE 13
+#endif
+#ifndef MADV_HUGEPAGE
+#define MADV_HUGEPAGE	14
+#endif
+#ifndef MADV_NOHUGEPAGE
+#define MADV_NOHUGEPAGE	15
+#endif
+#ifndef MADV_DONTDUMP
+#define MADV_DONTDUMP   16
+#endif
+#ifndef MADV_DODUMP
+#define MADV_DODUMP	17
+#endif
+#ifndef MAP_STACK
+#define MAP_STACK	0x20000
+#endif
+#ifndef MAP_HUGETLB
+#define MAP_HUGETLB	0x40000
+#endif
+#ifndef MAP_UNINITIALIZED
+#define MAP_UNINITIALIZED 0x4000000
+#endif
+#endif // __TOOLS_UAPI_ASM_MMAN_FIX_H
diff --git a/tools/perf/MANIFEST b/tools/perf/MANIFEST
index ff200c6..56ac24f 100644
--- a/tools/perf/MANIFEST
+++ b/tools/perf/MANIFEST
@@ -66,6 +66,7 @@  tools/include/linux/hash.h
 tools/include/linux/kernel.h
 tools/include/linux/list.h
 tools/include/linux/log2.h
+tools/include/uapi/asm-generic/mman-fix.h
 tools/include/uapi/linux/bpf.h
 tools/include/uapi/linux/bpf_common.h
 tools/include/uapi/linux/hw_breakpoint.h
@@ -80,3 +81,4 @@  tools/include/linux/err.h
 tools/include/linux/bitmap.h
 tools/include/linux/time64.h
 tools/arch/*/include/uapi/asm/perf_regs.h
+tools/arch/*/include/uapi/asm/mman-fix.h