linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* kernel//trace/fgraph.c:111:35: error: 'MCOUNT_INSN_SIZE' undeclared; did you mean 'UCOUNT_COUNTS'?
@ 2020-01-01 18:09 kbuild test robot
  2020-01-03  3:07 ` Steven Rostedt
  0 siblings, 1 reply; 4+ messages in thread
From: kbuild test robot @ 2020-01-01 18:09 UTC (permalink / raw)
  To: Alexei Starovoitov; +Cc: kbuild-all, linux-kernel, Steven Rostedt (VMware)

[-- Attachment #1: Type: text/plain, Size: 2605 bytes --]

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   738d2902773e30939a982c8df7a7f94293659810
commit: ff205766dbbee024a4a716638868d98ffb17748a ftrace: Fix function_graph tracer interaction with BPF trampoline
date:   3 weeks ago
config: riscv-randconfig-a001-20200102 (attached as .config)
compiler: riscv64-linux-gcc (GCC) 7.5.0
reproduce:
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        git checkout ff205766dbbee024a4a716638868d98ffb17748a
        # save the attached .config to linux build tree
        GCC_VERSION=7.5.0 make.cross ARCH=riscv 

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

All errors (new ones prefixed by >>):

   kernel//trace/fgraph.c: In function 'function_graph_enter':
>> kernel//trace/fgraph.c:111:35: error: 'MCOUNT_INSN_SIZE' undeclared (first use in this function); did you mean 'UCOUNT_COUNTS'?
         ftrace_find_rec_direct(ret - MCOUNT_INSN_SIZE))
                                      ^~~~~~~~~~~~~~~~
                                      UCOUNT_COUNTS
   kernel//trace/fgraph.c:111:35: note: each undeclared identifier is reported only once for each function it appears in

vim +111 kernel//trace/fgraph.c

    98	
    99	int function_graph_enter(unsigned long ret, unsigned long func,
   100				 unsigned long frame_pointer, unsigned long *retp)
   101	{
   102		struct ftrace_graph_ent trace;
   103	
   104		/*
   105		 * Skip graph tracing if the return location is served by direct trampoline,
   106		 * since call sequence and return addresses is unpredicatable anymore.
   107		 * Ex: BPF trampoline may call original function and may skip frame
   108		 * depending on type of BPF programs attached.
   109		 */
   110		if (ftrace_direct_func_count &&
 > 111		    ftrace_find_rec_direct(ret - MCOUNT_INSN_SIZE))
   112			return -EBUSY;
   113		trace.func = func;
   114		trace.depth = ++current->curr_ret_depth;
   115	
   116		if (ftrace_push_return_trace(ret, func, frame_pointer, retp))
   117			goto out;
   118	
   119		/* Only trace if the calling function expects to */
   120		if (!ftrace_graph_entry(&trace))
   121			goto out_ret;
   122	
   123		return 0;
   124	 out_ret:
   125		current->curr_ret_stack--;
   126	 out:
   127		current->curr_ret_depth--;
   128		return -EBUSY;
   129	}
   130	

---
0-DAY kernel test infrastructure                 Open Source Technology Center
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org Intel Corporation

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 24697 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: kernel//trace/fgraph.c:111:35: error: 'MCOUNT_INSN_SIZE' undeclared; did you mean 'UCOUNT_COUNTS'?
  2020-01-01 18:09 kernel//trace/fgraph.c:111:35: error: 'MCOUNT_INSN_SIZE' undeclared; did you mean 'UCOUNT_COUNTS'? kbuild test robot
@ 2020-01-03  3:07 ` Steven Rostedt
  2020-01-03  3:09   ` [PATCH] tracing: Define MCOUNT_INSN_SIZE when not defined without direct calls Steven Rostedt
  2020-01-03  3:09   ` [PATCH] tracing: Have stack tracer compile when MCOUNT_INSN_SIZE is not defined Steven Rostedt
  0 siblings, 2 replies; 4+ messages in thread
From: Steven Rostedt @ 2020-01-03  3:07 UTC (permalink / raw)
  To: kbuild test robot; +Cc: Alexei Starovoitov, kbuild-all, linux-kernel

On Thu, 2 Jan 2020 02:09:22 +0800
kbuild test robot <lkp@intel.com> wrote:

> tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
> head:   738d2902773e30939a982c8df7a7f94293659810
> commit: ff205766dbbee024a4a716638868d98ffb17748a ftrace: Fix function_graph tracer interaction with BPF trampoline
> date:   3 weeks ago
> config: riscv-randconfig-a001-20200102 (attached as .config)
> compiler: riscv64-linux-gcc (GCC) 7.5.0
> reproduce:
>         wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
>         chmod +x ~/bin/make.cross
>         git checkout ff205766dbbee024a4a716638868d98ffb17748a
>         # save the attached .config to linux build tree
>         GCC_VERSION=7.5.0 make.cross ARCH=riscv 
> 
> If you fix the issue, kindly add following tag
> Reported-by: kbuild test robot <lkp@intel.com>
> 
> All errors (new ones prefixed by >>):
> 
>    kernel//trace/fgraph.c: In function 'function_graph_enter':
> >> kernel//trace/fgraph.c:111:35: error: 'MCOUNT_INSN_SIZE' undeclared (first use in this function); did you mean 'UCOUNT_COUNTS'?  
>          ftrace_find_rec_direct(ret - MCOUNT_INSN_SIZE))
>                                       ^~~~~~~~~~~~~~~~
>                                       UCOUNT_COUNTS
>    kernel//trace/fgraph.c:111:35: note: each undeclared identifier is reported only once for each function it appears in
> 
>

