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 0819445A0E; Mon, 23 Sep 2024 10:40:15 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id A33C5402B4; Mon, 23 Sep 2024 10:40:14 +0200 (CEST) Received: from mail-qt1-f179.google.com (mail-qt1-f179.google.com [209.85.160.179]) by mails.dpdk.org (Postfix) with ESMTP id 1F0574029F for ; Mon, 23 Sep 2024 10:40:14 +0200 (CEST) Received: by mail-qt1-f179.google.com with SMTP id d75a77b69052e-4581e7f31eeso35236301cf.0 for ; Mon, 23 Sep 2024 01:40:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1727080813; x=1727685613; 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=xBXLegiTjVrEh+TSgUKrLXDmcfF0+yGIVZW7ExXugTA=; b=D5/SbMhzPdMolSEDXr4JDsf+w9JjkJGTvdmUA4dpMRT5A+oKtNod0m/AOCIMQ1o88w VSXszgbum+mzTUAeZmsyAj62aUCewiIvGuEoJpIByTJGgIkFxK7kOaZdSzOKDJT9TKwW 0D/kOmnNT9YBaEfJBeFbTcVyGwt74D0jaKiYgvKSPK9t/ksaOfvPnYnHDye+L1dBr6l/ 7jHMvKzypUE0qnHLvxwBi9MXxpf0EyosKoGsXOjggRC19HZAIlslsSsSrDPHJTi3jYnT VkIVM7ow+ZXNgaeGB0D6m9n8XdUWg2GKHvQqWL6BlMEJDtTf2/Gzd35MOG4AMkqkrAUr YZ8A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727080813; x=1727685613; 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=xBXLegiTjVrEh+TSgUKrLXDmcfF0+yGIVZW7ExXugTA=; b=ft33Q/n1Q2tRQCaxZtk+MqSQ/zYsySqM+uH3+N+ip2dZB13a8d+8ZYVajlWx5whwli Y8/Pas9GDgBdC9efZiFmWOLMypVjEtS5VjOJZfuLjaNEt7KDl+rChN6T6eEUWvEt9iX0 uHzSMYjSdbdUKYKZ3GxjfvwM/rmTi//S0ntITtdHZQidpRgNG+XErqIiIuqLmv9b6lF8 8q9hWF32prwNQJ2TsWPpsDxZpKlKevjLlQN/1f9vwPatbgbo9zeyNP3nRrRTBwlSyz0t BH3rsbvyulIkmuRy3H1VPjL6m8pQVNbsjQLh6lePWxQg7ZuvhVTrEWNNUTx/V6Y3T1i8 wkUg== X-Forwarded-Encrypted: i=1; AJvYcCUyl/jx/ETLoypvhtIUxZXJ/5dycKmVfUEyc7qSGJEoorsRkxz7oTjsLgJdf5TO62V8zxY=@dpdk.org X-Gm-Message-State: AOJu0YxbsAsdj0HSgP6Q+23JaSoyeXc01Trxomr8ScidrLEw/CQptGoX bkO3iPjZxeJUJGfxEgoyDJZIWIIYINwEU2O9AEbF6NWgu8a0zl1f6+zkZDqm0aBD2Esupflvnqg oxy3jiglADMhAt9X6tqTzNPvNrak= X-Google-Smtp-Source: AGHT+IGwBDQPZPFlh372J5rD/XQWviUBcAt3UrZi1Fq5nGt4QAb7wgaH4uY7LF8ohzCA44skcOK238u7Ti/GY7uB0XE= X-Received: by 2002:a05:622a:1a1c:b0:458:2405:3b68 with SMTP id d75a77b69052e-45b204de38fmr174112391cf.6.1727080813376; Mon, 23 Sep 2024 01:40:13 -0700 (PDT) MIME-Version: 1.0 References: <20240918085551.231015-1-mb@smartsharesystems.com> <20240920090826.571755-1-mb@smartsharesystems.com> In-Reply-To: <20240920090826.571755-1-mb@smartsharesystems.com> From: Jerin Jacob Date: Mon, 23 Sep 2024 14:09:47 +0530 Message-ID: Subject: Re: [PATCH v3] 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 Fri, Sep 20, 2024 at 2:38=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 > --- > v3: > * Simpler version with much fewer ifdefs. (Jerin Jacob) > v2: > * Added/modified macros required for building applications with trace > omitted. > --- > app/test/test_trace.c | 11 ++++++++++- > config/rte_config.h | 1 + > lib/eal/include/rte_trace_point.h | 21 +++++++++++++++++++++ > 3 files changed, 32 insertions(+), 1 deletion(-) > > 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) Now that, we are is not disabling any symbols, This conditional compilation can be removed. Use __rte_trace_point_generic_is_enabled() in another leg. > + > +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..b80688ce89 100644 > --- a/lib/eal/include/rte_trace_point.h > +++ b/lib/eal/include/rte_trace_point.h > @@ -212,6 +212,25 @@ bool rte_trace_point_is_enabled(rte_trace_point_t *t= p); > __rte_experimental > rte_trace_point_t *rte_trace_point_lookup(const char *name); > > +/** > + * @internal > + * > + * Test if the tracepoint compile-time option is enabled. > + * > + * @return > + * true if tracepoint enabled, false otherwise. > + */ > +__rte_experimental > +static __rte_always_inline bool > +__rte_trace_point_generic_is_enabled(void) Add to version.map file > +{ > +#ifdef RTE_TRACE > + return true; > +#else > + return false; > +#endif > +} > + > /** > * @internal > * > @@ -359,6 +378,8 @@ __rte_trace_point_emit_ev_header(void *mem, uint64_t = in) > #define __rte_trace_point_emit_header_generic(t) \ > void *mem; \ > do { \ > + if (!__rte_trace_point_generic_is_enabled()) \ > + return; \ To be super safe, Add similar check in RTE_INIT(trace##_init) > const uint64_t val =3D rte_atomic_load_explicit(t, rte_memory_ord= er_acquire); \ > if (likely(!(val & __RTE_TRACE_FIELD_ENABLE_MASK))) \ > return; \ > -- > 2.43.0 >