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 C5A16C4332F for ; Tue, 19 Oct 2021 06:41:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A60F26112D for ; Tue, 19 Oct 2021 06:41:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234270AbhJSGnn (ORCPT ); Tue, 19 Oct 2021 02:43:43 -0400 Received: from smtp-out2.suse.de ([195.135.220.29]:36636 "EHLO smtp-out2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229695AbhJSGnl (ORCPT ); Tue, 19 Oct 2021 02:43:41 -0400 Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id AA04B1FD8D; Tue, 19 Oct 2021 06:41:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1634625687; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=yiCf/K6bKrAWm+H5GwYg06T7whuQxu5z+Eyutq5ePEE=; b=teDjFL9lr91NMRNc6Iv52QSxJj4QGuwwqDT3OOPMzK0CBm/3l5zawNGoKRXzDeN51cXEJP MSlwF/JcwJeOLxY3hgNh8mmlyB20AXu0yYaXblNFINe8pkmoTcCpXT4iQCyA+bOZUlhR5W yl7nzpiJ+YDINXRghZ+OA0t106VXXYU= Received: from suse.cz (unknown [10.100.216.66]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by relay2.suse.de (Postfix) with ESMTPS id 0F30AA3B81; Tue, 19 Oct 2021 06:41:26 +0000 (UTC) Date: Tue, 19 Oct 2021 08:41:23 +0200 From: Petr Mladek To: Steven Rostedt Cc: LKML , Ingo Molnar , "James E.J. Bottomley" , Helge Deller , Michael Ellerman , Benjamin Herrenschmidt , Paul Mackerras , Paul Walmsley , Palmer Dabbelt , Albert Ou , Thomas Gleixner , Borislav Petkov , x86@kernel.org, "H. Peter Anvin" , Josh Poimboeuf , Jiri Kosina , Miroslav Benes , Joe Lawrence , Colin Ian King , Masami Hiramatsu , "Peter Zijlstra (Intel)" , Nicholas Piggin , Jisheng Zhang , linux-csky@vger.kernel.org, linux-parisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, live-patching@vger.kernel.org, =?utf-8?B?546L6LSH?= , Guo Ren Subject: Re: [PATCH] tracing: Have all levels of checks prevent recursion Message-ID: References: <20211015110035.14813389@gandalf.local.home> <20211018220203.064a42ed@gandalf.local.home> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20211018220203.064a42ed@gandalf.local.home> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon 2021-10-18 22:02:03, Steven Rostedt wrote: > On Mon, 18 Oct 2021 12:19:20 +0200 > Petr Mladek wrote: > > > > - > > > bit = trace_get_context_bit() + start; > > > if (unlikely(val & (1 << bit))) { > > > /* > > > * It could be that preempt_count has not been updated during > > > * a switch between contexts. Allow for a single recursion. > > > */ > > > - bit = TRACE_TRANSITION_BIT; > > > + bit = TRACE_CTX_TRANSITION + start; > > > > [..] > > > Could we please update the comment? I mean to say if it is a race > > or if we trace a function that should not get traced. > > What do you think of this change? > > diff --git a/include/linux/trace_recursion.h b/include/linux/trace_recursion.h > index 1d8cce02c3fb..24f284eb55a7 100644 > --- a/include/linux/trace_recursion.h > +++ b/include/linux/trace_recursion.h > @@ -168,8 +168,12 @@ static __always_inline int trace_test_and_set_recursion(unsigned long ip, unsign > bit = trace_get_context_bit() + start; > if (unlikely(val & (1 << bit))) { > /* > - * It could be that preempt_count has not been updated during > - * a switch between contexts. Allow for a single recursion. > + * If an interrupt occurs during a trace, and another trace > + * happens in that interrupt but before the preempt_count is > + * updated to reflect the new interrupt context, then this > + * will think a recursion occurred, and the event will be dropped. > + * Let a single instance happen via the TRANSITION_BIT to > + * not drop those events. > */ > bit = TRACE_TRANSITION_BIT; > if (val & (1 << bit)) { > > Looks good to me. Thanks for the update. Feel free to postpone this change. I do not want to complicate upstreaming the fix for stable. I am sorry if I already complicated it. Best Regards, Petr