The next two patches should fix this. The second patch fixes a
different location with the same problem. It appears that without
DYNAMIC_FTRACE (which x86 always has now) that this isn't defined.

-- Steve

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH] tracing: Define MCOUNT_INSN_SIZE when not defined without direct calls
  2020-01-03  3:07 ` Steven Rostedt
@ 2020-01-03  3:09   ` Steven Rostedt
  2020-01-03  3:09   ` [PATCH] tracing: Have stack tracer compile when MCOUNT_INSN_SIZE is not defined Steven Rostedt
  1 sibling, 0 replies; 4+ messages in thread
From: Steven Rostedt @ 2020-01-03  3:09 UTC (permalink / raw)
  To: kbuild test robot; +Cc: Alexei Starovoitov, kbuild-all, linux-kernel


From: "Steven Rostedt (VMware)" <rostedt@goodmis.org>

In order to handle direct calls along side of function graph tracer, a check
is made to see if the address being traced by the function graph tracer is a
direct call or not. To get the address used by direct callers, the return
address is subtracted by MCOUNT_INSN_SIZE.

For some archs with certain configurations, MCOUNT_INSN_SIZE is undefined
here. But these should not be using direct calls anyway. Just define
MCOUNT_INSN_SIZE to zero in this case.

Link: https://lore.kernel.org/r/202001020219.zvE3vsty%lkp@intel.com

Reported-by: kbuild test robot <lkp@intel.com>
Fixes: ff205766dbbee ("ftrace: Fix function_graph tracer interaction with BPF trampoline")
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
---
 kernel/trace/fgraph.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/kernel/trace/fgraph.c b/kernel/trace/fgraph.c
index a2659735db73..1af321dec0f1 100644
--- a/kernel/trace/fgraph.c
+++ b/kernel/trace/fgraph.c
@@ -96,6 +96,20 @@ ftrace_push_return_trace(unsigned long ret, unsigned long func,
 	return 0;
 }
 
+/*
+ * Not all archs define MCOUNT_INSN_SIZE which is used to look for direct
+ * functions. But those archs currently don't support direct functions
+ * anyway, and ftrace_find_rec_direct() is just a stub for them.
+ * Define MCOUNT_INSN_SIZE to keep those archs compiling.
+ */
+#ifndef MCOUNT_INSN_SIZE
+/* Make sure this only works without direct calls */
+# ifdef CONFIG_DYNAMIC_FTRACE_WITH_DIRECT_CALLS
+#  error MCOUNT_INSN_SIZE not defined with direct calls enabled
+# endif
+# define MCOUNT_INSN_SIZE 0
+#endif
+
 int function_graph_enter(unsigned long ret, unsigned long func,
 			 unsigned long frame_pointer, unsigned long *retp)
 {
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH] tracing: Have stack tracer compile when MCOUNT_INSN_SIZE is not defined
  2020-01-03  3:07 ` Steven Rostedt
  2020-01-03  3:09   ` [PATCH] tracing: Define MCOUNT_INSN_SIZE when not defined without direct calls Steven Rostedt
@ 2020-01-03  3:09   ` Steven Rostedt
  1 sibling, 0 replies; 4+ messages in thread
From: Steven Rostedt @ 2020-01-03  3:09 UTC (permalink / raw)
  To: kbuild test robot; +Cc: Alexei Starovoitov, kbuild-all, linux-kernel


From: "Steven Rostedt (VMware)" <rostedt@goodmis.org>

On some archs with some configurations, MCOUNT_INSN_SIZE is not defined, and
this makes the stack tracer fail to compile. Just define it to zero in this
case.

Link: https://lore.kernel.org/r/202001020219.zvE3vsty%lkp@intel.com

Cc: stable@vger.kernel.org
Fixes: 4df297129f622 ("tracing: Remove most or all of stack tracer stack size from stack_max_size")
Reported-by: kbuild test robot <lkp@intel.com>
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
---
 kernel/trace/trace_stack.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/kernel/trace/trace_stack.c b/kernel/trace/trace_stack.c
index 4df9a209f7ca..c557f42a9397 100644
--- a/kernel/trace/trace_stack.c
+++ b/kernel/trace/trace_stack.c
@@ -283,6 +283,11 @@ static void check_stack(unsigned long ip, unsigned long *stack)
 	local_irq_restore(flags);
 }
 
+/* Some archs may not define MCOUNT_INSN_SIZE */
+#ifndef MCOUNT_INSN_SIZE
+# define MCOUNT_INSN_SIZE 0
+#endif
+
 static void
 stack_trace_call(unsigned long ip, unsigned long parent_ip,
 		 struct ftrace_ops *op, struct pt_regs *pt_regs)
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-01-03  3:09 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-01 18:09 kernel//trace/fgraph.c:111:35: error: 'MCOUNT_INSN_SIZE' undeclared; did you mean 'UCOUNT_COUNTS'? kbuild test robot
2020-01-03  3:07 ` Steven Rostedt
2020-01-03  3:09   ` [PATCH] tracing: Define MCOUNT_INSN_SIZE when not defined without direct calls Steven Rostedt
2020-01-03  3:09   ` [PATCH] tracing: Have stack tracer compile when MCOUNT_INSN_SIZE is not defined Steven Rostedt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).