From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 8FDE2A04AF; Sun, 3 May 2020 22:33:10 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id BABAD1D551; Sun, 3 May 2020 22:32:30 +0200 (CEST) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by dpdk.org (Postfix) with ESMTP id 58DA31D54E for ; Sun, 3 May 2020 22:32:29 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1588537948; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=1jnK42+XP6JFecF5s+LCfXD+UQxTRe1OlOSNrAY1a+c=; b=YYClXdZWWBNdLtohbN9rIEG/+HotzyOM9VgByHvCVuzzwLqMTrR0xVo4f/aG+fCDJn4tfg Gmebm85M5fs6dFMNlv65TGmGhGBm8WvmAA/ef5Mvq3Lz6cGLnE1AUM5nHi7IEbi7REU+Ma Nwbo5558aVuBOpRf/RqP1D5r7QdGqus= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-44-BJcW6_m3MYWLOBut-R_Cyg-1; Sun, 03 May 2020 16:32:25 -0400 X-MC-Unique: BJcW6_m3MYWLOBut-R_Cyg-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 4299F107ACCA; Sun, 3 May 2020 20:32:24 +0000 (UTC) Received: from dmarchan.remote.csb (unknown [10.40.192.236]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9ABEA5798D; Sun, 3 May 2020 20:32:22 +0000 (UTC) From: David Marchand To: dev@dpdk.org Cc: thomas@monjalon.net, Jerin Jacob , Sunil Kumar Kori Date: Sun, 3 May 2020 22:31:33 +0200 Message-Id: <20200503203135.6493-7-david.marchand@redhat.com> In-Reply-To: <20200503203135.6493-1-david.marchand@redhat.com> References: <20200503203135.6493-1-david.marchand@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Subject: [dpdk-dev] [PATCH 6/8] trace: remove limitation on patterns number X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" There is nothing performance sensitive in this list, use dynamic allocations and remove the arbitrary limit on the number of trace patterns a user can pass. Signed-off-by: David Marchand --- lib/librte_eal/common/eal_common_trace.c | 10 +++--- .../common/eal_common_trace_utils.c | 33 ++++++++----------- lib/librte_eal/common/eal_trace.h | 8 ++--- 3 files changed, 23 insertions(+), 28 deletions(-) diff --git a/lib/librte_eal/common/eal_common_trace.c b/lib/librte_eal/comm= on/eal_common_trace.c index 5a365c61da..875553d7e5 100644 --- a/lib/librte_eal/common/eal_common_trace.c +++ b/lib/librte_eal/common/eal_common_trace.c @@ -21,7 +21,7 @@ static RTE_DEFINE_PER_LCORE(char, ctf_field[TRACE_CTF_FIE= LD_SIZE]); static RTE_DEFINE_PER_LCORE(int, ctf_count); =20 static struct trace_point_head tp_list =3D STAILQ_HEAD_INITIALIZER(tp_list= ); -static struct trace trace; +static struct trace trace =3D { .args =3D STAILQ_HEAD_INITIALIZER(trace.ar= gs), }; =20 struct trace * trace_obj_get(void) @@ -38,7 +38,7 @@ trace_list_head_get(void) int eal_trace_init(void) { -=09uint8_t i; +=09struct trace_arg *arg; =20 =09/* Trace memory should start with 8B aligned for natural alignment */ =09RTE_BUILD_BUG_ON((offsetof(struct __rte_trace_header, mem) % 8) !=3D 0)= ; @@ -49,7 +49,7 @@ eal_trace_init(void) =09=09goto fail; =09} =20 -=09if (trace.args.nb_args) +=09if (!STAILQ_EMPTY(&trace.args)) =09=09trace.status =3D true; =20 =09if (!rte_trace_is_enabled()) @@ -82,8 +82,8 @@ eal_trace_init(void) =09=09goto fail; =20 =09/* Apply global configurations */ -=09for (i =3D 0; i < trace.args.nb_args; i++) -=09=09trace_args_apply(trace.args.args[i]); +=09STAILQ_FOREACH(arg, &trace.args, next) +=09=09trace_args_apply(arg->val); =20 =09rte_trace_mode_set(trace.mode); =20 diff --git a/lib/librte_eal/common/eal_common_trace_utils.c b/lib/librte_ea= l/common/eal_common_trace_utils.c index 4077acf428..15384ce4f1 100644 --- a/lib/librte_eal/common/eal_common_trace_utils.c +++ b/lib/librte_eal/common/eal_common_trace_utils.c @@ -138,25 +138,20 @@ int eal_trace_args_save(const char *val) { =09struct trace *trace =3D trace_obj_get(); -=09char *trace_args; -=09uint8_t nb_args; +=09struct trace_arg *arg =3D malloc(sizeof(*arg)); =20 -=09nb_args =3D trace->args.nb_args; - -=09if (nb_args >=3D TRACE_MAX_ARGS) { -=09=09trace_err("ignoring trace %s as limit exceeds", val); -=09=09return 0; +=09if (arg =3D=3D NULL) { +=09=09trace_err("failed to allocate memory for %s", val); +=09=09return -ENOMEM; =09} =20 -=09trace_args =3D calloc(1, (strlen(val) + 1)); -=09if (trace_args =3D=3D NULL) { -=09=09trace_err("fail to allocate memory for %s", val); +=09arg->val =3D strdup(val); +=09if (arg->val =3D=3D NULL) { +=09=09trace_err("failed to allocate memory for %s", val); =09=09return -ENOMEM; =09} =20 -=09memcpy(trace_args, val, strlen(val)); -=09trace->args.args[nb_args++] =3D trace_args; -=09trace->args.nb_args =3D nb_args; +=09STAILQ_INSERT_TAIL(&trace->args, arg, next); =09return 0; } =20 @@ -164,13 +159,13 @@ void eal_trace_args_free(void) { =09struct trace *trace =3D trace_obj_get(); -=09int i; +=09struct trace_arg *arg; =20 -=09for (i =3D 0; i < trace->args.nb_args; i++) { -=09=09if (trace->args.args[i]) { -=09=09=09free((void *)trace->args.args[i]); -=09=09=09trace->args.args[i] =3D NULL; -=09=09} +=09while (!STAILQ_EMPTY(&trace->args)) { +=09=09arg =3D STAILQ_FIRST(&trace->args); +=09=09STAILQ_REMOVE_HEAD(&trace->args, next); +=09=09free(arg->val); +=09=09free(arg); =09} } =20 diff --git a/lib/librte_eal/common/eal_trace.h b/lib/librte_eal/common/eal_= trace.h index 7d95bd2aa9..943b5ecbc5 100644 --- a/lib/librte_eal/common/eal_trace.h +++ b/lib/librte_eal/common/eal_trace.h @@ -46,9 +46,9 @@ struct thread_mem_meta { =09enum trace_area_e area; }; =20 -struct trace_args { -=09uint8_t nb_args; -=09char *args[TRACE_MAX_ARGS]; +struct trace_arg { +=09STAILQ_ENTRY(trace_arg) next; +=09char *val; }; =20 struct trace { @@ -59,7 +59,7 @@ struct trace { =09enum rte_trace_mode mode; =09rte_uuid_t uuid; =09uint32_t buff_len; -=09struct trace_args args; +=09STAILQ_HEAD(trace_arg_head, trace_arg) args; =09uint32_t nb_trace_points; =09uint32_t nb_trace_mem_list; =09struct thread_mem_meta *lcore_meta; --=20 2.23.0