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 E5B7AC282D7 for ; Wed, 30 Jan 2019 10:38:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B85AA218A4 for ; Wed, 30 Jan 2019 10:38:04 +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="DPucvsXB" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729498AbfA3KiD (ORCPT ); Wed, 30 Jan 2019 05:38:03 -0500 Received: from merlin.infradead.org ([205.233.59.134]:47114 "EHLO merlin.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726548AbfA3KiD (ORCPT ); Wed, 30 Jan 2019 05:38:03 -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=xGHgItkCOpd2iHh5LhL9CpPGhKKHuv766sr1gAk4iYk=; b=DPucvsXBGMBrbMs7qEUN5N3ZB v/HUYK0MHE9IpqOZu2+UWS548eu6Ic1k+bkswplKoy6yb+OtlUwBVwKuqx0oYtpf3O3IpYJZt3JbQ y2HSc3MkQzXS5j8xMN0GdIqwnj84Lj/LHkriwcJKmQhS4vilKOT5qemplzYQ0SVtZ33BK6dvFgiC/ xkm5YEmTNlbEJH9ITpPuYuosLehNI58pS5geT50IsGN5IVglzfQkyhYbyS693WUegBTF6qXDZiLsb MOQIopZYt+2za/f6owvuPkW40AnyE+jlaKciUFwRaWfzlN4w1yfRmumEv48HFkibliZiWTfQWeFXo 7UqKAc+cw==; 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 1gonFk-0008E7-1b; Wed, 30 Jan 2019 10:37:56 +0000 Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id C0D7020276ABC; Wed, 30 Jan 2019 11:37:54 +0100 (CET) Date: Wed, 30 Jan 2019 11:37:54 +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: <20190130103754.GA3103@hirez.programming.kicks-ass.net> References: <20190130040458.2544340-1-ast@kernel.org> <20190130040458.2544340-4-ast@kernel.org> <20190130101058.GD2278@hirez.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190130101058.GD2278@hirez.programming.kicks-ass.net> 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 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(). > >