diff mbox series

[4/7] mm/vmalloc: Use a trace_alloc_vmap_area event

Message ID 20221017160233.16582-7-urezki@gmail.com (mailing list archive)
State New
Headers show
Series Add basic trace events for vmap/vmalloc | expand

Commit Message

Uladzislau Rezki Oct. 17, 2022, 4:02 p.m. UTC
This is for debug purpose and is called when an allocation
attempt occurs. This event gives some information about:
- a start address of allocated area;
- a size that is requested;
- an align that is required;
- vstart/vend restriction;
- if an allocation fails.

Cc: Steven Rostedt <rostedt@goodmis.org>
Signed-off-by: Uladzislau Rezki (Sony) <urezki@gmail.com>
---
 mm/vmalloc.c | 5 +++++
 1 file changed, 5 insertions(+)

Comments

kernel test robot Oct. 17, 2022, 7:12 p.m. UTC | #1
Hi Uladzislau,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on akpm-mm/mm-everything]
[also build test ERROR on linus/master v6.1-rc1 next-20221017]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Uladzislau-Rezki-Sony/Add-basic-trace-events-for-vmap-vmalloc/20221018-000544
base:   https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git mm-everything
patch link:    https://lore.kernel.org/r/20221017160233.16582-7-urezki%40gmail.com
patch subject: [PATCH 4/7] mm/vmalloc: Use a trace_alloc_vmap_area event
config: um-i386_defconfig
compiler: gcc-11 (Debian 11.3.0-8) 11.3.0
reproduce (this is a W=1 build):
        # https://github.com/intel-lab-lkp/linux/commit/fbc853c689b29d3bb9fe250b2653fd2dd8046fc7
        git remote add linux-review https://github.com/intel-lab-lkp/linux
        git fetch --no-tags linux-review Uladzislau-Rezki-Sony/Add-basic-trace-events-for-vmap-vmalloc/20221018-000544
        git checkout fbc853c689b29d3bb9fe250b2653fd2dd8046fc7
        # save the config file
        mkdir build_dir && cp config build_dir/.config
        make W=1 O=build_dir ARCH=um SUBARCH=i386 SHELL=/bin/bash

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@intel.com>

All errors (new ones prefixed by >>):

   In file included from include/trace/events/vmap.h:123,
                    from mm/vmalloc.c:47:
>> include/trace/define_trace.h:84:34: fatal error: trace/events/kernel_vmap.h: No such file or directory
      84 | # define __TRACE_INCLUDE(system) <trace/events/system.h>
         |                                  ^
   compilation terminated.


vim +84 include/trace/define_trace.h

a8d154b0091683 Steven Rostedt 2009-04-10  82  
a8d154b0091683 Steven Rostedt 2009-04-10  83  #ifndef TRACE_INCLUDE_PATH
ad8d75fff811a6 Steven Rostedt 2009-04-14 @84  # define __TRACE_INCLUDE(system) <trace/events/system.h>
c2518c4366f087 Steven Rostedt 2009-04-23  85  # define UNDEF_TRACE_INCLUDE_PATH
a8d154b0091683 Steven Rostedt 2009-04-10  86  #else
a8d154b0091683 Steven Rostedt 2009-04-10  87  # define __TRACE_INCLUDE(system) __stringify(TRACE_INCLUDE_PATH/system.h)
a8d154b0091683 Steven Rostedt 2009-04-10  88  #endif
a8d154b0091683 Steven Rostedt 2009-04-10  89
Uladzislau Rezki Oct. 18, 2022, 4:17 p.m. UTC | #2
Hello, Steven.

