Linux C-SKY architecture development
 help / color / mirror / Atom feed
From: Steven Rostedt <rostedt@goodmis.org>
To: guoren@kernel.org
Cc: mingo@redhat.com, linux-kernel@vger.kernel.org,
	linux-csky@vger.kernel.org, Guo Ren <guoren@linux.alibaba.com>
Subject: Re: [PATCH] ftrace: Fixup lockdep assert held of text_mutex
Date: Thu, 6 Aug 2020 11:48:50 -0400	[thread overview]
Message-ID: <20200806114850.051f84d0@oasis.local.home> (raw)
In-Reply-To: <1596725454-16245-1-git-send-email-guoren@kernel.org>

On Thu,  6 Aug 2020 14:50:54 +0000
guoren@kernel.org wrote:

> From: Guo Ren <guoren@linux.alibaba.com>
> 
> The function ftrace_process_locs() will modify text code, so we
> should give a text_mutex lock. Because some arch's patch code
> will assert held of text_mutex even during start_kernel->
> ftrace_init().

NAK.

This looks like a bug in the lockdep_assert_held() in whatever arch
(riscv) is running.

> 
> backtrace log:
>    assert by lockdep_assert_held(&text_mutex)
> 0  patch_insn_write (addr=0xffffffe0000010fc <set_reset_devices+10>, insn=0xffffffe001203eb8, len=8) at arch/riscv/kernel/patch.c:63
> 1  0xffffffe0002042ec in patch_text_nosync (addr=<optimized out>, insns=<optimized out>, len=<optimized out>) at arch/riscv/kernel/patch.c:93
> 2  0xffffffe00020628e in __ftrace_modify_call (hook_pos=<optimized out>, target=<optimized out>, enable=<optimized out>) at arch/riscv/kernel/ftrace.c:68
> 3  0xffffffe0002063c0 in ftrace_make_nop (mod=<optimized out>, rec=0xffffffe001221c70 <text_mutex+96>, addr=18446743936272720288) at arch/riscv/kernel/ftrace.c:97
> 4  0xffffffe0002b13f0 in ftrace_init_nop (rec=<optimized out>, mod=<optimized out>) at ./include/linux/ftrace.h:647
> 5  ftrace_nop_initialize (rec=<optimized out>, mod=<optimized out>) at kernel/trace/ftrace.c:2619
> 6  ftrace_update_code (new_pgs=<optimized out>, mod=<optimized out>) at kernel/trace/ftrace.c:3063
> 7  ftrace_process_locs (mod=<optimized out>, start=<optimized out>, end=<optimized out>) at kernel/trace/ftrace.c:6154
> 8  0xffffffe00000b6e6 in ftrace_init () at kernel/trace/ftrace.c:6715
> 9  0xffffffe000001b48 in start_kernel () at init/main.c:888
> 10 0xffffffe0000010a8 in _start_kernel () at arch/riscv/kernel/head.S:247
> 
> Signed-off-by: Guo Ren <guoren@linux.alibaba.com>
> Cc: Steven Rostedt <rostedt@goodmis.org>
> Cc: Ingo Molnar <mingo@redhat.com>
> ---
>  kernel/trace/ftrace.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
> index 1903b80..4b48b88 100644
> --- a/kernel/trace/ftrace.c
> +++ b/kernel/trace/ftrace.c
> @@ -26,6 +26,7 @@
>  #include <linux/uaccess.h>
>  #include <linux/bsearch.h>
>  #include <linux/module.h>
> +#include <linux/memory.h>
>  #include <linux/ftrace.h>
>  #include <linux/sysctl.h>
>  #include <linux/slab.h>
> @@ -6712,9 +6713,11 @@ void __init ftrace_init(void)

ftrace_init() is called before SMP is initialized. Nothing else should
be running here. That means grabbing a mutex is useless.

-- Steve


>  
>  	last_ftrace_enabled = ftrace_enabled = 1;
>  
> +	mutex_lock(&text_mutex);
>  	ret = ftrace_process_locs(NULL,
>  				  __start_mcount_loc,
>  				  __stop_mcount_loc);
> +	mutex_unlock(&text_mutex);
>  
>  	pr_info("ftrace: allocated %ld pages with %ld groups\n",
>  		ftrace_number_of_pages, ftrace_number_of_groups);


  reply	other threads:[~2020-08-06 16:54 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-06 14:50 [PATCH] ftrace: Fixup lockdep assert held of text_mutex guoren
2020-08-06 15:48 ` Steven Rostedt [this message]
2020-08-07  2:59   ` Guo Ren
2020-08-07  4:01     ` Steven Rostedt
2020-08-07  5:01       ` Guo Ren
2020-08-13  5:13         ` Palmer Dabbelt
2020-08-13 15:37           ` Steven Rostedt
2020-08-25  0:29             ` Palmer Dabbelt
2020-08-26 18:53               ` Steven Rostedt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200806114850.051f84d0@oasis.local.home \
    --to=rostedt@goodmis.org \
    --cc=guoren@kernel.org \
    --cc=guoren@linux.alibaba.com \
    --cc=linux-csky@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox