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=-5.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=no 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 6C8AAC433FE for ; Mon, 13 Sep 2021 10:36:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 57E4660F9B for ; Mon, 13 Sep 2021 10:36:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239132AbhIMKiH (ORCPT ); Mon, 13 Sep 2021 06:38:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48660 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239136AbhIMKiG (ORCPT ); Mon, 13 Sep 2021 06:38:06 -0400 Received: from desiato.infradead.org (desiato.infradead.org [IPv6:2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 918DBC061574; Mon, 13 Sep 2021 03:36:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; 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; bh=5cZgY+h2VLjKmM5rPcBYeoFqyIYGYh7lJNiFwhwUejg=; b=YxO+yq6Nfw5pNJZd/1y0ZUCWiD k78zpd8bvVZfIfpZ7hJXZybcBf6kxzts0xeKzu+yGsyZMVUMDwziMzmsbw2J3YOKlQWyVqCzDpH4a XSzBo14adAxwPXr9cC8z/6g1AYP7p8HmU6vxwjoWjLUz0Y9W38th8T8MuBI1Tke4ye1ego6CGmdCM O6/w+vxst0O1/35362z/HiWz/JuQxQVdA43OkjvigMb/wvbjmyNeVyiHfPKIqpwkmmkzyAkeOPlrv M0vA0SjNlgsn59ZIGLoArrcRO6d2gVNnohzjGmPABM3teK3os4xLl8GAvajPCehEpENIkabUQ0Q9l Nt4xcP8w==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=noisy.programming.kicks-ass.net) by desiato.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1mPjKH-002nu6-3p; Mon, 13 Sep 2021 10:36:37 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id 63601300047; Mon, 13 Sep 2021 12:36:36 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 241292BDAF0DC; Mon, 13 Sep 2021 12:36:36 +0200 (CEST) Date: Mon, 13 Sep 2021 12:36:36 +0200 From: Peter Zijlstra To: =?utf-8?B?546L6LSH?= Cc: Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , "open list:PERFORMANCE EVENTS SUBSYSTEM" , "open list:PERFORMANCE EVENTS SUBSYSTEM" , "open list:BPF (Safe dynamic programs and tools)" , "open list:BPF (Safe dynamic programs and tools)" Subject: Re: [RFC PATCH] perf: fix panic by mark recursion inside perf_log_throttle Message-ID: References: <20210910153839.GH4323@worktop.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-perf-users@vger.kernel.org On Mon, Sep 13, 2021 at 12:24:24PM +0200, Peter Zijlstra wrote: FWIW: > I'm confused tho; where does the #DF come from? Because taking a #PF > from NMI should be perfectly fine. > > AFAICT that callchain is something like: > > NMI > perf_event_nmi_handler() > (part of the chain is missing here) > perf_log_throttle() > perf_output_begin() /* events/ring_buffer.c */ > rcu_read_lock() > rcu_lock_acquire() > lock_acquire() > trace_lock_acquire() --> perf_trace_foo This function also calls perf_trace_buf_alloc(), and will have incremented the recursion count, such that: > > ... > perf_callchain() > perf_callchain_user() > #PF (fully expected during a userspace callchain) > (some stuff, until the first __fentry) > perf_trace_function_call > perf_trace_buf_alloc() > perf_swevent_get_recursion_context() > *BOOM* this one, if it wouldn't mysteriously explode, would find recursion and terminate, except that seems to be going side-ways. > Now, supposedly we then take another #PF from get_recursion_context() or > something, but that doesn't make sense. That should just work... > > Can you figure out what's going wrong there? going with the RIP, this > almost looks like 'swhash->recursion' goes splat, but again that makes > no sense, that's a per-cpu variable. > >