Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp5378496rdb; Wed, 13 Dec 2023 07:08:52 -0800 (PST) X-Google-Smtp-Source: AGHT+IGNUHzKKyyjm8e+Clf9oeM9ZcUqUyg6ZqMFKqn/acnhUTsox7ktuiLKp/4i7AxViPof3pjr X-Received: by 2002:aa7:888b:0:b0:6ce:6448:4961 with SMTP id z11-20020aa7888b000000b006ce64484961mr11206425pfe.12.1702480132115; Wed, 13 Dec 2023 07:08:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702480132; cv=none; d=google.com; s=arc-20160816; b=KzcQX5fncuLG2zzDiwy9w4uGYTZhvG3DasydA16DBiS37XNwql3OzIWTtw5MB86ouN r2cP3vw0cGWZKcaSmcdz27krnsqSIk5Jf2CTzx96bNMb8AcIlQSAWzgN2+lqU49Ck9Uq wTRHd48xkt2YLHgXj1ml1FTrqeo13pTY6cGqWPgAx4Bo0Tam9dgkKzWxeSSBQsPFAAzA VcpKnxNMPSXWPfx6nsNou0qO7Mk41HDqcWHKNGAgAZ07wzsa8hWdN9VJJmshI2DW93Rv U1CqXIQPq6s09TjOVas7aQOxL1CqrNkBQvRvAtxdwb7oZPl3kGpdDZpzbLA7OIe/VKT2 E1EQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=JEPH+eGb7fInmyjspViQgARNCBB0nvNmZOxruBaRhvo=; fh=5hzahh6hQHTw5Ti1BZXftjUpEgQKeWnhCW/Ese3xkZ0=; b=jgoH80S6pcuAPfdJ5Mq0C2o9hOg/ZqpqVt/N6RqeAXXO/VBZD9dKOH6spf66knwP5E 3y3/Pox2ZlaCpr28YJn41J6GQpuiop7jep8mDvna229DwnJDFGfaKcE07tcOCvHaogMK E4YTJZnYhh0AkyQZcVRaGUfnX/u0XNz2WKoCQFK8Gq4qzer7VWYz35X3kC6/MK5IceHQ VG0VdG5gFZwdZabCy5x4wQ3kk7b3Ygfr44QcTBDpKwHiydEnL/YKsPdziHy7K4SJQu3U Sy5X+ynpCl2GYf75/lYnGAx9y/UKalVp259QeDUNtp7o1CFYfclJqkBn311EO1y4s7xi 3Sew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=BimPnpda; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id u16-20020a056a00125000b006cb8a0c292esi9628561pfi.95.2023.12.13.07.08.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Dec 2023 07:08:52 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=BimPnpda; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id A86C3807529B; Wed, 13 Dec 2023 07:08:48 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1442170AbjLMPIc (ORCPT + 99 others); Wed, 13 Dec 2023 10:08:32 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42758 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1442073AbjLMPIb (ORCPT ); Wed, 13 Dec 2023 10:08:31 -0500 Received: from mail-yw1-x1132.google.com (mail-yw1-x1132.google.com [IPv6:2607:f8b0:4864:20::1132]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 13E7C93; Wed, 13 Dec 2023 07:08:38 -0800 (PST) Received: by mail-yw1-x1132.google.com with SMTP id 00721157ae682-5e25d1d189eso12141507b3.0; Wed, 13 Dec 2023 07:08:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1702480117; x=1703084917; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=JEPH+eGb7fInmyjspViQgARNCBB0nvNmZOxruBaRhvo=; b=BimPnpdaCkKjDBvk3uTHztLC3ubFE0Zhz3tNWxp4ag27TMQ/2lZrjTg/snQaKK0Khq 2vjrad3JIC9DCgLOajyHtnq0NncAbeSYs4y5n8d/PYGZ3ulrEQfDMejs1YYm4o4gJpKg CHQb5HEl0bepnAVvTSQWm7TZpiNIk23uIQ2EZV8lVAPPyL+w/CUy+XACOWCNWVa+T7AS FR90rKbDwgKLclz6ZGChnCTpHwuQ/gqWJNrozxDsN8UvEGrZ3L63HdsiW2CZYGorZW03 Z8R8M0XyMQe3q+Fak8h6/HS2//kCNqp++ifa3QYjJUb+R/wWPuA2XwoJXlyfWz04eU1V nqvg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702480117; x=1703084917; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=JEPH+eGb7fInmyjspViQgARNCBB0nvNmZOxruBaRhvo=; b=eCgLPihZC95RnOvHWTFUo0/HU5GrrBBw7PvVVdZmeM1zV3VFEjfp4R+wcaFV51+m1X SQisWEg7gAzXJtzvE84IsgOdA2XpQb0GYv6KRREdXpHO30URS/PExTApbk02k0K7ZvX1 /HGFvIz4ZoPKF1QC3+r91oX47a09fmJPKjmK1yRra7ao7cR/JwrGt/Xg/gHDtO6BGTCP qpmy0d7tvO69U6Xotnt9IuGijNCiSc1cVkT2Zwjm2vYXgtIkMO8yWeqB2LO1HKkh4eIR tKvUlLpyASwT0uMOTol4ZTxTXoVycv5MMpilNuWRnDYTydP3UgSAA7BDIx07lmwSOHZ0 Gl2A== X-Gm-Message-State: AOJu0YybDVJQLGOEt8YcrwbXWAdqkWuqDrCxjClgpZEZVfy4skaBcnTX cPkuPTiRA1jJP+EAkt2NB4v1p9prKeDBNe0VtUo= X-Received: by 2002:a81:df03:0:b0:5cb:1b6e:da89 with SMTP id c3-20020a81df03000000b005cb1b6eda89mr6487759ywn.12.1702480117084; Wed, 13 Dec 2023 07:08:37 -0800 (PST) MIME-Version: 1.0 References: <20231212192317.0fb6b101@gandalf.local.home> <20231213095749.5ff64569@gandalf.local.home> In-Reply-To: <20231213095749.5ff64569@gandalf.local.home> From: Alexander Kapshuk Date: Wed, 13 Dec 2023 17:08:00 +0200 Message-ID: Subject: Re: [PATCH v3] tracing/selftests: Add test to test the trace_marker To: Steven Rostedt Cc: LKML , Linux Trace Kernel , Masami Hiramatsu , Mark Rutland , Mathieu Desnoyers , Shuah Khan , linux-kselftest@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, 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 groat.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 (groat.vger.email [0.0.0.0]); Wed, 13 Dec 2023 07:08:49 -0800 (PST) On Wed, Dec 13, 2023 at 4:57=E2=80=AFPM Steven Rostedt wrote: > > 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 de= sired. > > > > On Wed, Dec 13, 2023 at 2:22=E2=80=AFAM Steven Rostedt wrote: > > > > > > From: "Steven Rostedt (Google)" > > > > > > Add a test that writes longs strings, some over the size of the sub b= uffer > > > 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/20231212= 151632.25c9b67d@gandalf.local.home > > > > > > - Realized with the upcoming change of the dynamic subbuffer sizes, t= hat > > > 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 sub= buffer > > > 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/tra= ce_marker.tc > > > > > > diff --git a/tools/testing/selftests/ftrace/test.d/00basic/trace_mark= er.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/heade= r_page > > sed -n 's!.*data.*size:\([^;]*\).*!\1!p' events/header_page > > Not sure the above change can be considered simpler, but it also loses ou= t > showing what exactly is being done. > > With the original, I have: > > sed -ne 's/^.*data.*size:\([0-9][0-9]*\).*/\1/p' events/header_pag= e > > 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/hea= der_page > > sed -n 's!.*data.*offset:\([^;]*\).*!\1!p' events/header_pa= ge > > Same here. > > > > +} > > > + > > > +get_event_header_size() { > > > + type_len=3D`sed -ne 's/^.*type_len.*:[^0-9]*\([0-9][0-9]*\).*= /\1/p' events/header_event` > > type_len=3D`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 t= he > format field. > > > > > > + time_len=3D`sed -ne 's/^.*time_delta.*:[^0-9]*\([0-9][0-9]*\)= .*/\1/p' events/header_event` > > time_len=3D`sed -n '/time_delta/s![^0-9]*!!gp' events/heade= r_event` > > > > > + array_len=3D`sed -ne 's/^.*array.*:[^0-9]*\([0-9][0-9]*\).*/\= 1/p' events/header_event` > > array_len=3D`sed -n '/array/s![^0-9]*!!gp' events/header_ev= ent` > > > > > + total_bits=3D$((type_len+time_len+array_len)) > > > + total_bits=3D$((total_bits+7)) > > > + echo $((total_bits/8)) > > > +} > > > + > > > +get_print_event_buf_offset() { > > > + sed -ne 's/^.*buf.*offset:\([0-9][0-9]*\).*/\1/p' events/ftra= ce/print/format > > sed -n 's!.*buf.*offset:\([^;]*\).*!\1!p' events/ftrace/pri= nt/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 Fair enough. Thanks.