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=-8.8 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=unavailable 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 5C7CBC433F5 for ; Mon, 13 Sep 2021 03:21:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 424A360E94 for ; Mon, 13 Sep 2021 03:21:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238393AbhIMDWv (ORCPT ); Sun, 12 Sep 2021 23:22:51 -0400 Received: from out30-133.freemail.mail.aliyun.com ([115.124.30.133]:47051 "EHLO out30-133.freemail.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238372AbhIMDWt (ORCPT ); Sun, 12 Sep 2021 23:22:49 -0400 X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R481e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e04426;MF=yun.wang@linux.alibaba.com;NM=1;PH=DS;RN=19;SR=0;TI=SMTPD_---0Uo6s7Rx_1631503290; Received: from testdeMacBook-Pro.local(mailfrom:yun.wang@linux.alibaba.com fp:SMTPD_---0Uo6s7Rx_1631503290) by smtp.aliyun-inc.com(127.0.0.1); Mon, 13 Sep 2021 11:21:31 +0800 Subject: Re: [RFC PATCH] perf: fix panic by mark recursion inside perf_log_throttle From: =?UTF-8?B?546L6LSH?= 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> Message-ID: <7aa8133d-a9e4-f0ae-7c98-4a38f0ca25d9@linux.alibaba.com> Date: Mon, 13 Sep 2021 11:21:30 +0800 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:78.0) Gecko/20100101 Thunderbird/78.13.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 上午11:00, 王贇 wrote: > > > On 2021/9/10 下午11:38, Peter Zijlstra wrote: >> On Thu, Sep 09, 2021 at 11:13:21AM +0800, 王贇 wrote: >>> When running with ftrace function enabled, we observed panic >>> as below: >>> >>> traps: PANIC: double fault, error_code: 0x0 >>> [snip] >>> RIP: 0010:perf_swevent_get_recursion_context+0x0/0x70 >>> [snip] >>> Call Trace: >>> >>> perf_trace_buf_alloc+0x26/0xd0 >>> perf_ftrace_function_call+0x18f/0x2e0 >>> kernelmode_fixup_or_oops+0x5/0x120 >>> __bad_area_nosemaphore+0x1b8/0x280 >>> do_user_addr_fault+0x410/0x920 >>> exc_page_fault+0x92/0x300 >>> asm_exc_page_fault+0x1e/0x30 >>> RIP: 0010:__get_user_nocheck_8+0x6/0x13 >>> perf_callchain_user+0x266/0x2f0 >>> get_perf_callchain+0x194/0x210 >>> perf_callchain+0xa3/0xc0 >>> perf_prepare_sample+0xa5/0xa60 >>> perf_event_output_forward+0x7b/0x1b0 >>> __perf_event_overflow+0x67/0x120 >>> perf_swevent_overflow+0xcb/0x110 >>> perf_swevent_event+0xb0/0xf0 >>> perf_tp_event+0x292/0x410 >>> perf_trace_run_bpf_submit+0x87/0xc0 >>> perf_trace_lock_acquire+0x12b/0x170 >>> lock_acquire+0x1bf/0x2e0 >>> perf_output_begin+0x70/0x4b0 >>> perf_log_throttle+0xe2/0x1a0 >>> perf_event_nmi_handler+0x30/0x50 >>> nmi_handle+0xba/0x2a0 >>> default_do_nmi+0x45/0xf0 >>> exc_nmi+0x155/0x170 >>> end_repeat_nmi+0x16/0x55 >> >> kernel/events/Makefile has: >> >> ifdef CONFIG_FUNCTION_TRACER >> CFLAGS_REMOVE_core.o = $(CC_FLAGS_FTRACE) >> endif >> >> Which, afaict, should avoid the above, no? > > I'm afraid it's not working for this case, the > start point of tracing is at lock_acquire() which > is not from 'kernel/events/core', the following PF > related function are also not from 'core', prevent > ftrace on 'core' can't prevent this from happen... By a second thinking, I think you're right about the way it should be fixed, since disabling ftrace on 'arch/x86/mm/fault.c' could also fix the problem. Will send a formal patch later :-) Regards, Michael Wang > > Regards, > Michael Wang > >>