Received: by 2002:a89:2c3:0:b0:1ed:23cc:44d1 with SMTP id d3csp134703lqs; Mon, 4 Mar 2024 18:34:27 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVqb0dQMwl1GB8wVehsZZaC/wOR4r2p/LH0HeEk1AFA119d/5HQPGLwYLgnvjhy7d53Vl0kFgP1XxRmDZQdAtVCG1WRITNtJHgJQgKaRQ== X-Google-Smtp-Source: AGHT+IFO5vp6WAg2Gm+jn0U9wt/WS+5Rc4ZybRx7NkLymihE+7tgLQhKNDr0PgST7qMPivGo5t8G X-Received: by 2002:a17:902:a987:b0:1db:fc02:f96e with SMTP id bh7-20020a170902a98700b001dbfc02f96emr485654plb.24.1709606066860; Mon, 04 Mar 2024 18:34:26 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709606066; cv=pass; d=google.com; s=arc-20160816; b=dyEfHxAA2CDgcohr8N/WUk2BaogecyNVEgz+xF4tJ4pPJjFZd08+7/y6XfYU42d/SY YTg27pN1zm1LrmkxgaVJDl+h2CYngaStYhaDspGtQXgO8eKIRD2XGp3qs/AhH8MNNr17 JqDNl/FELy6AYitlm9N62xT6/mKds+Pbcu332itbRilAfx83AB81VR/YQ10nuuPGEKe4 nGCw51CDLNRCoofaBkJImigBy7M9Nyw8govbcJKWAAGG8Rre8lRZD+eK3W0leF6+sAIt 6wBHJBt88R0n8TgGSP7wtd4wiPO2inIENrcsWNif4kpLVQ2gUfRw63AkRcWBeibTgQm+ 0dhw== ARC-Message-Signature: i=2; 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; bh=DoqM3DFoyozIt5ndpMdbrKZxwzz82JAfIIb5lf6vKz4=; fh=5GSL8iMgAyuzpToQ7VTfMGDhy7T5RKF49tB9TFqJckE=; b=f77CuLt4ZBwlEd1rJ7cvKVMbuMp31ykzVCG6i555L7TYEQg9X5ECeOe/wF0Jf68ds9 GKhE4lf0Fl9Z3LIF5Ddv+hYigR6i6900Z10DWXFuGnPUo6V3JvrLLravRzIVAPlgqZ4N xpa8GnuJXCBkbOfE9fzegCqN2AU0XJYfPVorzyR3Iz4KfRtndCSWbf5FKoXemxrJUF29 5AbuST943ZjArMaMvxKnOzDd4+vLBKlwzbo1V92SE4+kW4UlVXEbPx5Y03qbR6LQbsFp 2IpyN4PC8F0NEl6Yf44HleWPbx0BJUgtRXg9AgbaVrS5xHTK3CAjJ7DpYLbXI+jAyfpv tmww==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-91561-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-91561-linux.lists.archive=gmail.com@vger.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 m17-20020a170902db1100b001dd0034d236si4247403plx.249.2024.03.04.18.34.26 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Mar 2024 18:34:26 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-91561-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; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-91561-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-91561-linux.lists.archive=gmail.com@vger.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 05752286F5D for ; Tue, 5 Mar 2024 02:33:56 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id EEACC286A2; Tue, 5 Mar 2024 02:33:51 +0000 (UTC) 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 74E1D26AD6; Tue, 5 Mar 2024 02:33:51 +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=1709606031; cv=none; b=Vpq5fY/mh9tpuve1e1pAcRV1ZA5A1/yOZkkOK6+JK1HJm3Yan0Gl//gxP2wv4K02GPB/8KxdLt8W3I9/EiUlq6RKGwh9Awjqg8ChdwEroA4glzsjxIHt+JovrcHe1BqKD5VWxdbfY/Yy2yYUAN9qIfKSY0NYCb5tkexLRlQAKow= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709606031; c=relaxed/simple; bh=unSEVpgvFQOHSUq6Y/c148scLpjvR6nMaqI0LXc3blI=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=QiAuyBodal++lRLsRAoN1bOcOzpq/cIoaLFdCZMpwH5Lxy51S/gae0H2fYX3tgusjIwJZgDMGu1TClzO0hefC1Oi2ttgObTAwkFrN8wZOSItuNLa44QTmYr6I8hUZlmvktThH9fILvOc7TYUaKcI/txds0EaXEmroiERkN9wJz0= 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 41FC0C433F1; Tue, 5 Mar 2024 02:33:50 +0000 (UTC) Date: Mon, 4 Mar 2024 21:35:38 -0500 From: Steven Rostedt To: Mathieu Desnoyers Cc: LKML , Linux Trace Kernel , Masami Hiramatsu , Linus Torvalds , Sachin Sant Subject: Re: [PATCH] tracing: Have trace_marker writes be just half of TRACE_SEQ_SIZE Message-ID: <20240304213538.13fe1f3b@gandalf.local.home> In-Reply-To: References: <20240304192710.4c99677c@gandalf.local.home> <469d31a7-f358-4547-bb17-0979b3515924@efficios.com> <20240304203516.45b7a551@gandalf.local.home> <20240304204119.7503ab0b@gandalf.local.home> <91f27ba1-15a4-402d-8301-e2b9d23f64b0@efficios.com> <20240304205943.081bea96@gandalf.local.home> X-Mailer: Claws Mail 3.19.1 (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 Mon, 4 Mar 2024 21:18:13 -0500 Mathieu Desnoyers wrote: > On 2024-03-04 20:59, Steven Rostedt wrote: > > On Mon, 4 Mar 2024 20:42:39 -0500 > > Mathieu Desnoyers wrote: > > > >> #define TRACE_OUTPUT_META_DATA_MAX_LEN 80 > >> > >> and a runtime check in the code generating this header. > >> > >> This would avoid adding an unchecked upper limit. > > > > That would be a lot of complex code that is for debugging something that > > has never happened in the past 16 years and Linus has already reprimanded > > me on doing such things. > > Is it more complex than remembering the iterator position in > print_trace_fmt() right before: > > if (tr->trace_flags & TRACE_ITER_CONTEXT_INFO) { > if (iter->iter_flags & TRACE_FILE_LAT_FMT) > trace_print_lat_context(iter); > else > trace_print_context(iter); > } You forgot all of theses: if (iter->ent->type == TRACE_BPUTS && trace_flags & TRACE_ITER_PRINTK && trace_flags & TRACE_ITER_PRINTK_MSGONLY) return trace_print_bputs_msg_only(iter); if (iter->ent->type == TRACE_BPRINT && trace_flags & TRACE_ITER_PRINTK && trace_flags & TRACE_ITER_PRINTK_MSGONLY) return trace_print_bprintk_msg_only(iter); if (iter->ent->type == TRACE_PRINT && trace_flags & TRACE_ITER_PRINTK && trace_flags & TRACE_ITER_PRINTK_MSGONLY) return trace_print_printk_msg_only(iter); if (trace_flags & TRACE_ITER_BIN) return print_bin_fmt(iter); if (trace_flags & TRACE_ITER_HEX) return print_hex_fmt(iter); if (trace_flags & TRACE_ITER_RAW) return print_raw_fmt(iter); return print_trace_fmt(iter); > > and then checking just after that the offset is not beyond 128 > bytes ? Perhaps there is even something internal to "iter" > that already knows about this offset (?). > > This would catch any context going beyond its planned upper > limit early. Failing early and not just in rare corner cases > is good. > > And it's not for debugging, it's for validation of assumptions > made about an upper bound limit defined for a compile-time > check, so as the code evolves issues are caught early. validating is debugging. Seriously Mathieu. Why do we need that? The BUILD_BUG_ON() itself is probably not even needed. Why do all this just to prevent an unlikely situation of an event being dropped from printing? It's not even lost (unless they are using trace_pipe, which very few people use). If you see a "LINE TOO BIG" you can run: # trace-cmd extract # trace-cmd report Which will pull out the raw data where the kernel trace_seq doesn't matter and trace_cmd will handle it just fine (its trace_seq is dynamically allocated and can increase in size when needed). -- Steve