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 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 77914C433F5 for ; Mon, 11 Oct 2021 14:47:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 60C0960551 for ; Mon, 11 Oct 2021 14:47:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238878AbhJKOtV (ORCPT ); Mon, 11 Oct 2021 10:49:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48064 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238914AbhJKOtS (ORCPT ); Mon, 11 Oct 2021 10:49:18 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DA135C061570 for ; Mon, 11 Oct 2021 07:47:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Transfer-Encoding: Content-Type:MIME-Version:References:Message-ID:Subject:Cc:To:From:Date: Sender:Reply-To:Content-ID:Content-Description; bh=Gkf7XkH0VdIK/pbuIoYKIaOT9YKA9EZRImkIx3YMJ7Y=; b=Jv0uYq1DnYV+VksvI4hmLWzKTV I/aeYoPtsKVa3iE12nkyRtbx/eXzulMQDvAWllacJiuxsiEtJdhUFYSurWmfGFBy9rjzN9XBNbZXJ WtEqgrZ43hhinyYLisZE6ssA9ZS/CYZGkJkzaW036fxkUXdWGr3BKyn599NjNDtYRsez8zh9opNNu kvA/UQnfIwcztUHQM+IHsCR2UA6gA7AnuLfHXdExK7Gdoq13aph7Rw2zYGLGT+N6XVgDTloLsHkFm StqQO0EZpUMuBSIpbViY3uXzwb4y/NT2FWre783EFvHuI0rZ9kZIP/vmC4RL5jy7KsV60rX8gsE92 gVOy44aA==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=worktop.programming.kicks-ass.net) by casper.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1mZwYA-005kT9-R5; Mon, 11 Oct 2021 14:45:32 +0000 Received: by worktop.programming.kicks-ass.net (Postfix, from userid 1000) id 1304F9811D4; Mon, 11 Oct 2021 16:45:11 +0200 (CEST) Date: Mon, 11 Oct 2021 16:45:10 +0200 From: Peter Zijlstra To: =?utf-8?B?546L6LSH?= Cc: Steven Rostedt , Ingo Molnar , open list , Jiri Olsa Subject: Re: [RESEND PATCH v2] trace: prevent preemption in perf_ftrace_function_call() Message-ID: <20211011144510.GE174703@worktop.programming.kicks-ass.net> References: <20211008200328.5b88422d@oasis.local.home> <87aeef5b-c457-d4df-8abf-f9f035d73dbc@linux.alibaba.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <87aeef5b-c457-d4df-8abf-f9f035d73dbc@linux.alibaba.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Oct 11, 2021 at 05:39:32PM +0800, ηŽ‹θ΄‡ wrote: > > > On 2021/10/11 δΈ‹εˆ4:48, Peter Zijlstra wrote: > > On Mon, Oct 11, 2021 at 10:32:46AM +0200, Peter Zijlstra wrote: > >> diff --git a/include/linux/trace_recursion.h b/include/linux/trace_recursion.h > >> index a9f9c5714e65..ca12e2d8e060 100644 > >> --- a/include/linux/trace_recursion.h > >> +++ b/include/linux/trace_recursion.h > >> @@ -214,7 +214,14 @@ static __always_inline void trace_clear_recursion(int bit) > >> static __always_inline int ftrace_test_recursion_trylock(unsigned long ip, > >> unsigned long parent_ip) > >> { > >> - return trace_test_and_set_recursion(ip, parent_ip, TRACE_FTRACE_START, TRACE_FTRACE_MAX); > >> + bool ret; > >> + > >> + preempt_disable_notrace(); > >> + ret = trace_test_and_set_recursion(ip, parent_ip, TRACE_FTRACE_START, TRACE_FTRACE_MAX); > >> + if (!ret) > >> + preempt_enable_notrace(); > >> + > >> + return ret; > >> } > >> > >> /** > > > > Oh, I might've gotten that wrong, I assumed regular trylock semantics, > > but it doesn't look like that's right. > > I will use bit instead ret and give some testing :-) > > BTW, would you prefer to merge these changes into this patch or maybe send > another patch with your suggested-by? Yeah, please send another patch; once you've confirmed it actually works etc.. I did this before waking (as evidence per the above), who knows what else I did wrong :-)