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 24C00182B9; Fri, 23 Aug 2024 00:04:17 +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=1724371458; cv=none; b=sf0/aOe/r39EUv2L2tABWhiCgXiH3x+VEjiMtrSVl8lHfPlIoZHAQueu0T3iunlX/qlwKftPLnnzrRD9PohXnSKXgxL1BEJKoahupCKAOCfEH8USrE9ZrR8YXdbnYlBwZQVVVgwm/Xee+hlinh+WfQskywHvhyq4FwA+hMdJGdY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724371458; c=relaxed/simple; bh=2FSe8I9whgAZoIbQlZt5Ga3QttMxSxkF67pTJAIS5+I=; h=Date:From:To:Cc:Subject:Message-Id:In-Reply-To:References: Mime-Version:Content-Type; b=jLzy9ZDzZWsWEzmnwKhQkztEh9ycNdFBgqYcwGvdajDbvcpKZ0C3Asy65agsactif0cbqz8Xj5jRly2CMnAeVzJhZC1U9YT6Chj0974rdIOmGnCm+/tlZDXV3/9IeIEmJ1oiMKizwQBZXkQJKEBHUfggUfB7kGBEwDw2y7Pus6U= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=qpr2tO7i; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="qpr2tO7i" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C140EC32782; Fri, 23 Aug 2024 00:04:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1724371457; bh=2FSe8I9whgAZoIbQlZt5Ga3QttMxSxkF67pTJAIS5+I=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=qpr2tO7i2UGxSUkyhDoWf60Nyf149hbS8jzTLUFz18EnxVCNQvuuP0XLeFDL//dSl bSVbgKIVRiXOWISjYSe1ywlEBO7jj13fZ7wTu/79GQ3ciY8LeTg/f3xSCzeVomU1Gr cR2v8F1LkpDOG2CocTHjrSG8C+4I1DdWUyoeqrjJDBhJ+8evLVxxZlO2TYKF+k76eE aWaS+yKgI0UNWzhxmZNVH/ELtVYtewxC+GXKOB9h0TkuqnGmoojFkgO2cyrkbknpO5 z1z7Y/1xpB8AAHiy6EWsT10vw25q0ZzgzCLS6J+Sdth5GSlUyCcmrgZnNuhMHqRhZS RRSimlbFJs54g== Date: Fri, 23 Aug 2024 09:04:12 +0900 From: Masami Hiramatsu (Google) To: Steven Rostedt Cc: Mark Rutland , 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: <20240823090412.d63468ab89ba28415d7bc649@kernel.org> In-Reply-To: <20240821115000.387de298@gandalf.local.home> 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> <20240821115000.387de298@gandalf.local.home> X-Mailer: Sylpheed 3.7.0 (GTK+ 2.24.33; x86_64-pc-linux-gnu) Precedence: bulk X-Mailing-List: linux-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 11:50:00 -0400 Steven Rostedt wrote: > 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? Interesting, this fixes the issue! And it is great to find how to avoid the LTO removes function like this. Tested-by: Masami Hiramatsu (Google) Thank you, > > -- 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; > } -- Masami Hiramatsu (Google)