public inbox for netdev@vger.kernel.org 
 help / color / mirror / Atom feed
From: Peter Zijlstra <peterz@infradead•org>
To: Alexei Starovoitov <ast@kernel•org>
Cc: davem@davemloft•net, daniel@iogearbox•net, edumazet@google•com,
	jannh@google•com, netdev@vger•kernel.org, kernel-team@fb•com
Subject: Re: [PATCH bpf-next 3/4] bpf: fix lockdep false positive in bpf_prog_register
Date: Wed, 30 Jan 2019 11:37:54 +0100	[thread overview]
Message-ID: <20190130103754.GA3103@hirez.programming.kicks-ass.net> (raw)
In-Reply-To: <20190130101058.GD2278@hirez.programming.kicks-ass.net>

On Wed, Jan 30, 2019 at 11:10:58AM +0100, Peter Zijlstra wrote:
> On Tue, Jan 29, 2019 at 08:04:57PM -0800, Alexei Starovoitov wrote:
> > Lockdep warns about false positive:
> 
> The report reads like:
> 
> 	tracepoint_probe_register()
> #0	  mutex_lock(&tracepoint_mutex)
> 	  tracepoint_add_func()
> 	    static_key_slow_inc()
> #1	      cpus_read_lock();
> 
> 
> 	_cpu_up()
> #1	  cpus_write_lock();
> 	  ...
> 	  perf_event_init_cpu()
> #2	    mutex_lock(&pmus_lock);
> #3	    mutex_lock(&ctx->mutex);
> 
> 
> 	perf_ioctl()
> #4	  perf_event_ctx_lock();

Sorry, that's #3, and then do s/#5/#4/ on the rest of the text.

> 	  _perf_ioctl(IOC_QUERY_BPF)
> 	    perf_event_query_prog_array()
> #5	      mutex_lock(&bpf_event_mutex);
> 
> 
> 	bpf_probe_register()
> #5	  mutex_lock(&bpf_event_mutex);
> 	  __bpf_probe_register()
> 	    tracepoint_probe_register()
> #0	      mutex_lock(&tracepoint_mutex);
> 
> Which to me reads like an entirely valid deadlock scenario.
> 
> And note that the first and last can be combined to give:
> 
> 	bpf_probe_register()
> #5	  mutex_lock(&bpf_event_mutex);
> 	  __bpf_probe_register()
> 	    tracepoint_probe_register()
> #0	      mutex_lock(&tracepoint_mutex);
> 	      tracepoint_add_func()
> 	        static_key_slow_inc()
> #1		  cpus_read_lock();
> 
> 
> Which generates a deadlock even without #0.
> 
> Why do you say this is not possible? All you need is 3 CPUs, one doing a
> CPU online, one doing a perf ioctl() and one doing that
> bpf_probe_register().
> 
> 

  reply	other threads:[~2019-01-30 10:38 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-30  4:04 [PATCH bpf-next 0/4] bpf: fixes for lockdep and deadlock Alexei Starovoitov
2019-01-30  4:04 ` [PATCH bpf-next 1/4] bpf: fix lockdep false positive in percpu_freelist Alexei Starovoitov
2019-01-30 10:21   ` Peter Zijlstra
2019-01-30 19:27     ` Alexei Starovoitov
2019-01-30 19:53       ` Peter Zijlstra
2019-01-30 20:18         ` Alexei Starovoitov
2019-01-30  4:04 ` [PATCH bpf-next 2/4] bpf: fix lockdep false positive in stackmap Alexei Starovoitov
2019-01-30 10:15   ` Peter Zijlstra
2019-01-30 19:30     ` Alexei Starovoitov
2019-01-30 19:42       ` Waiman Long
2019-01-30 20:10         ` Alexei Starovoitov
2019-01-30 21:11           ` Waiman Long
2019-01-30 21:32             ` Waiman Long
2019-01-31  2:01               ` Alexei Starovoitov
2019-01-31  2:48                 ` Waiman Long
2019-02-06  3:21                   ` Eric Dumazet
2019-02-06  3:30                     ` Alexei Starovoitov
2019-02-06  3:40                       ` Eric Dumazet
2019-01-30 19:44       ` Peter Zijlstra
2019-01-30 20:05         ` Waiman Long
2019-01-30  4:04 ` [PATCH bpf-next 3/4] bpf: fix lockdep false positive in bpf_prog_register Alexei Starovoitov
2019-01-30 10:10   ` Peter Zijlstra
2019-01-30 10:37     ` Peter Zijlstra [this message]
2019-01-30 19:32     ` Alexei Starovoitov
2019-01-30 19:46       ` Peter Zijlstra
2019-01-30  4:04 ` [PATCH bpf-next 4/4] bpf: Fix syscall's stackmap lookup potential deadlock Alexei Starovoitov
2019-01-30  4:07 ` [PATCH bpf-next 0/4] bpf: fixes for lockdep and deadlock Alexei Starovoitov

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=20190130103754.GA3103@hirez.programming.kicks-ass.net \
    --to=peterz@infradead$(echo .)org \
    --cc=ast@kernel$(echo .)org \
    --cc=daniel@iogearbox$(echo .)net \
    --cc=davem@davemloft$(echo .)net \
    --cc=edumazet@google$(echo .)com \
    --cc=jannh@google$(echo .)com \
    --cc=kernel-team@fb$(echo .)com \
    --cc=netdev@vger$(echo .)kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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