From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.3 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_PASS,USER_AGENT_MUTT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7C2BFC282D7 for ; Wed, 30 Jan 2019 10:11:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3D4BE2184D for ; Wed, 30 Jan 2019 10:11:24 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="zyNliLZN" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730574AbfA3KLX (ORCPT ); Wed, 30 Jan 2019 05:11:23 -0500 Received: from merlin.infradead.org ([205.233.59.134]:46798 "EHLO merlin.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727770AbfA3KLX (ORCPT ); Wed, 30 Jan 2019 05:11:23 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=Y02wwZRa5mA4Cj/a8Cw/DyCa1GY5MKdyschv9TLkKYs=; b=zyNliLZN5iR250O2Y3PMgr7LR gh36jj4CsuYLSuTyC+s8QgO2t3cHODmVa4/ZjvX7+IkQKo5Gsu3T7pB2ayhcWLQj2h95/nDdKcOFh ejELKYSOiTZfixxxOZ8/dQz22Kmc20YN0dWGq0+c6uG6ybKGKeJB7QiaH5pyGFvIVQS7vB5imlVB9 /VFIBLyYufinCoblzy/u6SGQ6kHl7TjCDFWijOeLylhY31vpP9CyTZFSxhoSIEsOvF+l2IMU2qu2v FAOigRGshZa4T84icQ8yJJXeR4h0cKH6zM1udNkLtsbFaX8iZugvZWQZFyc4fL4Wv4SbMV6xXNO3I TEkjfV4XQ==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=hirez.programming.kicks-ass.net) by merlin.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1gompj-0007sy-Iv; Wed, 30 Jan 2019 10:11:03 +0000 Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id A4E8B206E8A8F; Wed, 30 Jan 2019 11:10:58 +0100 (CET) Date: Wed, 30 Jan 2019 11:10:58 +0100 From: Peter Zijlstra To: Alexei Starovoitov 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 Message-ID: <20190130101058.GD2278@hirez.programming.kicks-ass.net> References: <20190130040458.2544340-1-ast@kernel.org> <20190130040458.2544340-4-ast@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190130040458.2544340-4-ast@kernel.org> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org 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(); _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().