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=-7.2 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE, SPF_PASS,UNPARSEABLE_RELAY,USER_AGENT_SANE_1 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 ADEE1C433EF for ; Tue, 14 Sep 2021 02:02:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8F06960295 for ; Tue, 14 Sep 2021 02:02:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236260AbhINCDk (ORCPT ); Mon, 13 Sep 2021 22:03:40 -0400 Received: from out30-42.freemail.mail.aliyun.com ([115.124.30.42]:45460 "EHLO out30-42.freemail.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235913AbhINCD2 (ORCPT ); Mon, 13 Sep 2021 22:03:28 -0400 X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R201e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e04400;MF=yun.wang@linux.alibaba.com;NM=1;PH=DS;RN=19;SR=0;TI=SMTPD_---0UoJjVVb_1631584927; Received: from testdeMacBook-Pro.local(mailfrom:yun.wang@linux.alibaba.com fp:SMTPD_---0UoJjVVb_1631584927) by smtp.aliyun-inc.com(127.0.0.1); Tue, 14 Sep 2021 10:02:08 +0800 Subject: Re: [RFC PATCH] perf: fix panic by mark recursion inside perf_log_throttle To: Peter Zijlstra 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)" References: <20210910153839.GH4323@worktop.programming.kicks-ass.net> From: =?UTF-8?B?546L6LSH?= Message-ID: <6aefb972-3691-2b66-a189-97815df10a12@linux.alibaba.com> Date: Tue, 14 Sep 2021 10:02:07 +0800 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:78.0) Gecko/20100101 Thunderbird/78.14.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2021/9/13 下午6:36, Peter Zijlstra wrote: > 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. Yes, it supposed to avoid recursion in the same context, but it never got chance to do that, the function and struct should all be fine, any idea in such situation what can trigger this kind of double fault? Regards, Michael Wang > >> 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. >> >>