patches for DPDK stable branches
 help / color / mirror / Atom feed
From: Sunil Kumar Kori <skori@marvell.com>
To: David Marchand <david.marchand@redhat.com>,
	"dev@dpdk.org" <dev@dpdk.org>
Cc: "stable@dpdk.org" <stable@dpdk.org>,
	Jerin Jacob Kollanukkaran <jerinj@marvell.com>
Subject: RE: [EXT] [PATCH 4/8] trace: fix dynamically enabling trace points
Date: Thu, 22 Sep 2022 11:18:05 +0000	[thread overview]
Message-ID: <CO6PR18MB386015871DC31023C9947686B44E9@CO6PR18MB3860.namprd18.prod.outlook.com> (raw)
In-Reply-To: <20220921120359.2201131-5-david.marchand@redhat.com>

> -----Original Message-----
> From: David Marchand <david.marchand@redhat.com>
> Sent: Wednesday, September 21, 2022 5:34 PM
> To: dev@dpdk.org
> Cc: stable@dpdk.org; Jerin Jacob Kollanukkaran <jerinj@marvell.com>; Sunil
> Kumar Kori <skori@marvell.com>
> Subject: [EXT] [PATCH 4/8] trace: fix dynamically enabling trace points
> 
> External Email
> 
> ----------------------------------------------------------------------
> Enabling trace points at runtime was not working if no trace point had been
> enabled first at rte_eal_init() time. The reason was that trace.args reflected
> the arguments passed to --trace= EAL option.
> 
> To fix this:
> - the trace subsystem initialisation is updated: trace directory
>   creation is deferred to when traces are dumped (to avoid creating
>   directories that may not be used),
> - per lcore memory allocation still relies on rte_trace_is_enabled() but
>   this helper now tracks if any trace point is enabled. The
>   documentation is updated accordingly,
> - cleanup helpers must always be called in rte_eal_cleanup() since some
>   trace points might have been enabled and disabled in the lifetime of
>   the DPDK application,
> 
> With this fix, we can update the unit test and check that a trace point callback
> is invoked when expected.
> 
> Note:
> - the 'trace' global variable might be shadowed with the argument
>   passed to the functions dealing with trace point handles.
>   'tp' has been used for referring to trace_point object.
>   Prefer 't' for referring to handles,
> 
> Fixes: 84c4fae4628f ("trace: implement operation APIs")
> Cc: stable@dpdk.org
> 
> Signed-off-by: David Marchand <david.marchand@redhat.com>
> ---
>  app/test/test_trace.c                   | 20 ++++++++++
>  app/test/test_trace.h                   |  2 +
>  doc/guides/prog_guide/trace_lib.rst     | 14 +++++--
>  lib/eal/common/eal_common_trace.c       | 53 ++++++++++---------------
>  lib/eal/common/eal_common_trace_utils.c | 17 +++++++-
>  lib/eal/common/eal_trace.h              |  3 +-
>  6 files changed, 70 insertions(+), 39 deletions(-)
> 
> 

[snipped]

>  int
> -rte_trace_point_disable(rte_trace_point_t *trace)
> +rte_trace_point_disable(rte_trace_point_t *t)
>  {
> -	if (trace_point_is_invalid(trace))
> +	uint64_t prev;
> +
> +	if (trace_point_is_invalid(t))
>  		return -ERANGE;
> 
> -	__atomic_and_fetch(trace, ~__RTE_TRACE_FIELD_ENABLE_MASK,
> -		__ATOMIC_RELEASE);
> +	prev = __atomic_fetch_and(t, ~__RTE_TRACE_FIELD_ENABLE_MASK,
> __ATOMIC_RELEASE);
> +	if ((prev & __RTE_TRACE_FIELD_ENABLE_MASK) != 0)
> +		__atomic_sub_fetch(&trace.status, 1, __ATOMIC_RELEASE);
>  	return 0;
>  }
> 
IMO, above change should go as a separate commit as it just replaces the variable name.

