Received: by 2002:a89:2c3:0:b0:1ed:23cc:44d1 with SMTP id d3csp145564lqs; Mon, 4 Mar 2024 19:06:16 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWuEepeR+/HUej2rAnh8OAJuKHzKSUpIZyK/bpYQpXqU9bZUs16IAp9szo+aekCG+51V3aP2o67hTQnThYEC7WzV+VH4gJMwUEoFhkeCg== X-Google-Smtp-Source: AGHT+IHQ+zCb+E1JLJoLNcpy5epkCahZOMg+Rvh0Hl5xoScKxbstbyPzM5fMrzwsbsl1u70TBX5E X-Received: by 2002:a2e:8811:0:b0:2d2:a982:533e with SMTP id x17-20020a2e8811000000b002d2a982533emr343068ljh.52.1709607976519; Mon, 04 Mar 2024 19:06:16 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709607976; cv=pass; d=google.com; s=arc-20160816; b=kNQAnluo0vCGHcu807F1WNPK9YlutTo3PcYuzOM4ifUSNgB33fHUTayg3QxxKcv8uj 0JgYIfM9VKqUybWRtwz+UESQ+IZGep6KNmwYq67Qpn0OSqvP100a6MHMLUPAJ0WCYNAx B58YR7EVeI9krdXrwztDj3qZFJ3F6Ihz+4L3wluAkEQAntvZwMP1iQUtJ6UlJsEV8qJz MP0aRtdDn+lcw3+ov2l31Y17rEo7qqoaFFP3ZqL7XP0VJ8WutBe6D1cOZ9DioRz0JEEN 8HCRrNIRCuRateGBDWQqrFSeayLGk/AE97ZhKMx7yLR7y88rzKgxOrUSt/5Avfyc0ge7 5ufg== 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=nIWzbhVaoubELpzVSLhosBNnijfjjSHNIOUZyiZcrAc=; fh=5GSL8iMgAyuzpToQ7VTfMGDhy7T5RKF49tB9TFqJckE=; b=NmjIyzS0mvA0vIVpcY32pWR6NZPFUS4a/C52FuRsnE6GsplaD53chTD4bi7Nnb1pGy yu6dc7i1XT3wq/mNmcMqT5are9g2taZj6462D+g9hpDo4j9UT1CmgM5DA1D8QRMVGDcs +ISaxM8mIdMcCbjktp/keVuFyyci6xlOe5XZVI1urrXXFO0FZhps6pabqyWd4Av18tWD oTxwN2IKfsUQE3oBDJupizlEygtYdpCIFdLnirq6V19JCiAJO9ZSkvbOtXx4REH6cC2B eBQQZnuZPjq0/Ou+WxDq767PI6hgP7TO5Sm4AQK88VDuu7YvE+kS2QT81hn/teynYFQh BRYA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-91598-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-91598-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id y1-20020a50e601000000b00566c8190affsi3685924edm.385.2024.03.04.19.06.16 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Mar 2024 19:06:16 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-91598-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-91598-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-91598-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 4039C1F230DC for ; Tue, 5 Mar 2024 03:06:16 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B69912942C; Tue, 5 Mar 2024 03:06:07 +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 3D7DD28E23; Tue, 5 Mar 2024 03:06:06 +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=1709607967; cv=none; b=bio7mAbecqQyiWsspORaB+oWDsi0ugJWH3/VsFm+qC6xXJS159EZJKlKTtsUVZbxo70ltJb1w7sM6fvHzrswMixN6zcQO4Kk8rInIFtqLR6KrZaxxwAb1ri75BQDDB/+R/Qhuj+CYAppz2WT3TTjAS4Lu3w38TcH1PKQ3UK+Fmg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709607967; c=relaxed/simple; bh=OSg9KgrWcCqYD+LVxjqxALYSgKaYs8OihzNp27f3IZo=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=seMB0B9ePI8wGjo2JY03+18K/8tccQqFfLpWNVjPb6ydd+dMRkt4PpFvo7FgBdDIp6Dy6ah5YgYlw+5zvATLBHsEbXYBPt8/mQMk9Qx6JgT8YFrIi21jZJeXdzZIaIXPNQnOn+XNRRSoElxIxUQopkNVgESQ16Y4/MebrUnK5rY= 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 16329C433C7; Tue, 5 Mar 2024 03:06:05 +0000 (UTC) Date: Mon, 4 Mar 2024 22:07:54 -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: <20240304220754.4fbe3f34@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> <20240304213538.13fe1f3b@gandalf.local.home> <20240304213750.1baef01d@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:48:44 -0500 Mathieu Desnoyers wrote: > On 2024-03-04 21:37, Steven Rostedt wrote: > > On Mon, 4 Mar 2024 21:35:38 -0500 > > Steven Rostedt wrote: > > > >>> 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. > > > > Did Linus put you up to this? To test me to see if I'm learning how to say "No" ;-) > > No, he did not. I was being facetious. > I genuinely think that validating size limits like > this either at compile time or, when they can vary at runtime like > in this case, with a dynamic check, decreases the cognitive > load on the reviewers. We can then assume that whatever limit > was put in place is actually enforced and not just wishful > thinking. I'm for that too. But the purpose of trace_seq was to be able to safely append strings on top of each other. It was written specifically for the trace file output. It should be long enough to print the entire string. If the trace_seq overflows, it will not add any more content. But this is checked at the end to see if everything did fit. I had the "half" size logic because it was still way more than enough to hold the write and the header, where the header should never be that big. It's not much different than vsnprintf() having a 32K precision field that warns if you go over it. If a header is 128 bytes then it is really a failure in output, as it will cause each line to overflow a normal 80 character terminal screen before it even gets to the content of the event. Such a header is stupid and this is where I'm starting to understand Linus, where we don't need to write a bunch of debug code to make sure we don't have some huge header just because it may cause the content of the event from being visible. Oh! and yes, there are events that can be large (stack traces and such). If a header is created to be that big, you will likely drop actual real events that have nothing to do with trace_marker. > > If the "header" size upper bound is not validated at runtime, there > is not much point in adding the BUILD_BUG_ON() based on that value > in the first place, and you should then just add a runtime check that > you don't overflow the output buffer before writing the output to it. OK, then I guess we don't need the checks. 4K for a trace_marker limit and 8K for the trace_seq that will eventually hold its content, is a pretty simple concept. Do we need a bunch of logic to keep it from breaking? Especially since trace_marker is used a lot in testing the tracing code itself. -- Steve