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 1351845AF2; Wed, 9 Oct 2024 14:50:05 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 0204F4065D; Wed, 9 Oct 2024 14:50:05 +0200 (CEST) Received: from dkmailrelay1.smartsharesystems.com (smartserver.smartsharesystems.com [77.243.40.215]) by mails.dpdk.org (Postfix) with ESMTP id D81F54065D for ; Wed, 9 Oct 2024 14:50:03 +0200 (CEST) Received: from smartserver.smartsharesystems.com (smartserver.smartsharesys.local [192.168.4.10]) by dkmailrelay1.smartsharesystems.com (Postfix) with ESMTP id AA8BC20694; Wed, 9 Oct 2024 14:50:03 +0200 (CEST) Content-class: urn:content-classes:message Subject: RE: [PATCH v13 4/4] eal: add PMU support to tracing library MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Date: Wed, 9 Oct 2024 14:50:02 +0200 Message-ID: <98CBD80474FA8B44BF855DF32C47DC35E9F7A8@smartserver.smartshare.dk> In-Reply-To: <20241009112308.2973903-5-tduszynski@marvell.com> X-MS-Has-Attach: X-MimeOLE: Produced By Microsoft Exchange V6.5 X-MS-TNEF-Correlator: Thread-Topic: [PATCH v13 4/4] eal: add PMU support to tracing library Thread-Index: AdsaPbUsRh5KbYZdRkWvIQixj/QLnwACsifw References: <20240927220630.1802971-1-tduszynski@marvell.com> <20241009112308.2973903-1-tduszynski@marvell.com> <20241009112308.2973903-5-tduszynski@marvell.com> From: =?iso-8859-1?Q?Morten_Br=F8rup?= To: "Tomasz Duszynski" , "Jerin Jacob" , "Sunil Kumar Kori" , "Tyler Retzlaff" Cc: , , , , , , , 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 > 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. > + > +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; > +} This --trace parameter takes a regex, but the --log-level parameter = takes a globbing pattern (and a regex, for backwards compatibility, I = assume). This --trace parameter should behave like the --log-level parameter, or = if not able to parse both, use globbing pattern, not regex. Check the --trace parameter parser here: https://elixir.bootlin.com/dpdk/v24.07/source/lib/eal/common/eal_common_o= ptions.c#L1409