From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id C872245AF4; Wed, 9 Oct 2024 19:57:03 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 4B1B3427C7; Wed, 9 Oct 2024 19:57:03 +0200 (CEST) Received: from mail-pf1-f174.google.com (mail-pf1-f174.google.com [209.85.210.174]) by mails.dpdk.org (Postfix) with ESMTP id EC495427C6 for ; Wed, 9 Oct 2024 19:57:01 +0200 (CEST) Received: by mail-pf1-f174.google.com with SMTP id d2e1a72fcca58-71dfc78d6ddso91992b3a.0 for ; Wed, 09 Oct 2024 10:57:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1728496621; x=1729101421; darn=dpdk.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:from:to:cc:subject:date :message-id:reply-to; bh=pwVtyuiUWid36T/72claZlbRpU/9cOOllIYqTD5iUVs=; b=ptwB4O+ePnQCmXqnMXGs4Mo/Dt+0eYgH9LNbw9h5LmUlXrFJSYA6Ei8v4aGJjlJdeL ibqzgaQUhpQ14fQdJpJhaX3Xh3XQxV+AOe11xmB1YG36P754IxkML3x4hP2JyGUy117D B3niQd/jFFOUrLCw9L5LMpv5v3zcLHnaAXgQn3c3DmAL4Y8TMXzQw0oBC7bOhheTaSRY 08hnkrJFWqm9ex+qAewc6kEbRTPuewlo/AgcAv9zfRIz+GnIqCXQreYUi6nLlY5gW9jn smfCb0i5PPbLYKn7HRS8cGNIsRLTiF3RGp/MnRSopw6JpA8DGQv7Q57Jn7cY0SqFwE4a 36wQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728496621; x=1729101421; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=pwVtyuiUWid36T/72claZlbRpU/9cOOllIYqTD5iUVs=; b=u+Anfr2xG4qdNIPgGjQM4Yp7TgJHQLhATEGvnNU249cKV4tHuZN+O7ynXTMMnTahSa fD95FLMXxMmFL4tQHkn7sLzGjoN9wO9fgWM86AlN9ynZFGhxkmrYAmr97znAA+8CY5/f EBRCyE6YOl11vuZWmNtrYjDLdNywfbSfFqLRXHHWackl3M6BkNeSsyug2blNhINc8wni ceccPjk3ZZj59ReuoBKjO83H2BZn1VoavnraXiDVxOhRb9kP6wVt8po5UrfRZk1SbV6Z UqseQ5iYBX2g/EeHZvfjnlaSirAfSvKo8iSDGgxi4XbMK8B5JUzZXJSaEvaMzc9Wuc67 PSvg== X-Forwarded-Encrypted: i=1; AJvYcCXgqvicSx1ovnQEKxX1+7yNcP+yqF7lNF7EYMnCnGkZK7oHjvyl+6MnKFHK1IEgq8OAAG8=@dpdk.org X-Gm-Message-State: AOJu0YyJjKCG5HyetcGlvGROvokbu1AKBXyzh6Uiw1w9lih6bokXQmz2 AdmhjKMt4tONnPa/7/IdXNBJ5/AgpHrHKUnyJXVJCoKcuaz0aibeizDXCduYGr4= X-Google-Smtp-Source: AGHT+IHgEQCefBq+vWg6kRGtCVBWHuL1wKEkFjdBrKrLoPuvt9tlfXyWEChgh2Hde5cKpU4n0xs4sw== X-Received: by 2002:a05:6a21:4006:b0:1d4:fc75:8d48 with SMTP id adf61e73a8af0-1d8a3be380bmr6369308637.3.1728496621022; Wed, 09 Oct 2024 10:57:01 -0700 (PDT) Received: from hermes.local (204-195-96-226.wavecable.com. [204.195.96.226]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-7e9f6821c32sm8828744a12.33.2024.10.09.10.57.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Oct 2024 10:57:00 -0700 (PDT) Date: Wed, 9 Oct 2024 10:56:58 -0700 From: Stephen Hemminger To: Morten =?UTF-8?B?QnLDuHJ1cA==?= Cc: "Tomasz Duszynski" , "Jerin Jacob" , "Sunil Kumar Kori" , "Tyler Retzlaff" , , , , , , , , Subject: Re: [PATCH v13 4/4] eal: add PMU support to tracing library Message-ID: <20241009105658.18926a17@hermes.local> In-Reply-To: <98CBD80474FA8B44BF855DF32C47DC35E9F7A8@smartserver.smartshare.dk> References: <20240927220630.1802971-1-tduszynski@marvell.com> <20241009112308.2973903-1-tduszynski@marvell.com> <20241009112308.2973903-5-tduszynski@marvell.com> <98CBD80474FA8B44BF855DF32C47DC35E9F7A8@smartserver.smartshare.dk> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org On Wed, 9 Oct 2024 14:50:02 +0200 Morten Br=C3=B8rup wrote: > > From: Tomasz Duszynski [mailto:tduszynski@marvell.com] > > Sent: Wednesday, 9 October 2024 13.23 > >=20 > > +PMU tracepoint > > +-------------- > > + > > +Performance monitoring unit (PMU) event values can be read from > > hardware > > +registers using predefined ``rte_pmu_read`` tracepoint. > > + > > +Tracing is enabled via ``--trace`` EAL option by passing both > > expression > > +matching PMU tracepoint name i.e ``lib.eal.pmu.read`` and expression > > +``e=3Dev1[,ev2,...]`` matching particular events:: > > + > > + --trace=3D'.*pmu.read\|e=3Dcpu_cycles,l1d_cache' > > + > > +Event names are available under > > ``/sys/bus/event_source/devices/PMU/events`` > > +directory, where ``PMU`` is a placeholder for either a ``cpu`` or a > > directory > > +containing ``cpus``. > > + > > +In contrary to other tracepoints this does not need any extra > > variables > > +added to source files. Instead, caller passes index which follows the > > order of > > +events specified via ``--trace`` parameter. In the following example > > index ``0`` > > +corresponds to ``cpu_cyclces`` while index ``1`` corresponds to > > ``l1d_cache``. > > + > > +.. code-block:: c > > + > > + ... > > + rte_eal_trace_pmu_read(0); > > + rte_eal_trace_pmu_read(1); > > + ... > > + > > +PMU tracing support must be explicitly enabled using the > > ``enable_trace_fp`` > > +option for meson build. > > + =20 >=20 >=20 > > +int > > +rte_pmu_add_events_by_pattern(const char *pattern) > > +{ > > + regmatch_t rmatch; > > + char buf[BUFSIZ]; > > + unsigned int num; > > + regex_t reg; > > + int ret; > > + > > + /* events are matched against occurrences of e=3Dev1[,ev2,..] > > pattern */ > > + ret =3D regcomp(®, "e=3D([_[:alnum:]-],?)+", REG_EXTENDED); > > + if (ret) > > + return -EINVAL; > > + > > + for (;;) { > > + if (regexec(®, pattern, 1, &rmatch, 0)) > > + break; > > + > > + num =3D rmatch.rm_eo - rmatch.rm_so; > > + if (num > sizeof(buf)) > > + num =3D sizeof(buf); > > + > > + /* skip e=3D pattern prefix */ > > + memcpy(buf, pattern + rmatch.rm_so + 2, num - 2); > > + buf[num - 2] =3D '\0'; > > + ret =3D add_events(buf); > > + if (ret) > > + break; > > + > > + pattern +=3D rmatch.rm_eo; > > + } > > + > > + regfree(®); > > + > > + return ret; > > +} =20 >=20 > This --trace parameter takes a regex, but the --log-level parameter takes= a globbing pattern (and a regex, for backwards compatibility, I assume). >=20 > This --trace parameter should behave like the --log-level parameter, or i= f not able to parse both, use globbing pattern, not regex. >=20 > Check the --trace parameter parser here: > https://elixir.bootlin.com/dpdk/v24.07/source/lib/eal/common/eal_common_o= ptions.c#L1409 The log level has two API's one takes regex and one takes file glob pattern. The original one was the regex, but everybody (including the documentation)= got regex wrong when the log level format had periods in it. The glob match was more intuitive, and that is what is recommended. For tracing if you want to use regex then function should be named with _re= gexp( For extra bonus points, having both a regex and glob version (with pattern)= would be great.