Received: by 2002:a05:6a10:6d25:0:0:0:0 with SMTP id gq37csp1701709pxb; Mon, 13 Sep 2021 03:40:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxWENZw/SjMdpN7CwPWsIfTz/eBK9cLfS5wOIl46qJ3u+RoPDGg4rHMqnONXCYX5Fut7Lx2 X-Received: by 2002:a6b:3c16:: with SMTP id k22mr8460447iob.130.1631529644330; Mon, 13 Sep 2021 03:40:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631529644; cv=none; d=google.com; s=arc-20160816; b=kdupkTTGEfvvq0HjHJeGmM/Iv82czH99PtXnqJt+B9hp2ZnREIbScXPYV9okVFuQQz iK5YN8sPHsg5sJB36kX1Ydn5vG2LgfYMtdqyyQ33vPPsE2hOyIUBFWkz8xXAHnaRZLoy isyhNSoJT6uTsEzgwV3Ao23DzTRT79jzkhK585NaXFC8So5EfyZy0C+vhCo07Hc8lQev P80UWvsd1OjVOFB3IIZDtoSYP71ouRp7PvR3N965BTdx2O7S6F3Vw8s0yeLKIb+dc19o ggbwBflcxJ3khJay6io5GWLuSednfcbBPYvXCaw1tQczgGztjUTWBLK+/il18PZtCLOY TG4w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=5cZgY+h2VLjKmM5rPcBYeoFqyIYGYh7lJNiFwhwUejg=; b=xTn82/OamJjG/iO6okizHLIvBI9W5eKXr8SA+8q/HkqnnOKx6g3JCgIBobWY1AD3UY VhaGm4dtHRqs4NTGQX/II8i+DhHKaan6wq1QTW90yWYurbpTXMrIKYM6rncb6pr+s8vy ozOnBY4+NhGEVEU56CmbhREuKaytjlH0DmXg9naAiYQVUjS7IUkoYKpULL/KXitP3TOO 3vuUFbDUqXAVo5+1G437/qfSbmKsKoRpdPkyrrGjTEqLVot9PYTNEMSaP+Ld6+PUGHOp n0lsA1R83x6imfv97YVk83jKdTIF1JQHSyjA1UJ151XIyslwpz96k045rGTuDvKSB0Pj 6vLg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=desiato.20200630 header.b=YxO+yq6N; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id 13si5951579ily.171.2021.09.13.03.40.33; Mon, 13 Sep 2021 03:40:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=desiato.20200630 header.b=YxO+yq6N; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239150AbhIMKiI (ORCPT + 99 others); Mon, 13 Sep 2021 06:38:08 -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-kernel@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. > >