Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp5369324rdb; Wed, 13 Dec 2023 06:57:22 -0800 (PST) X-Google-Smtp-Source: AGHT+IGkZPJxqddwpi9C9MJTYN8pZD+tw5T5IZShYKRjByIymYpaALk/kgjwsozuUNi08g4sMZRv X-Received: by 2002:a05:6359:2c43:b0:170:2c52:2b4d with SMTP id qv3-20020a0563592c4300b001702c522b4dmr3985456rwb.19.1702479441973; Wed, 13 Dec 2023 06:57:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702479441; cv=none; d=google.com; s=arc-20160816; b=dZkZZrK8g/L8k0aX2sHazKRmIrYOgHiDWDoI4wlYXaIBRLFXu0H0LR4kA4bWk958r9 ISc4yRQcGFREAQtF0yh1Qldt8+nXGO81t42XPSSmr5GCv9+BbEq5FSvHb3RKi3S84OhI fptJAvITrtO2GXoBKw7KNE8yDjv/ZVZk6REdvunzW4LfWF1mfJHgYM6BU1vdgdpmxLke V34IH9KnZcRPcDMgqSvX2yk+YFUDCq2oiDmd9w5Ua07aw4VL2HBpP7DBB4NExPq+0EA0 kxeUIfgXElYuef/XmX2I+Bqc/gOHWYvJX82LP5qDc4uJVzy5PZEO99AdAU2/XdAsCa0j ooSw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date; bh=AFrolwiRlOq7ANfuIWOOfzH4w95Gn/+ZGxcfjkeGdec=; fh=scyWAHJbIB98o0kQcK2s/AjtbVATRpT0yshLxKHLnr0=; b=e5q2vm3cn7P5Ge5h9COVwPQrtWCNpYBstavQjUyXjSr98yAuw+DR1A4pd6A8epFJxJ oTGtC+RmBSvRro8v977klydJJ7GUYNmXoadb0SaC6VNCXyM5IQ7JuAB5Z3mhXga1A16K iQ5Wq63MAekOs2+JfrwLrFRfq9VvJDGmY+u7oilZ5iqNQrtE5RdmkomH6DnopUlcfcfJ 3jAw6fRGTP7XtHW5/gVgEhx7Ccn5r5CaoHiylldGKdo5nUNDuo6iEO2piLuis8D4bEHD 61+Kr1aQM+UmjKGdzK1IjeBL4oOk/a6DWdLToh2YyFWmJJGH5YpjIlbsH9ByWtMxaS0w X8PA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from morse.vger.email (morse.vger.email. [2620:137:e000::3:1]) by mx.google.com with ESMTPS id v28-20020a63151c000000b005c6617b52e3si9791207pgl.0.2023.12.13.06.57.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Dec 2023 06:57:21 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) client-ip=2620:137:e000::3:1; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id 0ACBB81F843E; Wed, 13 Dec 2023 06:57:19 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1442020AbjLMO5D convert rfc822-to-8bit (ORCPT + 99 others); Wed, 13 Dec 2023 09:57:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52158 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1442027AbjLMO5C (ORCPT ); Wed, 13 Dec 2023 09:57:02 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A8A04F2 for ; Wed, 13 Dec 2023 06:57:07 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5E630C433C8; Wed, 13 Dec 2023 14:57:06 +0000 (UTC) Date: Wed, 13 Dec 2023 09:57:49 -0500 From: Steven Rostedt To: Alexander Kapshuk Cc: LKML , Linux Trace Kernel , Masami Hiramatsu , Mark Rutland , Mathieu Desnoyers , Shuah Khan , linux-kselftest@vger.kernel.org Subject: Re: [PATCH v3] tracing/selftests: Add test to test the trace_marker Message-ID: <20231213095749.5ff64569@gandalf.local.home> In-Reply-To: References: <20231212192317.0fb6b101@gandalf.local.home> X-Mailer: Claws Mail 3.19.1 (GTK+ 2.24.33; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Wed, 13 Dec 2023 06:57:19 -0800 (PST) On Wed, 13 Dec 2023 10:09:50 +0200 Alexander Kapshuk wrote: > The REs used in the sed commands below may be simplified as shown if desired. > > On Wed, Dec 13, 2023 at 2:22 AM Steven Rostedt wrote: > > > > From: "Steven Rostedt (Google)" > > > > Add a test that writes longs strings, some over the size of the sub buffer > > and make sure that the entire content is there. > > > > Signed-off-by: Steven Rostedt (Google) > > --- > > Changes since v2: https://lore.kernel.org/linux-trace-kernel/20231212151632.25c9b67d@gandalf.local.home > > > > - Realized with the upcoming change of the dynamic subbuffer sizes, that > > this test will fail if the subbuffer is bigger than what the trace_seq > > can hold. Now the trace_marker does not always utilize the full subbuffer > > but the size of the trace_seq instead. As that size isn't available to > > user space, we can only just make sure all content is there. > > > > .../ftrace/test.d/00basic/trace_marker.tc | 82 +++++++++++++++++++ > > 1 file changed, 82 insertions(+) > > create mode 100755 tools/testing/selftests/ftrace/test.d/00basic/trace_marker.tc > > > > diff --git a/tools/testing/selftests/ftrace/test.d/00basic/trace_marker.tc b/tools/testing/selftests/ftrace/test.d/00basic/trace_marker.tc > > new file mode 100755 > > index 000000000000..b24aff5807df > > --- /dev/null > > +++ b/tools/testing/selftests/ftrace/test.d/00basic/trace_marker.tc > > @@ -0,0 +1,82 @@ > > +#!/bin/sh > > +# SPDX-License-Identifier: GPL-2.0 > > +# description: Basic tests on writing to trace_marker > > +# requires: trace_marker > > +# flags: instance > > + > > +get_buffer_data_size() { > > + sed -ne 's/^.*data.*size:\([0-9][0-9]*\).*/\1/p' events/header_page > sed -n 's!.*data.*size:\([^;]*\).*!\1!p' events/header_page Not sure the above change can be considered simpler, but it also loses out showing what exactly is being done. With the original, I have: sed -ne 's/^.*data.*size:\([0-9][0-9]*\).*/\1/p' events/header_page Which is obvious that I'm grabbing a number for the size field. sed -n 's!.*data.*size:\([^;]*\).*!\1!p' events/header_page Shows that I'm grabbing something after size. > > +} > > + > > +get_buffer_data_offset() { > > + sed -ne 's/^.*data.*offset:\([0-9][0-9]*\).*/\1/p' events/header_page > sed -n 's!.*data.*offset:\([^;]*\).*!\1!p' events/header_page Same here. > > +} > > + > > +get_event_header_size() { > > + type_len=`sed -ne 's/^.*type_len.*:[^0-9]*\([0-9][0-9]*\).*/\1/p' events/header_event` > type_len=`sed -n '/type_len.*bits/s![^0-9]*!!gp' > events/header_event` Honestly, the above may be "simplier" but I can't make out what exactly that line is doing without going back and looking at the text that's in the format field. > > > + time_len=`sed -ne 's/^.*time_delta.*:[^0-9]*\([0-9][0-9]*\).*/\1/p' events/header_event` > time_len=`sed -n '/time_delta/s![^0-9]*!!gp' events/header_event` > > > + array_len=`sed -ne 's/^.*array.*:[^0-9]*\([0-9][0-9]*\).*/\1/p' events/header_event` > array_len=`sed -n '/array/s![^0-9]*!!gp' events/header_event` > > > + total_bits=$((type_len+time_len+array_len)) > > + total_bits=$((total_bits+7)) > > + echo $((total_bits/8)) > > +} > > + > > +get_print_event_buf_offset() { > > + sed -ne 's/^.*buf.*offset:\([0-9][0-9]*\).*/\1/p' events/ftrace/print/format > sed -n 's!.*buf.*offset:\([^;]*\).*!\1!p' events/ftrace/print/format > > +} > > + Yeah, thanks for the suggestions, but I rather have it be more readable than "simplified". I write perl code the same way. I do not write it like any perl developer would, because I write it like C code. I want my code to be easily understandable. RE can become extremely obfuscated. So, even though my REs are not the simplest, they tend to be rather easy to understand what they are doing, and why. Cheers, -- Steve