> 
> [auto build test ERROR on akpm-mm/mm-everything]
> [also build test ERROR on linus/master v6.1-rc1 next-20221017]
> [If your patch is applied to the wrong git tree, kindly drop us a note.
> And when submitting patch, we suggest to use '--base' as documented in
> https://git-scm.com/docs/git-format-patch#_base_tree_information]
> 
> url:    https://github.com/intel-lab-lkp/linux/commits/Uladzislau-Rezki-Sony/Add-basic-trace-events-for-vmap-vmalloc/20221018-000544
> base:   https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git mm-everything
> patch link:    https://lore.kernel.org/r/20221017160233.16582-7-urezki%40gmail.com
> patch subject: [PATCH 4/7] mm/vmalloc: Use a trace_alloc_vmap_area event
> config: um-i386_defconfig
> compiler: gcc-11 (Debian 11.3.0-8) 11.3.0
> reproduce (this is a W=1 build):
>         # https://github.com/intel-lab-lkp/linux/commit/fbc853c689b29d3bb9fe250b2653fd2dd8046fc7
>         git remote add linux-review https://github.com/intel-lab-lkp/linux
>         git fetch --no-tags linux-review Uladzislau-Rezki-Sony/Add-basic-trace-events-for-vmap-vmalloc/20221018-000544
>         git checkout fbc853c689b29d3bb9fe250b2653fd2dd8046fc7
>         # save the config file
>         mkdir build_dir && cp config build_dir/.config
>         make W=1 O=build_dir ARCH=um SUBARCH=i386 SHELL=/bin/bash
> 
> If you fix the issue, kindly add following tag where applicable
> | Reported-by: kernel test robot <lkp@intel.com>
> 
> All errors (new ones prefixed by >>):
> 
>    In file included from include/trace/events/vmap.h:123,
>                     from mm/vmalloc.c:47:
> >> include/trace/define_trace.h:84:34: fatal error: trace/events/kernel_vmap.h: No such file or directory
>       84 | # define __TRACE_INCLUDE(system) <trace/events/system.h>
>          |                                  ^
>    compilation terminated.
>
I can reproduce it. It seems it happens so far only on the ARCH=um case.
For regular arm/x86 i do not see such build error.

If i rename the TRACE_SYSTEM macro to something different then "vmap"
it compiles fine. In case of:

#define TRACE_SYSTEM vmap

the prefix "kernel_" is added, thus the header name becomes as kernel_vmap.h

Steven can you give some indications? Or any thoughts about it?

Thank you in advance!

--
Uladzislau Rezki
Steven Rostedt Oct. 18, 2022, 4:44 p.m. UTC | #3
On Tue, 18 Oct 2022 18:17:55 +0200
Uladzislau Rezki <urezki@gmail.com> wrote:

> Hello, Steven.
> 
> > 
> > [auto build test ERROR on akpm-mm/mm-everything]
> > [also build test ERROR on linus/master v6.1-rc1 next-20221017]
> > [If your patch is applied to the wrong git tree, kindly drop us a note.
> > And when submitting patch, we suggest to use '--base' as documented in
> > https://git-scm.com/docs/git-format-patch#_base_tree_information]
> > 
> > url:    https://github.com/intel-lab-lkp/linux/commits/Uladzislau-Rezki-Sony/Add-basic-trace-events-for-vmap-vmalloc/20221018-000544
> > base:   https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git mm-everything
> > patch link:    https://lore.kernel.org/r/20221017160233.16582-7-urezki%40gmail.com
> > patch subject: [PATCH 4/7] mm/vmalloc: Use a trace_alloc_vmap_area event
> > config: um-i386_defconfig
> > compiler: gcc-11 (Debian 11.3.0-8) 11.3.0
> > reproduce (this is a W=1 build):
> >         # https://github.com/intel-lab-lkp/linux/commit/fbc853c689b29d3bb9fe250b2653fd2dd8046fc7
> >         git remote add linux-review https://github.com/intel-lab-lkp/linux
> >         git fetch --no-tags linux-review Uladzislau-Rezki-Sony/Add-basic-trace-events-for-vmap-vmalloc/20221018-000544
> >         git checkout fbc853c689b29d3bb9fe250b2653fd2dd8046fc7
> >         # save the config file
> >         mkdir build_dir && cp config build_dir/.config
> >         make W=1 O=build_dir ARCH=um SUBARCH=i386 SHELL=/bin/bash
> > 
> > If you fix the issue, kindly add following tag where applicable
> > | Reported-by: kernel test robot <lkp@intel.com>
> > 
> > All errors (new ones prefixed by >>):
> > 
> >    In file included from include/trace/events/vmap.h:123,
> >                     from mm/vmalloc.c:47:  
> > >> include/trace/define_trace.h:84:34: fatal error: trace/events/kernel_vmap.h: No such file or directory  
> >       84 | # define __TRACE_INCLUDE(system) <trace/events/system.h>
> >          |                                  ^
> >    compilation terminated.
> >  
> I can reproduce it. It seems it happens so far only on the ARCH=um case.
> For regular arm/x86 i do not see such build error.
> 
> If i rename the TRACE_SYSTEM macro to something different then "vmap"
> it compiles fine. In case of:
> 
> #define TRACE_SYSTEM vmap
> 
> the prefix "kernel_" is added, thus the header name becomes as kernel_vmap.h
> 
> Steven can you give some indications? Or any thoughts about it?
> 
> Thank you in advance!

It comes from this:

   arch/um/Makefile:# -Dvmap=kernel_vmap prevents anything from referencing the libpcap.o symbol so
   arch/um/Makefile:       $(ARCH_INCLUDE) $(MODE_INCLUDE) -Dvmap=kernel_vmap      \


It defines "vmap" to "kernel_vmap" which will change the above
TRACE_SYSTEM Define to:

  #define TRACE_SYSTEM kernel_vmap

and that will confuse everything else.

-- Steve


> 
> --
> Uladzislau Rezki
Uladzislau Rezki Oct. 18, 2022, 4:55 p.m. UTC | #4
On Tue, Oct 18, 2022 at 12:44:12PM -0400, Steven Rostedt wrote:
> On Tue, 18 Oct 2022 18:17:55 +0200
> Uladzislau Rezki <urezki@gmail.com> wrote:
> 
> > Hello, Steven.
> > 
> > > 
> > > [auto build test ERROR on akpm-mm/mm-everything]
> > > [also build test ERROR on linus/master v6.1-rc1 next-20221017]
> > > [If your patch is applied to the wrong git tree, kindly drop us a note.
> > > And when submitting patch, we suggest to use '--base' as documented in
> > > https://git-scm.com/docs/git-format-patch#_base_tree_information]
> > > 
> > > url:    https://github.com/intel-lab-lkp/linux/commits/Uladzislau-Rezki-Sony/Add-basic-trace-events-for-vmap-vmalloc/20221018-000544
> > > base:   https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git mm-everything
> > > patch link:    https://lore.kernel.org/r/20221017160233.16582-7-urezki%40gmail.com
> > > patch subject: [PATCH 4/7] mm/vmalloc: Use a trace_alloc_vmap_area event
> > > config: um-i386_defconfig
> > > compiler: gcc-11 (Debian 11.3.0-8) 11.3.0
> > > reproduce (this is a W=1 build):
> > >         # https://github.com/intel-lab-lkp/linux/commit/fbc853c689b29d3bb9fe250b2653fd2dd8046fc7
> > >         git remote add linux-review https://github.com/intel-lab-lkp/linux
> > >         git fetch --no-tags linux-review Uladzislau-Rezki-Sony/Add-basic-trace-events-for-vmap-vmalloc/20221018-000544
> > >         git checkout fbc853c689b29d3bb9fe250b2653fd2dd8046fc7
> > >         # save the config file
> > >         mkdir build_dir && cp config build_dir/.config
> > >         make W=1 O=build_dir ARCH=um SUBARCH=i386 SHELL=/bin/bash
> > > 
> > > If you fix the issue, kindly add following tag where applicable
> > > | Reported-by: kernel test robot <lkp@intel.com>
> > > 
> > > All errors (new ones prefixed by >>):
> > > 
> > >    In file included from include/trace/events/vmap.h:123,
> > >                     from mm/vmalloc.c:47:  
> > > >> include/trace/define_trace.h:84:34: fatal error: trace/events/kernel_vmap.h: No such file or directory  
> > >       84 | # define __TRACE_INCLUDE(system) <trace/events/system.h>
> > >          |                                  ^
> > >    compilation terminated.
> > >  
> > I can reproduce it. It seems it happens so far only on the ARCH=um case.
> > For regular arm/x86 i do not see such build error.
> > 
> > If i rename the TRACE_SYSTEM macro to something different then "vmap"
> > it compiles fine. In case of:
> > 
> > #define TRACE_SYSTEM vmap
> > 
> > the prefix "kernel_" is added, thus the header name becomes as kernel_vmap.h
> > 
> > Steven can you give some indications? Or any thoughts about it?
> > 
> > Thank you in advance!
> 
> It comes from this:
> 
>    arch/um/Makefile:# -Dvmap=kernel_vmap prevents anything from referencing the libpcap.o symbol so
>    arch/um/Makefile:       $(ARCH_INCLUDE) $(MODE_INCLUDE) -Dvmap=kernel_vmap      \
> 
> 
> It defines "vmap" to "kernel_vmap" which will change the above
> TRACE_SYSTEM Define to:
> 
>   #define TRACE_SYSTEM kernel_vmap
> 
> and that will confuse everything else.
> 
Hm... Right then it goes completely crazy. So there is only one option
it is to rename the trace header defined by the TRACE_SYSTEM.

Thank you for your help :)

--
Uladzislau Rezki
diff mbox series

Patch

diff --git a/mm/vmalloc.c b/mm/vmalloc.c
index 83b54beb12fa..f4397817ccd7 100644
--- a/mm/vmalloc.c
+++ b/mm/vmalloc.c
@@ -43,6 +43,9 @@ 
 #include <asm/tlbflush.h>
 #include <asm/shmparam.h>
 
+#define CREATE_TRACE_POINTS
+#include <trace/events/vmap.h>
+
 #include "internal.h"
 #include "pgalloc-track.h"
 
@@ -1621,6 +1624,8 @@  static struct vmap_area *alloc_vmap_area(unsigned long size,
 		size, align, vstart, vend);
 	spin_unlock(&free_vmap_area_lock);
 
+	trace_alloc_vmap_area(addr, size, align, vstart, vend, addr == vend);
+
 	/*
 	 * If an allocation fails, the "vend" address is
 	 * returned. Therefore trigger the overflow path.