From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8B6441B2ED2; Wed, 21 Aug 2024 15:49:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724255373; cv=none; b=l/VRQDB9Dl/22Jsi7G5KICp8ogUL58LNIwq+AGHP4ySMbs+rNFi3ULvoO8EQiQJfUdg5m5GMiaEU1d8rGKQNgT9McM6b2ge1SbtQxeSdBH4g5ZprhZFmztH5FtQAbqtAg2YQtvgFWuxSwsAAH+Zi7hZhs8UNtwgmpdO5/Xu/OP8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724255373; c=relaxed/simple; bh=GnQAu3Sodne1cCc1QQWgJVnenaMJ32qjTvMmXKUvEHc=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=kgH/P6MlKcZEIaQqE53LrZWV1w93S92p2ICxjpRXrCn0Um3s2c7n0GpyTbSFPUkAGE48NafrjMDy6+lzZEanvb7Qp4iRfMWmwgI5KXG6cBhO0BXwkBR/AP30vrgcC/5lWJcbyDxJTPKmfQkIPYKd7x3DFY6CLY+1M6FQk9vJUkk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 257F6C32781; Wed, 21 Aug 2024 15:49:32 +0000 (UTC) Date: Wed, 21 Aug 2024 11:50:00 -0400 From: Steven Rostedt To: Mark Rutland Cc: Masami Hiramatsu , Sami Tolvanen , Linux Trace Kernel , linux-kernel@vger.kernel.org, clang-built-linux , Nathan Chancellor Subject: Re: [BUG] tracing: dynamic ftrace selftest detected failures Message-ID: <20240821115000.387de298@gandalf.local.home> In-Reply-To: References: <20240819171152.12f05e0ae5c9472004d1b00a@kernel.org> <20240819112902.11451fe8@gandalf.local.home> <20240820005649.dd019cfa70a8955d91cf85a0@kernel.org> <20240819120244.5657eb2f@gandalf.local.home> <20240820100330.9ee6f3d51f22bb9bab7c4b83@kernel.org> <20240821070539.981b42e5f3b939c5ce5e3a71@kernel.org> X-Mailer: Claws Mail 3.20.0git84 (GTK+ 2.24.33; x86_64-pc-linux-gnu) Precedence: bulk X-Mailing-List: linux-trace-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit On Wed, 21 Aug 2024 16:42:07 +0100 Mark Rutland wrote: > FWIW, that was in samples/ftrace/ftrace-ops.c, where tracee_relevant() and > tracee_irrelevant() have the barrier(): > > | /* > | * Marked as noinline to ensure that an out-of-line traceable copy is > | * generated by the compiler. > | * > | * The barrier() ensures the compiler won't elide calls by determining there > | * are no side-effects. > | */ > | static noinline void tracee_relevant(void) > | { > | barrier(); > | } > > ... so we already have precedent for that in tracing code. If adding a barrier() fixes things, then I'm 100% for adding them. Masami, does this fix it? -- Steve diff --git a/kernel/trace/trace_selftest_dynamic.c b/kernel/trace/trace_selftest_dynamic.c index c364cf777e1a..a112433d78ce 100644 --- a/kernel/trace/trace_selftest_dynamic.c +++ b/kernel/trace/trace_selftest_dynamic.c @@ -4,12 +4,20 @@ noinline __noclone int DYN_FTRACE_TEST_NAME(void) { - /* used to call mcount */ + /* + * Used to test function tracing. Make sure the compiler doesn't + * remove it. + */ + barrier(); return 0; } noinline __noclone int DYN_FTRACE_TEST_NAME2(void) { - /* used to call mcount */ + /* + * Used to test function tracing. Make sure the compiler doesn't + * remove it. + */ + barrier(); return 0; }