Received: by 2002:a05:7413:20a6:b0:f7:18da:975a with SMTP id oo38csp256822rdb; Thu, 21 Dec 2023 00:11:55 -0800 (PST) X-Google-Smtp-Source: AGHT+IFCY94J4/lCldVPfaUHhE/DjIxdl0fGciYqMMh10ZKhdmo4WDij4dc3SgDNZo45KI2uWv49 X-Received: by 2002:a05:6870:b629:b0:204:2d88:5aff with SMTP id cm41-20020a056870b62900b002042d885affmr696311oab.33.1703146314883; Thu, 21 Dec 2023 00:11:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703146314; cv=none; d=google.com; s=arc-20160816; b=0EGwOea+rPtXMsoofspR9qnlANcs+C4OAwdXBRFS7KGe4INkQc23kLyJNyLQmrG645 nzwu267FNKwmd4NJV+gpDzC857vcmMjGe5O6zbfD/5zD77Iy8/JNU5kuW2fEWEGC+Q0s mx9gyfYeEozS5/x4k1OffJ/hRqNp6zaj+boe0w50Xz6Lz7iMJnmKJsHqj8q5Q7D+y2b1 f1IVzSnfKyi7CgApKn0mVsBR/JhTiqp1c5c05coqUvaAih2mJxTW523Ny8DOyis3V8ZQ WZhUMnSm5ECffetia60VHzvH3sDN+6c5GHCLIa1yUYQ6NjUkMdqLUBR36nLmVBfFOfE1 nHYg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :subject:cc:to:from:date:dkim-signature; bh=LOERPUXL90DDDc3nuhUynNzC431Ow+C6ls7VU8pDbjM=; fh=krDARTzr2W3hYHHB4MmQxfSZ2ZT26qJ/sj98pNKz2Bw=; b=IfeT9ggIPj5OUzxQw+cVvDl267R5WThncJZnYy2iO1KQOLquH6H/IJkp8OTT58KGsG pniH5EfpIe1pVHThTl5VetAJwCuW9s3dBShwi+JMhy6DzdWzbVaXutF3en4FXgqxsnur i67JfFpxbutVZuDl43zjl4pCI+912DqjubpsRdTdtFgTKwzsPKGXjdJODsDyV1Qfu57H mq3DU60KZidxH+vtw0SWH/Z35oAwtNBVdpIQxEWFyZ2Zn7QWUFQBzzPkiufD8pZga0or ntFyseLeuUPHJTcVX1720vpTVFtMbW7mg6tZQ6wh/RP8/AlY0UD45JuvKX4VraTUwxE/ xAvw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=VaRZpFET; spf=pass (google.com: domain of linux-kernel+bounces-7980-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-7980-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id f23-20020a635557000000b005c65e697bc4si1144231pgm.550.2023.12.21.00.11.54 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Dec 2023 00:11:54 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-7980-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=VaRZpFET; spf=pass (google.com: domain of linux-kernel+bounces-7980-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-7980-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id E05DF283659 for ; Thu, 21 Dec 2023 08:11:53 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9E4EE15AE7; Thu, 21 Dec 2023 08:11:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="VaRZpFET" X-Original-To: linux-kernel@vger.kernel.org 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 D05E217728; Thu, 21 Dec 2023 08:11:47 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 17C59C433C8; Thu, 21 Dec 2023 08:11:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1703146307; bh=/+ZyvbnXDl0xdqwufIhudNlc3aUzUEcu7XOoEwQcEQ0=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=VaRZpFETZDpotxN24QZQlU/SJNqJtgwA06kPabYDQ7eaOe9c+hrktzUSS2L39473k DRPFwpqfFKvmAbSUzsiJFfmwNKaW0I87sFgjy+1EUq/RauOppk3j4LHBa9guoupu3n 5xbGnQuN0px7fWYtscOLlEm42eIcotA6e+AJK07vncRQ3+cmTUi3CeuLma6DsNRTBC G3ez/qCdRrgsm74YFQrGpPoGbZWMWHVMbvtzq7MtWxCxeKTqSNSKlS8yefewBlm47R sKQOpdvA7kZ/MgXKfNW5YyUAorSgWhj4Qbxwv6Bhn+lJJ9RDwU1iWejTqBHgymbGv+ DEIU7uWVkzVzg== Date: Thu, 21 Dec 2023 17:11:44 +0900 From: Masami Hiramatsu (Google) To: Steven Rostedt Cc: LKML , Linux Trace Kernel , Masami Hiramatsu , Mathieu Desnoyers , Alexander Graf , Tom Zanussi Subject: Re: [PATCH] tracing / synthetic: Disable events after testing in synth_event_gen_test_init() Message-Id: <20231221171144.e95f0e55bcd62a6e9e08b8a4@kernel.org> In-Reply-To: <20231220111525.2f0f49b0@gandalf.local.home> References: <20231220111525.2f0f49b0@gandalf.local.home> X-Mailer: Sylpheed 3.8.0beta1 (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, 20 Dec 2023 11:15:25 -0500 Steven Rostedt wrote: > From: "Steven Rostedt (Google)" > > The synth_event_gen_test module can be built in, if someone wants to run > the tests at boot up and not have to load them. > > The synth_event_gen_test_init() function creates and enables the synthetic > events and runs its tests. > > The synth_event_gen_test_exit() disables the events it created and > destroys the events. > > If the module is builtin, the events are never disabled. The issue is, the > events should be disable after the tests are run. This could be an issue > if the rest of the boot up tests are enabled, as they expect the events to > be in a known state before testing. That known state happens to be > disabled. > > When CONFIG_SYNTH_EVENT_GEN_TEST=y and CONFIG_EVENT_TRACE_STARTUP_TEST=y > a warning will trigger: > > Running tests on trace events: > Testing event create_synth_test: > Enabled event during self test! > ------------[ cut here ]------------ > WARNING: CPU: 2 PID: 1 at kernel/trace/trace_events.c:4150 event_trace_self_tests+0x1c2/0x480 > Modules linked in: > CPU: 2 PID: 1 Comm: swapper/0 Not tainted 6.7.0-rc2-test-00031-gb803d7c664d5-dirty #276 > Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.2-debian-1.16.2-1 04/01/2014 > RIP: 0010:event_trace_self_tests+0x1c2/0x480 > Code: bb e8 a2 ab 5d fc 48 8d 7b 48 e8 f9 3d 99 fc 48 8b 73 48 40 f6 c6 01 0f 84 d6 fe ff ff 48 c7 c7 20 b6 ad bb e8 7f ab 5d fc 90 <0f> 0b 90 48 89 df e8 d3 3d 99 fc 48 8b 1b 4c 39 f3 0f 85 2c ff ff > RSP: 0000:ffffc9000001fdc0 EFLAGS: 00010246 > RAX: 0000000000000029 RBX: ffff88810399ca80 RCX: 0000000000000000 > RDX: 0000000000000000 RSI: ffffffffb9f19478 RDI: ffff88823c734e64 > RBP: ffff88810399f300 R08: 0000000000000000 R09: fffffbfff79eb32a > R10: ffffffffbcf59957 R11: 0000000000000001 R12: ffff888104068090 > R13: ffffffffbc89f0a0 R14: ffffffffbc8a0f08 R15: 0000000000000078 > FS: 0000000000000000(0000) GS:ffff88823c700000(0000) knlGS:0000000000000000 > CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 > CR2: 0000000000000000 CR3: 00000001f6282001 CR4: 0000000000170ef0 > Call Trace: > > ? __warn+0xa5/0x200 > ? event_trace_self_tests+0x1c2/0x480 > ? report_bug+0x1f6/0x220 > ? handle_bug+0x6f/0x90 > ? exc_invalid_op+0x17/0x50 > ? asm_exc_invalid_op+0x1a/0x20 > ? tracer_preempt_on+0x78/0x1c0 > ? event_trace_self_tests+0x1c2/0x480 > ? __pfx_event_trace_self_tests_init+0x10/0x10 > event_trace_self_tests_init+0x27/0xe0 > do_one_initcall+0xd6/0x3c0 > ? __pfx_do_one_initcall+0x10/0x10 > ? kasan_set_track+0x25/0x30 > ? rcu_is_watching+0x38/0x60 > kernel_init_freeable+0x324/0x450 > ? __pfx_kernel_init+0x10/0x10 > kernel_init+0x1f/0x1e0 > ? _raw_spin_unlock_irq+0x33/0x50 > ret_from_fork+0x34/0x60 > ? __pfx_kernel_init+0x10/0x10 > ret_from_fork_asm+0x1b/0x30 > > > This is because the synth_event_gen_test_init() left the synthetic events > that it created enabled. By having it disable them after testing, the > other selftests will run fine. > Ah, OK. It has to clean up the testing events. Acked-by: Masami Hiramatsu (Google) Thank you, > Cc: stable@vger.kernel.org > Fixes: 9fe41efaca084 ("tracing: Add synth event generation test module") > Reported-by: Alexander Graf > Signed-off-by: Steven Rostedt (Google) > --- > kernel/trace/synth_event_gen_test.c | 11 +++++++++++ > 1 file changed, 11 insertions(+) > > diff --git a/kernel/trace/synth_event_gen_test.c b/kernel/trace/synth_event_gen_test.c > index 8dfe85499d4a..354c2117be43 100644 > --- a/kernel/trace/synth_event_gen_test.c > +++ b/kernel/trace/synth_event_gen_test.c > @@ -477,6 +477,17 @@ static int __init synth_event_gen_test_init(void) > > ret = test_trace_synth_event(); > WARN_ON(ret); > + > + /* Disable when done */ > + trace_array_set_clr_event(gen_synth_test->tr, > + "synthetic", > + "gen_synth_test", false); > + trace_array_set_clr_event(empty_synth_test->tr, > + "synthetic", > + "empty_synth_test", false); > + trace_array_set_clr_event(create_synth_test->tr, > + "synthetic", > + "create_synth_test", false); > out: > return ret; > } > -- > 2.42.0 > -- Masami Hiramatsu (Google)