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 D7BD5459C3; Wed, 18 Sep 2024 11:50:26 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 8C7BD427DB; Wed, 18 Sep 2024 11:50:26 +0200 (CEST) Received: from mail-qt1-f170.google.com (mail-qt1-f170.google.com [209.85.160.170]) by mails.dpdk.org (Postfix) with ESMTP id 7B3C640E1E for ; Wed, 18 Sep 2024 11:50:24 +0200 (CEST) Received: by mail-qt1-f170.google.com with SMTP id d75a77b69052e-4585e25f42bso54328371cf.2 for ; Wed, 18 Sep 2024 02:50:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1726653024; x=1727257824; darn=dpdk.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=CJu5bO33tFQtRiGewmHkRSNwf9FPNz64WFNpEt2GoyQ=; b=np0FcT7+/3kb5t/MHC78GeJYkR8BqsJ+diwcfYa94GXR0xj8Jl96SJhgj8rLwWjgBT motfmh9AuKcXWDumodFGKTPoomIAuSe1HRVgHPKHdrduwNQfo8O3ZrQuZOSPkCOlDweQ lJhYEmqqkePhxp8TLQRWfpaPyQKHhzC4N565p0TRkXFtPT39+U+zLGuJnWAjiFw61579 lJuJNFq7klVQCJiWxPMcRH9J8J2c6DdvX/1AsSwp/zs5fbYgco15Cnv7UPAa4yYzEkdV Fuk7HkvnRwNVhQogh8CewbQM232rGH4MsRd2W4nBsIw72vXawP28+rW7PI/Bq5IyX7wQ jlLg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726653024; x=1727257824; 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=CJu5bO33tFQtRiGewmHkRSNwf9FPNz64WFNpEt2GoyQ=; b=L2hiEPj56ChujsBmL04uI3kGdWAgXYPpfmxss5sDIcgW/9hz3xP0HetGYuZ94bcUmh WLE1JcklyKVnj9bVw7moJxlYUytHfuxtSwkEMPO9IMCkb9tF00cbDNdw3apwDB1O/bX6 N3XSxqACv32WhhNJoNCoJux+8AMUPf/s6unB8u7+KnRvxVi5GsMl04q4O5SvrrTdsd9k vQ0DYSAg/gJImA9IDoG0JHXEcL2eeq46QbC6JASIGiNQHIODMKIZlte4gl12ZwElGMYD Pe8dt97cyzQtGz5tJhTeRrGRspA0jNS265kDELOl3pOqlXkKkldAbLMsFaSEvrHMItug jEZQ== X-Forwarded-Encrypted: i=1; AJvYcCU6DrLVZMhxyycBbNtUVbSr1NQrghsAUlUq8DfRPIsWupC1r7tRhlrxkyHPwo69wfpqB1E=@dpdk.org X-Gm-Message-State: AOJu0YwUO+ruT0PLw2mS79itEvLYMFw5KJMNBoky6qGQeXQcNKeus94l sr3/AHs0z+fdNNtz6TzuUXnFpD1myNAwSATUXecLeacHGKO0mFtq2MVo799E/zbiPdMqUPDKISh oJpRGVlf67VbKGzqVUeqSpuiHWsw= X-Google-Smtp-Source: AGHT+IFhPUr/iXJrYYtkGH3tvqSmjvseKbe5iWIg/MTecBMhlFBwY/wWZi8RtTQmH1uA7HYr7NKPSQEX0OeloU/gtnc= X-Received: by 2002:ac8:57d2:0:b0:458:4025:818c with SMTP id d75a77b69052e-4599d2d8754mr238639021cf.60.1726653023757; Wed, 18 Sep 2024 02:50:23 -0700 (PDT) MIME-Version: 1.0 References: <20240918085551.231015-1-mb@smartsharesystems.com> In-Reply-To: <20240918085551.231015-1-mb@smartsharesystems.com> From: Jerin Jacob Date: Wed, 18 Sep 2024 15:19:57 +0530 Message-ID: Subject: Re: [PATCH] eal: add build-time option to omit trace To: =?UTF-8?Q?Morten_Br=C3=B8rup?= Cc: Jerin Jacob , Sunil Kumar Kori , dev@dpdk.org 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, Sep 18, 2024 at 2:39=E2=80=AFPM Morten Br=C3=B8rup wrote: > > Some applications want to omit the trace feature. > Either to reduce the memory footprint, to reduce the exposed attack > surface, or for other reasons. > > This patch adds an option in rte_config.h to include or omit trace in the > build. Trace is included by default. > > Omitting trace works by omitting all trace points. > For API and ABI compatibility, the trace feature itself remains. > > Signed-off-by: Morten Br=C3=B8rup > --- > app/test/test_trace.c | 11 ++++++++++- > config/rte_config.h | 1 + > lib/eal/include/rte_trace_point.h | 6 +++++- > lib/eal/include/rte_trace_point_register.h | 8 ++++++++ > 4 files changed, 24 insertions(+), 2 deletions(-) > > diff --git a/app/test/test_trace.c b/app/test/test_trace.c > index 00809f433b..7918cc865d 100644 > --- a/app/test/test_trace.c > +++ b/app/test/test_trace.c > @@ -12,7 +12,16 @@ > > int app_dpdk_test_tp_count; > > -#ifdef RTE_EXEC_ENV_WINDOWS > +#if !defined(RTE_TRACE) > + > +static int > +test_trace(void) > +{ > + printf("trace omitted at build-time, skipping test\n"); > + return TEST_SKIPPED; > +} > + > +#elif defined(RTE_EXEC_ENV_WINDOWS) > > static int > test_trace(void) > diff --git a/config/rte_config.h b/config/rte_config.h > index dd7bb0d35b..fd6f8a2f1a 100644 > --- a/config/rte_config.h > +++ b/config/rte_config.h > @@ -49,6 +49,7 @@ > #define RTE_MAX_TAILQ 32 > #define RTE_LOG_DP_LEVEL RTE_LOG_INFO > #define RTE_MAX_VFIO_CONTAINERS 64 > +#define RTE_TRACE 1 > > /* bsd module defines */ > #define RTE_CONTIGMEM_MAX_NUM_BUFS 64 > diff --git a/lib/eal/include/rte_trace_point.h b/lib/eal/include/rte_trac= e_point.h > index 41e2a7f99e..1b60bba043 100644 > --- a/lib/eal/include/rte_trace_point.h > +++ b/lib/eal/include/rte_trace_point.h > @@ -212,6 +212,7 @@ bool rte_trace_point_is_enabled(rte_trace_point_t *tp= ); > __rte_experimental > rte_trace_point_t *rte_trace_point_lookup(const char *name); > > +#ifdef RTE_TRACE > /** > * @internal > * > @@ -230,6 +231,7 @@ __rte_trace_point_fp_is_enabled(void) > return false; > #endif > } > +#endif /* RTE_TRACE */ > > /** > * @internal > @@ -356,6 +358,8 @@ __rte_trace_point_emit_ev_header(void *mem, uint64_t = in) > return RTE_PTR_ADD(mem, __RTE_TRACE_EVENT_HEADER_SZ); > } > > +#ifdef RTE_TRACE Please change to 1.4.5 style _if possible_ in https://doc.dpdk.org/guides/contributing/coding_style.html. Assuming linker will remove the memory from the image if it is not using by stubbing out. Untested. #define __rte_trace_point_emit_header_generic(t) \ void *mem; \ do { \ + if (RTE_TRACE_ENABLED =3D=3D 0) \ + return \ const uint64_t val =3D rte_atomic_load_explicit(t, rte_memory_order_acquire); \ if (likely(!(val & __RTE_TRACE_FIELD_ENABLE_MASK))) \ return; \ mem =3D __rte_trace_mem_get(val); \ if (unlikely(mem =3D=3D NULL)) \ return; \ mem =3D __rte_trace_point_emit_ev_header(mem, val); \ } while (0) > + > #define __rte_trace_point_emit_header_generic(t) \ > void *mem; \ > do { \ > @@ -411,7 +415,7 @@ do { \ > RTE_SET_USED(len); \ > } while (0) > > - > +#endif /* RTE_TRACE */ > #endif /* ALLOW_EXPERIMENTAL_API */ > #endif /* _RTE_TRACE_POINT_REGISTER_H_ */ > > diff --git a/lib/eal/include/rte_trace_point_register.h b/lib/eal/include= /rte_trace_point_register.h > index 41260e5964..78c0ede5f1 100644 > --- a/lib/eal/include/rte_trace_point_register.h > +++ b/lib/eal/include/rte_trace_point_register.h > @@ -18,6 +18,8 @@ extern "C" { > > RTE_DECLARE_PER_LCORE(volatile int, trace_point_sz); > > +#ifdef RTE_TRACE > + > #define RTE_TRACE_POINT_REGISTER(trace, name) \ > rte_trace_point_t __rte_section("__rte_trace_point") __##trace; \ > static const char __##trace##_name[] =3D RTE_STR(name); \ > @@ -27,6 +29,12 @@ RTE_INIT(trace##_init) \ > (void (*)(void)) trace); \ > } > > +#else > + > +#define RTE_TRACE_POINT_REGISTER(trace, name) > + > +#endif /* RTE_TRACE */ > + > #define __rte_trace_point_emit_header_generic(t) \ > RTE_PER_LCORE(trace_point_sz) =3D __RTE_TRACE_EVENT_HEADER_SZ > > -- > 2.43.0 >