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 E9153C433F5 for ; Tue, 19 Oct 2021 06:42:18 +0000 (UTC) Received: from lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 1CF2460F59 for ; Tue, 19 Oct 2021 06:42:18 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 1CF2460F59 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=suse.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.ozlabs.org Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4HYPLJ3r04z3cR1 for ; Tue, 19 Oct 2021 17:42:16 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=suse.com header.i=@suse.com header.a=rsa-sha256 header.s=susede1 header.b=teDjFL9l; dkim-atps=neutral Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=suse.com (client-ip=195.135.220.29; helo=smtp-out2.suse.de; envelope-from=pmladek@suse.com; receiver=) Authentication-Results: lists.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=suse.com header.i=@suse.com header.a=rsa-sha256 header.s=susede1 header.b=teDjFL9l; dkim-atps=neutral Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4HYPKX4BbWz2yPY for ; Tue, 19 Oct 2021 17:41:34 +1100 (AEDT) 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 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> X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?B?546L6LSH?= , "Peter Zijlstra \(Intel\)" , Paul Walmsley , "James E.J. Bottomley" , Paul Mackerras , Jisheng Zhang , "H. Peter Anvin" , live-patching@vger.kernel.org, linux-riscv@lists.infradead.org, Miroslav Benes , Joe Lawrence , Helge Deller , x86@kernel.org, linux-csky@vger.kernel.org, Ingo Molnar , Albert Ou , Jiri Kosina , Nicholas Piggin , Borislav Petkov , Josh Poimboeuf , Thomas Gleixner , linux-parisc@vger.kernel.org, LKML , Palmer Dabbelt , Masami Hiramatsu , Guo Ren , Colin Ian King , linuxppc-dev@lists.ozlabs.org Errors-To: linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Sender: "Linuxppc-dev" 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