> @@ -413,9 +407,6 @@ trace_mem_free(void)
>  	struct trace *trace = trace_obj_get();
>  	uint32_t count;
> 
> -	if (!rte_trace_is_enabled())
> -		return;
> -
>  	rte_spinlock_lock(&trace->lock);
>  	for (count = 0; count < trace->nb_trace_mem_list; count++) {
>  		trace_mem_per_thread_free_unlocked(&trace-
> >lcore_meta[count]);
> diff --git a/lib/eal/common/eal_common_trace_utils.c
> b/lib/eal/common/eal_common_trace_utils.c
> index 2b55dbec65..6340caabbf 100644
> --- a/lib/eal/common/eal_common_trace_utils.c
> +++ b/lib/eal/common/eal_common_trace_utils.c
> @@ -314,14 +314,18 @@ trace_dir_default_path_get(char *dir_path)
>  	return 0;
>  }
> 
> -int
> +static int
>  trace_mkdir(void)
>  {
>  	struct trace *trace = trace_obj_get();
>  	char session[TRACE_DIR_STR_LEN];
> +	static bool already_done;
>  	char *dir_path;
>  	int rc;
> 
> +	if (already_done)
> +		return 0;
> +
>  	if (!trace->dir_offset) {
>  		dir_path = calloc(1, sizeof(trace->dir));
>  		if (dir_path == NULL) {
> @@ -364,7 +368,8 @@ trace_mkdir(void)
>  		return -rte_errno;
>  	}
> 
> -	RTE_LOG(INFO, EAL, "Trace dir: %s\n", trace->dir);
> +	RTE_LOG(DEBUG, EAL, "Trace dir: %s\n", trace->dir);
> +	already_done = true;

I request you to keep it as INFO only. If a user enables traces, then it will give information directly about the directory without running in debug mode. 

>  	return 0;
>  }
> 
> @@ -375,6 +380,10 @@ trace_meta_save(struct trace *trace)
>  	FILE *f;
>  	int rc;
> 
> +	rc = trace_mkdir();
> +	if (rc < 0)
> +		return rc;
> +

Trace directory is being created here and in trace_mem_save() function along with the logic to handle whether it is already done or not.
Instead can't it be called in rte_trace_save() directly. That will suffice the intention, I believe.

>  	rc = snprintf(file_name, PATH_MAX, "%s/metadata", trace->dir);
>  	if (rc < 0)
>  		return rc;
> @@ -406,6 +415,10 @@ trace_mem_save(struct trace *trace, struct
> __rte_trace_header *hdr,
>  	FILE *f;
>  	int rc;
> 
> +	rc = trace_mkdir();
> +	if (rc < 0)
> +		return rc;
> +
>  	rc = snprintf(file_name, PATH_MAX, "%s/channel0_%d", trace->dir,
> cnt);
>  	if (rc < 0)
>  		return rc;
> --

[snipped]
> 2.37.3


  reply	other threads:[~2022-09-22 11:18 UTC|newest]

Thread overview: 48+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20220921120359.2201131-1-david.marchand@redhat.com>
2022-09-21 12:03 ` [PATCH 1/8] trace: fix mode for new trace point David Marchand
2022-09-21 12:03 ` [PATCH 2/8] trace: fix mode change David Marchand
2022-09-21 12:03 ` [PATCH 3/8] trace: fix leak with regexp David Marchand
2022-09-22 11:00   ` [EXT] " Sunil Kumar Kori
2022-09-23  6:35     ` David Marchand
2022-09-23  7:37       ` Sunil Kumar Kori
2022-09-21 12:03 ` [PATCH 4/8] trace: fix dynamically enabling trace points David Marchand
2022-09-22 11:18   ` Sunil Kumar Kori [this message]
2022-09-23  6:36     ` [EXT] " David Marchand
2022-09-21 12:03 ` [PATCH 5/8] trace: fix race in debug dump David Marchand
2022-10-11 14:37   ` Jerin Jacob
2022-09-21 12:03 ` [PATCH 6/8] trace: fix metadata dump David Marchand
     [not found] ` <20221004094418.196544-1-david.marchand@redhat.com>
2022-10-04  9:44   ` [PATCH v2 1/9] trace: fix mode for new trace point David Marchand
2022-10-11 14:16     ` Jerin Jacob
2022-10-12  9:05     ` [EXT] " Sunil Kumar Kori
2022-10-04  9:44   ` [PATCH v2 2/9] trace: fix mode change David Marchand
2022-10-11 14:20     ` Jerin Jacob
2022-10-12  9:07     ` [EXT] " Sunil Kumar Kori
2022-10-04  9:44   ` [PATCH v2 3/9] trace: fix leak with regexp David Marchand
2022-10-11 14:21     ` Jerin Jacob
2022-10-12  9:10     ` [EXT] " Sunil Kumar Kori
2022-10-04  9:44   ` [PATCH v2 5/9] trace: fix dynamically enabling trace points David Marchand
2022-10-12  9:23     ` [EXT] " Sunil Kumar Kori
2022-10-12  9:57       ` David Marchand
2022-10-12 10:15         ` Sunil Kumar Kori
2022-10-04  9:44   ` [PATCH v2 6/9] trace: fix race in debug dump David Marchand
2022-10-12  9:25     ` [EXT] " Sunil Kumar Kori
2022-10-04  9:44   ` [PATCH v2 7/9] trace: fix metadata dump David Marchand
2022-10-12  9:28     ` [EXT] " Sunil Kumar Kori
     [not found] ` <20221012123112.2951802-1-david.marchand@redhat.com>
2022-10-12 12:31   ` [PATCH v3 1/9] trace: fix mode for new trace point David Marchand
2022-10-12 12:31   ` [PATCH v3 2/9] trace: fix mode change David Marchand
2022-10-12 12:31   ` [PATCH v3 3/9] trace: fix leak with regexp David Marchand
2022-10-12 12:31   ` [PATCH v3 5/9] trace: fix dynamically enabling trace points David Marchand
2022-10-13 14:53     ` [EXT] " Harman Kalra
2022-10-13 15:51       ` David Marchand
2022-10-13 17:07         ` Harman Kalra
2022-10-13 19:10           ` David Marchand
2022-10-14  4:26             ` Jerin Jacob
2022-10-14  8:19               ` David Marchand
2022-10-14  8:37                 ` Jerin Jacob
2022-10-12 12:31   ` [PATCH v3 6/9] trace: fix race in debug dump David Marchand
2022-10-12 12:31   ` [PATCH v3 7/9] trace: fix metadata dump David Marchand
     [not found] ` <20221018132654.3760561-1-david.marchand@redhat.com>
2022-10-18 13:26   ` [PATCH v4 01/11] trace: fix mode for new trace point David Marchand
2022-10-18 13:26   ` [PATCH v4 02/11] trace: fix mode change David Marchand
2022-10-18 13:26   ` [PATCH v4 03/11] trace: fix leak with regexp David Marchand
2022-10-18 13:26   ` [PATCH v4 05/11] trace: fix dynamically enabling trace points David Marchand
2022-10-18 13:26   ` [PATCH v4 06/11] trace: fix race in debug dump David Marchand
2022-10-18 13:26   ` [PATCH v4 07/11] trace: fix metadata dump David Marchand

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CO6PR18MB386015871DC31023C9947686B44E9@CO6PR18MB3860.namprd18.prod.outlook.com \
    --to=skori@marvell.com \
    --cc=david.marchand@redhat.com \
    --cc=dev@dpdk.org \
    --cc=jerinj@marvell.com \
    --cc=stable@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).