Skip to contentSkip to conversation

DPDK Trace support

PATCH Superseded [email protected] 10 participants 321 messages Mar 18, 2020 – May 18, 2020 Page 4 of 5

Subsystems (6)
lore
Share & tools
lore
#179 lore raw
In reply to Thomas Monjalon
Quoted 26 lines · Thomas Monjalon

09/04/2020 17:36, Jerin Jacob:

Quoted 14 lines · Thomas Monjalon
Quoted 11 lines

03/04/2020 17:36, [email protected]:

Quoted 4 lines

Features:
~~~~~~~~~
- APIs and Features are similar to rte_log dynamic framework API(expect log prints on stdout vs it dumps on trace file)

A log can print to syslog as well.

As discussed somewhere else, please do not introduce global level in rte_trace. I think it is useless. If we need to change the level of all trace types, we can just use a wildcard (globbing or regexp).

Quoted 6 lines

Currently, In the log library, when EAL command-line argument specifies the "--log-level=val" it, will call
the rte_log_global_level_set(val)

Is the suggestion to make rte_log_global_level_set() as an internal EAL API or remove that feature?

Completely remove global level.
Why would we need 2 levels of level?

Quoted 8 lines
Quoted 2 lines

If we remove, then I dont know, how we can map --log-level or --trace-level EAL command-line argument.

They are setting levels with regex or globbing.
--log-level supports 3 syntaxes today:
- int (global level)
- globbing:int
- regex,int

Here is my understanding.

IMO, Actual Syntax is
- int (global level)
- globbing: int (global level)
- regex: int (global level)

i.e

1) Each log/trace has a "level"
2) There is a global level. See [1]
3) The trace will be emitted when
a) When it is enabled(not applicable for log as it is always enabled) AND
b) it is less than the global level.

The global level will be useful to control what category of trace "level" needs to enable.
I think, it is useful to trace only DEBUG or CRITICAL events, Any reason for thinking, it is not.

[1]
/**
* Set the global log level.
*
* After this call, logs with a level lower or equal than the level
* passed as argument will be displayed.
*
* @param level
* Log level. A value between RTE_LOG_EMERG (1) and RTE_LOG_DEBUG (8).
*/
void rte_log_set_global_level(uint32_t level);

Quoted 7 lines

I propose to drop the first syntax because it became useless now that we have powerful globbing and regex.

Quoted 3 lines
Quoted 2 lines

And about wording, "pattern" is too vague and should be replaced with "globbing".

Quoted 8 lines
Quoted 5 lines

Currently, we are using the word "shell pattern" in log and trace. According to man 3 fnmatch, both being used.
I can send a patch for changing the "shell pattern" to "glob" in rte_log.h and update the trace if needed.
Let me know?. IMO, Both has to use same word.

Yes I think globbing is more accurate than "shell pattern", because we can use regex pattern in shell as well.

I will change to "gloabbing" in trace and submit a patch for the same for rte_log as well.

Quoted 10 lines
Quoted 8 lines
Quoted 6 lines
Quoted 4 lines

- No specific limit on the events. A string-based event like rte_log for pattern matching

Would it be possible to replace rte_log with rte_trace?

Yes, I kept public API similar to log to have that use case in mind.

OK I think it would be good to have only one system.

Yes. We can switch over to rte_trace when it is decided.

Quoted 30 lines
Quoted 9 lines
Quoted 5 lines
Quoted 3 lines

- Dynamic enable/disable support.

How dynamic it is? Can we start/stop a trace after starting DPDK?

Yes, we have fine control enabling and disabling a specific or group of events. See rte_trace_enable(), rte_trace_disable() and rte_trace_pattern()

Quoted 6 lines
Quoted 2 lines

I think we need a control channel for this.
I propose to introduce a general control channel in DPDK.

Yes. Once we have a general control channel in DPDK. We can hook rte_trace_enable() and friends
in the message handler.

That would be a nice feature.

Quoted 11 lines
Quoted 10 lines
Quoted 1 line

- Instructmention overhead is ~1 cycle. i.e cost of adding the code

Nice

Quoted 2 lines

wth out using trace feature.
- Timestamp support for all the events using DPDK rte_rtdsc

Could we use other timestamp sources, like the mbuf timestamp for Rx traces?

Quoted 6 lines
Quoted 2 lines

Trace will be running at the global wall clock. Rx specific tracepoint can add mbuf->timestamp as FIELD in the future if needed.

OK makes sense.

Note: I prefer rte_get_timer_cycles() because rdtsc is an x86 instruction.

Code is using rte_get_tsc_cycles() public API as wall clock is based on tsc clock(
Which is available in the system in all the cases)

Quoted 7 lines
Quoted 7 lines
Quoted 6 lines
Quoted 4 lines

- No dependency on another library. Clean room native implementation of CTF.

No benefit of using an external CTF library maintained somewhere else?

Quoted 7 lines
Quoted 5 lines

See performance data comparison with LTTng in the cover letter.

We discussed this enough in the mailing list on RFC and decide to use Faster trace support for Fastpath use case and avoid any external library to EAL (We need tracepoints in the EAL too for tracing).

I can understand the performance reason.

OK

Quoted 3 lines

But if another library can provide the same performance, I don't see any reason not depending on it.
If the dependency is not found, the feature can be disabled.

Yes. But, if we replace rte_log with trace, it can not be just an optional component and
it can run wherever EAL can run(i.e Windows OS). Trace format will be the same across all
the EAL environments a.k.a common post trace analysis tools.

Quoted 2 lines
#180 lore raw

09/04/2020 18:34, Jerin Jacob:

Quoted 26 lines · Thomas Monjalon
Quoted 16 lines

09/04/2020 17:36, Jerin Jacob:

Quoted 11 lines · Thomas Monjalon
Quoted 3 lines

As discussed somewhere else, please do not introduce global level in rte_trace. I think it is useless. If we need to change the level of all trace types, we can just use a wildcard (globbing or regexp).

Currently, In the log library, when EAL command-line argument specifies the "--log-level=val" it, will call
the rte_log_global_level_set(val)

Is the suggestion to make rte_log_global_level_set() as an internal EAL API or remove that feature?

Completely remove global level.
Why would we need 2 levels of level?

Quoted 8 lines
Quoted 2 lines

If we remove, then I dont know, how we can map --log-level or --trace-level EAL command-line argument.

They are setting levels with regex or globbing.
--log-level supports 3 syntaxes today:
- int (global level)
- globbing:int
- regex,int

Quoted 6 lines

Here is my understanding.

IMO, Actual Syntax is
- int (global level)
- globbing: int (global level)
- regex: int (global level)

The level apply to the logs matching the pattern (globbing or regex) so I don't understand why you call it "global".

Quoted 8 lines

i.e

1) Each log/trace has a "level"
2) There is a global level. See [1]
3) The trace will be emitted when
a) When it is enabled(not applicable for log as it is always enabled) AND
b) it is less than the global level.

When it is less than both global and logtype level. See rte_log_can_log().

Quoted 6 lines

The global level will be useful to control what category of trace "level" needs to enable.
I think, it is useful to trace only DEBUG or CRITICAL events, Any reason for thinking, it is not.

Quoted 11 lines

[1]
/**
* Set the global log level.
*
* After this call, logs with a level lower or equal than the level
* passed as argument will be displayed.
*
* @param level
* Log level. A value between RTE_LOG_EMERG (1) and RTE_LOG_DEBUG (8).
*/
void rte_log_set_global_level(uint32_t level);

rte_log_can_log(uint32_t logtype, uint32_t level)

{
    int log_level;

    if (level > rte_log_get_global_level())
        return false;

    log_level = rte_log_get_level(logtype);
    if (log_level < 0)
        return false;

    if (level > (uint32_t)log_level)
        return false;

    return true;
}

The global level is just disabling some logs even if it is enabled in the logtype level.
It only makes usage complicate.
We should consider only logtype levels.

Currently, the global log level is disabled by default by setting the global level to DEBUG:

RTE_INIT_PRIO(rte_log_init, LOG)
{
[...]

    rte_log_set_global_level(RTE_LOG_DEBUG);

It was done by Pavan 2 years ago.

#181 lore raw
Quoted 9 lines
Quoted 9 lines
Quoted 6 lines

They are setting levels with regex or globbing.
--log-level supports 3 syntaxes today:
- int (global level)
- globbing:int
- regex,int

Here is my understanding.

Quoted 7 lines
Quoted 4 lines

IMO, Actual Syntax is
- int (global level)
- globbing: int (global level)
- regex: int (global level)

The level apply to the logs matching the pattern (globbing or regex) so I don't understand why you call it "global".

What I meant is, if there is no global, what is the point of changing the trace level with EAL command-line argument with globbing and regex.

Quoted 10 lines
Quoted 9 lines

i.e

1) Each log/trace has a "level"
2) There is a global level. See [1]
3) The trace will be emitted when
a) When it is enabled(not applicable for log as it is always enabled) AND
b) it is less than the global level.

Quoted 2 lines

When it is less than both global and logtype level. See rte_log_can_log().

OK.

Quoted 5 lines

The global level is just disabling some logs even if it is enabled in the logtype level.
It only makes usage complicate.
We should consider only logtype levels.

OK. Do we care about the following use case?
# Trace only specific types of events(example, DEBUG or CRITICAL)?

IF NOT,

There is no need for,
# rte_trace_global_* API
# No need to introduce trace type(ie DEBUG or CRITICAL) i.e remove rte_trace_level_set() API etc

# In summary:
~~~~~~~~~~~~~
# In the existing code:
The trace will be emitted when
a) When the trace is enabled
AND
b) trace level than the global level.

# in new suggestion
The trace will be emitted when
 a) When it is enabled

And the EAL argument will be --trace=regex/globbing, This EAL argument will call rte_trace_regexp() and enable the selected tracepoints.

The downside will be it will not be similar to log API. I am fine with either way.

@Mattias Rönnblom, Do you have any thoughts as you spend some time reviewing the public API.

Thoughts in general?

#182 lore raw
Quoted 15 lines · Jerin Jacob
Quoted 15 lines
Quoted 14 lines
Quoted 7 lines

They are setting levels with regex or globbing.
--log-level supports 3 syntaxes today:
- int (global level)
- globbing:int
- regex,int

Here is my understanding.

IMO, Actual Syntax is
- int (global level)
- globbing: int (global level)
- regex: int (global level)

Quoted 5 lines
Quoted 2 lines

The level apply to the logs matching the pattern (globbing or regex) so I don't understand why you call it "global".

What I meant is, if there is no global, what is the point of changing the trace level with EAL command-line argument with globbing and regex.

Self reply on this:

I understood where is the disconnect is:

In case of log:
~~~~~~~~~~~
It will be printed when:
a) When it is less than both the "global" and "log level"

NOTE: in case of log, log level passed on to log function (see rte_log(uint32_t level..)

In case of trace:
~~~~~~~~~~~~
it will be emitted when:
a) The trace is enabled (rte_trace_enable() called on the tracepoint)
b) When it is less than the global level.

NOTE: in case of trace, Nothing like log level passed to trace emit function. The control lies with a slow path enable/disable decision(item (a)) due to performance requirements
to instrumentation overhead.

#183 lore raw
In reply to Jerin Jacob
Quoted 7 lines · Jerin Jacob
Quoted 4 lines

The global level is just disabling some logs even if it is enabled in the logtype level.
It only makes usage complicate.
We should consider only logtype levels.

OK. Do we care about the following use case?
# Trace only specific types of events(example, DEBUG or CRITICAL)?

The event types can be encoded in the tracepoint names if we want to organise trace points with types (maybe as a suffix).

Quoted 21 lines

IF NOT,

There is no need for,
# rte_trace_global_* API
# No need to introduce trace type(ie DEBUG or CRITICAL) i.e remove rte_trace_level_set() API etc

# In summary:
~~~~~~~~~~~~~
# In the existing code:
The trace will be emitted when
a) When the trace is enabled
AND
b) trace level than the global level.

# in new suggestion
The trace will be emitted when
 a) When it is enabled
Quoted 5 lines

And the EAL argument will be --trace=regex/globbing, This EAL argument will call rte_trace_regexp() and enable the selected tracepoints.

The downside will be it will not be similar to log API. I am fine with either way.

The level notion in the traces api is artificial.
I prefer a simple api where tracepoints state is controlled via a single criteria: with the new suggestion that would be names. So +1.

Afaiu, for logs, if we wanted to make use of the trace api, the level notion can be done in the rte_log layer.

Signature · 1 line
David Marchand
#184 lore raw
Quoted 37 lines · David Marchand
Quoted 7 lines · Jerin Jacob
Quoted 4 lines

The global level is just disabling some logs even if it is enabled in the logtype level.
It only makes usage complicate.
We should consider only logtype levels.

OK. Do we care about the following use case?
# Trace only specific types of events(example, DEBUG or CRITICAL)?

The event types can be encoded in the tracepoint names if we want to organise trace points with types (maybe as a suffix).

Quoted 24 lines

IF NOT,

There is no need for,
# rte_trace_global_* API
# No need to introduce trace type(ie DEBUG or CRITICAL) i.e remove rte_trace_level_set() API etc

# In summary:
~~~~~~~~~~~~~
# In the existing code:
The trace will be emitted when
a) When the trace is enabled
AND
b) trace level than the global level.

# in new suggestion
The trace will be emitted when
 a) When it is enabled

And the EAL argument will be --trace=regex/globbing, This EAL argument will call rte_trace_regexp() and enable the selected tracepoints.

Quoted 7 lines
Quoted 2 lines

The downside will be it will not be similar to log API. I am fine with either way.

The level notion in the traces api is artificial.
I prefer a simple api where tracepoints state is controlled via a single criteria: with the new suggestion that would be names. So +1.

I thought it may be helpful to replace log and I decided to pick the level in the trace.

Looks like the consensus is to remove "level" from Trace.
OK. I will rework the Trace API to remove the "level" and rte_trace_global_* API from Trace library.
Let me know If you have any other top-level architecture comments if any. I will send v5 with new changes.

Quoted 4 lines

Afaiu, for logs, if we wanted to make use of the trace api, the level notion can be done in the rte_log layer.

That works too.

Quoted 5 lines

--
David Marchand

#185 lore raw
Quoted 48 lines · Jerin Jacob
Quoted 37 lines · David Marchand
Quoted 7 lines · Jerin Jacob
Quoted 4 lines

The global level is just disabling some logs even if it is enabled in the logtype level.
It only makes usage complicate.
We should consider only logtype levels.

OK. Do we care about the following use case?
# Trace only specific types of events(example, DEBUG or CRITICAL)?

The event types can be encoded in the tracepoint names if we want to organise trace points with types (maybe as a suffix).

Quoted 24 lines

IF NOT,

There is no need for,
# rte_trace_global_* API
# No need to introduce trace type(ie DEBUG or CRITICAL) i.e remove rte_trace_level_set() API etc

# In summary:
~~~~~~~~~~~~~
# In the existing code:
The trace will be emitted when
a) When the trace is enabled
AND
b) trace level than the global level.

# in new suggestion
The trace will be emitted when
 a) When it is enabled

And the EAL argument will be --trace=regex/globbing, This EAL argument will call rte_trace_regexp() and enable the selected tracepoints.

Quoted 7 lines
Quoted 2 lines

The downside will be it will not be similar to log API. I am fine with either way.

The level notion in the traces api is artificial.
I prefer a simple api where tracepoints state is controlled via a single criteria: with the new suggestion that would be names. So +1.

Quoted 8 lines

I thought it may be helpful to replace log and I decided to pick the level in the trace.

Looks like the consensus is to remove "level" from Trace.
OK. I will rework the Trace API to remove the "level" and rte_trace_global_* API from Trace library.
Let me know If you have any other top-level architecture comments if any. I will send v5 with new changes.

Thanks Jerin.

- I am still looking at the event record mode.
I just wonder why we have this notion per tracepoint.
The documentation talks about it being an attribute of the trace buffers, and the described behavior looks fine.
But if we can set this mode per tracepoints, once a trace buffer is full, won't it be hard to figure out why some events have been caught and not others?

- Another comment, on the form, I can see that we talk about dataplane tracepoints and fastpath API.
Is there a difference? or could everything be named in a consistent way (the headers would have to be aligned too)?

- Do we really need to export the rte_trace_lib_eal_generic_* trace points? They seem more like examples and I don't see a usage outside of the tests.

Signature · 1 line
David Marchand
#186 lore raw
Quoted 53 lines · David Marchand
Quoted 51 lines · Jerin Jacob
Quoted 37 lines · David Marchand
Quoted 7 lines · Jerin Jacob
Quoted 4 lines

The global level is just disabling some logs even if it is enabled in the logtype level.
It only makes usage complicate.
We should consider only logtype levels.

OK. Do we care about the following use case?
# Trace only specific types of events(example, DEBUG or CRITICAL)?

The event types can be encoded in the tracepoint names if we want to organise trace points with types (maybe as a suffix).

Quoted 24 lines

IF NOT,

There is no need for,
# rte_trace_global_* API
# No need to introduce trace type(ie DEBUG or CRITICAL) i.e remove rte_trace_level_set() API etc

# In summary:
~~~~~~~~~~~~~
# In the existing code:
The trace will be emitted when
a) When the trace is enabled
AND
b) trace level than the global level.

# in new suggestion
The trace will be emitted when
 a) When it is enabled

And the EAL argument will be --trace=regex/globbing, This EAL argument will call rte_trace_regexp() and enable the selected tracepoints.

Quoted 7 lines
Quoted 2 lines

The downside will be it will not be similar to log API. I am fine with either way.

The level notion in the traces api is artificial.
I prefer a simple api where tracepoints state is controlled via a single criteria: with the new suggestion that would be names. So +1.

I thought it may be helpful to replace log and I decided to pick the level in the trace.

Quoted 7 lines
Quoted 5 lines

Looks like the consensus is to remove "level" from Trace.
OK. I will rework the Trace API to remove the "level" and rte_trace_global_* API from Trace library.
Let me know If you have any other top-level architecture comments if any. I will send v5 with new changes.

Thanks Jerin.

Thanks, David for the comments.

Quoted 9 lines

- I am still looking at the event record mode.
I just wonder why we have this notion per tracepoint.
The documentation talks about it being an attribute of the trace buffers, and the described behavior looks fine.
But if we can set this mode per tracepoints, once a trace buffer is full, won't it be hard to figure out why some events have been caught and not others?

In fastpath, I tried to avoid reading multiple control variables to improve performance.
i.e the tracepoint(uint64_t) has all control information. So it has given a feature to control mode per tracepoint.
I thought it may be useful. No strong option here.

If you think, it is not usefull and creates more problems, I will change to the following:

1) Remove int rte_trace_mode_set(rte_trace_t trace, enum rte_trace_mode_e mode);
2) Change
From:
void rte_trace_global_mode_set(enum rte_trace_mode_e mode);
to:
void rte_trace_mode_set(enum rte_trace_mode_e mode);

Let me know.

Quoted 5 lines

- Another comment, on the form, I can see that we talk about dataplane tracepoints and fastpath API.
Is there a difference? or could everything be named in a consistent

No. Both are the same.

Quoted 1 line

way (the headers would have to be aligned too)?

Personally I like the fast path. The log calls it as DP( see RTE_LOG_DP). In order to have consistency, I will pick the DP and change it everywhere to DP, and header files to xxxxx_dp.h from xxxx_fp.h.

If you have a preference then I will change to the same. Let me know.

Quoted 4 lines

- Do we really need to export the rte_trace_lib_eal_generic_* trace points? They seem more like examples and I don't see a usage outside of the tests.

This generic tracepoint for any quick debug, For example, if some need to add tracepoint to just emit string in the middle of debugging a problem, they can use rte_trace_lib_eal_generic_str.
That's the reason for exporting it.

Quoted 5 lines

--
David Marchand

#187 lore raw
Quoted 17 lines · Jerin Jacob
Quoted 7 lines

- I am still looking at the event record mode.
I just wonder why we have this notion per tracepoint.
The documentation talks about it being an attribute of the trace buffers, and the described behavior looks fine.
But if we can set this mode per tracepoints, once a trace buffer is full, won't it be hard to figure out why some events have been caught and not others?

In fastpath, I tried to avoid reading multiple control variables to improve performance.
i.e the tracepoint(uint64_t) has all control information. So it has given a feature to control mode per tracepoint.
I thought it may be useful. No strong option here.

If you think, it is not usefull and creates more problems, I will change to the following:

Quoted 6 lines

1) Remove int rte_trace_mode_set(rte_trace_t trace, enum rte_trace_mode_e mode);
2) Change
From:
void rte_trace_global_mode_set(enum rte_trace_mode_e mode);
to:
void rte_trace_mode_set(enum rte_trace_mode_e mode);

Yes, you can keep the information in the tracepoint descriptor and expose a single api that impacts all tracepoints.
+1 for me.

Quoted 11 lines
Quoted 3 lines

- Another comment, on the form, I can see that we talk about dataplane tracepoints and fastpath API.
Is there a difference? or could everything be named in a consistent

No. Both are the same.

Quoted 1 line

way (the headers would have to be aligned too)?

Personally I like the fast path. The log calls it as DP( see RTE_LOG_DP). In order to have consistency, I will pick the DP and change it everywhere to DP, and header files to xxxxx_dp.h from xxxx_fp.h.

I too have a preference for "fast path".
Thomas ?

Quoted 7 lines
Quoted 2 lines

- Do we really need to export the rte_trace_lib_eal_generic_* trace points? They seem more like examples and I don't see a usage outside of the tests.

This generic tracepoint for any quick debug, For example, if some need to add tracepoint to just emit string in the middle of debugging a problem, they can use rte_trace_lib_eal_generic_str.
That's the reason for exporting it.

Ok, let's leave it as is, I need to think about it.

Signature · 1 line
David Marchand
#188 lore raw

10/04/2020 17:00, David Marchand:

Quoted 7 lines · Jerin Jacob
Quoted 6 lines
Quoted 3 lines

- Another comment, on the form, I can see that we talk about dataplane tracepoints and fastpath API.
Is there a difference? or could everything be named in a consistent

No. Both are the same.

Quoted 8 lines
Quoted 5 lines
Quoted 1 line

way (the headers would have to be aligned too)?

Personally I like the fast path. The log calls it as DP( see RTE_LOG_DP). In order to have consistency, I will pick the DP and change it everywhere to DP, and header files to xxxxx_dp.h from xxxx_fp.h.

I too have a preference for "fast path".
Thomas ?

OK for fp.

#189 lore raw
In reply to Jerin Jacob

10/04/2020 15:29, Jerin Jacob:

Quoted 26 lines
Quoted 16 lines · David Marchand
Quoted 15 lines · Jerin Jacob

# In summary:
~~~~~~~~~~~~~
# In the existing code:
The trace will be emitted when
a) When the trace is enabled
AND
b) trace level than the global level.

# in new suggestion
The trace will be emitted when
 a) When it is enabled

And the EAL argument will be --trace=regex/globbing, This EAL argument will call rte_trace_regexp() and enable the selected tracepoints.

Quoted 7 lines
Quoted 2 lines

The downside will be it will not be similar to log API. I am fine with either way.

The level notion in the traces api is artificial.
I prefer a simple api where tracepoints state is controlled via a single criteria: with the new suggestion that would be names. So +1.

Quoted 4 lines

I thought it may be helpful to replace log and I decided to pick the level in the trace.

Looks like the consensus is to remove "level" from Trace.

I miss the plan to rework logs on top of trace.
How could it be done?

#190 lore raw
Quoted 28 lines · Thomas Monjalon

10/04/2020 15:29, Jerin Jacob:

Quoted 26 lines
Quoted 23 lines · David Marchand
Quoted 12 lines · Jerin Jacob

# In summary:
~~~~~~~~~~~~~
# In the existing code:
The trace will be emitted when
a) When the trace is enabled
AND
b) trace level than the global level.

# in new suggestion
The trace will be emitted when
 a) When it is enabled
Quoted 5 lines

And the EAL argument will be --trace=regex/globbing, This EAL argument will call rte_trace_regexp() and enable the selected tracepoints.

The downside will be it will not be similar to log API. I am fine with either way.

The level notion in the traces api is artificial.
I prefer a simple api where tracepoints state is controlled via a single criteria: with the new suggestion that would be names. So +1.

Quoted 7 lines
Quoted 4 lines

I thought it may be helpful to replace log and I decided to pick the level in the trace.

Looks like the consensus is to remove "level" from Trace.

I miss the plan to rework logs on top of trace.
How could it be done?

# I think, David suggestion is to add "level" as a string in the trace name. Say "debug.lib.eal.*"

# I am thinking, If we don't like above,
a) Add following EAL private APIs to get and set "level" as opaque
object when _needed_ from trace.
1) int eal_trace_opaque_set(rte_trace_t trace, uint8_t opaque);
2) uint8_t eal_trace_opaque_get(rte_trace_t trace);

The above private API would be enough to implement.

Quoted 2 lines
#191 lore raw

v5 cover DPDK Trace support

In reply to [email protected]

From: Jerin Jacob <[email protected]>

This patch depends on http://patches.dpdk.org/patch/68119/
Depends-on:series-9295

v5
~~

Following API rework based David and Thomas feedback.

1) Rename - "Shell pattern" to "Globbing pattern"
2) Remove the log "level" notion from trace library.
3) Remove rte_trace_global_[level/mode]* API from trace library.
4) EAL command line arg to --trace=regex/globing from --trace-level=regex/globing:level
5) Remove "@b EXPERIMENTAL: this API may change without prior notice" from each functions.
6) Use FP instead of DP for fastpath reference.
7) Updated documentation to reflect the above rework.
8) Updated UT to to reflect the above rework.
8) Updated UT for a FP trace point emit.
9) Updated performance test case for a FP trace point emission.
10) Updated git commit comments to reflect the above rework.

v4:
~~

1) Rebased to master.

2) Adapted to latest EAL directory structure change.

3) Fix possible build issue with out of tree application wherein it does not define -DALLOW_EXPERIMENTAL_API. Fixed by making fast path trace functions as NOP as it was getting included in the inline functions of ethdev,mempool, cryptodev, etc(David)

4) Removed DALLOW_EXPERIMENTAL_API definition from individual driver files. Now it set as global using http://patches.dpdk.org/patch/67758/ patch (David)

5) Added new meson option(-Denable_trace_dp=true)for enabling the datapath trace point (David, Bruce)

6) Changed the authorship and Rewrote the programmer's guide based on the below feedback(Thomas)
http://patches.dpdk.org/patch/67352/

v3:
~~

1) Fix the following build issues reported by CI
http://mails.dpdk.org/archives/test-report/2020-March/122060.html

a) clang + i686 meson build issue(Fixed in the the patch meson: add libatomic as a global dependency for i686 clang)
b) fixed build issue with FreeBSD with top of tree change.
c) fixed missing experimental API for iavf and ice with meson build in avx512 files.

v2:
~~
Addressed the following review comments from Mattias Rönnblom:

1) Changed

from:

	typedef uint64_t* rte_trace_t;

to
typedef uint64_t rte_trace_t;

Initially thought to make the handle as
struct rte_trace {
uint64_t val;
}

but changed to uint64_t for the following reasons
a) It is opaque to the application and it will fix the compile-time type check as well.
b) The handle has an index that will point to an internal slow-path structure so no ABI change required in the future.
c) RTE_TRACE_POINT_DEFINE need to expose trace object. So it is better to keep as uint64_t and avoid one more indirection for no use.

2)
Changed:
from:

	enum rte_trace_mode_e {
to:
	enum rte_trace_mode {

3) removed [out] "found" param from rte_trace_pattern() and rte_trace_regexp()

4) Changed rte_trace_from_name to rte_trace_by_name

5) rte_trace_is_dp_enabled() return bool now

6) in __rte_trace_point_register() the argument fn change to register_fn

7) removed !! from rte_trace_is_enabled()

8) Remove uninitialized "rc warning" from rte_trace_pattern() and rte_trace_regexp()

9) fixup bool return type for trace_entry_compare()

10) fixup calloc casting in trace_mkdir()

11) check fclose() return in trace_meta_save() and trace_mem_save()

12) rte_trace_ctf_* macro cleanup

13) added release notes

14) fix build issues reported by CI
http://mails.dpdk.org/archives/test-report/2020-March/121235.html

This patch set contains
~~~~~~~~~~~~~~~~~~~~~~~~

# The native implementation of common trace format(CTF)[1] based tracer # Public API to create the trace points.
# Add tracepoints to eal, ethdev, mempool, eventdev and cryptodev library for tracing support
# A unit test case
# Performance test case to measure the trace overhead. (See eal/trace:

# add trace performance test cases, patch)
# Programmers guide for Trace support(See doc: add trace library guide,
# patch)

# Tested OS:
~~~~~~~~~~~
- Linux
- FreeBSD

# Tested open source CTF trace viewers
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- Babeltrace
- Tracecompass

# Trace overhead comparison with LTTng
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

trace overhead data on x86:[2]
# 236 cycles with LTTng(>100ns)
# 18 cycles(7ns) with Native DPDK CTF emitter.(See eal/trace: add trace

# performance test cases patch)

trace overhead data on arm64:

#  312  cycles to  1100 cycles with LTTng based on the class of arm64
#  CPU.
#  11 cycles to 13 cycles with Native DPDK CTF emitter based on the

class of arm64 CPU.

18 cycles(on x86) vs 11 cycles(on arm64) is due to rdtsc() overhead in x86. It seems rdtsc takes around 15cycles in x86.

More details:
~~~~~~~~~~~~~

# The Native DPDK CTF trace support does not have any dependency on third-party library.
The generated output file is compatible with LTTng as both are using CTF trace format.

The performance gain comes from:
1) exploit dpdk worker thread usage model to avoid atomics and use per core variables
2) use hugepage,
3) avoid a lot function pointers in fast-path etc
4) avoid unaligned store for arm64 etc

Features:
~~~~~~~~~
- No specific limit on the events. A string-based event like rte_log for pattern matching
- Dynamic enable/disable support.
- Instructmention overhead is ~1 cycle. i.e cost of adding the code wth out using trace feature.
- Timestamp support for all the events using DPDK rte_rtdsc
- No dependency on another library. Clean room native implementation of CTF.

Functional test case:
a) echo "trace_autotest" | sudo ./build/app/test/dpdk-test -c 0x3 --trace=.*

The above command emits the following trace events <code>

        uint8_t i;

        rte_trace_lib_eal_generic_void();
        rte_trace_lib_eal_generic_u64(0x10000000000000);
        rte_trace_lib_eal_generic_u32(0x10000000);
        rte_trace_lib_eal_generic_u16(0xffee);
        rte_trace_lib_eal_generic_u8(0xc);
        rte_trace_lib_eal_generic_i64(-1234);
        rte_trace_lib_eal_generic_i32(-1234567);
        rte_trace_lib_eal_generic_i16(12);
        rte_trace_lib_eal_generic_i8(-3);
        rte_trace_lib_eal_generic_string("my string");
        rte_trace_lib_eal_generic_function(__func__);

</code>

Install babeltrace package in Linux and point the generated trace file to babel trace. By default trace file created under <user>/dpdk-traces/time_stamp/

example:

# babeltrace /root/dpdk-traces/rte-2020-02-15-PM-02-56-51 | more

[13:27:36.138468807] (+?.?????????) lib.eal.generic.void: { cpu_id =0, name = "dpdk-test" }, { } [13:27:36.138468851] (+0.000000044) lib.eal.generic.u64: { cpu_id = 0, name = "dpdk-test" }, { in = 4503599627370496 } [13:27:36.138468860] (+0.000000009) lib.eal.generic.u32: { cpu_id = 0, name = "dpdk-test" }, { in = 268435456 } [13:27:36.138468934] (+0.000000074) lib.eal.generic.u16: { cpu_id = 0, name = "dpdk-test" }, { in = 65518 } [13:27:36.138468949] (+0.000000015) lib.eal.generic.u8: { cpu_id = 0, name = "dpdk-test" }, { in = 12 } [13:27:36.138468956] (+0.000000007) lib.eal.generic.i64: { cpu_id = 0, name = "dpdk-test" }, { in = -1234 } [13:27:36.138468963] (+0.000000007) lib.eal.generic.i32: { cpu_id = 0, name = "dpdk-test" }, { in = -1234567 } [13:27:36.138469024] (+0.000000061) lib.eal.generic.i16: { cpu_id = 0, name = "dpdk-test" }, { in = 12 } [13:27:36.138469044] (+0.000000020) lib.eal.generic.i8: { cpu_id = 0, name = "dpdk-test" }, { in = -3 } [13:27:36.138469051] (+0.000000007) lib.eal.generic.string: { cpu_id = 0, name = "dpdk-test" }, { str = "my string" } [13:27:36.138469203] (+0.000000152) lib.eal.generic.func: { cpu_id = 0, name = "dpdk-test" }, { func = "test_trace_points" }

# There is a GUI based trace viewer available in Windows, Linux and Mac. It is called as tracecompass.(https://www.eclipse.org/tracecompass/)

The example screenshot and Histogram of above DPDK trace using Tracecompass.

https://github.com/jerinjacobk/share/blob/master/dpdk_trace.JPG

File walk through:
~~~~~~~~~~~~~~~~~~

lib/librte_eal/common/include/rte_trace.h - Public API for Trace provider and Trace control lib/librte_eal/common/eal_common_trace.c - main trace implementation lib/librte_eal/common/eal_common_trace_ctf.c - CTF metadata spec implementation lib/librte_eal/common/eal_common_trace_utils.c - command line utils and filesystem operations. lib/librte_eal/common/eal_common_trace_points.c - trace points for EAL library
lib/librte_eal/common/include/rte_trace_eal.h - EAL tracepoint public API.
lib/librte_eal/common/eal_trace.h - Private trace header file.

[1] https://diamon.org/ctf/

[2] The above test is ported to LTTng for finding the LTTng trace overhead. It available at
https://github.com/jerinjacobk/lttng-overhead
https://github.com/jerinjacobk/lttng-overhead/blob/master/README

Jerin Jacob (22):
eal: introduce API for getting thread name eal/trace: define the public API for trace support eal/trace: implement trace register API eal/trace: implement trace operation APIs eal/trace: add internal trace init and fini interface eal/trace: get bootup timestamp for trace eal/trace: create CTF TDSL metadata in memory eal/trace: implement trace memory allocation eal/trace: implement debug dump function eal/trace: implement trace save
eal/trace: implement registration payload eal/trace: implement provider payload eal/trace: hook internal trace APIs to Linux eal/trace: hook internal trace APIs to FreeBSD eal/trace: add generic tracepoints eal/trace: add alarm tracepoints
eal/trace: add memory tracepoints
eal/trace: add memzone tracepoints eal/trace: add thread tracepoints
eal/trace: add interrupt tracepoints eal/trace: add trace performance test cases
doc: add trace library guide

Pavan Nikhilesh (1):
meson: add libatomic as a global dependency for i686 clang

Sunil Kumar Kori (10):
eal/trace: handle CTF keyword collision eal/trace: add trace configuration parameter eal/trace: add trace dir configuration parameter eal/trace: add trace bufsize configuration parameter eal/trace: add trace mode configuration parameter eal/trace: add unit test cases
ethdev: add tracepoints
eventdev: add tracepoints
cryptodev: add tracepoints
mempool: add tracepoints

 MAINTAINERS                                   |   8 +
 app/test/Makefile                             |   4 +-
 app/test/meson.build                          |   3 +
 app/test/test_trace.c                         | 258 +++++++++
 app/test/test_trace.h                         |  15 +
 app/test/test_trace_perf.c                    | 183 +++++++
 app/test/test_trace_register.c                |  19 +
 config/common_base                            |   1 +
 config/meson.build                            |   9 +
 doc/api/doxy-api-index.md                     |   3 +-
 doc/guides/linux_gsg/eal_args.include.rst     |  52 ++
 doc/guides/prog_guide/build-sdk-meson.rst     |   5 +
 doc/guides/prog_guide/index.rst               |   1 +
 doc/guides/prog_guide/trace_lib.rst           | 334 +++++++++++
 doc/guides/rel_notes/release_20_05.rst        |   9 +
 drivers/event/octeontx/meson.build            |   5 -
 drivers/event/octeontx2/meson.build           |   5 -
 drivers/event/opdl/meson.build                |   5 -
 examples/cmdline/Makefile                     |   1 +
 examples/cmdline/meson.build                  |   1 +
 examples/distributor/Makefile                 |   1 +
 examples/distributor/meson.build              |   1 +
 examples/ethtool/ethtool-app/Makefile         |   1 +
 examples/eventdev_pipeline/meson.build        |   1 +
 examples/flow_filtering/Makefile              |   1 +
 examples/flow_filtering/meson.build           |   1 +
 examples/helloworld/Makefile                  |   1 +
 examples/helloworld/meson.build               |   1 +
 examples/ioat/Makefile                        |   1 +
 examples/ioat/meson.build                     |   1 +
 examples/ip_fragmentation/Makefile            |   2 +
 examples/ip_fragmentation/meson.build         |   1 +
 examples/ip_reassembly/Makefile               |   1 +
 examples/ip_reassembly/meson.build            |   1 +
 examples/ipv4_multicast/Makefile              |   1 +
 examples/ipv4_multicast/meson.build           |   1 +
 examples/l2fwd-cat/Makefile                   |   1 +
 examples/l2fwd-cat/meson.build                |   1 +
 examples/l2fwd-event/Makefile                 |   1 +
 examples/l2fwd-event/meson.build              |   6 +-
 examples/l2fwd-jobstats/Makefile              |   1 +
 examples/l2fwd-jobstats/meson.build           |   1 +
 examples/l2fwd-keepalive/Makefile             |   1 +
 examples/l2fwd-keepalive/ka-agent/Makefile    |   1 +
 examples/l2fwd-keepalive/meson.build          |   1 +
 examples/l3fwd-acl/Makefile                   |   1 +
 examples/l3fwd-acl/meson.build                |   1 +
 examples/l3fwd/Makefile                       |   1 +
 examples/l3fwd/meson.build                    |   1 +
 examples/link_status_interrupt/Makefile       |   1 +
 examples/link_status_interrupt/meson.build    |   1 +
 .../client_server_mp/mp_client/Makefile       |   1 +
 .../client_server_mp/mp_client/meson.build    |   1 +
 .../client_server_mp/mp_server/meson.build    |   1 +
 examples/multi_process/hotplug_mp/Makefile    |   1 +
 examples/multi_process/hotplug_mp/meson.build |   1 +
 examples/multi_process/simple_mp/Makefile     |   1 +
 examples/multi_process/simple_mp/meson.build  |   1 +
 examples/multi_process/symmetric_mp/Makefile  |   1 +
 .../multi_process/symmetric_mp/meson.build    |   1 +
 examples/ntb/Makefile                         |   1 +
 examples/ntb/meson.build                      |   1 +
 examples/packet_ordering/Makefile             |   1 +
 examples/packet_ordering/meson.build          |   1 +
 .../performance-thread/l3fwd-thread/Makefile  |   1 +
 .../l3fwd-thread/meson.build                  |   1 +
 .../performance-thread/pthread_shim/Makefile  |   1 +
 .../pthread_shim/meson.build                  |   1 +
 examples/ptpclient/Makefile                   |   1 +
 examples/ptpclient/meson.build                |   1 +
 examples/qos_meter/Makefile                   |   1 +
 examples/qos_meter/meson.build                |   1 +
 examples/qos_sched/Makefile                   |   1 +
 examples/qos_sched/meson.build                |   1 +
 examples/server_node_efd/node/Makefile        |   1 +
 examples/server_node_efd/node/meson.build     |   1 +
 examples/server_node_efd/server/Makefile      |   1 +
 examples/server_node_efd/server/meson.build   |   1 +
 examples/service_cores/Makefile               |   1 +
 examples/service_cores/meson.build            |   1 +
 examples/skeleton/Makefile                    |   1 +
 examples/skeleton/meson.build                 |   1 +
 examples/timer/Makefile                       |   1 +
 examples/timer/meson.build                    |   1 +
 examples/vm_power_manager/Makefile            |   1 +
 examples/vm_power_manager/meson.build         |   1 +
 examples/vmdq/Makefile                        |   1 +
 examples/vmdq/meson.build                     |   1 +
 examples/vmdq_dcb/Makefile                    |   1 +
 examples/vmdq_dcb/meson.build                 |   1 +
 lib/librte_cryptodev/Makefile                 |   4 +-
 lib/librte_cryptodev/cryptodev_trace_points.c |  70 +++
 lib/librte_cryptodev/meson.build              |   6 +-
 lib/librte_cryptodev/rte_cryptodev.c          |  18 +
 lib/librte_cryptodev/rte_cryptodev.h          |   6 +
 .../rte_cryptodev_version.map                 |  18 +
 lib/librte_cryptodev/rte_trace_cryptodev.h    | 133 +++++
 lib/librte_cryptodev/rte_trace_cryptodev_fp.h |  34 ++
 lib/librte_distributor/meson.build            |   5 -
 lib/librte_eal/common/eal_common_memzone.c    |   9 +
 lib/librte_eal/common/eal_common_options.c    |  65 +++
 lib/librte_eal/common/eal_common_thread.c     |   3 +-
 lib/librte_eal/common/eal_common_trace.c      | 518 ++++++++++++++++++
 lib/librte_eal/common/eal_common_trace_ctf.c  | 488 +++++++++++++++++
 .../common/eal_common_trace_points.c          | 115 ++++
 .../common/eal_common_trace_utils.c           | 478 ++++++++++++++++
 lib/librte_eal/common/eal_options.h           |   8 +
 lib/librte_eal/common/eal_private.h           |   5 +
 lib/librte_eal/common/eal_trace.h             | 121 ++++
 lib/librte_eal/common/meson.build             |   4 +
 lib/librte_eal/common/rte_malloc.c            |  60 +-
 lib/librte_eal/freebsd/Makefile               |   4 +
 lib/librte_eal/freebsd/eal.c                  |  10 +
 lib/librte_eal/freebsd/eal_alarm.c            |   3 +
 lib/librte_eal/freebsd/eal_interrupts.c       |  54 +-
 lib/librte_eal/freebsd/eal_thread.c           |  21 +-
 lib/librte_eal/include/meson.build            |   4 +
 lib/librte_eal/include/rte_lcore.h            |  17 +
 lib/librte_eal/include/rte_trace.h            | 424 ++++++++++++++
 lib/librte_eal/include/rte_trace_eal.h        | 247 +++++++++
 lib/librte_eal/include/rte_trace_provider.h   | 157 ++++++
 lib/librte_eal/include/rte_trace_register.h   |  52 ++
 lib/librte_eal/linux/Makefile                 |   4 +
 lib/librte_eal/linux/eal.c                    |   9 +
 lib/librte_eal/linux/eal_alarm.c              |   4 +
 lib/librte_eal/linux/eal_interrupts.c         |  84 +--
 lib/librte_eal/linux/eal_thread.c             |  27 +-
 lib/librte_eal/rte_eal_version.map            |  53 ++
 lib/librte_ethdev/Makefile                    |   3 +
 lib/librte_ethdev/ethdev_trace_points.c       |  43 ++
 lib/librte_ethdev/meson.build                 |   5 +-
 lib/librte_ethdev/rte_ethdev.c                |  12 +
 lib/librte_ethdev/rte_ethdev.h                |   5 +
 lib/librte_ethdev/rte_ethdev_version.map      |  10 +
 lib/librte_ethdev/rte_trace_ethdev.h          |  90 +++
 lib/librte_ethdev/rte_trace_ethdev_fp.h       |  40 ++
 lib/librte_eventdev/Makefile                  |   3 +
 lib/librte_eventdev/eventdev_trace_points.c   | 173 ++++++
 lib/librte_eventdev/meson.build               |   3 +
 .../rte_event_crypto_adapter.c                |  10 +
 .../rte_event_eth_rx_adapter.c                |  11 +
 .../rte_event_eth_tx_adapter.c                |  13 +-
 .../rte_event_eth_tx_adapter.h                |   2 +
 lib/librte_eventdev/rte_event_timer_adapter.c |   8 +-
 lib/librte_eventdev/rte_event_timer_adapter.h |   8 +
 lib/librte_eventdev/rte_eventdev.c            |   9 +
 lib/librte_eventdev/rte_eventdev.h            |   5 +-
 lib/librte_eventdev/rte_eventdev_version.map  |  42 ++
 lib/librte_eventdev/rte_trace_eventdev.h      | 278 ++++++++++
 lib/librte_eventdev/rte_trace_eventdev_fp.h   |  75 +++
 lib/librte_mempool/Makefile                   |   3 +
 lib/librte_mempool/mempool_trace_points.c     | 108 ++++
 lib/librte_mempool/meson.build                |   5 +-
 lib/librte_mempool/rte_mempool.c              |  16 +
 lib/librte_mempool/rte_mempool.h              |  13 +
 lib/librte_mempool/rte_mempool_ops.c          |   7 +
 lib/librte_mempool/rte_mempool_version.map    |  26 +
 lib/librte_mempool/rte_trace_mempool.h        | 148 +++++
 lib/librte_mempool/rte_trace_mempool_fp.h     | 102 ++++
 lib/librte_rcu/meson.build                    |   5 -
 meson_options.txt                             |   2 +
 161 files changed, 5517 insertions(+), 105 deletions(-)
 create mode 100644 app/test/test_trace.c
 create mode 100644 app/test/test_trace.h
 create mode 100644 app/test/test_trace_perf.c
 create mode 100644 app/test/test_trace_register.c
 create mode 100644 doc/guides/prog_guide/trace_lib.rst
 create mode 100644 lib/librte_cryptodev/cryptodev_trace_points.c
 create mode 100644 lib/librte_cryptodev/rte_trace_cryptodev.h
 create mode 100644 lib/librte_cryptodev/rte_trace_cryptodev_fp.h
 create mode 100644 lib/librte_eal/common/eal_common_trace.c
 create mode 100644 lib/librte_eal/common/eal_common_trace_ctf.c
 create mode 100644 lib/librte_eal/common/eal_common_trace_points.c
 create mode 100644 lib/librte_eal/common/eal_common_trace_utils.c
 create mode 100644 lib/librte_eal/common/eal_trace.h
 create mode 100644 lib/librte_eal/include/rte_trace.h
 create mode 100644 lib/librte_eal/include/rte_trace_eal.h
 create mode 100644 lib/librte_eal/include/rte_trace_provider.h
 create mode 100644 lib/librte_eal/include/rte_trace_register.h
 create mode 100644 lib/librte_ethdev/ethdev_trace_points.c
 create mode 100644 lib/librte_ethdev/rte_trace_ethdev.h
 create mode 100644 lib/librte_ethdev/rte_trace_ethdev_fp.h
 create mode 100644 lib/librte_eventdev/eventdev_trace_points.c
 create mode 100644 lib/librte_eventdev/rte_trace_eventdev.h
 create mode 100644 lib/librte_eventdev/rte_trace_eventdev_fp.h
 create mode 100644 lib/librte_mempool/mempool_trace_points.c
 create mode 100644 lib/librte_mempool/rte_trace_mempool.h
 create mode 100644 lib/librte_mempool/rte_trace_mempool_fp.h
Signature · 1 line
2.25.1
#192 lore raw

PATCH v5 1/33 meson: add libatomic as a global dependency for i686 clang

From: Pavan Nikhilesh <[email protected]>

Add libatomic as a global dependency when compiling for 32-bit using clang. As we need libatomic for 64-bit atomic ops.

---
 config/meson.build                  | 8 ++++++++
 drivers/event/octeontx/meson.build  | 5 -----
 drivers/event/octeontx2/meson.build | 5 -----
 drivers/event/opdl/meson.build      | 5 -----
 examples/l2fwd-event/meson.build    | 5 -----
 lib/librte_distributor/meson.build  | 5 -----
 lib/librte_rcu/meson.build          | 5 -----
 7 files changed, 8 insertions(+), 30 deletions(-)
config/meson.build +8 -0
index 58421342b..8a4c692a9 100644
@@ -173,6 +173,14 @@ if pcap_dep.found() and cc.has_header('pcap.h', dependencies: pcap_dep)
 	dpdk_extra_ldflags += '-lpcap'
 endif
 
+
+# for clang 32-bit compiles we need libatomic for 64-bit atomic ops
+if cc.get_id() == 'clang' and dpdk_conf.get('RTE_ARCH_64') == false
+	atomic_dep = cc.find_library('atomic', required: true)
+	add_project_link_arguments('-latomic', language: 'c')
+	dpdk_extra_ldflags += '-latomic'
+endif
+
 # add -include rte_config to cflags
 add_project_arguments('-include', 'rte_config.h', language: 'c')
 
drivers/event/octeontx/meson.build +0 -5
index 73118a485..2b74bb62d 100644
@@ -11,8 +11,3 @@ sources = files('ssovf_worker.c',
 )
 
 deps += ['common_octeontx', 'mempool_octeontx', 'bus_vdev', 'pmd_octeontx']
-
-# for clang 32-bit compiles we need libatomic for 64-bit atomic ops
-if cc.get_id() == 'clang' and dpdk_conf.get('RTE_ARCH_64') == false
-	ext_deps += cc.find_library('atomic')
-endif
drivers/event/octeontx2/meson.build +0 -5
index 4b938416b..0ade51cec 100644
@@ -18,11 +18,6 @@ if not dpdk_conf.get('RTE_ARCH_64')
 	extra_flags += ['-Wno-int-to-pointer-cast', '-Wno-pointer-to-int-cast']
 endif
 
-# for clang 32-bit compiles we need libatomic for 64-bit atomic ops
-if cc.get_id() == 'clang' and dpdk_conf.get('RTE_ARCH_64') == false
-	ext_deps += cc.find_library('atomic')
-endif
-
 foreach flag: extra_flags
 	if cc.has_argument(flag)
 		cflags += flag
drivers/event/opdl/meson.build +0 -5
index 1fe034ea1..cc6029c6f 100644
@@ -9,8 +9,3 @@ sources = files(
 	'opdl_test.c',
 )
 deps += ['bus_vdev']
-
-# for clang 32-bit compiles we need libatomic for 64-bit atomic ops
-if cc.get_id() == 'clang' and dpdk_conf.get('RTE_ARCH_64') == false
-	ext_deps += cc.find_library('atomic')
-endif
examples/l2fwd-event/meson.build +0 -5
index c4664c3a3..4e9a069d6 100644
@@ -16,8 +16,3 @@ sources = files(
 	'l2fwd_event_internal_port.c',
 	'l2fwd_event_generic.c'
 )
-
-# for clang 32-bit compiles we need libatomic for 64-bit atomic ops
-if cc.get_id() == 'clang' and dpdk_conf.get('RTE_ARCH_64') == false
-	ext_deps += cc.find_library('atomic')
-endif
lib/librte_distributor/meson.build +0 -5
index 266af6434..bd12ddb2f 100644
@@ -9,8 +9,3 @@ else
 endif
 headers = files('rte_distributor.h')
 deps += ['mbuf']
-
-# for clang 32-bit compiles we need libatomic for 64-bit atomic ops
-if cc.get_id() == 'clang' and dpdk_conf.get('RTE_ARCH_64') == false
-	ext_deps += cc.find_library('atomic')
-endif
lib/librte_rcu/meson.build +0 -5
index 5929bd3a7..c009ae4b7 100644
@@ -3,8 +3,3 @@
 
 sources = files('rte_rcu_qsbr.c')
 headers = files('rte_rcu_qsbr.h')
-
-# for clang 32-bit compiles we need libatomic for 64-bit atomic ops
-if cc.get_id() == 'clang' and dpdk_conf.get('RTE_ARCH_64') == false
-	ext_deps += cc.find_library('atomic')
-endif
Signature · 1 line
2.25.1
#193 lore raw

PATCH v5 2/33 eal: introduce API for getting thread name

In reply to [email protected]

From: Jerin Jacob <[email protected]>

Introduce rte_thread_getname() API to get the thread name and implement it for Linux and FreeBSD.

FreeBSD does not support getting the thread name.

One of the consumers of this API will be the trace subsystem where it used as an informative purpose.

---
 lib/librte_eal/freebsd/eal_thread.c |  9 +++++++++
 lib/librte_eal/include/rte_lcore.h  | 17 +++++++++++++++++
 lib/librte_eal/linux/eal_thread.c   | 15 +++++++++++++++
 lib/librte_eal/rte_eal_version.map  |  1 +
 4 files changed, 42 insertions(+)
lib/librte_eal/freebsd/eal_thread.c +9 -0
index 309b58726..ae7b57672 100644
@@ -175,3 +175,12 @@ int rte_thread_setname(pthread_t id, const char *name)
 	pthread_set_name_np(id, name);
 	return 0;
 }
+
+int rte_thread_getname(pthread_t id, char *name, size_t len)
+{
+	RTE_SET_USED(id);
+	RTE_SET_USED(name);
+	RTE_SET_USED(len);
+
+	return -ENOTSUP;
+}
lib/librte_eal/include/rte_lcore.h +17 -0
index 476b8ef3a..339046bc8 100644
@@ -240,6 +240,23 @@ void rte_thread_get_affinity(rte_cpuset_t *cpusetp);
  */
 int rte_thread_setname(pthread_t id, const char *name);
 
+/**
+ * Get thread name.
+ *
+ * @note It fails with glibc < 2.12.
+ *
+ * @param id
+ *   Thread id.
+ * @param name
+ *   Thread name to set.
+ * @param len
+ *   Thread name buffer length.
+ * @return
+ *   On success, return 0; otherwise return a negative value.
+ */
+__rte_experimental
+int rte_thread_getname(pthread_t id, char *name, size_t len);
+
 /**
  * Create a control thread.
  *
lib/librte_eal/linux/eal_thread.c +15 -0
index 379773b68..3f82b286c 100644
@@ -186,3 +186,18 @@ int rte_thread_setname(pthread_t id, const char *name)
 	RTE_SET_USED(name);
 	return -ret;
 }
+
+int rte_thread_getname(pthread_t id, char *name, size_t len)
+{
+	int ret = ENOSYS;
+#if defined(__GLIBC__) && defined(__GLIBC_PREREQ)
+#if __GLIBC_PREREQ(2, 12)
+	ret = pthread_getname_np(id, name, len);
+#endif
+#endif
+	RTE_SET_USED(id);
+	RTE_SET_USED(name);
+	RTE_SET_USED(len);
+	return -ret;
+
+}
lib/librte_eal/rte_eal_version.map +1 -0
index f9ede5b41..71098581f 100644
@@ -338,4 +338,5 @@ EXPERIMENTAL {
 
 	# added in 20.05
 	rte_log_can_log;
+	rte_thread_getname;
 };
Signature · 1 line
2.25.1
#194 lore raw

PATCH v5 3/33 eal/trace: define the public API for trace support

In reply to [email protected]

From: Jerin Jacob <[email protected]>

Define the public API for trace support.
This patch also adds support for the build infrastructure and update the MAINTAINERS file for the trace subsystem.

---
 MAINTAINERS                               |   6 +
 config/common_base                        |   1 +
 config/meson.build                        |   1 +
 doc/api/doxy-api-index.md                 |   3 +-
 doc/guides/prog_guide/build-sdk-meson.rst |   5 +
 lib/librte_eal/common/eal_common_trace.c  |   6 +
 lib/librte_eal/common/meson.build         |   1 +
 lib/librte_eal/freebsd/Makefile           |   1 +
 lib/librte_eal/include/meson.build        |   1 +
 lib/librte_eal/include/rte_trace.h        | 366 ++++++++++++++++++++++
 lib/librte_eal/linux/Makefile             |   1 +
 meson_options.txt                         |   2 +
 12 files changed, 393 insertions(+), 1 deletion(-)
 create mode 100644 lib/librte_eal/common/eal_common_trace.c
 create mode 100644 lib/librte_eal/include/rte_trace.h
MAINTAINERS +6 -0
index 4800f6884..b71a8c99a 100644
@@ -194,6 +194,12 @@ F: app/test/test_string_fns.c
 F: app/test/test_tailq.c
 F: app/test/test_version.c
 
+Trace - EXPERIMENTAL
+M: Jerin Jacob <[email protected]>
+M: Sunil Kumar Kori <[email protected]>
+F: lib/librte_eal/include/rte_trace*.h
+F: lib/librte_eal/common/eal_common_trace*.c
+
 Memory Allocation
 M: Anatoly Burakov <[email protected]>
 F: lib/librte_eal/include/rte_fbarray.h
config/common_base +1 -0
index c31175f9d..ac5257b8e 100644
@@ -99,6 +99,7 @@ CONFIG_RTE_MAX_MEMZONE=2560
 CONFIG_RTE_MAX_TAILQ=32
 CONFIG_RTE_ENABLE_ASSERT=n
 CONFIG_RTE_LOG_DP_LEVEL=RTE_LOG_INFO
+CONFIG_RTE_ENABLE_TRACE_FP=n
 CONFIG_RTE_LOG_HISTORY=256
 CONFIG_RTE_BACKTRACE=y
 CONFIG_RTE_LIBEAL_USE_HPET=n
config/meson.build +1 -0
index 8a4c692a9..f416be23e 100644
@@ -230,6 +230,7 @@ dpdk_conf.set('RTE_MAX_LCORE', get_option('max_lcores'))
 dpdk_conf.set('RTE_MAX_NUMA_NODES', get_option('max_numa_nodes'))
 dpdk_conf.set('RTE_MAX_ETHPORTS', get_option('max_ethports'))
 dpdk_conf.set('RTE_LIBEAL_USE_HPET', get_option('use_hpet'))
+dpdk_conf.set('RTE_ENABLE_TRACE_FP', get_option('enable_trace_fp'))
 # values which have defaults which may be overridden
 dpdk_conf.set('RTE_MAX_VFIO_GROUPS', 64)
 dpdk_conf.set('RTE_DRIVER_MEMPOOL_BUCKET_SIZE_KB', 64)
doc/api/doxy-api-index.md +2 -1
index dff496be0..190f0ccc2 100644
@@ -174,7 +174,8 @@ The public API headers are grouped by topics:
   [hexdump]            (@ref rte_hexdump.h),
   [debug]              (@ref rte_debug.h),
   [log]                (@ref rte_log.h),
-  [errno]              (@ref rte_errno.h)
+  [errno]              (@ref rte_errno.h),
+  [trace]              (@ref rte_trace.h)
 
 - **misc**:
   [EAL config]         (@ref rte_eal.h),
doc/guides/prog_guide/build-sdk-meson.rst +5 -0
index e34daab91..a036299da 100644
@@ -87,6 +87,9 @@ Project-specific options are passed used -Doption=value::
 	meson -Ddisable_drivers=event/*,net/tap  # disable tap driver and all
 					# eventdev PMDs for a smaller build
 
+	meson -Denable_trace_fp=true tracebuild # build with fastpath trace
+					#enabled
+
 Examples of setting some of the same options using meson configure::
 
 	meson configure -Dwerror=true
@@ -97,6 +100,8 @@ Examples of setting some of the same options using meson configure::
 
 	meson configure -Dmax_lcores=8
 
+	meson configure -Denable_trace_fp=true
+
 NOTE: once meson has been run to configure a build in a directory, it
 cannot be run again on the same directory. Instead ``meson configure``
 should be used to change the build settings within the directory, and when
lib/librte_eal/common/eal_common_trace.c new file +6 -0
new file mode 100644
index 000000000..e18ba1c95
@@ -0,0 +1,6 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(C) 2020 Marvell International Ltd.
+ */
+
+#include <rte_trace.h>
+
lib/librte_eal/common/meson.build +1 -0
index 02d9280cc..429e89f99 100644
@@ -42,6 +42,7 @@ sources += files(
 	'eal_common_tailqs.c',
 	'eal_common_thread.c',
 	'eal_common_timer.c',
+	'eal_common_trace.c',
 	'eal_common_uuid.c',
 	'hotplug_mp.c',
 	'malloc_elem.c',
lib/librte_eal/freebsd/Makefile +1 -0
index 2d53ce9ee..500afc578 100644
@@ -59,6 +59,7 @@ SRCS-$(CONFIG_RTE_EXEC_ENV_FREEBSD) += eal_common_thread.c
 SRCS-$(CONFIG_RTE_EXEC_ENV_FREEBSD) += eal_common_proc.c
 SRCS-$(CONFIG_RTE_EXEC_ENV_FREEBSD) += eal_common_fbarray.c
 SRCS-$(CONFIG_RTE_EXEC_ENV_FREEBSD) += eal_common_uuid.c
+SRCS-$(CONFIG_RTE_EXEC_ENV_FREEBSD) += eal_common_trace.c
 SRCS-$(CONFIG_RTE_EXEC_ENV_FREEBSD) += rte_malloc.c
 SRCS-$(CONFIG_RTE_EXEC_ENV_FREEBSD) += hotplug_mp.c
 SRCS-$(CONFIG_RTE_EXEC_ENV_FREEBSD) += malloc_elem.c
lib/librte_eal/include/meson.build +1 -0
index 6fd427494..37dcb02fa 100644
@@ -40,6 +40,7 @@ headers += files(
 	'rte_string_fns.h',
 	'rte_tailq.h',
 	'rte_time.h',
+	'rte_trace.h',
 	'rte_uuid.h',
 	'rte_version.h',
 	'rte_vfio.h',
lib/librte_eal/include/rte_trace.h new file +366 -0

366 lines not on this page · raw message

lib/librte_eal/linux/Makefile +1 -0
index fc2316667..2ced2085b 100644
@@ -66,6 +66,7 @@ SRCS-$(CONFIG_RTE_EXEC_ENV_LINUX) += eal_common_thread.c
 SRCS-$(CONFIG_RTE_EXEC_ENV_LINUX) += eal_common_proc.c
 SRCS-$(CONFIG_RTE_EXEC_ENV_LINUX) += eal_common_fbarray.c
 SRCS-$(CONFIG_RTE_EXEC_ENV_LINUX) += eal_common_uuid.c
+SRCS-$(CONFIG_RTE_EXEC_ENV_LINUX) += eal_common_trace.c
 SRCS-$(CONFIG_RTE_EXEC_ENV_LINUX) += rte_malloc.c
 SRCS-$(CONFIG_RTE_EXEC_ENV_LINUX) += hotplug_mp.c
 SRCS-$(CONFIG_RTE_EXEC_ENV_LINUX) += malloc_elem.c
meson_options.txt +2 -0
index 9e4923a4f..3578a23ab 100644
@@ -30,6 +30,8 @@ option('max_lcores', type: 'integer', value: 128,
 	description: 'maximum number of cores/threads supported by EAL')
 option('max_numa_nodes', type: 'integer', value: 4,
 	description: 'maximum number of NUMA nodes supported by EAL')
+option('enable_trace_fp', type: 'boolean', value: false,
+	description: 'enable fastpath trace points.')
 option('tests', type: 'boolean', value: true,
 	description: 'build unit tests')
 option('use_hpet', type: 'boolean', value: false,
Signature · 1 line
2.25.1
#195 lore raw

PATCH v5 4/33 eal/trace: implement trace register API

In reply to [email protected]

From: Jerin Jacob <[email protected]>

The consumers of trace API defines the tracepoint and registers to eal. Internally these tracepoints will be stored in STAILQ for future use. This patch implements the tracepoint registration function.

---
 MAINTAINERS                                 |  1 +
 lib/librte_eal/common/eal_common_trace.c    | 99 ++++++++++++++++++++-
 lib/librte_eal/common/eal_trace.h           | 36 ++++++++
 lib/librte_eal/include/meson.build          |  2 +
 lib/librte_eal/include/rte_trace.h          | 26 ++++++
 lib/librte_eal/include/rte_trace_provider.h | 22 +++++
 lib/librte_eal/include/rte_trace_register.h | 20 +++++
 lib/librte_eal/rte_eal_version.map          |  1 +
 8 files changed, 206 insertions(+), 1 deletion(-)
 create mode 100644 lib/librte_eal/common/eal_trace.h
 create mode 100644 lib/librte_eal/include/rte_trace_provider.h
 create mode 100644 lib/librte_eal/include/rte_trace_register.h
MAINTAINERS +1 -0
index b71a8c99a..49a97e592 100644
@@ -199,6 +199,7 @@ M: Jerin Jacob <[email protected]>
 M: Sunil Kumar Kori <[email protected]>
 F: lib/librte_eal/include/rte_trace*.h
 F: lib/librte_eal/common/eal_common_trace*.c
+F: lib/librte_eal/common/eal_trace.h
 
 Memory Allocation
 M: Anatoly Burakov <[email protected]>
lib/librte_eal/common/eal_common_trace.c +98 -1

103 lines not on this page · raw message

lib/librte_eal/common/eal_trace.h new file +36 -0
new file mode 100644
index 000000000..7665bd6be
@@ -0,0 +1,36 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(C) 2020 Marvell International Ltd.
+ */
+
+#ifndef __EAL_TRACE_H
+#define __EAL_TRACE_H
+
+#include <rte_trace.h>
+
+#define trace_err(fmt, args...)\
+	RTE_LOG(ERR, EAL, "%s():%u " fmt "\n",\
+		__func__, __LINE__, ## args)
+
+#define trace_crit(fmt, args...)\
+	RTE_LOG(CRIT, EAL, "%s():%u " fmt "\n",\
+		__func__, __LINE__, ## args)
+
+#define TRACE_CTF_FIELD_SIZE 384
+#define TRACE_POINT_NAME_SIZE 64
+
+struct trace_point {
+	STAILQ_ENTRY(trace_point) next;
+	rte_trace_t *handle;
+	char name[TRACE_POINT_NAME_SIZE];
+	char ctf_field[TRACE_CTF_FIELD_SIZE];
+};
+
+struct trace {
+	int register_errno;
+	uint32_t nb_trace_points;
+};
+
+/* Trace point list functions */
+STAILQ_HEAD(trace_point_head, trace_point);
+
+#endif /* __EAL_TRACE_H */
lib/librte_eal/include/meson.build +2 -0
index 37dcb02fa..037a4ae63 100644
@@ -41,6 +41,8 @@ headers += files(
 	'rte_tailq.h',
 	'rte_time.h',
 	'rte_trace.h',
+	'rte_trace_provider.h',
+	'rte_trace_register.h',
 	'rte_uuid.h',
 	'rte_version.h',
 	'rte_vfio.h',
lib/librte_eal/include/rte_trace.h +26 -0
index 83105c980..1c8010f08 100644
@@ -359,6 +359,32 @@ _tp _args \
 
 #endif /* __DOXYGEN__ */
 
+/**
+ * @internal
+ *
+ * Helper function to register a dynamic tracepoint.
+ * Use RTE_TRACE_POINT_REGISTER macro for tracepoint registration.
+ *
+ * @param trace
+ *   The tracepoint object created using RTE_TRACE_POINT_DEFINE.
+ * @param name
+ *   The name of the tracepoint object.
+ * @param register_fn
+ *   Trace registration function.
+ * @return
+ *   - 0: Successfully registered the tracepoint.
+ *   - <0: Failure to register the tracepoint.
+ */
+__rte_experimental
+int __rte_trace_point_register(rte_trace_t *trace, const char *name,
+			       void (*register_fn)(void));
+
+#ifdef RTE_TRACE_POINT_REGISTER_SELECT
+#include <rte_trace_register.h>
+#else
+#include <rte_trace_provider.h>
+#endif
+
 #ifdef __cplusplus
 }
 #endif
lib/librte_eal/include/rte_trace_provider.h new file +22 -0
new file mode 100644
index 000000000..d1b45a4c7
@@ -0,0 +1,22 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(C) 2020 Marvell International Ltd.
+ */
+
+#ifndef _RTE_TRACE_H_
+#error do not include this file directly, use <rte_trace.h> instead
+#endif
+
+#ifndef _RTE_TRACE_PROVIDER_H_
+#define _RTE_TRACE_PROVIDER_H_
+
+#define __RTE_TRACE_EVENT_HEADER_ID_SHIFT (48)
+
+#define __RTE_TRACE_FIELD_SIZE_SHIFT 0
+#define __RTE_TRACE_FIELD_SIZE_MASK (0xffffULL << __RTE_TRACE_FIELD_SIZE_SHIFT)
+#define __RTE_TRACE_FIELD_ID_SHIFT (16)
+#define __RTE_TRACE_FIELD_ID_MASK (0xffffULL << __RTE_TRACE_FIELD_ID_SHIFT)
+#define __RTE_TRACE_FIELD_ENABLE_MASK (1ULL << 63)
+#define __RTE_TRACE_FIELD_ENABLE_DISCARD (1ULL << 62)
+
+
+#endif /* _RTE_TRACE_PROVIDER_H_ */
lib/librte_eal/include/rte_trace_register.h new file +20 -0
new file mode 100644
index 000000000..b36c00827
@@ -0,0 +1,20 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(C) 2020 Marvell International Ltd.
+ */
+
+#ifndef _RTE_TRACE_H_
+#error do not include this file directly, use <rte_trace.h> instead
+#endif
+
+#ifndef _RTE_TRACE_REGISTER_H_
+#define _RTE_TRACE_REGISTER_H_
+
+#include <rte_per_lcore.h>
+
+RTE_DECLARE_PER_LCORE(volatile int, trace_point_sz);
+
+#define RTE_TRACE_POINT_REGISTER(trace, name)\
+	__rte_trace_point_register(&__##trace, RTE_STR(name),\
+				   (void (*)(void)) trace)
+
+#endif /* _RTE_TRACE_REGISTER_H_ */
lib/librte_eal/rte_eal_version.map +1 -0
index 71098581f..3a1be3e3f 100644
@@ -339,4 +339,5 @@ EXPERIMENTAL {
 	# added in 20.05
 	rte_log_can_log;
 	rte_thread_getname;
+	__rte_trace_point_register;
 };
Signature · 1 line
2.25.1
#196 lore raw

Re: [dpdk-dev] [PATCH v5 04/33] eal/trace: implement trace register API

Quoted 13 lines · On Mon, Apr 13, 2020 at 5:02 PM <[email protected]> wrote:
lib/librte_eal/common/eal_common_trace.c +3 -1
index e18ba1c95..abb656838 100644
@@ -2,5 +2,102 @@
  * Copyright(C) 2020 Marvell International Ltd.
  */
 
-#include <rte_trace.h>
+#include <inttypes.h>
+#include <sys/queue.h>
 
+#include <rte_common.h>

lib/librte_eal/common/eal_common_trace.c line 18

Quoted 10 lines
lib/librte_eal/common/eal_common_trace.c +10 -0
+#include <rte_errno.h>
+#include <rte_lcore.h>
+#include <rte_per_lcore.h>
+#include <rte_string_fns.h>
+
+#include "eal_trace.h"
+
+RTE_DEFINE_PER_LCORE(volatile int, trace_point_sz);
+RTE_DEFINE_PER_LCORE(char, ctf_field[TRACE_CTF_FIELD_SIZE]);
+RTE_DEFINE_PER_LCORE(int, ctf_count);

Afaics, ctf_field and ctf_count can be static.

Signature · 1 line
David Marchand
#197 lore raw

PATCH v5 5/33 eal/trace: implement trace operation APIs

In reply to [email protected]

From: Jerin Jacob <[email protected]>

This patch implements the following public trace APIs.

- rte_trace_global_is_enabled()
- rte_trace_global_is_disabled()
- rte_trace_id_is_invalid()
- rte_trace_enable()
- rte_trace_disable()
- rte_trace_is_enabled()
- rte_trace_is_disabled()
- rte_trace_mode_set()
- rte_trace_mode_get()
- rte_trace_pattern()
- rte_trace_regexp()
- rte_trace_by_name()

---
 lib/librte_eal/common/eal_common_trace.c | 165 +++++++++++++++++++++++
 lib/librte_eal/common/eal_trace.h        |  10 ++
 lib/librte_eal/rte_eal_version.map       |  12 ++
 3 files changed, 187 insertions(+)
lib/librte_eal/common/eal_common_trace.c +165 -0
index abb656838..12e11bf69 100644
@@ -3,7 +3,9 @@
  */
 
 #include <inttypes.h>
+#include <fnmatch.h>
 #include <sys/queue.h>
+#include <regex.h>
 
 #include <rte_common.h>
 #include <rte_errno.h>
@@ -20,6 +22,169 @@ RTE_DEFINE_PER_LCORE(int, ctf_count);
 static struct trace_point_head tp_list = STAILQ_HEAD_INITIALIZER(tp_list);
 static struct trace trace;
 
+bool
+rte_trace_global_is_enabled(void)
+{
+	return trace.global_status;
+}
+
+bool
+rte_trace_global_is_disabled(void)
+{
+	return !trace.global_status;
+}
+
+static void
+trace_mode_set(rte_trace_t *trace, enum rte_trace_mode mode)
+{
+	if (mode == RTE_TRACE_MODE_OVERWRITE)
+		__atomic_and_fetch(trace, ~__RTE_TRACE_FIELD_ENABLE_DISCARD,
+				   __ATOMIC_RELEASE);
+	else
+		__atomic_or_fetch(trace, __RTE_TRACE_FIELD_ENABLE_DISCARD,
+				  __ATOMIC_RELEASE);
+}
+
+void
+rte_trace_mode_set(enum rte_trace_mode mode)
+{
+	struct trace_point *tp;
+
+	if (rte_trace_global_is_disabled())
+		return;
+
+	STAILQ_FOREACH(tp, &tp_list, next)
+		trace_mode_set(tp->handle, mode);
+
+	trace.mode = mode;
+}
+
+enum
+rte_trace_mode rte_trace_mode_get(void)
+{
+	return trace.mode;
+}
+
+bool
+rte_trace_id_is_invalid(rte_trace_t *t)
+{
+	if (t == NULL)
+		return false;
+
+	if (trace_id_get(t) >= trace.nb_trace_points)
+		return true;
+
+	return false;
+}
+
+bool
+rte_trace_is_enabled(rte_trace_t *trace)
+{
+	uint64_t val;
+
+	if (rte_trace_id_is_invalid(trace))
+		return false;
+
+	val = __atomic_load_n(trace, __ATOMIC_ACQUIRE);
+	return val & __RTE_TRACE_FIELD_ENABLE_MASK;
+}
+
+bool
+rte_trace_is_disabled(rte_trace_t *trace)
+{
+	uint64_t val;
+
+	if (rte_trace_id_is_invalid(trace))
+		return true;
+
+	val = __atomic_load_n(trace, __ATOMIC_ACQUIRE);
+	return !(val & __RTE_TRACE_FIELD_ENABLE_MASK);
+}
+
+int
+rte_trace_enable(rte_trace_t *trace)
+{
+	if (rte_trace_id_is_invalid(trace))
+		return -ERANGE;
+
+	__atomic_or_fetch(trace, __RTE_TRACE_FIELD_ENABLE_MASK,
+			  __ATOMIC_RELEASE);
+	return 0;
+}
+
+int
+rte_trace_disable(rte_trace_t *trace)
+{
+	if (rte_trace_id_is_invalid(trace))
+		return -ERANGE;
+
+	__atomic_and_fetch(trace, ~__RTE_TRACE_FIELD_ENABLE_MASK,
+			   __ATOMIC_RELEASE);
+	return 0;
+}
+
+int
+rte_trace_pattern(const char *pattern, bool enable)
+{
+	struct trace_point *tp;
+	int rc = 0, found = 0;
+
+	STAILQ_FOREACH(tp, &tp_list, next) {
+		if (fnmatch(pattern, tp->name, 0) == 0) {
+			if (enable)
+				rc = rte_trace_enable(tp->handle);
+			else
+				rc = rte_trace_disable(tp->handle);
+			found = 1;
+		}
+		if (rc < 0)
+			return rc;
+	}
+
+	return rc | found;
+}
+
+int
+rte_trace_regexp(const char *regex, bool enable)
+{
+	struct trace_point *tp;
+	int rc = 0, found = 0;
+	regex_t r;
+
+	if (regcomp(&r, regex, 0) != 0)
+		return -EINVAL;
+
+	STAILQ_FOREACH(tp, &tp_list, next) {
+		if (regexec(&r, tp->name, 0, NULL, 0) == 0) {
+			if (enable)
+				rc = rte_trace_enable(tp->handle);
+			else
+				rc = rte_trace_disable(tp->handle);
+			found = 1;
+		}
+		if (rc < 0)
+			return rc;
+	}
+	regfree(&r);
+
+	return rc | found;
+}
+
+rte_trace_t *
+rte_trace_by_name(const char *name)
+{
+	struct trace_point *tp;
+
+	if (name == NULL)
+		return NULL;
+
+	STAILQ_FOREACH(tp, &tp_list, next)
+		if (strncmp(tp->name, name, TRACE_POINT_NAME_SIZE) == 0)
+			return tp->handle;
+
+	return NULL;
+}
+
 int
 __rte_trace_point_register(rte_trace_t *handle, const char *name,
 			   void (*register_fn)(void))
lib/librte_eal/common/eal_trace.h +10 -0
index 7665bd6be..dcaf9e7f7 100644
@@ -27,9 +27,19 @@ struct trace_point {
 
 struct trace {
 	int register_errno;
+	bool global_status;
+	enum rte_trace_mode mode;
 	uint32_t nb_trace_points;
 };
 
+/* Helper functions */
+static inline uint16_t
+trace_id_get(rte_trace_t *trace)
+{
+	return (*trace & __RTE_TRACE_FIELD_ID_MASK) >>
+		__RTE_TRACE_FIELD_ID_SHIFT;
+}
+
 /* Trace point list functions */
 STAILQ_HEAD(trace_point_head, trace_point);
 
lib/librte_eal/rte_eal_version.map +12 -0
index 3a1be3e3f..546371e72 100644
@@ -340,4 +340,16 @@ EXPERIMENTAL {
 	rte_log_can_log;
 	rte_thread_getname;
 	__rte_trace_point_register;
+	rte_trace_global_is_enabled;
+	rte_trace_global_is_disabled;
+	rte_trace_id_is_invalid;
+	rte_trace_enable;
+	rte_trace_disable;
+	rte_trace_is_enabled;
+	rte_trace_is_disabled;
+	rte_trace_mode_set;
+	rte_trace_mode_get;
+	rte_trace_pattern;
+	rte_trace_regexp;
+	rte_trace_by_name;
 };
Signature · 1 line
2.25.1
#198 lore raw

Re: [dpdk-dev] [PATCH v5 05/33] eal/trace: implement trace operation APIs

Quoted 10 lines · On Mon, Apr 13, 2020 at 5:02 PM <[email protected]> wrote:
lib/librte_eal/rte_eal_version.map +2 -0
index 3a1be3e3f..546371e72 100644
@@ -340,4 +340,16 @@ EXPERIMENTAL {
        rte_log_can_log;
        rte_thread_getname;
        __rte_trace_point_register;
+       rte_trace_global_is_enabled;
+       rte_trace_global_is_disabled;

lib/librte_eal/rte_eal_version.map EXPERIMENTAL { · line 354

Quoted 10 lines
lib/librte_eal/rte_eal_version.map +10 -0
+       rte_trace_id_is_invalid;
+       rte_trace_enable;
+       rte_trace_disable;
+       rte_trace_is_enabled;
+       rte_trace_is_disabled;
+       rte_trace_mode_set;
+       rte_trace_mode_get;
+       rte_trace_pattern;
+       rte_trace_regexp;
+       rte_trace_by_name;

Generic comment for this series, alphabetic order in map files please.

Signature · 1 line
David Marchand
#199 lore raw

PATCH v5 6/33 eal/trace: add internal trace init and fini interface

In reply to [email protected]

From: Jerin Jacob <[email protected]>

Define eal_trace_init() and eal_trace_fini() EAL interface functions that rte_eal_init() and rte_eal_cleanup() function can be use to initialize and finalize the trace subsystem. eal_trace_init() function will add the following functionality if trace is enabled through EAL command line param.

- Test for trace registration failure.
- Test for duplicate trace name registration
- Generate UUID ver 4.
- Create a trace directory

---
 lib/librte_eal/common/eal_common_trace.c      |  54 ++++++
 .../common/eal_common_trace_utils.c           | 173 ++++++++++++++++++
 lib/librte_eal/common/eal_trace.h             |  22 +++
 lib/librte_eal/common/meson.build             |   1 +
 lib/librte_eal/freebsd/Makefile               |   1 +
 lib/librte_eal/linux/Makefile                 |   1 +
 6 files changed, 252 insertions(+)
 create mode 100644 lib/librte_eal/common/eal_common_trace_utils.c
lib/librte_eal/common/eal_common_trace.c +54 -0
index 12e11bf69..501f939ea 100644
@@ -22,6 +22,60 @@ RTE_DEFINE_PER_LCORE(int, ctf_count);
 static struct trace_point_head tp_list = STAILQ_HEAD_INITIALIZER(tp_list);
 static struct trace trace;
 
+struct trace*
+trace_obj_get(void)
+{
+	return &trace;
+}
+
+struct trace_point_head *
+trace_list_head_get(void)
+{
+	return &tp_list;
+}
+
+int
+eal_trace_init(void)
+{
+	/* One of the Trace registration failed */
+	if (trace.register_errno) {
+		rte_errno = trace.register_errno;
+		goto fail;
+	}
+
+	if (rte_trace_global_is_disabled())
+		return 0;
+
+	rte_spinlock_init(&trace.lock);
+
+	/* Is duplicate trace name registered */
+	if (trace_has_duplicate_entry())
+		goto fail;
+
+	/* Generate UUID ver 4 with total size of events and number of events */
+	trace_uuid_generate();
+
+	/* Create trace directory */
+	if (trace_mkdir())
+		goto fail;
+
+
+	rte_trace_mode_set(trace.mode);
+
+	return 0;
+
+fail:
+	trace_err("failed to initialize trace [%s]", rte_strerror(rte_errno));
+	return -rte_errno;
+}
+
+void
+eal_trace_fini(void)
+{
+	if (rte_trace_global_is_disabled())
+		return;
+}
+
 bool
 rte_trace_global_is_enabled(void)
 {
lib/librte_eal/common/eal_common_trace_utils.c new file +173 -0

173 lines not on this page · raw message

lib/librte_eal/common/eal_trace.h +22 -0
index dcaf9e7f7..9e0cd7ce3 100644
@@ -5,7 +5,9 @@
 #ifndef __EAL_TRACE_H
 #define __EAL_TRACE_H
 
+#include <rte_spinlock.h>
 #include <rte_trace.h>
+#include <rte_uuid.h>
 
 #define trace_err(fmt, args...)\
 	RTE_LOG(ERR, EAL, "%s():%u " fmt "\n",\
@@ -15,6 +17,8 @@
 	RTE_LOG(CRIT, EAL, "%s():%u " fmt "\n",\
 		__func__, __LINE__, ## args)
 
+#define TRACE_PREFIX_LEN 12
+#define TRACE_DIR_STR_LEN (sizeof("YYYY-mm-dd-AM-HH-MM-SS") + TRACE_PREFIX_LEN)
 #define TRACE_CTF_FIELD_SIZE 384
 #define TRACE_POINT_NAME_SIZE 64
 
@@ -26,10 +30,15 @@ struct trace_point {
 };
 
 struct trace {
+	char dir[PATH_MAX];
+	int dir_offset;
 	int register_errno;
 	bool global_status;
 	enum rte_trace_mode mode;
+	rte_uuid_t uuid;
+	uint32_t buff_len;
 	uint32_t nb_trace_points;
+	rte_spinlock_t lock;
 };
 
 /* Helper functions */
@@ -40,7 +49,20 @@ trace_id_get(rte_trace_t *trace)
 		__RTE_TRACE_FIELD_ID_SHIFT;
 }
 
+/* Trace object functions */
+struct trace *trace_obj_get(void);
+
 /* Trace point list functions */
 STAILQ_HEAD(trace_point_head, trace_point);
+struct trace_point_head *trace_list_head_get(void);
+
+/* Util functions */
+bool trace_has_duplicate_entry(void);
+void trace_uuid_generate(void);
+int trace_mkdir(void);
+
+/* EAL interface */
+int eal_trace_init(void);
+void eal_trace_fini(void);
 
 #endif /* __EAL_TRACE_H */
lib/librte_eal/common/meson.build +1 -0
index 429e89f99..3dc320327 100644
@@ -43,6 +43,7 @@ sources += files(
 	'eal_common_thread.c',
 	'eal_common_timer.c',
 	'eal_common_trace.c',
+	'eal_common_trace_utils.c',
 	'eal_common_uuid.c',
 	'hotplug_mp.c',
 	'malloc_elem.c',
lib/librte_eal/freebsd/Makefile +1 -0
index 500afc578..ae59c8c19 100644
@@ -60,6 +60,7 @@ SRCS-$(CONFIG_RTE_EXEC_ENV_FREEBSD) += eal_common_proc.c
 SRCS-$(CONFIG_RTE_EXEC_ENV_FREEBSD) += eal_common_fbarray.c
 SRCS-$(CONFIG_RTE_EXEC_ENV_FREEBSD) += eal_common_uuid.c
 SRCS-$(CONFIG_RTE_EXEC_ENV_FREEBSD) += eal_common_trace.c
+SRCS-$(CONFIG_RTE_EXEC_ENV_FREEBSD) += eal_common_trace_utils.c
 SRCS-$(CONFIG_RTE_EXEC_ENV_FREEBSD) += rte_malloc.c
 SRCS-$(CONFIG_RTE_EXEC_ENV_FREEBSD) += hotplug_mp.c
 SRCS-$(CONFIG_RTE_EXEC_ENV_FREEBSD) += malloc_elem.c
lib/librte_eal/linux/Makefile +1 -0
index 2ced2085b..7992500a9 100644
@@ -67,6 +67,7 @@ SRCS-$(CONFIG_RTE_EXEC_ENV_LINUX) += eal_common_proc.c
 SRCS-$(CONFIG_RTE_EXEC_ENV_LINUX) += eal_common_fbarray.c
 SRCS-$(CONFIG_RTE_EXEC_ENV_LINUX) += eal_common_uuid.c
 SRCS-$(CONFIG_RTE_EXEC_ENV_LINUX) += eal_common_trace.c
+SRCS-$(CONFIG_RTE_EXEC_ENV_LINUX) += eal_common_trace_utils.c
 SRCS-$(CONFIG_RTE_EXEC_ENV_LINUX) += rte_malloc.c
 SRCS-$(CONFIG_RTE_EXEC_ENV_LINUX) += hotplug_mp.c
 SRCS-$(CONFIG_RTE_EXEC_ENV_LINUX) += malloc_elem.c
Signature · 1 line
2.25.1
#200 lore raw

PATCH v5 7/33 eal/trace: get bootup timestamp for trace

In reply to [email protected]

From: Jerin Jacob <[email protected]>

Find epoch_sec, epoch_nsec and uptime_ticks time information on eal_trace_init()/bootup to derive the time in the trace.

---
 lib/librte_eal/common/eal_common_trace.c      |  3 +++
 .../common/eal_common_trace_utils.c           | 22 +++++++++++++++++++
 lib/librte_eal/common/eal_trace.h             |  5 +++++
 3 files changed, 30 insertions(+)
lib/librte_eal/common/eal_common_trace.c +3 -0
index 501f939ea..c6db3002f 100644
@@ -59,6 +59,9 @@ eal_trace_init(void)
 	if (trace_mkdir())
 		goto fail;
 
+	/* Save current epoch timestamp for future use */
+	if (trace_epoch_time_save() < 0)
+		goto fail;
 
 	rte_trace_mode_set(trace.mode);
 
lib/librte_eal/common/eal_common_trace_utils.c +22 -0
index d2ab8f845..f7700934b 100644
@@ -98,6 +98,28 @@ trace_session_name_generate(char *trace_dir)
 	return -rte_errno;
 }
 
+int
+trace_epoch_time_save(void)
+{
+	struct trace *trace = trace_obj_get();
+	struct timespec epoch = { 0, 0 };
+	uint64_t avg, start, end;
+
+	start = rte_get_tsc_cycles();
+	if (clock_gettime(CLOCK_REALTIME, &epoch) < 0) {
+		trace_err("failed to get the epoch time");
+		return -1;
+	}
+	end = rte_get_tsc_cycles();
+	avg = (start + end) >> 1;
+
+	trace->epoch_sec = (uint64_t) epoch.tv_sec;
+	trace->epoch_nsec = (uint64_t) epoch.tv_nsec;
+	trace->uptime_ticks = avg;
+
+	return 0;
+}
+
 static int
 trace_dir_default_path_get(char *dir_path)
 {
lib/librte_eal/common/eal_trace.h +5 -0
index 9e0cd7ce3..7819f7221 100644
@@ -5,6 +5,7 @@
 #ifndef __EAL_TRACE_H
 #define __EAL_TRACE_H
 
+#include <rte_cycles.h>
 #include <rte_spinlock.h>
 #include <rte_trace.h>
 #include <rte_uuid.h>
@@ -38,6 +39,9 @@ struct trace {
 	rte_uuid_t uuid;
 	uint32_t buff_len;
 	uint32_t nb_trace_points;
+	uint64_t epoch_sec;
+	uint64_t epoch_nsec;
+	uint64_t uptime_ticks;
 	rte_spinlock_t lock;
 };
 
@@ -60,6 +64,7 @@ struct trace_point_head *trace_list_head_get(void);
 bool trace_has_duplicate_entry(void);
 void trace_uuid_generate(void);
 int trace_mkdir(void);
+int trace_epoch_time_save(void);
 
 /* EAL interface */
 int eal_trace_init(void);
Signature · 1 line
2.25.1
#201 lore raw

PATCH v5 8/33 eal/trace: create CTF TDSL metadata in memory

In reply to [email protected]

From: Jerin Jacob <[email protected]>

Common trace format(CTF) defines the metadata[1][2] for trace events, This patch creates the metadata for the DPDK events in memory and latter this will be saved to trace directory on rte_trace_save() invocation.

[1] https://diamon.org/ctf/#specification
[2] https://diamon.org/ctf/#examples

---
 lib/librte_eal/common/eal_common_trace.c     |   9 +-
 lib/librte_eal/common/eal_common_trace_ctf.c | 302 +++++++++++++++++++
 lib/librte_eal/common/eal_trace.h            |   7 +
 lib/librte_eal/common/meson.build            |   1 +
 lib/librte_eal/freebsd/Makefile              |   1 +
 lib/librte_eal/linux/Makefile                |   1 +
 6 files changed, 320 insertions(+), 1 deletion(-)
 create mode 100644 lib/librte_eal/common/eal_common_trace_ctf.c
lib/librte_eal/common/eal_common_trace.c +8 -1
index c6db3002f..cd8539d58 100644
@@ -55,9 +55,13 @@ eal_trace_init(void)
 	/* Generate UUID ver 4 with total size of events and number of events */
 	trace_uuid_generate();
 
+	/* Generate CTF TDSL metadata */
+	if (trace_metadata_create() < 0)
+		goto fail;
+
 	/* Create trace directory */
 	if (trace_mkdir())
-		goto fail;
+		goto free_meta;
 
 	/* Save current epoch timestamp for future use */
 	if (trace_epoch_time_save() < 0)
@@ -67,6 +71,8 @@ eal_trace_init(void)
 
 	return 0;
 
+free_meta:
+	trace_metadata_destroy();
 fail:
 	trace_err("failed to initialize trace [%s]", rte_strerror(rte_errno));
 	return -rte_errno;
@@ -77,6 +83,7 @@ eal_trace_fini(void)
 {
 	if (rte_trace_global_is_disabled())
 		return;
+	trace_metadata_destroy();
 }
 
 bool
lib/librte_eal/common/eal_common_trace_ctf.c new file +302 -0

302 lines not on this page · raw message

lib/librte_eal/common/eal_trace.h +7 -0
index 7819f7221..0e8941d5d 100644
@@ -42,6 +42,11 @@ struct trace {
 	uint64_t epoch_sec;
 	uint64_t epoch_nsec;
 	uint64_t uptime_ticks;
+	char *ctf_meta;
+	uint32_t ctf_meta_offset_freq;
+	uint32_t ctf_meta_offset_freq_off_s;
+	uint32_t ctf_meta_offset_freq_off;
+	uint16_t ctf_fixup_done;
 	rte_spinlock_t lock;
 };
 
@@ -63,6 +68,8 @@ struct trace_point_head *trace_list_head_get(void);
 /* Util functions */
 bool trace_has_duplicate_entry(void);
 void trace_uuid_generate(void);
+int trace_metadata_create(void);
+void trace_metadata_destroy(void);
 int trace_mkdir(void);
 int trace_epoch_time_save(void);
 
lib/librte_eal/common/meson.build +1 -0
index 3dc320327..d2ac44313 100644
@@ -43,6 +43,7 @@ sources += files(
 	'eal_common_thread.c',
 	'eal_common_timer.c',
 	'eal_common_trace.c',
+	'eal_common_trace_ctf.c',
 	'eal_common_trace_utils.c',
 	'eal_common_uuid.c',
 	'hotplug_mp.c',
lib/librte_eal/freebsd/Makefile +1 -0
index ae59c8c19..539ad44a7 100644
@@ -60,6 +60,7 @@ SRCS-$(CONFIG_RTE_EXEC_ENV_FREEBSD) += eal_common_proc.c
 SRCS-$(CONFIG_RTE_EXEC_ENV_FREEBSD) += eal_common_fbarray.c
 SRCS-$(CONFIG_RTE_EXEC_ENV_FREEBSD) += eal_common_uuid.c
 SRCS-$(CONFIG_RTE_EXEC_ENV_FREEBSD) += eal_common_trace.c
+SRCS-$(CONFIG_RTE_EXEC_ENV_FREEBSD) += eal_common_trace_ctf.c
 SRCS-$(CONFIG_RTE_EXEC_ENV_FREEBSD) += eal_common_trace_utils.c
 SRCS-$(CONFIG_RTE_EXEC_ENV_FREEBSD) += rte_malloc.c
 SRCS-$(CONFIG_RTE_EXEC_ENV_FREEBSD) += hotplug_mp.c
lib/librte_eal/linux/Makefile +1 -0
index 7992500a9..f00588d6e 100644
@@ -67,6 +67,7 @@ SRCS-$(CONFIG_RTE_EXEC_ENV_LINUX) += eal_common_proc.c
 SRCS-$(CONFIG_RTE_EXEC_ENV_LINUX) += eal_common_fbarray.c
 SRCS-$(CONFIG_RTE_EXEC_ENV_LINUX) += eal_common_uuid.c
 SRCS-$(CONFIG_RTE_EXEC_ENV_LINUX) += eal_common_trace.c
+SRCS-$(CONFIG_RTE_EXEC_ENV_LINUX) += eal_common_trace_ctf.c
 SRCS-$(CONFIG_RTE_EXEC_ENV_LINUX) += eal_common_trace_utils.c
 SRCS-$(CONFIG_RTE_EXEC_ENV_LINUX) += rte_malloc.c
 SRCS-$(CONFIG_RTE_EXEC_ENV_LINUX) += hotplug_mp.c
Signature · 1 line
2.25.1
#202 lore raw

PATCH v5 9/33 eal/trace: handle CTF keyword collision

In reply to [email protected]

From: Sunil Kumar Kori <[email protected]>

Some of the keyword like align, event, "." and "->" etc will be used in CTF metadata syntax. This patch support for handling those keywords with DPDK events name.

---
 lib/librte_eal/common/eal_common_trace_ctf.c | 119 +++++++++++++++++++
 1 file changed, 119 insertions(+)
lib/librte_eal/common/eal_common_trace_ctf.c +119 -0
index 5ad44cc8d..c4f00bf22 100644
@@ -215,12 +215,131 @@ meta_stream_emit(char **meta, int *offset)
 	return meta_copy(meta, offset, str, rc);
 }
 
+static void
+string_fixed_replace(char *input, const char *search, const char *replace)
+{
+	char *found;
+	size_t len;
+
+	found = strstr(input, search);
+	if (found == NULL)
+		return;
+
+	if (strlen(found) != strlen(search))
+		return;
+
+	len = strlen(replace);
+	memcpy(found, replace, len);
+	found[len] = '\0';
+}
+
+static void
+ctf_fixup_align(char *str)
+{
+	string_fixed_replace(str, "align", "_align");
+}
+
+static void
+ctf_fixup_arrow_deref(char *str)
+{
+	const char *replace = "_";
+	const char *search = "->";
+	char *found;
+	size_t len;
+
+	found = strstr(str, search);
+	if (found == NULL)
+		return;
+
+	do {
+		memcpy(found, replace, strlen(replace));
+		len = strlen(found + 2);
+		memcpy(found + 1, found + 2, len);
+		found[len + 1] = '\0';
+		found = strstr(str, search);
+	} while (found != NULL);
+}
+
+static void
+ctf_fixup_dot_deref(char *str)
+{
+	const char *replace = "_";
+	const char *search = ".";
+	char *found;
+	size_t len;
+
+	found = strstr(str, search);
+	if (found == NULL)
+		return;
+
+	len = strlen(replace);
+	do {
+		memcpy(found, replace, len);
+		found = strstr(str, search);
+	} while (found != NULL);
+}
+
+static void
+ctf_fixup_event(char *str)
+{
+	string_fixed_replace(str, "event", "_event");
+}
+
+static int
+ctf_fixup_keyword(char *str)
+{
+	char dup_str[TRACE_CTF_FIELD_SIZE];
+	char input[TRACE_CTF_FIELD_SIZE];
+	const char *delim = ";";
+	char *from;
+	int len;
+
+	if (str == NULL)
+		return 0;
+
+	len = strlen(str);
+	if (len >= TRACE_CTF_FIELD_SIZE) {
+		trace_err("ctf_field reached its maximum limit");
+		return -EMSGSIZE;
+	}
+
+	/* Create duplicate string */
+	strcpy(dup_str, str);
+
+	len = 0;
+	from = strtok(dup_str, delim);
+	while (from != NULL) {
+		strcpy(input, from);
+		ctf_fixup_align(input);
+		ctf_fixup_dot_deref(input);
+		ctf_fixup_arrow_deref(input);
+		ctf_fixup_event(input);
+
+		strcpy(&input[strlen(input)], delim);
+		if ((len + strlen(input)) >= TRACE_CTF_FIELD_SIZE) {
+			trace_err("ctf_field reached its maximum limit");
+			return -EMSGSIZE;
+		}
+
+		strcpy(str + len, input);
+		len += strlen(input);
+		from = strtok(NULL, delim);
+	}
+
+	return 0;
+}
+
 static int
 meta_event_emit(char **meta, int *offset, struct trace_point *tp)
 {
 	char *str = NULL;
 	int rc;
 
+	/* Fixup ctf field string in case it using reserved ctf keywords */
+	rc = ctf_fixup_keyword(tp->ctf_field);
+	if (rc)
+		return rc;
+
 	rc = metadata_printf(&str,
 		"event {\n"
 		"    id = %d;\n"
Signature · 1 line
2.25.1
#203 lore raw

PATCH v5 10/33 eal/trace: implement trace memory allocation

In reply to [email protected]

From: Jerin Jacob <[email protected]>

Trace memory will be allocated per thread to enable lockless trace events updates to the memory. The allocator will first attempt to allocate from hugepage, if not available from hugepage then fallback to malloc memory.

Later in the patches series, This API will be hooked to DPDK fastpath and control plane thread creation API. It is possible for non DPDK thread to use trace events, in that case, trace memory will be allocated on the first event emission.

---
 lib/librte_eal/common/eal_common_trace.c      | 97 +++++++++++++++++++
 .../common/eal_common_trace_utils.c           | 20 ++++
 lib/librte_eal/common/eal_trace.h             | 28 ++++++
 lib/librte_eal/include/rte_trace.h            | 12 +++
 lib/librte_eal/include/rte_trace_provider.h   | 19 ++++
 lib/librte_eal/rte_eal_version.map            |  2 +
 6 files changed, 178 insertions(+)
lib/librte_eal/common/eal_common_trace.c +97 -0
index cd8539d58..01d42f6e5 100644
@@ -16,6 +16,7 @@
 #include "eal_trace.h"
 
 RTE_DEFINE_PER_LCORE(volatile int, trace_point_sz);
+RTE_DEFINE_PER_LCORE(void *, trace_mem);
 RTE_DEFINE_PER_LCORE(char, ctf_field[TRACE_CTF_FIELD_SIZE]);
 RTE_DEFINE_PER_LCORE(int, ctf_count);
 
@@ -37,6 +38,9 @@ trace_list_head_get(void)
 int
 eal_trace_init(void)
 {
+	/* Trace memory should start with 8B aligned for natural alignment */
+	RTE_BUILD_BUG_ON((offsetof(struct __rte_trace_header, mem) % 8) != 0);
+
 	/* One of the Trace registration failed */
 	if (trace.register_errno) {
 		rte_errno = trace.register_errno;
@@ -83,6 +87,7 @@ eal_trace_fini(void)
 {
 	if (rte_trace_global_is_disabled())
 		return;
+	trace_mem_per_thread_free();
 	trace_metadata_destroy();
 }
 
@@ -249,6 +254,98 @@ rte_trace_by_name(const char *name)
 	return NULL;
 }
 
+static inline size_t
+list_sz(uint32_t index)
+{
+	return sizeof(struct thread_mem_meta) * (index + 1);
+}
+
+void
+__rte_trace_mem_per_thread_alloc(void)
+{
+	struct trace *trace = trace_obj_get();
+	struct __rte_trace_header *header;
+	uint32_t count;
+
+	if (rte_trace_global_is_disabled())
+		return;
+
+	if (RTE_PER_LCORE(trace_mem))
+		return;
+
+	rte_spinlock_lock(&trace->lock);
+
+	count = trace->nb_trace_mem_list;
+
+	/* Allocate room for storing the thread trace mem meta */
+	trace->lcore_meta = realloc(trace->lcore_meta, list_sz(count));
+
+	/* Provide dummy space for fastpath to consume */
+	if (trace->lcore_meta == NULL) {
+		trace_crit("trace mem meta memory realloc failed");
+		header = NULL; goto fail;
+	}
+
+	/* First attempt from huge page */
+	header = rte_malloc(NULL, trace_mem_sz(trace->buff_len), 8);
+	if (header) {
+		trace->lcore_meta[count].area = TRACE_AREA_HUGEPAGE;
+		goto found;
+	}
+
+	/* Second attempt from heap */
+	header = malloc(trace_mem_sz(trace->buff_len));
+	if (header == NULL) {
+		trace_crit("trace mem malloc attempt failed");
+		header = NULL; goto fail;
+
+	}
+
+	/* Second attempt from heap is success */
+	trace->lcore_meta[count].area = TRACE_AREA_HEAP;
+
+	/* Initialize the trace header */
+found:
+	header->offset = 0;
+	header->len = trace->buff_len;
+	header->stream_header.magic = TRACE_CTF_MAGIC;
+	rte_uuid_copy(header->stream_header.uuid, trace->uuid);
+	header->stream_header.lcore_id = rte_lcore_id();
+
+	/* Store the thread name */
+	char *name = header->stream_header.thread_name;
+	memset(name, 0, __RTE_TRACE_EMIT_STRING_LEN_MAX);
+	rte_thread_getname(pthread_self(), name,
+			   __RTE_TRACE_EMIT_STRING_LEN_MAX);
+
+	trace->lcore_meta[count].mem = header;
+	trace->nb_trace_mem_list++;
+fail:
+	RTE_PER_LCORE(trace_mem) = header;
+	rte_spinlock_unlock(&trace->lock);
+}
+
+void
+trace_mem_per_thread_free(void)
+{
+	struct trace *trace = trace_obj_get();
+	uint32_t count;
+	void *mem;
+
+	if (rte_trace_global_is_disabled())
+		return;
+
+	rte_spinlock_lock(&trace->lock);
+	for (count = 0; count < trace->nb_trace_mem_list; count++) {
+		mem = trace->lcore_meta[count].mem;
+		if (trace->lcore_meta[count].area == TRACE_AREA_HUGEPAGE)
+			rte_free(mem);
+		else if (trace->lcore_meta[count].area == TRACE_AREA_HEAP)
+			free(mem);
+	}
+	rte_spinlock_unlock(&trace->lock);
+}
+
 int
 __rte_trace_point_register(rte_trace_t *handle, const char *name,
 			   void (*register_fn)(void))
lib/librte_eal/common/eal_common_trace_utils.c +20 -0
index f7700934b..de8d43661 100644
@@ -14,6 +14,26 @@
 #include "eal_filesystem.h"
 #include "eal_trace.h"
 
+const char *
+trace_mode_to_string(enum rte_trace_mode mode)
+{
+	switch (mode) {
+	case RTE_TRACE_MODE_OVERWRITE: return "overwrite";
+	case RTE_TRACE_MODE_DISCARD: return "discard";
+	default: return "unknown";
+	}
+}
+
+const char *
+trace_area_to_string(enum trace_area_e area)
+{
+	switch (area) {
+	case TRACE_AREA_HEAP: return "heap";
+	case TRACE_AREA_HUGEPAGE: return "hugepage";
+	default: return "unknown";
+	}
+}
+
 static bool
 trace_entry_compare(const char *name)
 {
lib/librte_eal/common/eal_trace.h +28 -0
index 0e8941d5d..c284a2e0b 100644
@@ -6,10 +6,15 @@
 #define __EAL_TRACE_H
 
 #include <rte_cycles.h>
+#include <rte_log.h>
+#include <rte_malloc.h>
 #include <rte_spinlock.h>
 #include <rte_trace.h>
 #include <rte_uuid.h>
 
+#include "eal_private.h"
+#include "eal_thread.h"
+
 #define trace_err(fmt, args...)\
 	RTE_LOG(ERR, EAL, "%s():%u " fmt "\n",\
 		__func__, __LINE__, ## args)
@@ -22,6 +27,8 @@
 #define TRACE_DIR_STR_LEN (sizeof("YYYY-mm-dd-AM-HH-MM-SS") + TRACE_PREFIX_LEN)
 #define TRACE_CTF_FIELD_SIZE 384
 #define TRACE_POINT_NAME_SIZE 64
+#define TRACE_CTF_MAGIC 0xC1FC1FC1
+
 
 struct trace_point {
 	STAILQ_ENTRY(trace_point) next;
@@ -30,6 +37,16 @@ struct trace_point {
 	char ctf_field[TRACE_CTF_FIELD_SIZE];
 };
 
+enum trace_area_e {
+	TRACE_AREA_HEAP,
+	TRACE_AREA_HUGEPAGE,
+};
+
+struct thread_mem_meta {
+	void *mem;
+	enum trace_area_e area;
+};
+
 struct trace {
 	char dir[PATH_MAX];
 	int dir_offset;
@@ -39,6 +56,8 @@ struct trace {
 	rte_uuid_t uuid;
 	uint32_t buff_len;
 	uint32_t nb_trace_points;
+	uint32_t nb_trace_mem_list;
+	struct thread_mem_meta *lcore_meta;
 	uint64_t epoch_sec;
 	uint64_t epoch_nsec;
 	uint64_t uptime_ticks;
@@ -58,6 +77,12 @@ trace_id_get(rte_trace_t *trace)
 		__RTE_TRACE_FIELD_ID_SHIFT;
 }
 
+static inline size_t
+trace_mem_sz(uint32_t len)
+{
+	return len + sizeof(struct __rte_trace_header);
+}
+
 /* Trace object functions */
 struct trace *trace_obj_get(void);
 
@@ -66,12 +91,15 @@ STAILQ_HEAD(trace_point_head, trace_point);
 struct trace_point_head *trace_list_head_get(void);
 
 /* Util functions */
+const char *trace_mode_to_string(enum rte_trace_mode mode);
+const char *trace_area_to_string(enum trace_area_e area);
 bool trace_has_duplicate_entry(void);
 void trace_uuid_generate(void);
 int trace_metadata_create(void);
 void trace_metadata_destroy(void);
 int trace_mkdir(void);
 int trace_epoch_time_save(void);
+void trace_mem_per_thread_free(void);
 
 /* EAL interface */
 int eal_trace_init(void);
lib/librte_eal/include/rte_trace.h +12 -0
index 1c8010f08..cd9bf937f 100644
@@ -359,6 +359,18 @@ _tp _args \
 
 #endif /* __DOXYGEN__ */
 
+/** @internal Macro to define maximum emit length of string datatype. */
+#define __RTE_TRACE_EMIT_STRING_LEN_MAX 32
+
+/**
+ * @internal
+ *
+ * Allocate trace memory buffer per thread.
+ *
+ */
+__rte_experimental
+void __rte_trace_mem_per_thread_alloc(void);
+
 /**
  * @internal
  *
lib/librte_eal/include/rte_trace_provider.h +19 -0
index d1b45a4c7..57906cda6 100644
@@ -9,6 +9,10 @@
 #ifndef _RTE_TRACE_PROVIDER_H_
 #define _RTE_TRACE_PROVIDER_H_
 
+#include <rte_per_lcore.h>
+#include <rte_string_fns.h>
+#include <rte_uuid.h>
+
 #define __RTE_TRACE_EVENT_HEADER_ID_SHIFT (48)
 
 #define __RTE_TRACE_FIELD_SIZE_SHIFT 0
@@ -18,5 +22,20 @@
 #define __RTE_TRACE_FIELD_ENABLE_MASK (1ULL << 63)
 #define __RTE_TRACE_FIELD_ENABLE_DISCARD (1ULL << 62)
 
+struct __rte_trace_stream_header {
+	uint32_t magic;
+	rte_uuid_t uuid;
+	uint32_t lcore_id;
+	char thread_name[__RTE_TRACE_EMIT_STRING_LEN_MAX];
+} __rte_packed;
+
+struct __rte_trace_header {
+	uint32_t offset;
+	uint32_t len;
+	struct __rte_trace_stream_header stream_header;
+	uint8_t mem[];
+};
+
+RTE_DECLARE_PER_LCORE(void *, trace_mem);
 
 #endif /* _RTE_TRACE_PROVIDER_H_ */
lib/librte_eal/rte_eal_version.map +2 -0
index 546371e72..2cec94f55 100644
@@ -339,7 +339,9 @@ EXPERIMENTAL {
 	# added in 20.05
 	rte_log_can_log;
 	rte_thread_getname;
+	__rte_trace_mem_per_thread_alloc;
 	__rte_trace_point_register;
+	per_lcore_trace_mem;
 	rte_trace_global_is_enabled;
 	rte_trace_global_is_disabled;
 	rte_trace_id_is_invalid;
Signature · 1 line
2.25.1
#204 lore raw

PATCH v5 11/33 eal/trace: implement debug dump function

In reply to [email protected]

From: Jerin Jacob <[email protected]>

Implement rte_trace_metadata_dump() and rte_trace_dump() functions. Former one used to dump the CTF metadata file and the latter one to dump all the registered events and its status.

---
 lib/librte_eal/common/eal_common_trace.c     | 57 +++++++++++++++++
 lib/librte_eal/common/eal_common_trace_ctf.c | 67 ++++++++++++++++++++
 lib/librte_eal/rte_eal_version.map           |  2 +
 3 files changed, 126 insertions(+)
lib/librte_eal/common/eal_common_trace.c +57 -0
index 01d42f6e5..8181c0f02 100644
@@ -254,6 +254,63 @@ rte_trace_by_name(const char *name)
 	return NULL;
 }
 
+static void
+trace_point_dump(FILE *f, struct trace_point *tp)
+{
+	rte_trace_t *handle = tp->handle;
+
+	fprintf(f, "\tid %d, %s, size is %d, %s\n",
+		trace_id_get(handle), tp->name,
+		(uint16_t)(*handle & __RTE_TRACE_FIELD_SIZE_MASK),
+		rte_trace_is_enabled(handle) ? "enabled" : "disabled");
+}
+
+static void
+trace_lcore_mem_dump(FILE *f)
+{
+	struct trace *trace = trace_obj_get();
+	struct __rte_trace_header *header;
+	uint32_t count;
+
+	if (trace->nb_trace_mem_list == 0)
+		return;
+
+	rte_spinlock_lock(&trace->lock);
+	fprintf(f, "nb_trace_mem_list = %d\n", trace->nb_trace_mem_list);
+	fprintf(f, "\nTrace mem info\n--------------\n");
+	for (count = 0; count < trace->nb_trace_mem_list; count++) {
+		header = trace->lcore_meta[count].mem;
+		fprintf(f, "\tid %d, mem=%p, area=%s, lcore_id=%d, name=%s\n",
+		count, header,
+		trace_area_to_string(trace->lcore_meta[count].area),
+		header->stream_header.lcore_id,
+		header->stream_header.thread_name);
+	}
+	rte_spinlock_unlock(&trace->lock);
+}
+
+void
+rte_trace_dump(FILE *f)
+{
+	struct trace_point_head *tp_list = trace_list_head_get();
+	struct trace *trace = trace_obj_get();
+	struct trace_point *tp;
+
+	fprintf(f, "\nGlobal info\n-----------\n");
+	fprintf(f, "status = %s\n",
+		rte_trace_global_is_enabled() ? "enabled" : "disabled");
+	fprintf(f, "mode = %s\n",
+		trace_mode_to_string(rte_trace_mode_get()));
+	fprintf(f, "dir = %s\n", trace->dir);
+	fprintf(f, "buffer len = %d\n", trace->buff_len);
+	fprintf(f, "number of trace points = %d\n", trace->nb_trace_points);
+
+	trace_lcore_mem_dump(f);
+	fprintf(f, "\nTrace point info\n----------------\n");
+	STAILQ_FOREACH(tp, tp_list, next)
+		trace_point_dump(f, tp);
+}
+
 static inline size_t
 list_sz(uint32_t index)
 {
lib/librte_eal/common/eal_common_trace_ctf.c +67 -0

70 lines not on this page · raw message

lib/librte_eal/rte_eal_version.map +2 -0
index 2cec94f55..f95f90e3f 100644
@@ -354,4 +354,6 @@ EXPERIMENTAL {
 	rte_trace_pattern;
 	rte_trace_regexp;
 	rte_trace_by_name;
+	rte_trace_metadata_dump;
+	rte_trace_dump;
 };
Signature · 1 line
2.25.1
#205 lore raw

PATCH v5 12/33 eal/trace: implement trace save

In reply to [email protected]

From: Jerin Jacob <[email protected]>

Implement rte_trace_save(), which will save the metadata file and trace memory snapshot to the trace directory.

---
 .../common/eal_common_trace_utils.c           | 80 +++++++++++++++++++
 lib/librte_eal/rte_eal_version.map            |  1 +
 2 files changed, 81 insertions(+)
lib/librte_eal/common/eal_common_trace_utils.c +80 -0
index de8d43661..bbe099473 100644
@@ -213,3 +213,83 @@ trace_mkdir(void)
 	return 0;
 }
 
+static int
+trace_meta_save(struct trace *trace)
+{
+	char file_name[PATH_MAX];
+	FILE *f;
+	int rc;
+
+	rc = snprintf(file_name, PATH_MAX, "%s/metadata", trace->dir);
+	if (rc < 0)
+		return rc;
+
+	f = fopen(file_name, "w");
+	if (f == NULL)
+		return -errno;
+
+	rc = rte_trace_metadata_dump(f);
+
+	if (fclose(f))
+		rc = -errno;
+
+	return rc;
+}
+
+
+static inline int
+trace_file_sz(struct __rte_trace_header *hdr)
+{
+	return sizeof(struct __rte_trace_stream_header) + hdr->offset;
+}
+
+static int
+trace_mem_save(struct trace *trace, struct __rte_trace_header *hdr,
+	       uint32_t cnt)
+{
+	char file_name[PATH_MAX];
+	FILE *f;
+	int rc;
+
+	rc = snprintf(file_name, PATH_MAX, "%s/channel0_%d", trace->dir, cnt);
+	if (rc < 0)
+		return rc;
+
+	f = fopen(file_name, "w");
+	if (f == NULL)
+		return -errno;
+
+	rc = fwrite(&hdr->stream_header, trace_file_sz(hdr), 1, f);
+	rc = (rc == 1) ?  0 : -EACCES;
+
+	if (fclose(f))
+		rc = -errno;
+
+	return rc;
+}
+
+int
+rte_trace_save(void)
+{
+	struct trace *trace = trace_obj_get();
+	struct __rte_trace_header *header;
+	uint32_t count;
+	int rc = 0;
+
+	if (trace->nb_trace_mem_list == 0)
+		return rc;
+
+	rc = trace_meta_save(trace);
+	if (rc)
+		return rc;
+
+	rte_spinlock_lock(&trace->lock);
+	for (count = 0; count < trace->nb_trace_mem_list; count++) {
+		header = trace->lcore_meta[count].mem;
+		rc =  trace_mem_save(trace, header, count);
+		if (rc)
+			break;
+	}
+	rte_spinlock_unlock(&trace->lock);
+	return rc;
+}
lib/librte_eal/rte_eal_version.map +1 -0
index f95f90e3f..1d478449b 100644
@@ -354,6 +354,7 @@ EXPERIMENTAL {
 	rte_trace_pattern;
 	rte_trace_regexp;
 	rte_trace_by_name;
+	rte_trace_save;
 	rte_trace_metadata_dump;
 	rte_trace_dump;
 };
Signature · 1 line
2.25.1
#206 lore raw

PATCH v5 13/33 eal/trace: implement registration payload

In reply to [email protected]

From: Jerin Jacob <[email protected]>

The trace function payloads such as rte_trace_ctf_* have dual functions. The first to emit the payload for the registration function and the second one to act as trace memory emitters.

When it used as registration payload, it will do the following to fulfill the registration job.
- Find out the size of the event
- Generate metadata field string using __rte_trace_emit_ctf_field().

---
 lib/librte_eal/common/eal_common_trace.c    | 19 ++++++++++++
 lib/librte_eal/include/rte_trace.h          | 20 +++++++++++++
 lib/librte_eal/include/rte_trace_register.h | 32 +++++++++++++++++++++
 lib/librte_eal/rte_eal_version.map          |  2 ++
 4 files changed, 73 insertions(+)
lib/librte_eal/common/eal_common_trace.c +19 -0
index 8181c0f02..906e2d706 100644
@@ -403,6 +403,25 @@ trace_mem_per_thread_free(void)
 	rte_spinlock_unlock(&trace->lock);
 }
 
+void
+__rte_trace_emit_ctf_field(size_t sz, const char *in, const char *datatype)
+{
+	char *field = RTE_PER_LCORE(ctf_field);
+	int count = RTE_PER_LCORE(ctf_count);
+	int rc;
+
+	RTE_PER_LCORE(trace_point_sz) += sz;
+	rc = snprintf(RTE_PTR_ADD(field, count),
+		      RTE_MAX(0, TRACE_CTF_FIELD_SIZE - 1 - count),
+		      "%s %s;", datatype, in);
+	if (rc <= 0) {
+		RTE_PER_LCORE(trace_point_sz) = 0;
+		trace_crit("CTF field is too long");
+		return;
+	}
+	RTE_PER_LCORE(ctf_count) += rc;
+}
+
 int
 __rte_trace_point_register(rte_trace_t *handle, const char *name,
 			   void (*register_fn)(void))
lib/librte_eal/include/rte_trace.h +20 -0
index cd9bf937f..b327ef44a 100644
@@ -361,6 +361,8 @@ _tp _args \
 
 /** @internal Macro to define maximum emit length of string datatype. */
 #define __RTE_TRACE_EMIT_STRING_LEN_MAX 32
+/** @internal Macro to define event header size. */
+#define __RTE_TRACE_EVENT_HEADER_SZ sizeof(uint64_t)
 
 /**
  * @internal
@@ -391,6 +393,24 @@ __rte_experimental
 int __rte_trace_point_register(rte_trace_t *trace, const char *name,
 			       void (*register_fn)(void));
 
+/**
+ * @internal
+ *
+ * Helper function to emit ctf field.
+ *
+ * @param sz
+ *   The tracepoint size.
+ * @param field
+ *   The name of the trace event.
+ * @param type
+ *   The datatype of the trace event as string.
+ * @return
+ *   - 0: Success.
+ *   - <0: Failure.
+ */
+__rte_experimental
+void __rte_trace_emit_ctf_field(size_t sz, const char *field, const char *type);
+
 #ifdef RTE_TRACE_POINT_REGISTER_SELECT
 #include <rte_trace_register.h>
 #else
lib/librte_eal/include/rte_trace_register.h +32 -0
index b36c00827..6c55a4a9a 100644
@@ -17,4 +17,36 @@ RTE_DECLARE_PER_LCORE(volatile int, trace_point_sz);
 	__rte_trace_point_register(&__##trace, RTE_STR(name),\
 				   (void (*)(void)) trace)
 
+#define __rte_trace_emit_header_generic(t)\
+	RTE_PER_LCORE(trace_point_sz) = __RTE_TRACE_EVENT_HEADER_SZ
+
+#define __rte_trace_emit_header_fp(t) __rte_trace_emit_header_generic(t)
+
+#define __rte_trace_emit_datatype(in, type)\
+do {\
+	RTE_BUILD_BUG_ON(sizeof(type) != sizeof(typeof(in)));\
+	__rte_trace_emit_ctf_field(sizeof(type), RTE_STR(in), RTE_STR(type));\
+} while (0)
+
+#define rte_trace_ctf_u64(in) __rte_trace_emit_datatype(in, uint64_t)
+#define rte_trace_ctf_i64(in) __rte_trace_emit_datatype(in, int64_t)
+#define rte_trace_ctf_u32(in) __rte_trace_emit_datatype(in, uint32_t)
+#define rte_trace_ctf_i32(in) __rte_trace_emit_datatype(in, int32_t)
+#define rte_trace_ctf_u16(in) __rte_trace_emit_datatype(in, uint16_t)
+#define rte_trace_ctf_i16(in) __rte_trace_emit_datatype(in, int16_t)
+#define rte_trace_ctf_u8(in) __rte_trace_emit_datatype(in, uint8_t)
+#define rte_trace_ctf_i8(in) __rte_trace_emit_datatype(in, int8_t)
+#define rte_trace_ctf_int(in) __rte_trace_emit_datatype(in, int32_t)
+#define rte_trace_ctf_long(in) __rte_trace_emit_datatype(in, long)
+#define rte_trace_ctf_float(in) __rte_trace_emit_datatype(in, float)
+#define rte_trace_ctf_double(in) __rte_trace_emit_datatype(in, double)
+#define rte_trace_ctf_ptr(in) __rte_trace_emit_datatype(in, uintptr_t)
+
+#define rte_trace_ctf_string(in)\
+do {\
+	RTE_SET_USED(in);\
+	__rte_trace_emit_ctf_field(__RTE_TRACE_EMIT_STRING_LEN_MAX,\
+				   RTE_STR(in)"[32]", "string_bounded_t");\
+} while (0)
+
 #endif /* _RTE_TRACE_REGISTER_H_ */
lib/librte_eal/rte_eal_version.map +2 -0
index 1d478449b..155dd4e25 100644
@@ -340,7 +340,9 @@ EXPERIMENTAL {
 	rte_log_can_log;
 	rte_thread_getname;
 	__rte_trace_mem_per_thread_alloc;
+	__rte_trace_emit_ctf_field;
 	__rte_trace_point_register;
+	per_lcore_trace_point_sz;
 	per_lcore_trace_mem;
 	rte_trace_global_is_enabled;
 	rte_trace_global_is_disabled;
Signature · 1 line
2.25.1
#207 lore raw

Re: [dpdk-dev] [PATCH v5 13/33] eal/trace: implement registration payload

Quoted 9 lines · On Mon, Apr 13, 2020 at 5:02 PM <[email protected]> wrote:
lib/librte_eal/common/eal_common_trace.c +1 -0
index 8181c0f02..906e2d706 100644
@@ -403,6 +403,25 @@ trace_mem_per_thread_free(void)
        rte_spinlock_unlock(&trace->lock);
 }
 
+void

lib/librte_eal/common/eal_common_trace.c trace_mem_per_thread_free(void) · line 416

Quoted 10 lines
lib/librte_eal/common/eal_common_trace.c +10 -0
+__rte_trace_emit_ctf_field(size_t sz, const char *in, const char *datatype)
+{
+       char *field = RTE_PER_LCORE(ctf_field);
+       int count = RTE_PER_LCORE(ctf_count);
+       int rc;
+
+       RTE_PER_LCORE(trace_point_sz) += sz;
+       rc = snprintf(RTE_PTR_ADD(field, count),
+                     RTE_MAX(0, TRACE_CTF_FIELD_SIZE - 1 - count),
+                     "%s %s;", datatype, in);

rc <= 0 does not check if a truncation happened.

Quoted 11 lines
lib/librte_eal/common/eal_common_trace.c +8 -0
+       if (rc <= 0) {
+               RTE_PER_LCORE(trace_point_sz) = 0;
+               trace_crit("CTF field is too long");
+               return;
+       }
+       RTE_PER_LCORE(ctf_count) += rc;
+}
+
 int
 __rte_trace_point_register(rte_trace_t *handle, const char *name,
                           void (*register_fn)(void))
Signature · 1 line
David Marchand
#208 lore raw

PATCH v5 14/33 eal/trace: implement provider payload

In reply to [email protected]

From: Jerin Jacob <[email protected]>

The trace function payloads such as rte_trace_ctf_* have dual functions. The first to emit the payload for the registration function and the second one to act as trace mem emitters aka provider payload.

When it used as provider payload, those function copy the trace field to trace memory based on the tracing mode.

Added payload definitions under ALLOW_EXPERIMENTAL define to allow the out_of_tree application to compile with out ALLOW_EXPERIMENTAL flag.

---
 lib/librte_eal/include/rte_trace_provider.h | 116 ++++++++++++++++++++
 1 file changed, 116 insertions(+)
lib/librte_eal/include/rte_trace_provider.h +116 -0
index 57906cda6..47767245e 100644
@@ -9,6 +9,10 @@
 #ifndef _RTE_TRACE_PROVIDER_H_
 #define _RTE_TRACE_PROVIDER_H_
 
+#ifdef ALLOW_EXPERIMENTAL_API
+
+#include <rte_branch_prediction.h>
+#include <rte_cycles.h>
 #include <rte_per_lcore.h>
 #include <rte_string_fns.h>
 #include <rte_uuid.h>
@@ -38,4 +42,116 @@ struct __rte_trace_header {
 
 RTE_DECLARE_PER_LCORE(void *, trace_mem);
 
+static __rte_always_inline void*
+__rte_trace_mem_get(uint64_t in)
+{
+	struct __rte_trace_header *trace = RTE_PER_LCORE(trace_mem);
+	const uint16_t sz = in & __RTE_TRACE_FIELD_SIZE_MASK;
+
+	/* Trace memory is not initialized for this thread */
+	if (unlikely(trace == NULL)) {
+		__rte_trace_mem_per_thread_alloc();
+		trace = RTE_PER_LCORE(trace_mem);
+		if (unlikely(trace == NULL))
+			return NULL;
+	}
+	/* Check the wrap around case */
+	uint32_t offset = trace->offset;
+	if (unlikely((offset + sz) >= trace->len)) {
+		/* Disable the trace event if it in DISCARD mode */
+		if (unlikely(in & __RTE_TRACE_FIELD_ENABLE_DISCARD))
+			return NULL;
+
+		offset = 0;
+	}
+	/* Align to event header size */
+	offset = RTE_ALIGN_CEIL(offset, __RTE_TRACE_EVENT_HEADER_SZ);
+	void *mem = RTE_PTR_ADD(&trace->mem[0], offset);
+	offset += sz;
+	trace->offset = offset;
+
+	return mem;
+}
+
+static __rte_always_inline void*
+__rte_trace_emit_ev_header(void *mem, uint64_t in)
+{
+	uint64_t val;
+
+	/* Event header [63:0] = id [63:48] | timestamp [47:0] */
+	val = rte_get_tsc_cycles() &
+		~(0xffffULL << __RTE_TRACE_EVENT_HEADER_ID_SHIFT);
+	val |= ((in & __RTE_TRACE_FIELD_ID_MASK) <<
+	      (__RTE_TRACE_EVENT_HEADER_ID_SHIFT - __RTE_TRACE_FIELD_ID_SHIFT));
+
+	*(uint64_t *)mem = val;
+	return RTE_PTR_ADD(mem, __RTE_TRACE_EVENT_HEADER_SZ);
+}
+
+#define __rte_trace_emit_header_generic(t)\
+void *mem;\
+do {\
+	const uint64_t val = __atomic_load_n(t, __ATOMIC_ACQUIRE);\
+	if (likely(!(val & __RTE_TRACE_FIELD_ENABLE_MASK)))\
+		return;\
+	mem = __rte_trace_mem_get(val);\
+	if (unlikely(mem == NULL)) \
+		return;\
+	mem = __rte_trace_emit_ev_header(mem, val);\
+} while (0)
+
+#define __rte_trace_emit_header_fp(t)\
+	if (rte_trace_fp_is_enabled() == false)\
+		return;\
+	__rte_trace_emit_header_generic(t);
+
+#define __rte_trace_emit_datatype(in)\
+do {\
+	memcpy(mem, &(in), sizeof(in));\
+	mem = RTE_PTR_ADD(mem, sizeof(in));\
+} while (0)
+
+#define rte_trace_ctf_u64(in) __rte_trace_emit_datatype(in)
+#define rte_trace_ctf_i64(in) __rte_trace_emit_datatype(in)
+#define rte_trace_ctf_u32(in) __rte_trace_emit_datatype(in)
+#define rte_trace_ctf_i32(in) __rte_trace_emit_datatype(in)
+#define rte_trace_ctf_u16(in) __rte_trace_emit_datatype(in)
+#define rte_trace_ctf_i16(in) __rte_trace_emit_datatype(in)
+#define rte_trace_ctf_u8(in) __rte_trace_emit_datatype(in)
+#define rte_trace_ctf_i8(in) __rte_trace_emit_datatype(in)
+#define rte_trace_ctf_int(in) __rte_trace_emit_datatype(in)
+#define rte_trace_ctf_long(in) __rte_trace_emit_datatype(in)
+#define rte_trace_ctf_float(in) __rte_trace_emit_datatype(in)
+#define rte_trace_ctf_ptr(in) __rte_trace_emit_datatype(in)
+#define rte_trace_ctf_double(in) __rte_trace_emit_datatype(in)
+
+#define rte_trace_ctf_string(in)\
+do {\
+	if (unlikely(in == NULL))\
+		return;\
+	rte_strscpy(mem, in, __RTE_TRACE_EMIT_STRING_LEN_MAX);\
+	mem = RTE_PTR_ADD(mem, __RTE_TRACE_EMIT_STRING_LEN_MAX);\
+} while (0)
+
+#else
+
+#define __rte_trace_emit_header_generic(t) RTE_SET_USED(t)
+#define __rte_trace_emit_header_fp(t) RTE_SET_USED(t)
+#define rte_trace_ctf_u64(in) RTE_SET_USED(in)
+#define rte_trace_ctf_i64(in) RTE_SET_USED(in)
+#define rte_trace_ctf_u32(in) RTE_SET_USED(in)
+#define rte_trace_ctf_i32(in) RTE_SET_USED(in)
+#define rte_trace_ctf_u16(in) RTE_SET_USED(in)
+#define rte_trace_ctf_i16(in) RTE_SET_USED(in)
+#define rte_trace_ctf_u8(in) RTE_SET_USED(in)
+#define rte_trace_ctf_i8(in) RTE_SET_USED(in)
+#define rte_trace_ctf_int(in) RTE_SET_USED(in)
+#define rte_trace_ctf_long(in) RTE_SET_USED(in)
+#define rte_trace_ctf_float(in) RTE_SET_USED(in)
+#define rte_trace_ctf_ptr(in) RTE_SET_USED(in)
+#define rte_trace_ctf_double(in) RTE_SET_USED(in)
+#define rte_trace_ctf_string(in) RTE_SET_USED(in)
+
+#endif
+
 #endif /* _RTE_TRACE_PROVIDER_H_ */
Signature · 1 line
2.25.1
#209 lore raw

PATCH v5 15/33 eal/trace: hook internal trace APIs to Linux

In reply to [email protected]

From: Jerin Jacob <[email protected]>

Connect the internal trace interface API to Linux EAL.

---
 lib/librte_eal/common/eal_common_thread.c | 3 ++-
 lib/librte_eal/linux/eal.c                | 9 +++++++++
 lib/librte_eal/linux/eal_thread.c         | 3 +++
 3 files changed, 14 insertions(+), 1 deletion(-)
lib/librte_eal/common/eal_common_thread.c +2 -1
index 99fe1aa4e..bc9732d88 100644
@@ -15,6 +15,7 @@
 #include <rte_lcore.h>
 #include <rte_memory.h>
 #include <rte_log.h>
+#include <rte_trace.h>
 
 #include "eal_internal_cfg.h"
 #include "eal_private.h"
@@ -165,7 +166,7 @@ static void *rte_thread_init(void *arg)
 		pthread_barrier_destroy(&params->configured);
 		free(params);
 	}
-
+	__rte_trace_mem_per_thread_alloc();
 	return start_routine(routine_arg);
 }
 
lib/librte_eal/linux/eal.c +9 -0
index 9530ee55f..ee777b0cd 100644
@@ -58,6 +58,7 @@
 #include "eal_filesystem.h"
 #include "eal_hugepages.h"
 #include "eal_memcfg.h"
+#include "eal_trace.h"
 #include "eal_options.h"
 #include "eal_vfio.h"
 #include "hotplug_mp.h"
@@ -1012,6 +1013,12 @@ rte_eal_init(int argc, char **argv)
 		return -1;
 	}
 
+	if (eal_trace_init() < 0) {
+		rte_eal_init_alert("Cannot init trace");
+		rte_errno = EFAULT;
+		return -1;
+	}
+
 	if (eal_option_device_parse()) {
 		rte_errno = ENODEV;
 		rte_atomic32_clear(&run_once);
@@ -1327,6 +1334,8 @@ rte_eal_cleanup(void)
 		rte_memseg_walk(mark_freeable, NULL);
 	rte_service_finalize();
 	rte_mp_channel_cleanup();
+	rte_trace_save();
+	eal_trace_fini();
 	eal_cleanup_config(&internal_config);
 	return 0;
 }
lib/librte_eal/linux/eal_thread.c +3 -0
index 3f82b286c..45f4dce44 100644
@@ -20,6 +20,7 @@
 #include <rte_per_lcore.h>
 #include <rte_eal.h>
 #include <rte_lcore.h>
+#include <rte_trace.h>
 
 #include "eal_private.h"
 #include "eal_thread.h"
@@ -124,6 +125,8 @@ eal_thread_loop(__attribute__((unused)) void *arg)
 	RTE_LOG(DEBUG, EAL, "lcore %u is ready (tid=%zx;cpuset=[%s%s])\n",
 		lcore_id, (uintptr_t)thread_id, cpuset, ret == 0 ? "" : "...");
 
+	__rte_trace_mem_per_thread_alloc();
+
 	/* read on our pipe to get commands */
 	while (1) {
 		void *fct_arg;
Signature · 1 line
2.25.1
#210 lore raw

PATCH v5 16/33 eal/trace: hook internal trace APIs to FreeBSD

In reply to [email protected]

From: Jerin Jacob <[email protected]>

Connect the internal trace interface API to FreeBSD EAL.

---
 lib/librte_eal/freebsd/eal.c        | 10 ++++++++++
 lib/librte_eal/freebsd/eal_thread.c |  3 +++
 2 files changed, 13 insertions(+)
lib/librte_eal/freebsd/eal.c +10 -0
index 6ae37e7e6..c453e11f2 100644
@@ -52,6 +52,7 @@
 #include "eal_hugepages.h"
 #include "eal_options.h"
 #include "eal_memcfg.h"
+#include "eal_trace.h"
 
 #define MEMSIZE_IF_NO_HUGE_PAGE (64ULL * 1024ULL * 1024ULL)
 
@@ -751,6 +752,13 @@ rte_eal_init(int argc, char **argv)
 		return -1;
 	}
 
+	if (eal_trace_init() < 0) {
+		rte_eal_init_alert("Cannot init trace");
+		rte_errno = EFAULT;
+		rte_atomic32_clear(&run_once);
+		return -1;
+	}
+
 	if (eal_option_device_parse()) {
 		rte_errno = ENODEV;
 		rte_atomic32_clear(&run_once);
@@ -966,6 +974,8 @@ rte_eal_cleanup(void)
 {
 	rte_service_finalize();
 	rte_mp_channel_cleanup();
+	rte_trace_save();
+	eal_trace_fini();
 	eal_cleanup_config(&internal_config);
 	return 0;
 }
lib/librte_eal/freebsd/eal_thread.c +3 -0
index ae7b57672..aaccb4926 100644
@@ -20,6 +20,7 @@
 #include <rte_per_lcore.h>
 #include <rte_eal.h>
 #include <rte_lcore.h>
+#include <rte_trace.h>
 
 #include "eal_private.h"
 #include "eal_thread.h"
@@ -124,6 +125,8 @@ eal_thread_loop(__attribute__((unused)) void *arg)
 	RTE_LOG(DEBUG, EAL, "lcore %u is ready (tid=%p;cpuset=[%s%s])\n",
 		lcore_id, thread_id, cpuset, ret == 0 ? "" : "...");
 
+	__rte_trace_mem_per_thread_alloc();
+
 	/* read on our pipe to get commands */
 	while (1) {
 		void *fct_arg;
Signature · 1 line
2.25.1
#211 lore raw

PATCH v5 17/33 eal/trace: add generic tracepoints

In reply to [email protected]

From: Jerin Jacob <[email protected]>

This patch creates the following generic tracepoint for generic tracing when there is no dedicated tracepoint is available.

rte_trace_lib_eal_generic_void()
rte_trace_lib_eal_generic_u64()
rte_trace_lib_eal_generic_u32()
rte_trace_lib_eal_generic_u16()
rte_trace_lib_eal_generic_u8()
rte_trace_lib_eal_generic_i64()
rte_trace_lib_eal_generic_i32()
rte_trace_lib_eal_generic_i16()
rte_trace_lib_eal_generic_i8()
rte_trace_lib_eal_generic_int()
rte_trace_lib_eal_generic_long()
rte_trace_lib_eal_generic_float()
rte_trace_lib_eal_generic_double()
rte_trace_lib_eal_generic_ptr()
rte_trace_lib_eal_generic_str()

For example, if an application wishes to emit an int datatype, it can call rte_trace_lib_eal_generic_int(val) to emit the trace.

---
 .../common/eal_common_trace_points.c          |  60 +++++++++
 lib/librte_eal/common/meson.build             |   1 +
 lib/librte_eal/freebsd/Makefile               |   1 +
 lib/librte_eal/include/meson.build            |   1 +
 lib/librte_eal/include/rte_trace_eal.h        | 122 ++++++++++++++++++
 lib/librte_eal/linux/Makefile                 |   1 +
 lib/librte_eal/rte_eal_version.map            |  17 +++
 7 files changed, 203 insertions(+)
 create mode 100644 lib/librte_eal/common/eal_common_trace_points.c
 create mode 100644 lib/librte_eal/include/rte_trace_eal.h
lib/librte_eal/common/eal_common_trace_points.c new file +60 -0
new file mode 100644
index 000000000..cd70fc1e3
@@ -0,0 +1,60 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(C) 2020 Marvell International Ltd.
+ */
+
+#define RTE_TRACE_POINT_REGISTER_SELECT /* Select trace point register macros */
+
+#include <rte_trace_eal.h>
+
+RTE_TRACE_POINT_DEFINE(rte_trace_lib_eal_generic_void);
+RTE_TRACE_POINT_DEFINE(rte_trace_lib_eal_generic_u64);
+RTE_TRACE_POINT_DEFINE(rte_trace_lib_eal_generic_u32);
+RTE_TRACE_POINT_DEFINE(rte_trace_lib_eal_generic_u16);
+RTE_TRACE_POINT_DEFINE(rte_trace_lib_eal_generic_u8);
+RTE_TRACE_POINT_DEFINE(rte_trace_lib_eal_generic_i64);
+RTE_TRACE_POINT_DEFINE(rte_trace_lib_eal_generic_i32);
+RTE_TRACE_POINT_DEFINE(rte_trace_lib_eal_generic_i16);
+RTE_TRACE_POINT_DEFINE(rte_trace_lib_eal_generic_i8);
+RTE_TRACE_POINT_DEFINE(rte_trace_lib_eal_generic_int);
+RTE_TRACE_POINT_DEFINE(rte_trace_lib_eal_generic_long);
+RTE_TRACE_POINT_DEFINE(rte_trace_lib_eal_generic_float);
+RTE_TRACE_POINT_DEFINE(rte_trace_lib_eal_generic_double);
+RTE_TRACE_POINT_DEFINE(rte_trace_lib_eal_generic_ptr);
+RTE_TRACE_POINT_DEFINE(rte_trace_lib_eal_generic_str);
+RTE_TRACE_POINT_DEFINE(rte_trace_lib_eal_generic_func);
+
+RTE_INIT(eal_trace_init)
+{
+	RTE_TRACE_POINT_REGISTER(rte_trace_lib_eal_generic_void,
+				 lib.eal.generic.void);
+	RTE_TRACE_POINT_REGISTER(rte_trace_lib_eal_generic_u64,
+				 lib.eal.generic.u64);
+	RTE_TRACE_POINT_REGISTER(rte_trace_lib_eal_generic_u32,
+				 lib.eal.generic.u32);
+	RTE_TRACE_POINT_REGISTER(rte_trace_lib_eal_generic_u16,
+				 lib.eal.generic.u16);
+	RTE_TRACE_POINT_REGISTER(rte_trace_lib_eal_generic_u8,
+				 lib.eal.generic.u8);
+	RTE_TRACE_POINT_REGISTER(rte_trace_lib_eal_generic_i64,
+				 lib.eal.generic.i64);
+	RTE_TRACE_POINT_REGISTER(rte_trace_lib_eal_generic_i32,
+				 lib.eal.generic.i32);
+	RTE_TRACE_POINT_REGISTER(rte_trace_lib_eal_generic_i16,
+				 lib.eal.generic.i16);
+	RTE_TRACE_POINT_REGISTER(rte_trace_lib_eal_generic_i8,
+				 lib.eal.generic.i8);
+	RTE_TRACE_POINT_REGISTER(rte_trace_lib_eal_generic_int,
+				 lib.eal.generic.int);
+	RTE_TRACE_POINT_REGISTER(rte_trace_lib_eal_generic_long,
+				 lib.eal.generic.long);
+	RTE_TRACE_POINT_REGISTER(rte_trace_lib_eal_generic_float,
+				 lib.eal.generic.float);
+	RTE_TRACE_POINT_REGISTER(rte_trace_lib_eal_generic_double,
+				 lib.eal.generic.double);
+	RTE_TRACE_POINT_REGISTER(rte_trace_lib_eal_generic_ptr,
+				 lib.eal.generic.ptr);
+	RTE_TRACE_POINT_REGISTER(rte_trace_lib_eal_generic_str,
+				 lib.eal.generic.string);
+	RTE_TRACE_POINT_REGISTER(rte_trace_lib_eal_generic_func,
+				 lib.eal.generic.func);
+}
lib/librte_eal/common/meson.build +1 -0
index d2ac44313..155da29b4 100644
@@ -44,6 +44,7 @@ sources += files(
 	'eal_common_timer.c',
 	'eal_common_trace.c',
 	'eal_common_trace_ctf.c',
+	'eal_common_trace_points.c',
 	'eal_common_trace_utils.c',
 	'eal_common_uuid.c',
 	'hotplug_mp.c',
lib/librte_eal/freebsd/Makefile +1 -0
index 539ad44a7..a8400f20a 100644
@@ -61,6 +61,7 @@ SRCS-$(CONFIG_RTE_EXEC_ENV_FREEBSD) += eal_common_fbarray.c
 SRCS-$(CONFIG_RTE_EXEC_ENV_FREEBSD) += eal_common_uuid.c
 SRCS-$(CONFIG_RTE_EXEC_ENV_FREEBSD) += eal_common_trace.c
 SRCS-$(CONFIG_RTE_EXEC_ENV_FREEBSD) += eal_common_trace_ctf.c
+SRCS-$(CONFIG_RTE_EXEC_ENV_FREEBSD) += eal_common_trace_points.c
 SRCS-$(CONFIG_RTE_EXEC_ENV_FREEBSD) += eal_common_trace_utils.c
 SRCS-$(CONFIG_RTE_EXEC_ENV_FREEBSD) += rte_malloc.c
 SRCS-$(CONFIG_RTE_EXEC_ENV_FREEBSD) += hotplug_mp.c
lib/librte_eal/include/meson.build +1 -0
index 037a4ae63..57b7f25c8 100644
@@ -41,6 +41,7 @@ headers += files(
 	'rte_tailq.h',
 	'rte_time.h',
 	'rte_trace.h',
+	'rte_trace_eal.h',
 	'rte_trace_provider.h',
 	'rte_trace_register.h',
 	'rte_uuid.h',
lib/librte_eal/include/rte_trace_eal.h new file +122 -0

122 lines not on this page · raw message

lib/librte_eal/linux/Makefile +1 -0
index f00588d6e..a77eb1757 100644
@@ -68,6 +68,7 @@ SRCS-$(CONFIG_RTE_EXEC_ENV_LINUX) += eal_common_fbarray.c
 SRCS-$(CONFIG_RTE_EXEC_ENV_LINUX) += eal_common_uuid.c
 SRCS-$(CONFIG_RTE_EXEC_ENV_LINUX) += eal_common_trace.c
 SRCS-$(CONFIG_RTE_EXEC_ENV_LINUX) += eal_common_trace_ctf.c
+SRCS-$(CONFIG_RTE_EXEC_ENV_LINUX) += eal_common_trace_points.c
 SRCS-$(CONFIG_RTE_EXEC_ENV_LINUX) += eal_common_trace_utils.c
 SRCS-$(CONFIG_RTE_EXEC_ENV_LINUX) += rte_malloc.c
 SRCS-$(CONFIG_RTE_EXEC_ENV_LINUX) += hotplug_mp.c
lib/librte_eal/rte_eal_version.map +17 -0
index 155dd4e25..48b02bb6a 100644
@@ -359,4 +359,21 @@ EXPERIMENTAL {
 	rte_trace_save;
 	rte_trace_metadata_dump;
 	rte_trace_dump;
+
+	__rte_trace_lib_eal_generic_void;
+	__rte_trace_lib_eal_generic_u64;
+	__rte_trace_lib_eal_generic_u32;
+	__rte_trace_lib_eal_generic_u16;
+	__rte_trace_lib_eal_generic_u8;
+	__rte_trace_lib_eal_generic_i64;
+	__rte_trace_lib_eal_generic_i32;
+	__rte_trace_lib_eal_generic_i16;
+	__rte_trace_lib_eal_generic_i8;
+	__rte_trace_lib_eal_generic_int;
+	__rte_trace_lib_eal_generic_long;
+	__rte_trace_lib_eal_generic_float;
+	__rte_trace_lib_eal_generic_double;
+	__rte_trace_lib_eal_generic_ptr;
+	__rte_trace_lib_eal_generic_str;
+	__rte_trace_lib_eal_generic_func;
 };
Signature · 1 line
2.25.1
#212 lore raw

PATCH v5 18/33 eal/trace: add alarm tracepoints

In reply to [email protected]

From: Jerin Jacob <[email protected]>

Add following alarm related trace points.

rte_trace_lib_eal_alarm_set()
rte_trace_lib_eal_alarm_cancel()

---
 .../common/eal_common_trace_points.c           |  9 +++++++++
 lib/librte_eal/freebsd/eal_alarm.c             |  3 +++
 lib/librte_eal/include/rte_trace_eal.h         | 18 ++++++++++++++++++
 lib/librte_eal/linux/eal_alarm.c               |  4 ++++
 lib/librte_eal/rte_eal_version.map             |  2 ++
 5 files changed, 36 insertions(+)
lib/librte_eal/common/eal_common_trace_points.c +9 -0
index cd70fc1e3..50c255034 100644
@@ -23,6 +23,9 @@ RTE_TRACE_POINT_DEFINE(rte_trace_lib_eal_generic_ptr);
 RTE_TRACE_POINT_DEFINE(rte_trace_lib_eal_generic_str);
 RTE_TRACE_POINT_DEFINE(rte_trace_lib_eal_generic_func);
 
+RTE_TRACE_POINT_DEFINE(rte_trace_lib_eal_alarm_set);
+RTE_TRACE_POINT_DEFINE(rte_trace_lib_eal_alarm_cancel);
+
 RTE_INIT(eal_trace_init)
 {
 	RTE_TRACE_POINT_REGISTER(rte_trace_lib_eal_generic_void,
@@ -57,4 +60,10 @@ RTE_INIT(eal_trace_init)
 				 lib.eal.generic.string);
 	RTE_TRACE_POINT_REGISTER(rte_trace_lib_eal_generic_func,
 				 lib.eal.generic.func);
+
+	RTE_TRACE_POINT_REGISTER(rte_trace_lib_eal_alarm_set,
+				 lib.eal.alarm.set);
+	RTE_TRACE_POINT_REGISTER(rte_trace_lib_eal_alarm_cancel,
+				 lib.eal.alarm.cancel);
+
 }
lib/librte_eal/freebsd/eal_alarm.c +3 -0
index 51ea4b8c0..5f03ab4c4 100644
@@ -17,6 +17,7 @@
 #include <rte_errno.h>
 #include <rte_interrupts.h>
 #include <rte_spinlock.h>
+#include <rte_trace_eal.h>
 
 #include "eal_private.h"
 #include "eal_alarm_private.h"
@@ -223,6 +224,7 @@ rte_eal_alarm_set(uint64_t us, rte_eal_alarm_callback cb_fn, void *cb_arg)
 
 	rte_spinlock_unlock(&alarm_list_lk);
 
+	rte_trace_lib_eal_alarm_set(us, cb_fn, cb_arg, ret);
 	return ret;
 }
 
@@ -310,5 +312,6 @@ rte_eal_alarm_cancel(rte_eal_alarm_callback cb_fn, void *cb_arg)
 
 	rte_spinlock_unlock(&alarm_list_lk);
 
+	rte_trace_lib_eal_alarm_cancel(cb_fn, cb_arg, count);
 	return count;
 }
lib/librte_eal/include/rte_trace_eal.h +18 -0
index 269ef7502..df1b3854b 100644
@@ -15,6 +15,7 @@
 extern "C" {
 #endif
 
+#include <rte_alarm.h>
 #include <rte_trace.h>
 
 /* Generic */
@@ -115,6 +116,23 @@ RTE_TRACE_POINT(
 
 #define RTE_TRACE_LIB_EAL_GENERIC_FUNC rte_trace_lib_eal_generic_func(__func__)
 
+/* Alarm */
+RTE_TRACE_POINT(
+	rte_trace_lib_eal_alarm_set,
+	RTE_TRACE_POINT_ARGS(uint64_t us, rte_eal_alarm_callback cb_fn,
+			     void *cb_arg, int rc),
+	rte_trace_ctf_u64(us); rte_trace_ctf_ptr(cb_fn);
+	rte_trace_ctf_ptr(cb_arg); rte_trace_ctf_int(rc);
+)
+
+RTE_TRACE_POINT(
+	rte_trace_lib_eal_alarm_cancel,
+	RTE_TRACE_POINT_ARGS(rte_eal_alarm_callback cb_fn, void *cb_arg,
+			     int count),
+	rte_trace_ctf_ptr(cb_fn); rte_trace_ctf_ptr(cb_arg);
+	rte_trace_ctf_int(count);
+)
+
 #ifdef __cplusplus
 }
 #endif
lib/librte_eal/linux/eal_alarm.c +4 -0
index 0924c9205..9fef3e6c8 100644
@@ -20,6 +20,8 @@
 #include <rte_lcore.h>
 #include <rte_errno.h>
 #include <rte_spinlock.h>
+#include <rte_trace_eal.h>
+
 #include <eal_private.h>
 
 #ifndef	TFD_NONBLOCK
@@ -172,6 +174,7 @@ rte_eal_alarm_set(uint64_t us, rte_eal_alarm_callback cb_fn, void *cb_arg)
 	}
 	rte_spinlock_unlock(&alarm_list_lk);
 
+	rte_trace_lib_eal_alarm_set(us, cb_fn, cb_arg, ret);
 	return ret;
 }
 
@@ -240,5 +243,6 @@ rte_eal_alarm_cancel(rte_eal_alarm_callback cb_fn, void *cb_arg)
 	else if (err)
 		rte_errno = err;
 
+	rte_trace_lib_eal_alarm_cancel(cb_fn, cb_arg, count);
 	return count;
 }
lib/librte_eal/rte_eal_version.map +2 -0
index 48b02bb6a..ad2e4ab7c 100644
@@ -376,4 +376,6 @@ EXPERIMENTAL {
 	__rte_trace_lib_eal_generic_ptr;
 	__rte_trace_lib_eal_generic_str;
 	__rte_trace_lib_eal_generic_func;
+	__rte_trace_lib_eal_alarm_set;
+	__rte_trace_lib_eal_alarm_cancel;
 };
Signature · 1 line
2.25.1
#213 lore raw

PATCH v5 19/33 eal/trace: add memory tracepoints

In reply to [email protected]

From: Jerin Jacob <[email protected]>

Add the following memory-related tracepoints.

rte_trace_lib_eal_mem_zmalloc;
rte_trace_lib_eal_mem_malloc;
rte_trace_lib_eal_mem_realloc;
rte_trace_lib_eal_mem_free;

rte_malloc() and rte_free() has been used in the trace implementation, in order to avoid tracing implementation specific events, added an internal no trace version rte_malloc() and rte_free().

---
 lib/librte_eal/common/eal_common_trace.c      |  4 +-
 .../common/eal_common_trace_points.c          | 14 +++++
 lib/librte_eal/common/eal_private.h           |  5 ++
 lib/librte_eal/common/rte_malloc.c            | 60 ++++++++++++++++---
 lib/librte_eal/include/rte_trace_eal.h        | 33 ++++++++++
 lib/librte_eal/rte_eal_version.map            |  4 ++
 6 files changed, 109 insertions(+), 11 deletions(-)
lib/librte_eal/common/eal_common_trace.c +2 -2
index 906e2d706..903a62a98 100644
@@ -344,7 +344,7 @@ __rte_trace_mem_per_thread_alloc(void)
 	}
 
 	/* First attempt from huge page */
-	header = rte_malloc(NULL, trace_mem_sz(trace->buff_len), 8);
+	header = eal_malloc_no_trace(NULL, trace_mem_sz(trace->buff_len), 8);
 	if (header) {
 		trace->lcore_meta[count].area = TRACE_AREA_HUGEPAGE;
 		goto found;
@@ -396,7 +396,7 @@ trace_mem_per_thread_free(void)
 	for (count = 0; count < trace->nb_trace_mem_list; count++) {
 		mem = trace->lcore_meta[count].mem;
 		if (trace->lcore_meta[count].area == TRACE_AREA_HUGEPAGE)
-			rte_free(mem);
+			eal_free_no_trace(mem);
 		else if (trace->lcore_meta[count].area == TRACE_AREA_HEAP)
 			free(mem);
 	}
lib/librte_eal/common/eal_common_trace_points.c +14 -0
index 50c255034..5a8444f07 100644
@@ -26,6 +26,11 @@ RTE_TRACE_POINT_DEFINE(rte_trace_lib_eal_generic_func);
 RTE_TRACE_POINT_DEFINE(rte_trace_lib_eal_alarm_set);
 RTE_TRACE_POINT_DEFINE(rte_trace_lib_eal_alarm_cancel);
 
+RTE_TRACE_POINT_DEFINE(rte_trace_lib_eal_mem_zmalloc);
+RTE_TRACE_POINT_DEFINE(rte_trace_lib_eal_mem_malloc);
+RTE_TRACE_POINT_DEFINE(rte_trace_lib_eal_mem_realloc);
+RTE_TRACE_POINT_DEFINE(rte_trace_lib_eal_mem_free);
+
 RTE_INIT(eal_trace_init)
 {
 	RTE_TRACE_POINT_REGISTER(rte_trace_lib_eal_generic_void,
@@ -66,4 +71,13 @@ RTE_INIT(eal_trace_init)
 	RTE_TRACE_POINT_REGISTER(rte_trace_lib_eal_alarm_cancel,
 				 lib.eal.alarm.cancel);
 
+	RTE_TRACE_POINT_REGISTER(rte_trace_lib_eal_mem_zmalloc,
+				 lib.eal.mem.zmalloc);
+	RTE_TRACE_POINT_REGISTER(rte_trace_lib_eal_mem_malloc,
+				 lib.eal.mem.malloc);
+	RTE_TRACE_POINT_REGISTER(rte_trace_lib_eal_mem_realloc,
+				 lib.eal.mem.realloc);
+	RTE_TRACE_POINT_REGISTER(rte_trace_lib_eal_mem_free,
+				 lib.eal.mem.free);
+
 }
lib/librte_eal/common/eal_private.h +5 -0
index ddcfbe2e4..79cf1f7be 100644
@@ -443,4 +443,9 @@ rte_option_usage(void);
 uint64_t
 eal_get_baseaddr(void);
 
+void *
+eal_malloc_no_trace(const char *type, size_t size, unsigned int align);
+
+void eal_free_no_trace(void *addr);
+
 #endif /* _EAL_PRIVATE_H_ */
lib/librte_eal/common/rte_malloc.c +51 -9

105 lines not on this page · raw message

lib/librte_eal/include/rte_trace_eal.h +33 -0
index df1b3854b..597cf9ca3 100644
@@ -133,6 +133,39 @@ RTE_TRACE_POINT(
 	rte_trace_ctf_int(count);
 )
 
+/* Memory */
+RTE_TRACE_POINT(
+	rte_trace_lib_eal_mem_zmalloc,
+	RTE_TRACE_POINT_ARGS(const char *type, size_t size, unsigned int align,
+			     int socket, void *ptr),
+	rte_trace_ctf_string(type); rte_trace_ctf_long(size);
+	rte_trace_ctf_u32(align); rte_trace_ctf_int(socket);
+	rte_trace_ctf_ptr(ptr);
+)
+
+RTE_TRACE_POINT(
+	rte_trace_lib_eal_mem_malloc,
+	RTE_TRACE_POINT_ARGS(const char *type, size_t size, unsigned int align,
+			     int socket, void *ptr),
+	rte_trace_ctf_string(type); rte_trace_ctf_long(size);
+	rte_trace_ctf_u32(align); rte_trace_ctf_int(socket);
+	rte_trace_ctf_ptr(ptr);
+)
+
+RTE_TRACE_POINT(
+	rte_trace_lib_eal_mem_realloc,
+	RTE_TRACE_POINT_ARGS(size_t size, unsigned int align,
+			     int socket, void *ptr),
+	rte_trace_ctf_long(size); rte_trace_ctf_u32(align);
+	rte_trace_ctf_int(socket); rte_trace_ctf_ptr(ptr);
+)
+
+RTE_TRACE_POINT(
+	rte_trace_lib_eal_mem_free,
+	RTE_TRACE_POINT_ARGS(void *ptr),
+	rte_trace_ctf_ptr(ptr);
+)
+
 #ifdef __cplusplus
 }
 #endif
lib/librte_eal/rte_eal_version.map +4 -0
index ad2e4ab7c..d1a7541f5 100644
@@ -378,4 +378,8 @@ EXPERIMENTAL {
 	__rte_trace_lib_eal_generic_func;
 	__rte_trace_lib_eal_alarm_set;
 	__rte_trace_lib_eal_alarm_cancel;
+	__rte_trace_lib_eal_mem_zmalloc;
+	__rte_trace_lib_eal_mem_malloc;
+	__rte_trace_lib_eal_mem_realloc;
+	__rte_trace_lib_eal_mem_free;
 };
Signature · 1 line
2.25.1
#214 lore raw

PATCH v5 20/33 eal/trace: add memzone tracepoints

In reply to [email protected]

From: Jerin Jacob <[email protected]>

Add the following memzone related tracepoints.

rte_trace_lib_eal_memzone_reserve
rte_trace_lib_eal_memzone_lookup
rte_trace_lib_eal_memzone_free

---
 lib/librte_eal/common/eal_common_memzone.c    |  9 +++++++
 .../common/eal_common_trace_points.c          | 10 +++++++
 lib/librte_eal/include/rte_trace_eal.h        | 26 +++++++++++++++++++
 lib/librte_eal/rte_eal_version.map            |  3 +++
 4 files changed, 48 insertions(+)
lib/librte_eal/common/eal_common_memzone.c +9 -0
index 86f61369b..0f6556714 100644
@@ -19,6 +19,7 @@
 #include <rte_errno.h>
 #include <rte_string_fns.h>
 #include <rte_common.h>
+#include <rte_trace_eal.h>
 
 #include "malloc_heap.h"
 #include "malloc_elem.h"
@@ -201,6 +202,9 @@ rte_memzone_reserve_thread_safe(const char *name, size_t len, int socket_id,
 	mz = memzone_reserve_aligned_thread_unsafe(
 		name, len, socket_id, flags, align, bound);
 
+	rte_trace_lib_eal_memzone_reserve(name, len, socket_id, flags, align,
+					  bound, mz);
+
 	rte_rwlock_write_unlock(&mcfg->mlock);
 
 	return mz;
@@ -246,6 +250,7 @@ rte_memzone_reserve(const char *name, size_t len, int socket_id,
 int
 rte_memzone_free(const struct rte_memzone *mz)
 {
+	char name[RTE_MEMZONE_NAMESIZE];
 	struct rte_mem_config *mcfg;
 	struct rte_fbarray *arr;
 	struct rte_memzone *found_mz;
@@ -256,6 +261,7 @@ rte_memzone_free(const struct rte_memzone *mz)
 	if (mz == NULL)
 		return -EINVAL;
 
+	rte_strlcpy(name, mz->name, RTE_MEMZONE_NAMESIZE);
 	mcfg = rte_eal_get_configuration()->mem_config;
 	arr = &mcfg->memzones;
 
@@ -280,6 +286,8 @@ rte_memzone_free(const struct rte_memzone *mz)
 	if (addr != NULL)
 		rte_free(addr);
 
+	rte_trace_lib_eal_memzone_free(name, addr, ret);
+
 	return ret;
 }
 
@@ -300,6 +308,7 @@ rte_memzone_lookup(const char *name)
 
 	rte_rwlock_read_unlock(&mcfg->mlock);
 
+	rte_trace_lib_eal_memzone_lookup(name, memzone);
 	return memzone;
 }
 
lib/librte_eal/common/eal_common_trace_points.c +10 -0
index 5a8444f07..a3c9bc01b 100644
@@ -31,6 +31,10 @@ RTE_TRACE_POINT_DEFINE(rte_trace_lib_eal_mem_malloc);
 RTE_TRACE_POINT_DEFINE(rte_trace_lib_eal_mem_realloc);
 RTE_TRACE_POINT_DEFINE(rte_trace_lib_eal_mem_free);
 
+RTE_TRACE_POINT_DEFINE(rte_trace_lib_eal_memzone_reserve);
+RTE_TRACE_POINT_DEFINE(rte_trace_lib_eal_memzone_lookup);
+RTE_TRACE_POINT_DEFINE(rte_trace_lib_eal_memzone_free);
+
 RTE_INIT(eal_trace_init)
 {
 	RTE_TRACE_POINT_REGISTER(rte_trace_lib_eal_generic_void,
@@ -80,4 +84,10 @@ RTE_INIT(eal_trace_init)
 	RTE_TRACE_POINT_REGISTER(rte_trace_lib_eal_mem_free,
 				 lib.eal.mem.free);
 
+	RTE_TRACE_POINT_REGISTER(rte_trace_lib_eal_memzone_reserve,
+				 lib.eal.memzone.reserve);
+	RTE_TRACE_POINT_REGISTER(rte_trace_lib_eal_memzone_lookup,
+				 lib.eal.memzone.lookup);
+	RTE_TRACE_POINT_REGISTER(rte_trace_lib_eal_memzone_free,
+				 lib.eal.memzone.free);
 }
lib/librte_eal/include/rte_trace_eal.h +26 -0
index 597cf9ca3..abbaea5e0 100644
@@ -166,6 +166,32 @@ RTE_TRACE_POINT(
 	rte_trace_ctf_ptr(ptr);
 )
 
+/* Memzone */
+RTE_TRACE_POINT(
+	rte_trace_lib_eal_memzone_reserve,
+	RTE_TRACE_POINT_ARGS(const char *name, size_t len, int socket_id,
+			     unsigned int flags, unsigned int align,
+			     unsigned int bound, const void *mz),
+	rte_trace_ctf_string(name); rte_trace_ctf_long(len);
+	rte_trace_ctf_int(socket_id); rte_trace_ctf_u32(flags);
+	rte_trace_ctf_u32(align); rte_trace_ctf_u32(bound);
+	rte_trace_ctf_ptr(mz);
+)
+
+RTE_TRACE_POINT(
+	rte_trace_lib_eal_memzone_lookup,
+	RTE_TRACE_POINT_ARGS(const char *name, const void *memzone),
+	rte_trace_ctf_string(name); rte_trace_ctf_ptr(memzone);
+)
+
+RTE_TRACE_POINT(
+	rte_trace_lib_eal_memzone_free,
+	RTE_TRACE_POINT_ARGS(const char *name, void *addr, int rc),
+	rte_trace_ctf_string(name); rte_trace_ctf_ptr(addr);
+	rte_trace_ctf_int(rc);
+)
+
+
 #ifdef __cplusplus
 }
 #endif
lib/librte_eal/rte_eal_version.map +3 -0
index d1a7541f5..c3b7172ba 100644
@@ -382,4 +382,7 @@ EXPERIMENTAL {
 	__rte_trace_lib_eal_mem_malloc;
 	__rte_trace_lib_eal_mem_realloc;
 	__rte_trace_lib_eal_mem_free;
+	__rte_trace_lib_eal_memzone_reserve;
+	__rte_trace_lib_eal_memzone_lookup;
+	__rte_trace_lib_eal_memzone_free;
 };
Signature · 1 line
2.25.1
#215 lore raw

PATCH v5 21/33 eal/trace: add thread tracepoints

In reply to [email protected]

From: Jerin Jacob <[email protected]>

Add the following thread related tracepoints.

rte_trace_lib_eal_thread_remote_launch;
rte_trace_lib_eal_thread_lcore_ready;

---
 lib/librte_eal/common/eal_common_trace_points.c |  8 ++++++++
 lib/librte_eal/freebsd/eal_interrupts.c         |  2 +-
 lib/librte_eal/freebsd/eal_thread.c             | 11 ++++++++---
 lib/librte_eal/include/rte_trace_eal.h          | 14 ++++++++++++++
 lib/librte_eal/linux/eal_thread.c               | 11 ++++++++---
 lib/librte_eal/rte_eal_version.map              |  2 ++
 6 files changed, 41 insertions(+), 7 deletions(-)
lib/librte_eal/common/eal_common_trace_points.c +8 -0
index a3c9bc01b..9cecd8206 100644
@@ -35,6 +35,9 @@ RTE_TRACE_POINT_DEFINE(rte_trace_lib_eal_memzone_reserve);
 RTE_TRACE_POINT_DEFINE(rte_trace_lib_eal_memzone_lookup);
 RTE_TRACE_POINT_DEFINE(rte_trace_lib_eal_memzone_free);
 
+RTE_TRACE_POINT_DEFINE(rte_trace_lib_eal_thread_remote_launch);
+RTE_TRACE_POINT_DEFINE(rte_trace_lib_eal_thread_lcore_ready);
+
 RTE_INIT(eal_trace_init)
 {
 	RTE_TRACE_POINT_REGISTER(rte_trace_lib_eal_generic_void,
@@ -90,4 +93,9 @@ RTE_INIT(eal_trace_init)
 				 lib.eal.memzone.lookup);
 	RTE_TRACE_POINT_REGISTER(rte_trace_lib_eal_memzone_free,
 				 lib.eal.memzone.free);
+
+	RTE_TRACE_POINT_REGISTER(rte_trace_lib_eal_thread_remote_launch,
+				 lib.eal.thread.remote.launch);
+	RTE_TRACE_POINT_REGISTER(rte_trace_lib_eal_thread_lcore_ready,
+				 lib.eal.thread.lcore.ready);
 }
lib/librte_eal/freebsd/eal_interrupts.c +1 -1
index 00991f26a..7def3189b 100644
@@ -85,7 +85,7 @@ rte_intr_callback_register(const struct rte_intr_handle *intr_handle,
 {
 	struct rte_intr_callback *callback;
 	struct rte_intr_source *src;
-	int ret, add_event = 0;
+	int ret = 0, add_event = 0;
 
 	/* first do parameter checking */
 	if (intr_handle == NULL || intr_handle->fd < 0 || cb == NULL) {
lib/librte_eal/freebsd/eal_thread.c +8 -3
index aaccb4926..66b0765cf 100644
@@ -20,7 +20,7 @@
 #include <rte_per_lcore.h>
 #include <rte_eal.h>
 #include <rte_lcore.h>
-#include <rte_trace.h>
+#include <rte_trace_eal.h>
 
 #include "eal_private.h"
 #include "eal_thread.h"
@@ -41,9 +41,10 @@ rte_eal_remote_launch(int (*f)(void *), void *arg, unsigned slave_id)
 	char c = 0;
 	int m2s = lcore_config[slave_id].pipe_master2slave[1];
 	int s2m = lcore_config[slave_id].pipe_slave2master[0];
+	int rc = -EBUSY;
 
 	if (lcore_config[slave_id].state != WAIT)
-		return -EBUSY;
+		goto finish;
 
 	lcore_config[slave_id].f = f;
 	lcore_config[slave_id].arg = arg;
@@ -63,7 +64,10 @@ rte_eal_remote_launch(int (*f)(void *), void *arg, unsigned slave_id)
 	if (n <= 0)
 		rte_panic("cannot read on configuration pipe\n");
 
-	return 0;
+	rc = 0;
+finish:
+	rte_trace_lib_eal_thread_remote_launch(f, arg, slave_id, rc);
+	return rc;
 }
 
 /* set affinity for current thread */
@@ -126,6 +130,7 @@ eal_thread_loop(__attribute__((unused)) void *arg)
 		lcore_id, thread_id, cpuset, ret == 0 ? "" : "...");
 
 	__rte_trace_mem_per_thread_alloc();
+	rte_trace_lib_eal_thread_lcore_ready(lcore_id, cpuset);
 
 	/* read on our pipe to get commands */
 	while (1) {
lib/librte_eal/include/rte_trace_eal.h +14 -0
index abbaea5e0..8197e198a 100644
@@ -191,6 +191,20 @@ RTE_TRACE_POINT(
 	rte_trace_ctf_int(rc);
 )
 
+/* Thread */
+RTE_TRACE_POINT(
+	rte_trace_lib_eal_thread_remote_launch,
+	RTE_TRACE_POINT_ARGS(int (*f)(void *), void *arg,
+			     unsigned int slave_id, int rc),
+	rte_trace_ctf_ptr(f); rte_trace_ctf_ptr(arg);
+	rte_trace_ctf_u32(slave_id); rte_trace_ctf_int(rc);
+)
+RTE_TRACE_POINT(
+	rte_trace_lib_eal_thread_lcore_ready,
+	RTE_TRACE_POINT_ARGS(unsigned int lcore_id, const char *cpuset),
+	rte_trace_ctf_u32(lcore_id); rte_trace_ctf_string(cpuset);
+)
+
 
 #ifdef __cplusplus
 }
lib/librte_eal/linux/eal_thread.c +8 -3
index 45f4dce44..afadbcbd7 100644
@@ -20,7 +20,7 @@
 #include <rte_per_lcore.h>
 #include <rte_eal.h>
 #include <rte_lcore.h>
-#include <rte_trace.h>
+#include <rte_trace_eal.h>
 
 #include "eal_private.h"
 #include "eal_thread.h"
@@ -41,9 +41,10 @@ rte_eal_remote_launch(int (*f)(void *), void *arg, unsigned slave_id)
 	char c = 0;
 	int m2s = lcore_config[slave_id].pipe_master2slave[1];
 	int s2m = lcore_config[slave_id].pipe_slave2master[0];
+	int rc = -EBUSY;
 
 	if (lcore_config[slave_id].state != WAIT)
-		return -EBUSY;
+		goto finish;
 
 	lcore_config[slave_id].f = f;
 	lcore_config[slave_id].arg = arg;
@@ -63,7 +64,10 @@ rte_eal_remote_launch(int (*f)(void *), void *arg, unsigned slave_id)
 	if (n <= 0)
 		rte_panic("cannot read on configuration pipe\n");
 
-	return 0;
+	rc = 0;
+finish:
+	rte_trace_lib_eal_thread_remote_launch(f, arg, slave_id, rc);
+	return rc;
 }
 
 /* set affinity for current EAL thread */
@@ -126,6 +130,7 @@ eal_thread_loop(__attribute__((unused)) void *arg)
 		lcore_id, (uintptr_t)thread_id, cpuset, ret == 0 ? "" : "...");
 
 	__rte_trace_mem_per_thread_alloc();
+	rte_trace_lib_eal_thread_lcore_ready(lcore_id, cpuset);
 
 	/* read on our pipe to get commands */
 	while (1) {
lib/librte_eal/rte_eal_version.map +2 -0
index c3b7172ba..0ee4f29b2 100644
@@ -385,4 +385,6 @@ EXPERIMENTAL {
 	__rte_trace_lib_eal_memzone_reserve;
 	__rte_trace_lib_eal_memzone_lookup;
 	__rte_trace_lib_eal_memzone_free;
+	__rte_trace_lib_eal_thread_remote_launch;
+	__rte_trace_lib_eal_thread_lcore_ready;
 };
Signature · 1 line
2.25.1
#216 lore raw

PATCH v5 22/33 eal/trace: add interrupt tracepoints

In reply to [email protected]

From: Jerin Jacob <[email protected]>

Add the following interrupt related tracepoints.

rte_trace_lib_eal_intr_callback_register;
rte_trace_lib_eal_intr_callback_unregister;
rte_trace_lib_eal_intr_enable;
rte_trace_lib_eal_intr_disable;

---
 .../common/eal_common_trace_points.c          | 14 ++++
 lib/librte_eal/freebsd/eal_interrupts.c       | 52 ++++++++----
 lib/librte_eal/include/rte_trace_eal.h        | 34 ++++++++
 lib/librte_eal/linux/eal_interrupts.c         | 84 ++++++++++++-------
 lib/librte_eal/rte_eal_version.map            |  4 +
 5 files changed, 140 insertions(+), 48 deletions(-)
lib/librte_eal/common/eal_common_trace_points.c +14 -0
index 9cecd8206..4c1dd699b 100644
@@ -38,6 +38,11 @@ RTE_TRACE_POINT_DEFINE(rte_trace_lib_eal_memzone_free);
 RTE_TRACE_POINT_DEFINE(rte_trace_lib_eal_thread_remote_launch);
 RTE_TRACE_POINT_DEFINE(rte_trace_lib_eal_thread_lcore_ready);
 
+RTE_TRACE_POINT_DEFINE(rte_trace_lib_eal_intr_callback_register);
+RTE_TRACE_POINT_DEFINE(rte_trace_lib_eal_intr_callback_unregister);
+RTE_TRACE_POINT_DEFINE(rte_trace_lib_eal_intr_enable);
+RTE_TRACE_POINT_DEFINE(rte_trace_lib_eal_intr_disable);
+
 RTE_INIT(eal_trace_init)
 {
 	RTE_TRACE_POINT_REGISTER(rte_trace_lib_eal_generic_void,
@@ -98,4 +103,13 @@ RTE_INIT(eal_trace_init)
 				 lib.eal.thread.remote.launch);
 	RTE_TRACE_POINT_REGISTER(rte_trace_lib_eal_thread_lcore_ready,
 				 lib.eal.thread.lcore.ready);
+
+	RTE_TRACE_POINT_REGISTER(rte_trace_lib_eal_intr_callback_register,
+				 lib.eal.intr.register);
+	RTE_TRACE_POINT_REGISTER(rte_trace_lib_eal_intr_callback_unregister,
+				 lib.eal.intr.unregister);
+	RTE_TRACE_POINT_REGISTER(rte_trace_lib_eal_intr_enable,
+				 lib.eal.intr.enable);
+	RTE_TRACE_POINT_REGISTER(rte_trace_lib_eal_intr_disable,
+				 lib.eal.intr.disable);
 }
lib/librte_eal/freebsd/eal_interrupts.c +35 -17

114 lines not on this page · raw message

lib/librte_eal/include/rte_trace_eal.h +34 -0
index 8197e198a..7ab7b9659 100644
@@ -16,6 +16,7 @@ extern "C" {
 #endif
 
 #include <rte_alarm.h>
+#include <rte_interrupts.h>
 #include <rte_trace.h>
 
 /* Generic */
@@ -205,6 +206,39 @@ RTE_TRACE_POINT(
 	rte_trace_ctf_u32(lcore_id); rte_trace_ctf_string(cpuset);
 )
 
+/* Interrupt */
+RTE_TRACE_POINT(
+	rte_trace_lib_eal_intr_callback_register,
+	RTE_TRACE_POINT_ARGS(const struct rte_intr_handle *handle,
+			     rte_intr_callback_fn cb, void *cb_arg, int rc),
+	rte_trace_ctf_int(rc); rte_trace_ctf_int(handle->vfio_dev_fd);
+	rte_trace_ctf_int(handle->fd); rte_trace_ctf_int(handle->type);
+	rte_trace_ctf_u32(handle->max_intr); rte_trace_ctf_u32(handle->nb_efd);
+	rte_trace_ctf_ptr(cb); rte_trace_ctf_ptr(cb_arg);
+)
+RTE_TRACE_POINT(
+	rte_trace_lib_eal_intr_callback_unregister,
+	RTE_TRACE_POINT_ARGS(const struct rte_intr_handle *handle,
+			     rte_intr_callback_fn cb, void *cb_arg, int rc),
+	rte_trace_ctf_int(rc); rte_trace_ctf_int(handle->vfio_dev_fd);
+	rte_trace_ctf_int(handle->fd); rte_trace_ctf_int(handle->type);
+	rte_trace_ctf_u32(handle->max_intr); rte_trace_ctf_u32(handle->nb_efd);
+	rte_trace_ctf_ptr(cb); rte_trace_ctf_ptr(cb_arg);
+)
+RTE_TRACE_POINT(
+	rte_trace_lib_eal_intr_enable,
+	RTE_TRACE_POINT_ARGS(const struct rte_intr_handle *handle, int rc),
+	rte_trace_ctf_int(rc); rte_trace_ctf_int(handle->vfio_dev_fd);
+	rte_trace_ctf_int(handle->fd); rte_trace_ctf_int(handle->type);
+	rte_trace_ctf_u32(handle->max_intr); rte_trace_ctf_u32(handle->nb_efd);
+)
+RTE_TRACE_POINT(
+	rte_trace_lib_eal_intr_disable,
+	RTE_TRACE_POINT_ARGS(const struct rte_intr_handle *handle, int rc),
+	rte_trace_ctf_int(rc); rte_trace_ctf_int(handle->vfio_dev_fd);
+	rte_trace_ctf_int(handle->fd); rte_trace_ctf_int(handle->type);
+	rte_trace_ctf_u32(handle->max_intr); rte_trace_ctf_u32(handle->nb_efd);
+)
 
 #ifdef __cplusplus
 }
lib/librte_eal/linux/eal_interrupts.c +53 -31

187 lines not on this page · raw message

lib/librte_eal/rte_eal_version.map +4 -0
index 0ee4f29b2..0c0039780 100644
@@ -387,4 +387,8 @@ EXPERIMENTAL {
 	__rte_trace_lib_eal_memzone_free;
 	__rte_trace_lib_eal_thread_remote_launch;
 	__rte_trace_lib_eal_thread_lcore_ready;
+	__rte_trace_lib_eal_intr_callback_register;
+	__rte_trace_lib_eal_intr_callback_unregister;
+	__rte_trace_lib_eal_intr_enable;
+	__rte_trace_lib_eal_intr_disable;
 };
Signature · 1 line
2.25.1
#217 lore raw

PATCH v5 23/33 eal/trace: add trace configuration parameter

In reply to [email protected]

From: Sunil Kumar Kori <[email protected]>

Trace library exposes --trace EAL parameter to enable trace points.

---
 doc/guides/linux_gsg/eal_args.include.rst     | 16 +++++
 lib/librte_eal/common/eal_common_options.c    | 16 +++++
 lib/librte_eal/common/eal_common_trace.c      | 10 ++++
 .../common/eal_common_trace_utils.c           | 59 +++++++++++++++++++
 lib/librte_eal/common/eal_options.h           |  2 +
 lib/librte_eal/common/eal_trace.h             | 11 +++-
 6 files changed, 113 insertions(+), 1 deletion(-)
doc/guides/linux_gsg/eal_args.include.rst +16 -0
index ed8b0e35b..d9e6a1d95 100644
@@ -136,6 +136,22 @@ Debugging options
 
     Can be specified multiple times.
 
+*   ``--trace=<regex-match>``
+
+    Enable trace based on regular expression trace name. By default, the trace is
+    disabled. User must specify this option to enable trace.
+    For example:
+
+    Global trace configuration for EAL only::
+
+        --trace=eal
+
+    Global trace configuration for ALL the components::
+
+        --trace=.*
+
+    Can be specified multiple times up to 32 times.
+
 Other options
 ~~~~~~~~~~~~~
 
lib/librte_eal/common/eal_common_options.c +16 -0
index 525e51e7d..b2b2624e6 100644
@@ -34,6 +34,7 @@
 #include "eal_options.h"
 #include "eal_filesystem.h"
 #include "eal_private.h"
+#include "eal_trace.h"
 
 #define BITS_PER_HEX 4
 #define LCORE_OPT_LST 1
@@ -67,6 +68,7 @@ eal_long_options[] = {
 	{OPT_IOVA_MODE,	        1, NULL, OPT_IOVA_MODE_NUM        },
 	{OPT_LCORES,            1, NULL, OPT_LCORES_NUM           },
 	{OPT_LOG_LEVEL,         1, NULL, OPT_LOG_LEVEL_NUM        },
+	{OPT_TRACE,             1, NULL, OPT_TRACE_NUM            },
 	{OPT_MASTER_LCORE,      1, NULL, OPT_MASTER_LCORE_NUM     },
 	{OPT_MBUF_POOL_OPS_NAME, 1, NULL, OPT_MBUF_POOL_OPS_NAME_NUM},
 	{OPT_NO_HPET,           0, NULL, OPT_NO_HPET_NUM          },
@@ -1418,6 +1420,16 @@ eal_parse_common_option(int opt, const char *optarg,
 		}
 		break;
 	}
+
+	case OPT_TRACE_NUM: {
+		if (eal_trace_args_save(optarg) < 0) {
+			RTE_LOG(ERR, EAL, "invalid parameters for --"
+				OPT_TRACE "\n");
+			return -1;
+		}
+		break;
+	}
+
 	case OPT_LCORES_NUM:
 		if (eal_parse_lcores(optarg) < 0) {
 			RTE_LOG(ERR, EAL, "invalid parameter for --"
@@ -1693,6 +1705,10 @@ eal_common_usage(void)
 	       "  --"OPT_LOG_LEVEL"=<int>   Set global log level\n"
 	       "  --"OPT_LOG_LEVEL"=<type-match>:<int>\n"
 	       "                      Set specific log level\n"
+	       "  --"OPT_TRACE"=<regex-match>\n"
+	       "                      Enable trace based on regular expression trace name.\n"
+	       "                      By default, the trace is disabled.\n"
+	       "		      User must specify this option to enable trace.\n"
 	       "  -v                  Display version information on startup\n"
 	       "  -h, --help          This help\n"
 	       "  --"OPT_IN_MEMORY"   Operate entirely in memory. This will\n"
lib/librte_eal/common/eal_common_trace.c +10 -0
index 903a62a98..dd8086b88 100644
@@ -38,6 +38,8 @@ trace_list_head_get(void)
 int
 eal_trace_init(void)
 {
+	uint8_t i;
+
 	/* Trace memory should start with 8B aligned for natural alignment */
 	RTE_BUILD_BUG_ON((offsetof(struct __rte_trace_header, mem) % 8) != 0);
 
@@ -47,6 +49,9 @@ eal_trace_init(void)
 		goto fail;
 	}
 
+	if (trace.args.nb_args)
+		trace.global_status = true;
+
 	if (rte_trace_global_is_disabled())
 		return 0;
 
@@ -71,6 +76,10 @@ eal_trace_init(void)
 	if (trace_epoch_time_save() < 0)
 		goto fail;
 
+	/* Apply global configurations */
+	for (i = 0; i < trace.args.nb_args; i++)
+		trace_args_apply(trace.args.args[i]);
+
 	rte_trace_mode_set(trace.mode);
 
 	return 0;
@@ -89,6 +98,7 @@ eal_trace_fini(void)
 		return;
 	trace_mem_per_thread_free();
 	trace_metadata_destroy();
+	eal_trace_args_free();
 }
 
 bool
lib/librte_eal/common/eal_common_trace_utils.c +59 -0

65 lines not on this page · raw message

lib/librte_eal/common/eal_options.h +2 -0
index 9855429e5..4700410fd 100644
@@ -33,6 +33,8 @@ enum {
 	OPT_LCORES_NUM,
 #define OPT_LOG_LEVEL         "log-level"
 	OPT_LOG_LEVEL_NUM,
+#define OPT_TRACE             "trace"
+	OPT_TRACE_NUM,
 #define OPT_MASTER_LCORE      "master-lcore"
 	OPT_MASTER_LCORE_NUM,
 #define OPT_MBUF_POOL_OPS_NAME "mbuf-pool-ops-name"
lib/librte_eal/common/eal_trace.h +10 -1
index c284a2e0b..95ab3614a 100644
@@ -28,7 +28,7 @@
 #define TRACE_CTF_FIELD_SIZE 384
 #define TRACE_POINT_NAME_SIZE 64
 #define TRACE_CTF_MAGIC 0xC1FC1FC1
-
+#define TRACE_MAX_ARGS	32
 
 struct trace_point {
 	STAILQ_ENTRY(trace_point) next;
@@ -47,6 +47,11 @@ struct thread_mem_meta {
 	enum trace_area_e area;
 };
 
+struct trace_args {
+	uint8_t nb_args;
+	char *args[TRACE_MAX_ARGS];
+};
+
 struct trace {
 	char dir[PATH_MAX];
 	int dir_offset;
@@ -55,6 +60,7 @@ struct trace {
 	enum rte_trace_mode mode;
 	rte_uuid_t uuid;
 	uint32_t buff_len;
+	struct trace_args args;
 	uint32_t nb_trace_points;
 	uint32_t nb_trace_mem_list;
 	struct thread_mem_meta *lcore_meta;
@@ -93,6 +99,7 @@ struct trace_point_head *trace_list_head_get(void);
 /* Util functions */
 const char *trace_mode_to_string(enum rte_trace_mode mode);
 const char *trace_area_to_string(enum trace_area_e area);
+int trace_args_apply(const char *arg);
 bool trace_has_duplicate_entry(void);
 void trace_uuid_generate(void);
 int trace_metadata_create(void);
@@ -104,5 +111,7 @@ void trace_mem_per_thread_free(void);
 /* EAL interface */
 int eal_trace_init(void);
 void eal_trace_fini(void);
+int eal_trace_args_save(const char *optarg);
+void eal_trace_args_free(void);
 
 #endif /* __EAL_TRACE_H */
Signature · 1 line
2.25.1
#218 lore raw

PATCH v5 24/33 eal/trace: add trace dir configuration parameter

In reply to [email protected]

From: Sunil Kumar Kori <[email protected]>

Trace library exposes --trace-dir EAL parameter to configure directory where traces will be generated.

---
 doc/guides/linux_gsg/eal_args.include.rst     | 11 ++++
 lib/librte_eal/common/eal_common_options.c    | 15 ++++++
 .../common/eal_common_trace_utils.c           | 54 +++++++++++++++++++
 lib/librte_eal/common/eal_options.h           |  2 +
 lib/librte_eal/common/eal_trace.h             |  1 +
 5 files changed, 83 insertions(+)
doc/guides/linux_gsg/eal_args.include.rst +11 -0
index d9e6a1d95..98bfcd357 100644
@@ -152,6 +152,17 @@ Debugging options
 
     Can be specified multiple times up to 32 times.
 
+*   ``--trace-dir=<directory path>``
+
+    Specify trace directory for trace output. For example:
+
+    Configuring ``/tmp/`` as a trace output directory::
+
+        --trace-dir=/tmp
+
+    By default, trace output will created at ``home`` directory and parameter
+    must be specified once only.
+
 Other options
 ~~~~~~~~~~~~~
 
lib/librte_eal/common/eal_common_options.c +15 -0
index b2b2624e6..d6b3ea5ca 100644
@@ -69,6 +69,7 @@ eal_long_options[] = {
 	{OPT_LCORES,            1, NULL, OPT_LCORES_NUM           },
 	{OPT_LOG_LEVEL,         1, NULL, OPT_LOG_LEVEL_NUM        },
 	{OPT_TRACE,             1, NULL, OPT_TRACE_NUM            },
+	{OPT_TRACE_DIR,         1, NULL, OPT_TRACE_DIR_NUM        },
 	{OPT_MASTER_LCORE,      1, NULL, OPT_MASTER_LCORE_NUM     },
 	{OPT_MBUF_POOL_OPS_NAME, 1, NULL, OPT_MBUF_POOL_OPS_NAME_NUM},
 	{OPT_NO_HPET,           0, NULL, OPT_NO_HPET_NUM          },
@@ -1430,6 +1431,15 @@ eal_parse_common_option(int opt, const char *optarg,
 		break;
 	}
 
+	case OPT_TRACE_DIR_NUM: {
+		if (eal_trace_dir_args_save(optarg) < 0) {
+			RTE_LOG(ERR, EAL, "invalid parameters for --"
+				OPT_TRACE_DIR "\n");
+			return -1;
+		}
+		break;
+	}
+
 	case OPT_LCORES_NUM:
 		if (eal_parse_lcores(optarg) < 0) {
 			RTE_LOG(ERR, EAL, "invalid parameter for --"
@@ -1709,6 +1719,11 @@ eal_common_usage(void)
 	       "                      Enable trace based on regular expression trace name.\n"
 	       "                      By default, the trace is disabled.\n"
 	       "		      User must specify this option to enable trace.\n"
+	       "  --"OPT_TRACE_DIR"=<directory path>\n"
+	       "                      Specify trace directory for trace output.\n"
+	       "                      By default, trace output will created at\n"
+	       "                      $HOME directory and parameter must be\n"
+	       "                      specified once only.\n"
 	       "  -v                  Display version information on startup\n"
 	       "  -h, --help          This help\n"
 	       "  --"OPT_IN_MEMORY"   Operate entirely in memory. This will\n"
lib/librte_eal/common/eal_common_trace_utils.c +54 -0

78 lines not on this page · raw message

lib/librte_eal/common/eal_options.h +2 -0
index 4700410fd..04222e57f 100644
@@ -35,6 +35,8 @@ enum {
 	OPT_LOG_LEVEL_NUM,
 #define OPT_TRACE             "trace"
 	OPT_TRACE_NUM,
+#define OPT_TRACE_DIR         "trace-dir"
+	OPT_TRACE_DIR_NUM,
 #define OPT_MASTER_LCORE      "master-lcore"
 	OPT_MASTER_LCORE_NUM,
 #define OPT_MBUF_POOL_OPS_NAME "mbuf-pool-ops-name"
lib/librte_eal/common/eal_trace.h +1 -0
index 95ab3614a..ce4e90b8d 100644
@@ -113,5 +113,6 @@ int eal_trace_init(void);
 void eal_trace_fini(void);
 int eal_trace_args_save(const char *optarg);
 void eal_trace_args_free(void);
+int eal_trace_dir_args_save(const char *optarg);
 
 #endif /* __EAL_TRACE_H */
Signature · 1 line
2.25.1
#219 lore raw

PATCH v5 25/33 eal/trace: add trace bufsize configuration parameter

In reply to [email protected]

From: Sunil Kumar Kori <[email protected]>

Trace library exposes --trace-bufsz EAL parameter to configure maximum size of ring buffer where events are to be stored.

---
 doc/guides/linux_gsg/eal_args.include.rst     | 13 ++++++++
 lib/librte_eal/common/eal_common_options.c    | 17 +++++++++++
 lib/librte_eal/common/eal_common_trace.c      |  3 ++
 .../common/eal_common_trace_utils.c           | 30 +++++++++++++++++++
 lib/librte_eal/common/eal_options.h           |  2 ++
 lib/librte_eal/common/eal_trace.h             |  2 ++
 6 files changed, 67 insertions(+)
doc/guides/linux_gsg/eal_args.include.rst +13 -0
index 98bfcd357..b921c83b8 100644
@@ -163,6 +163,19 @@ Debugging options
     By default, trace output will created at ``home`` directory and parameter
     must be specified once only.
 
+*   ``--trace-bufsz=<val>``
+
+    Specify maximum size of allocated memory for trace output for each thread.
+    Valid unit can be either ``B`` or ``K`` or ``M`` for ``Bytes``, ``KBytes``
+    and ``MBytes`` respectively. For example:
+
+    Configuring ``2MB`` as a maximum size for trace output file::
+
+        --trace-bufsz=2M
+
+    By default, size of trace output file is ``1MB`` and parameter
+    must be specified once only.
+
 Other options
 ~~~~~~~~~~~~~
 
lib/librte_eal/common/eal_common_options.c +17 -0
index d6b3ea5ca..aea743e6f 100644
@@ -70,6 +70,7 @@ eal_long_options[] = {
 	{OPT_LOG_LEVEL,         1, NULL, OPT_LOG_LEVEL_NUM        },
 	{OPT_TRACE,             1, NULL, OPT_TRACE_NUM            },
 	{OPT_TRACE_DIR,         1, NULL, OPT_TRACE_DIR_NUM        },
+	{OPT_TRACE_BUF_SIZE,    1, NULL, OPT_TRACE_BUF_SIZE_NUM   },
 	{OPT_MASTER_LCORE,      1, NULL, OPT_MASTER_LCORE_NUM     },
 	{OPT_MBUF_POOL_OPS_NAME, 1, NULL, OPT_MBUF_POOL_OPS_NAME_NUM},
 	{OPT_NO_HPET,           0, NULL, OPT_NO_HPET_NUM          },
@@ -1440,6 +1441,15 @@ eal_parse_common_option(int opt, const char *optarg,
 		break;
 	}
 
+	case OPT_TRACE_BUF_SIZE_NUM: {
+		if (eal_trace_bufsz_args_save(optarg) < 0) {
+			RTE_LOG(ERR, EAL, "invalid parameters for --"
+				OPT_TRACE_BUF_SIZE "\n");
+			return -1;
+		}
+		break;
+	}
+
 	case OPT_LCORES_NUM:
 		if (eal_parse_lcores(optarg) < 0) {
 			RTE_LOG(ERR, EAL, "invalid parameter for --"
@@ -1724,6 +1734,13 @@ eal_common_usage(void)
 	       "                      By default, trace output will created at\n"
 	       "                      $HOME directory and parameter must be\n"
 	       "                      specified once only.\n"
+	       "  --"OPT_TRACE_BUF_SIZE"=<int>\n"
+	       "                      Specify maximum size of allocated memory\n"
+	       "                      for trace output for each thread. Valid\n"
+	       "                      unit can be either 'B|K|M' for 'Bytes',\n"
+	       "                      'KBytes' and 'MBytes' respectively.\n"
+	       "                      Default is 1MB and parameter must be\n"
+	       "                      specified once only.\n"
 	       "  -v                  Display version information on startup\n"
 	       "  -h, --help          This help\n"
 	       "  --"OPT_IN_MEMORY"   Operate entirely in memory. This will\n"
lib/librte_eal/common/eal_common_trace.c +3 -0
index dd8086b88..9e76d90fb 100644
@@ -64,6 +64,9 @@ eal_trace_init(void)
 	/* Generate UUID ver 4 with total size of events and number of events */
 	trace_uuid_generate();
 
+	/* Apply buffer size configuration for trace output */
+	trace_bufsz_args_apply();
+
 	/* Generate CTF TDSL metadata */
 	if (trace_metadata_create() < 0)
 		goto fail;
lib/librte_eal/common/eal_common_trace_utils.c +30 -0
index 41f2bdd05..b4ac79c95 100644
@@ -193,6 +193,36 @@ trace_args_apply(const char *arg)
 	return 0;
 }
 
+int
+eal_trace_bufsz_args_save(char const *optarg)
+{
+	struct trace *trace = trace_obj_get();
+	uint64_t bufsz;
+
+	if (optarg == NULL) {
+		trace_err("no optarg is passed");
+		return -EINVAL;
+	}
+
+	bufsz = rte_str_to_size(optarg);
+	if (bufsz == 0) {
+		trace_err("buffer size cannot be zero");
+		return -EINVAL;
+	}
+
+	trace->buff_len = bufsz;
+	return 0;
+}
+
+void
+trace_bufsz_args_apply(void)
+{
+	struct trace *trace = trace_obj_get();
+
+	if (trace->buff_len == 0)
+		trace->buff_len = 1024 * 1024; /* 1MB */
+}
+
 int
 eal_trace_dir_args_save(char const *optarg)
 {
lib/librte_eal/common/eal_options.h +2 -0
index 04222e57f..3e9a54f3a 100644
@@ -37,6 +37,8 @@ enum {
 	OPT_TRACE_NUM,
 #define OPT_TRACE_DIR         "trace-dir"
 	OPT_TRACE_DIR_NUM,
+#define OPT_TRACE_BUF_SIZE    "trace-bufsz"
+	OPT_TRACE_BUF_SIZE_NUM,
 #define OPT_MASTER_LCORE      "master-lcore"
 	OPT_MASTER_LCORE_NUM,
 #define OPT_MBUF_POOL_OPS_NAME "mbuf-pool-ops-name"
lib/librte_eal/common/eal_trace.h +2 -0
index ce4e90b8d..890d1d1ee 100644
@@ -100,6 +100,7 @@ struct trace_point_head *trace_list_head_get(void);
 const char *trace_mode_to_string(enum rte_trace_mode mode);
 const char *trace_area_to_string(enum trace_area_e area);
 int trace_args_apply(const char *arg);
+void trace_bufsz_args_apply(void);
 bool trace_has_duplicate_entry(void);
 void trace_uuid_generate(void);
 int trace_metadata_create(void);
@@ -114,5 +115,6 @@ void eal_trace_fini(void);
 int eal_trace_args_save(const char *optarg);
 void eal_trace_args_free(void);
 int eal_trace_dir_args_save(const char *optarg);
+int eal_trace_bufsz_args_save(const char *optarg);
 
 #endif /* __EAL_TRACE_H */
Signature · 1 line
2.25.1
#220 lore raw

PATCH v5 26/33 eal/trace: add trace mode configuration parameter

In reply to [email protected]

From: Sunil Kumar Kori <[email protected]>

Trace library exposes --trace-mode eal parameter to configure event record mode when ring buffers are full.

---
 doc/guides/linux_gsg/eal_args.include.rst     | 12 ++++++
 lib/librte_eal/common/eal_common_options.c    | 17 ++++++++
 .../common/eal_common_trace_utils.c           | 40 +++++++++++++++++++
 lib/librte_eal/common/eal_options.h           |  2 +
 lib/librte_eal/common/eal_trace.h             |  1 +
 5 files changed, 72 insertions(+)
doc/guides/linux_gsg/eal_args.include.rst +12 -0
index b921c83b8..361c7cf67 100644
@@ -176,6 +176,18 @@ Debugging options
     By default, size of trace output file is ``1MB`` and parameter
     must be specified once only.
 
+*   ``--trace-mode=<o[verwrite] | d[iscard] >``
+
+    Specify the mode of update of trace output file. Either update on a file
+    can be wrapped or discarded when file size reaches its maximum limit.
+    For example:
+
+    To ``discard`` update on trace output file::
+
+        --trace-mode=d or --trace-mode=discard
+
+    Default mode is ``overwrite`` and parameter must be specified once only.
+
 Other options
 ~~~~~~~~~~~~~
 
lib/librte_eal/common/eal_common_options.c +17 -0
index aea743e6f..6999cabc4 100644
@@ -71,6 +71,7 @@ eal_long_options[] = {
 	{OPT_TRACE,             1, NULL, OPT_TRACE_NUM            },
 	{OPT_TRACE_DIR,         1, NULL, OPT_TRACE_DIR_NUM        },
 	{OPT_TRACE_BUF_SIZE,    1, NULL, OPT_TRACE_BUF_SIZE_NUM   },
+	{OPT_TRACE_MODE,        1, NULL, OPT_TRACE_MODE_NUM       },
 	{OPT_MASTER_LCORE,      1, NULL, OPT_MASTER_LCORE_NUM     },
 	{OPT_MBUF_POOL_OPS_NAME, 1, NULL, OPT_MBUF_POOL_OPS_NAME_NUM},
 	{OPT_NO_HPET,           0, NULL, OPT_NO_HPET_NUM          },
@@ -1450,6 +1451,15 @@ eal_parse_common_option(int opt, const char *optarg,
 		break;
 	}
 
+	case OPT_TRACE_MODE_NUM: {
+		if (eal_trace_mode_args_save(optarg) < 0) {
+			RTE_LOG(ERR, EAL, "invalid parameters for --"
+				OPT_TRACE_MODE "\n");
+			return -1;
+		}
+		break;
+	}
+
 	case OPT_LCORES_NUM:
 		if (eal_parse_lcores(optarg) < 0) {
 			RTE_LOG(ERR, EAL, "invalid parameter for --"
@@ -1741,6 +1751,13 @@ eal_common_usage(void)
 	       "                      'KBytes' and 'MBytes' respectively.\n"
 	       "                      Default is 1MB and parameter must be\n"
 	       "                      specified once only.\n"
+	       "  --"OPT_TRACE_MODE"=<o[verwrite] | d[iscard]>\n"
+	       "                      Specify the mode of update of trace\n"
+	       "                      output file. Either update on a file can\n"
+	       "                      be wrapped or discarded when file size\n"
+	       "                      reaches its maximum limit.\n"
+	       "                      Default mode is 'overwrite' and parameter\n"
+	       "                      must be specified once only.\n"
 	       "  -v                  Display version information on startup\n"
 	       "  -h, --help          This help\n"
 	       "  --"OPT_IN_MEMORY"   Operate entirely in memory. This will\n"
lib/librte_eal/common/eal_common_trace_utils.c +40 -0
index b4ac79c95..5b2906677 100644
@@ -223,6 +223,46 @@ trace_bufsz_args_apply(void)
 		trace->buff_len = 1024 * 1024; /* 1MB */
 }
 
+int
+eal_trace_mode_args_save(const char *optarg)
+{
+	struct trace *trace = trace_obj_get();
+	size_t len = strlen(optarg);
+	unsigned long tmp;
+	char *pattern;
+
+	if (optarg == NULL) {
+		trace_err("no optarg is passed");
+		return -EINVAL;
+	}
+
+	if (len == 0) {
+		trace_err("value is not provided with option");
+		return -EINVAL;
+	}
+
+	pattern = (char *)calloc(1, len + 2);
+	if (pattern == NULL) {
+		trace_err("fail to allocate memory");
+		return -ENOMEM;
+	}
+
+	sprintf(pattern, "%s*", optarg);
+
+	if (fnmatch(pattern, "overwrite", 0) == 0)
+		tmp = RTE_TRACE_MODE_OVERWRITE;
+	else if (fnmatch(pattern, "discard", 0) == 0)
+		tmp = RTE_TRACE_MODE_DISCARD;
+	else {
+		free(pattern);
+		return -EINVAL;
+	}
+
+	trace->mode = tmp;
+	free(pattern);
+	return 0;
+}
+
 int
 eal_trace_dir_args_save(char const *optarg)
 {
lib/librte_eal/common/eal_options.h +2 -0
index 3e9a54f3a..90ead1b7c 100644
@@ -39,6 +39,8 @@ enum {
 	OPT_TRACE_DIR_NUM,
 #define OPT_TRACE_BUF_SIZE    "trace-bufsz"
 	OPT_TRACE_BUF_SIZE_NUM,
+#define OPT_TRACE_MODE        "trace-mode"
+	OPT_TRACE_MODE_NUM,
 #define OPT_MASTER_LCORE      "master-lcore"
 	OPT_MASTER_LCORE_NUM,
 #define OPT_MBUF_POOL_OPS_NAME "mbuf-pool-ops-name"
lib/librte_eal/common/eal_trace.h +1 -0
index 890d1d1ee..25401ad84 100644
@@ -115,6 +115,7 @@ void eal_trace_fini(void);
 int eal_trace_args_save(const char *optarg);
 void eal_trace_args_free(void);
 int eal_trace_dir_args_save(const char *optarg);
+int eal_trace_mode_args_save(const char *optarg);
 int eal_trace_bufsz_args_save(const char *optarg);
 
 #endif /* __EAL_TRACE_H */
Signature · 1 line
2.25.1
#221 lore raw

PATCH v5 27/33 eal/trace: add unit test cases

In reply to [email protected]

From: Sunil Kumar Kori <[email protected]>

Example commands to run UT and check the traces with babeltrace viewer.

- Delete the existing /root/dpdk-traces/ directory if needed.

Quoted 1 line

sudo rm -rf /root/dpdk-traces/

- Start the dpdk-test

Quoted 1 line

sudo ./build/app/test/dpdk-test -c 0x3 - --trace=.*

- Run trace_autotest

Quoted 1 line

trace_autotest

- View the traces with babletrace viewer.

Quoted 1 line

sudo babeltrace /root/dpdk-traces/

---
 app/test/Makefile              |   3 +-
 app/test/meson.build           |   2 +
 app/test/test_trace.c          | 258 +++++++++++++++++++++++++++++++++
 app/test/test_trace.h          |  15 ++
 app/test/test_trace_register.c |  19 +++
 5 files changed, 296 insertions(+), 1 deletion(-)
 create mode 100644 app/test/test_trace.c
 create mode 100644 app/test/test_trace.h
 create mode 100644 app/test/test_trace_register.c
app/test/Makefile +2 -1
index be53d33c3..9fb7b843f 100644
@@ -148,7 +148,8 @@ SRCS-y += test_alarm.c
 SRCS-y += test_interrupts.c
 SRCS-y += test_version.c
 SRCS-y += test_func_reentrancy.c
-
+SRCS-y += test_trace.c
+SRCS-y += test_trace_register.c
 SRCS-y += test_service_cores.c
 
 ifeq ($(CONFIG_RTE_LIBRTE_PMD_RING),y)
app/test/meson.build +2 -0
index 351d29cb6..4966236e8 100644
@@ -121,6 +121,8 @@ test_sources = files('commands.c',
 	'test_timer_racecond.c',
 	'test_timer_secondary.c',
 	'test_ticketlock.c',
+	'test_trace.c',
+	'test_trace_register.c',
 	'test_version.c',
 	'virtual_pmd.c'
 )
app/test/test_trace.c new file +258 -0

258 lines not on this page · raw message

app/test/test_trace.h new file +15 -0
new file mode 100644
index 000000000..18dd573f3
@@ -0,0 +1,15 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(C) 2020 Marvell International Ltd.
+ */
+#include <rte_trace.h>
+
+RTE_TRACE_POINT(
+	app_dpdk_test_tp,
+	RTE_TRACE_POINT_ARGS(const char *str),
+	rte_trace_ctf_string(str);
+)
+
+RTE_TRACE_POINT_FP(
+	app_dpdk_test_fp,
+	RTE_TRACE_POINT_ARGS(void),
+)
app/test/test_trace_register.c new file +19 -0
new file mode 100644
index 000000000..074b4f4bb
@@ -0,0 +1,19 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(C) 2020 Marvell International Ltd.
+ */
+#define RTE_TRACE_POINT_REGISTER_SELECT /* Select trace point register macros */
+
+#include <rte_trace.h>
+
+#include "test_trace.h"
+
+/* Define trace points */
+RTE_TRACE_POINT_DEFINE(app_dpdk_test_tp);
+RTE_TRACE_POINT_DEFINE(app_dpdk_test_fp);
+
+RTE_INIT(register_valid_trace_points)
+{
+	RTE_TRACE_POINT_REGISTER(app_dpdk_test_tp, app.dpdk.test.tp);
+	RTE_TRACE_POINT_REGISTER(app_dpdk_test_fp, app.dpdk.test.fp);
+}
+
Signature · 1 line
2.25.1
#222 lore raw

PATCH v5 28/33 eal/trace: add trace performance test cases

In reply to [email protected]

From: Jerin Jacob <[email protected]>

This test case shall be used to measure the trace overhead.

Example command to run the performance test case.

echo "trace_perf" | ./build/app/test/dpdk-test -c 0x3 --trace=.*

---
 app/test/Makefile          |   1 +
 app/test/meson.build       |   1 +
 app/test/test_trace_perf.c | 183 +++++++++++++++++++++++++++++++++++++
 3 files changed, 185 insertions(+)
 create mode 100644 app/test/test_trace_perf.c
app/test/Makefile +1 -0
index 9fb7b843f..0f990a0ae 100644
@@ -150,6 +150,7 @@ SRCS-y += test_version.c
 SRCS-y += test_func_reentrancy.c
 SRCS-y += test_trace.c
 SRCS-y += test_trace_register.c
+SRCS-y += test_trace_perf.c
 SRCS-y += test_service_cores.c
 
 ifeq ($(CONFIG_RTE_LIBRTE_PMD_RING),y)
app/test/meson.build +1 -0
index 4966236e8..efe8536c1 100644
@@ -123,6 +123,7 @@ test_sources = files('commands.c',
 	'test_ticketlock.c',
 	'test_trace.c',
 	'test_trace_register.c',
+	'test_trace_perf.c',
 	'test_version.c',
 	'virtual_pmd.c'
 )
app/test/test_trace_perf.c new file +183 -0

183 lines not on this page · raw message

Signature · 1 line
2.25.1
#223 lore raw

PATCH v5 29/33 ethdev: add tracepoints

In reply to [email protected]

From: Sunil Kumar Kori <[email protected]>

Add tracepoints at important and mandatory APIs for tracing support.

---
 examples/cmdline/Makefile                     |  1 +
 examples/cmdline/meson.build                  |  1 +
 examples/distributor/Makefile                 |  1 +
 examples/distributor/meson.build              |  1 +
 examples/ethtool/ethtool-app/Makefile         |  1 +
 examples/eventdev_pipeline/meson.build        |  1 +
 examples/flow_filtering/Makefile              |  1 +
 examples/flow_filtering/meson.build           |  1 +
 examples/helloworld/Makefile                  |  1 +
 examples/helloworld/meson.build               |  1 +
 examples/ioat/Makefile                        |  1 +
 examples/ioat/meson.build                     |  1 +
 examples/ip_fragmentation/Makefile            |  2 +
 examples/ip_fragmentation/meson.build         |  1 +
 examples/ip_reassembly/Makefile               |  1 +
 examples/ip_reassembly/meson.build            |  1 +
 examples/ipv4_multicast/Makefile              |  1 +
 examples/ipv4_multicast/meson.build           |  1 +
 examples/l2fwd-cat/Makefile                   |  1 +
 examples/l2fwd-cat/meson.build                |  1 +
 examples/l2fwd-event/Makefile                 |  1 +
 examples/l2fwd-event/meson.build              |  1 +
 examples/l2fwd-jobstats/Makefile              |  1 +
 examples/l2fwd-jobstats/meson.build           |  1 +
 examples/l2fwd-keepalive/Makefile             |  1 +
 examples/l2fwd-keepalive/ka-agent/Makefile    |  1 +
 examples/l2fwd-keepalive/meson.build          |  1 +
 examples/l3fwd-acl/Makefile                   |  1 +
 examples/l3fwd-acl/meson.build                |  1 +
 examples/l3fwd/Makefile                       |  1 +
 examples/l3fwd/meson.build                    |  1 +
 examples/link_status_interrupt/Makefile       |  1 +
 examples/link_status_interrupt/meson.build    |  1 +
 .../client_server_mp/mp_client/Makefile       |  1 +
 .../client_server_mp/mp_client/meson.build    |  1 +
 .../client_server_mp/mp_server/meson.build    |  1 +
 examples/multi_process/hotplug_mp/Makefile    |  1 +
 examples/multi_process/hotplug_mp/meson.build |  1 +
 examples/multi_process/simple_mp/Makefile     |  1 +
 examples/multi_process/simple_mp/meson.build  |  1 +
 examples/multi_process/symmetric_mp/Makefile  |  1 +
 .../multi_process/symmetric_mp/meson.build    |  1 +
 examples/ntb/Makefile                         |  1 +
 examples/ntb/meson.build                      |  1 +
 examples/packet_ordering/Makefile             |  1 +
 examples/packet_ordering/meson.build          |  1 +
 .../performance-thread/l3fwd-thread/Makefile  |  1 +
 .../l3fwd-thread/meson.build                  |  1 +
 .../performance-thread/pthread_shim/Makefile  |  1 +
 .../pthread_shim/meson.build                  |  1 +
 examples/ptpclient/Makefile                   |  1 +
 examples/ptpclient/meson.build                |  1 +
 examples/qos_meter/Makefile                   |  1 +
 examples/qos_meter/meson.build                |  1 +
 examples/qos_sched/Makefile                   |  1 +
 examples/qos_sched/meson.build                |  1 +
 examples/server_node_efd/node/Makefile        |  1 +
 examples/server_node_efd/node/meson.build     |  1 +
 examples/server_node_efd/server/Makefile      |  1 +
 examples/server_node_efd/server/meson.build   |  1 +
 examples/service_cores/Makefile               |  1 +
 examples/service_cores/meson.build            |  1 +
 examples/skeleton/Makefile                    |  1 +
 examples/skeleton/meson.build                 |  1 +
 examples/timer/Makefile                       |  1 +
 examples/timer/meson.build                    |  1 +
 examples/vm_power_manager/Makefile            |  1 +
 examples/vm_power_manager/meson.build         |  1 +
 examples/vmdq/Makefile                        |  1 +
 examples/vmdq/meson.build                     |  1 +
 examples/vmdq_dcb/Makefile                    |  1 +
 examples/vmdq_dcb/meson.build                 |  1 +
 lib/librte_ethdev/Makefile                    |  3 +
 lib/librte_ethdev/ethdev_trace_points.c       | 43 +++++++++
 lib/librte_ethdev/meson.build                 |  5 +-
 lib/librte_ethdev/rte_ethdev.c                | 12 +++
 lib/librte_ethdev/rte_ethdev.h                |  5 ++
 lib/librte_ethdev/rte_ethdev_version.map      | 10 +++
 lib/librte_ethdev/rte_trace_ethdev.h          | 90 +++++++++++++++++++
 lib/librte_ethdev/rte_trace_ethdev_fp.h       | 40 +++++++++
 80 files changed, 280 insertions(+), 1 deletion(-)
 create mode 100644 lib/librte_ethdev/ethdev_trace_points.c
 create mode 100644 lib/librte_ethdev/rte_trace_ethdev.h
 create mode 100644 lib/librte_ethdev/rte_trace_ethdev_fp.h
examples/cmdline/Makefile +1 -0
index 0b6b54540..9a33355d0 100644
@@ -57,6 +57,7 @@ SRCS-y := main.c commands.c parse_obj_list.c
 
 CFLAGS += -O3
 CFLAGS += $(WERROR_FLAGS)
+CFLAGS += -DALLOW_EXPERIMENTAL_API
 
 include $(RTE_SDK)/mk/rte.extapp.mk
 
examples/cmdline/meson.build +1 -0
index a8608c21a..7de0f1625 100644
@@ -6,6 +6,7 @@
 # To build this example as a standalone application with an already-installed
 # DPDK instance, use 'make'
 
+allow_experimental_apis = true
 sources = files(
 	'commands.c', 'main.c', 'parse_obj_list.c'
 )
examples/distributor/Makefile +1 -0
index 4192d8a4a..63c14dfca 100644
@@ -50,6 +50,7 @@ RTE_TARGET ?= $(notdir $(abspath $(dir $(firstword $(wildcard $(RTE_SDK)/*/.conf
 include $(RTE_SDK)/mk/rte.vars.mk
 
 CFLAGS += $(WERROR_FLAGS)
+CFLAGS += -DALLOW_EXPERIMENTAL_API
 
 # workaround for a gcc bug with noreturn attribute
 # http://gcc.gnu.org/bugzilla/show_bug.cgi?id=12603
examples/distributor/meson.build +1 -0
index 26f108d65..9fec7f883 100644
@@ -9,6 +9,7 @@
 # require the power library
 build = dpdk_conf.has('RTE_LIBRTE_POWER')
 
+allow_experimental_apis = true
 deps += ['distributor', 'power']
 sources = files(
 	'main.c'
examples/ethtool/ethtool-app/Makefile +1 -0
index 3543bdee0..20ac0d324 100644
@@ -18,6 +18,7 @@ SRCS-y := main.c ethapp.c
 
 CFLAGS += -O3 -pthread -I$(SRCDIR)/../lib
 CFLAGS += $(WERROR_FLAGS)
+CFLAGS += -DALLOW_EXPERIMENTAL_API
 
 LDLIBS += -L$(subst ethtool-app,lib,$(RTE_OUTPUT))/lib
 LDLIBS += -lrte_ethtool
examples/eventdev_pipeline/meson.build +1 -0
index a54c35aa7..1dfeba0d3 100644
@@ -6,6 +6,7 @@
 # To build this example as a standalone application with an already-installed
 # DPDK instance, use 'make'
 
+allow_experimental_apis = true
 deps += 'eventdev'
 sources = files(
 	'main.c',
examples/flow_filtering/Makefile +1 -0
index 6c51c0b7a..e0d546de9 100644
@@ -49,6 +49,7 @@ include $(RTE_SDK)/mk/rte.vars.mk
 
 CFLAGS += -O3
 CFLAGS += $(WERROR_FLAGS)
+CFLAGS += -DALLOW_EXPERIMENTAL_API
 
 include $(RTE_SDK)/mk/rte.extapp.mk
 
examples/flow_filtering/meson.build +1 -0
index 407795c42..6f5d1b08a 100644
@@ -6,6 +6,7 @@
 # To build this example as a standalone application with an already-installed
 # DPDK instance, use 'make'
 
+allow_experimental_apis = true
 sources = files(
 	'main.c',
 )
examples/helloworld/Makefile +1 -0
index 16d82b02f..0f5af0806 100644
@@ -51,6 +51,7 @@ include $(RTE_SDK)/mk/rte.vars.mk
 
 CFLAGS += -O3
 CFLAGS += $(WERROR_FLAGS)
+CFLAGS += -DALLOW_EXPERIMENTAL_API
 
 include $(RTE_SDK)/mk/rte.extapp.mk
 
examples/helloworld/meson.build +1 -0
index c34e11e36..2b0a25036 100644
@@ -6,6 +6,7 @@
 # To build this example as a standalone application with an already-installed
 # DPDK instance, use 'make'
 
+allow_experimental_apis = true
 sources = files(
 	'main.c'
 )
examples/ioat/Makefile +1 -0
index ef63f5d68..9b277eb7b 100644
@@ -51,6 +51,7 @@ include $(RTE_SDK)/mk/rte.vars.mk
 
 CFLAGS += -O3
 CFLAGS += $(WERROR_FLAGS)
+CFLAGS += -DALLOW_EXPERIMENTAL_API
 
 include $(RTE_SDK)/mk/rte.extapp.mk
 endif
examples/ioat/meson.build +1 -0
index ed8328963..f72cf70e7 100644
@@ -6,6 +6,7 @@
 # To build this example as a standalone application with an already-installed
 # DPDK instance, use 'make'
 
+allow_experimental_apis = true
 build = dpdk_conf.has('RTE_LIBRTE_PMD_IOAT_RAWDEV')
 
 deps += ['rawdev_ioat']
examples/ip_fragmentation/Makefile +2 -0
index ede0c4f02..8babbbf82 100644
@@ -22,6 +22,7 @@ PKGCONF ?= pkg-config
 
 PC_FILE := $(shell $(PKGCONF) --path libdpdk 2>/dev/null)
 CFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk)
+CFLAGS += -DALLOW_EXPERIMENTAL_API
 LDFLAGS_SHARED = $(shell $(PKGCONF) --libs libdpdk)
 LDFLAGS_STATIC = -Wl,-Bstatic $(shell $(PKGCONF) --static --libs libdpdk)
 
@@ -52,6 +53,7 @@ include $(RTE_SDK)/mk/rte.vars.mk
 
 CFLAGS += -O3
 CFLAGS += $(WERROR_FLAGS)
+CFLAGS += -DALLOW_EXPERIMENTAL_API
 
 # workaround for a gcc bug with noreturn attribute
 # http://gcc.gnu.org/bugzilla/show_bug.cgi?id=12603
examples/ip_fragmentation/meson.build +1 -0
index 304203eed..1230db477 100644
@@ -6,6 +6,7 @@
 # To build this example as a standalone application with an already-installed
 # DPDK instance, use 'make'
 
+allow_experimental_apis = true
 deps +=  ['ip_frag', 'lpm']
 sources = files(
 	'main.c'
examples/ip_reassembly/Makefile +1 -0
index 3f2888b33..11be2a74a 100644
@@ -52,6 +52,7 @@ include $(RTE_SDK)/mk/rte.vars.mk
 
 CFLAGS += -O3
 CFLAGS += $(WERROR_FLAGS)
+CFLAGS += -DALLOW_EXPERIMENTAL_API
 
 # workaround for a gcc bug with noreturn attribute
 # http://gcc.gnu.org/bugzilla/show_bug.cgi?id=12603
examples/ip_reassembly/meson.build +1 -0
index 8ebd48291..517bd4e19 100644
@@ -6,6 +6,7 @@
 # To build this example as a standalone application with an already-installed
 # DPDK instance, use 'make'
 
+allow_experimental_apis = true
 deps += ['lpm', 'ip_frag']
 sources = files(
 	'main.c'
examples/ipv4_multicast/Makefile +1 -0
index 92d3db0f4..b9f0813ed 100644
@@ -52,6 +52,7 @@ include $(RTE_SDK)/mk/rte.vars.mk
 
 CFLAGS += -O3
 CFLAGS += $(WERROR_FLAGS)
+CFLAGS += -DALLOW_EXPERIMENTAL_API
 
 # workaround for a gcc bug with noreturn attribute
 # http://gcc.gnu.org/bugzilla/show_bug.cgi?id=12603
examples/ipv4_multicast/meson.build +1 -0
index d9e4c7c21..7dc13fb8f 100644
@@ -6,6 +6,7 @@
 # To build this example as a standalone application with an already-installed
 # DPDK instance, use 'make'
 
+allow_experimental_apis = true
 deps += 'hash'
 sources = files(
 	'main.c'
examples/l2fwd-cat/Makefile +1 -0
index b0e53c37e..ca1202be1 100644
@@ -56,6 +56,7 @@ RTE_TARGET ?= $(notdir $(abspath $(dir $(firstword $(wildcard $(RTE_SDK)/*/.conf
 include $(RTE_SDK)/mk/rte.vars.mk
 
 CFLAGS += $(WERROR_FLAGS)
+CFLAGS += -DALLOW_EXPERIMENTAL_API
 
 # workaround for a gcc bug with noreturn attribute
 # http://gcc.gnu.org/bugzilla/show_bug.cgi?id=12603
examples/l2fwd-cat/meson.build +1 -0
index 4e2777a03..2bed18e74 100644
@@ -9,6 +9,7 @@
 pqos = cc.find_library('pqos', required: false)
 build = pqos.found()
 ext_deps += pqos
+allow_experimental_apis = true
 cflags += '-I/usr/local/include' # assume pqos lib installed in /usr/local
 sources = files(
 	'cat.c', 'l2fwd-cat.c'
examples/l2fwd-event/Makefile +1 -0
index 4cdae36f1..807f7f1b8 100644
@@ -57,6 +57,7 @@ include $(RTE_SDK)/mk/rte.vars.mk
 
 CFLAGS += -O3
 CFLAGS += $(WERROR_FLAGS)
+CFLAGS += -DALLOW_EXPERIMENTAL_API
 
 include $(RTE_SDK)/mk/rte.extapp.mk
 endif
examples/l2fwd-event/meson.build +1 -0
index 4e9a069d6..4a546eaf8 100644
@@ -7,6 +7,7 @@
 # To build this example as a standalone application with an already-installed
 # DPDK instance, use 'make'
 
+allow_experimental_apis = true
 deps += 'eventdev'
 sources = files(
 	'main.c',
examples/l2fwd-jobstats/Makefile +1 -0
index 73c91faa8..6cd9dcd9c 100644
@@ -52,6 +52,7 @@ include $(RTE_SDK)/mk/rte.vars.mk
 
 CFLAGS += -O3
 CFLAGS += $(WERROR_FLAGS)
+CFLAGS += -DALLOW_EXPERIMENTAL_API
 
 include $(RTE_SDK)/mk/rte.extapp.mk
 endif
examples/l2fwd-jobstats/meson.build +1 -0
index 1ffd484e2..72273736b 100644
@@ -6,6 +6,7 @@
 # To build this example as a standalone application with an already-installed
 # DPDK instance, use 'make'
 
+allow_experimental_apis = true
 deps += ['jobstats', 'timer']
 sources = files(
 	'main.c'
examples/l2fwd-keepalive/Makefile +1 -0
index 94d1e58bb..0db5e6015 100644
@@ -53,6 +53,7 @@ include $(RTE_SDK)/mk/rte.vars.mk
 
 CFLAGS += -O3
 CFLAGS += $(WERROR_FLAGS)
+CFLAGS += -DALLOW_EXPERIMENTAL_API
 LDFLAGS += -lrt
 
 include $(RTE_SDK)/mk/rte.extapp.mk
examples/l2fwd-keepalive/ka-agent/Makefile +1 -0
index 755e47438..8d5061b17 100644
@@ -17,5 +17,6 @@ APP = ka-agent
 SRCS-y := main.c
 
 CFLAGS += $(WERROR_FLAGS) -I$(SRCDIR)/../
+CFLAGS += -DALLOW_EXPERIMENTAL_API
 LDFLAGS += -lrt
 include $(RTE_SDK)/mk/rte.extapp.mk
examples/l2fwd-keepalive/meson.build +1 -0
index 6f7b007e1..d678a8ddd 100644
@@ -6,6 +6,7 @@
 # To build this example as a standalone application with an already-installed
 # DPDK instance, use 'make'
 
+allow_experimental_apis = true
 ext_deps += cc.find_library('rt')
 deps += 'timer'
 sources = files(
examples/l3fwd-acl/Makefile +1 -0
index d9909584b..9f31abef8 100644
@@ -51,6 +51,7 @@ include $(RTE_SDK)/mk/rte.vars.mk
 
 CFLAGS += -O3
 CFLAGS += $(WERROR_FLAGS)
+CFLAGS += -DALLOW_EXPERIMENTAL_API
 
 # workaround for a gcc bug with noreturn attribute
 # http://gcc.gnu.org/bugzilla/show_bug.cgi?id=12603
examples/l3fwd-acl/meson.build +1 -0
index 7096e00c1..6fa468b3a 100644
@@ -6,6 +6,7 @@
 # To build this example as a standalone application with an already-installed
 # DPDK instance, use 'make'
 
+allow_experimental_apis = true
 deps += ['acl', 'lpm', 'hash']
 sources = files(
 	'main.c'
examples/l3fwd/Makefile +1 -0
index 59a110d12..839439f0f 100644
@@ -53,6 +53,7 @@ include $(RTE_SDK)/mk/rte.vars.mk
 CFLAGS += -I$(SRCDIR)
 CFLAGS += -O3 $(USER_FLAGS)
 CFLAGS += $(WERROR_FLAGS)
+CFLAGS += -DALLOW_EXPERIMENTAL_API
 
 include $(RTE_SDK)/mk/rte.extapp.mk
 endif
examples/l3fwd/meson.build +1 -0
index ebed3b518..7d72b1b36 100644
@@ -6,6 +6,7 @@
 # To build this example as a standalone application with an already-installed
 # DPDK instance, use 'make'
 
+allow_experimental_apis = true
 deps += ['hash', 'lpm', 'eventdev']
 sources = files(
 	'l3fwd_em.c', 'l3fwd_lpm.c', 'l3fwd_event.c',
examples/link_status_interrupt/Makefile +1 -0
index 4f02a8901..613bb1167 100644
@@ -51,6 +51,7 @@ include $(RTE_SDK)/mk/rte.vars.mk
 
 CFLAGS += -O3
 CFLAGS += $(WERROR_FLAGS)
+CFLAGS += -DALLOW_EXPERIMENTAL_API
 
 include $(RTE_SDK)/mk/rte.extapp.mk
 endif
examples/link_status_interrupt/meson.build +1 -0
index c34e11e36..2b0a25036 100644
@@ -6,6 +6,7 @@
 # To build this example as a standalone application with an already-installed
 # DPDK instance, use 'make'
 
+allow_experimental_apis = true
 sources = files(
 	'main.c'
 )
examples/multi_process/client_server_mp/mp_client/Makefile +1 -0
index 298e1b020..7c447feba 100644
@@ -16,5 +16,6 @@ SRCS-y := client.c
 
 CFLAGS += $(WERROR_FLAGS) -O3
 CFLAGS += -I$(SRCDIR)/../shared
+CFLAGS += -DALLOW_EXPERIMENTAL_API
 
 include $(RTE_SDK)/mk/rte.extapp.mk
examples/multi_process/client_server_mp/mp_client/meson.build +1 -0
index a6241b83a..69c3d3bfb 100644
@@ -8,6 +8,7 @@
 
 includes += include_directories('../shared')
 
+allow_experimental_apis = true
 sources = files(
 	'client.c'
 )
examples/multi_process/client_server_mp/mp_server/meson.build +1 -0
index 1b2f78638..0ef6424f4 100644
@@ -8,6 +8,7 @@
 
 includes += include_directories('../shared')
 
+allow_experimental_apis = true
 sources = files(
 	'args.c', 'init.c', 'main.c'
 )
examples/multi_process/hotplug_mp/Makefile +1 -0
index 3ff74d52a..1fd7aa085 100644
@@ -18,5 +18,6 @@ SRCS-y := main.c commands.c
 
 CFLAGS += -O3
 CFLAGS += $(WERROR_FLAGS)
+CFLAGS += -DALLOW_EXPERIMENTAL_API
 
 include $(RTE_SDK)/mk/rte.extapp.mk
examples/multi_process/hotplug_mp/meson.build +1 -0
index 076f4e3dc..f82f4d48a 100644
@@ -6,6 +6,7 @@
 # To build this example as a standalone application with an already-installed
 # DPDK instance, use 'make'
 
+allow_experimental_apis = true
 sources = files(
 	'commands.c', 'main.c'
 )
examples/multi_process/simple_mp/Makefile +1 -0
index 4c0764451..f88b499bd 100644
@@ -18,5 +18,6 @@ SRCS-y := main.c mp_commands.c
 
 CFLAGS += -O3
 CFLAGS += $(WERROR_FLAGS)
+CFLAGS += -DALLOW_EXPERIMENTAL_API
 
 include $(RTE_SDK)/mk/rte.extapp.mk
examples/multi_process/simple_mp/meson.build +1 -0
index b2261e00e..cb02c65a6 100644
@@ -6,6 +6,7 @@
 # To build this example as a standalone application with an already-installed
 # DPDK instance, use 'make'
 
+allow_experimental_apis = true
 sources = files(
 	'mp_commands.c', 'main.c'
 )
examples/multi_process/symmetric_mp/Makefile +1 -0
index bdc415621..b7544489b 100644
@@ -18,5 +18,6 @@ SRCS-y := main.c
 
 CFLAGS += -O3
 CFLAGS += $(WERROR_FLAGS)
+CFLAGS += -DALLOW_EXPERIMENTAL_API
 
 include $(RTE_SDK)/mk/rte.extapp.mk
examples/multi_process/symmetric_mp/meson.build +1 -0
index 458f83642..14167825b 100644
@@ -6,6 +6,7 @@
 # To build this example as a standalone application with an already-installed
 # DPDK instance, use 'make'
 
+allow_experimental_apis = true
 sources = files(
 	'main.c'
 )
examples/ntb/Makefile +1 -0
index baeba11e8..f2920ed54 100644
@@ -25,6 +25,7 @@ LDFLAGS += -pthread
 
 PC_FILE := $(shell $(PKGCONF) --path libdpdk 2>/dev/null)
 CFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk)
+CFLAGS += -DALLOW_EXPERIMENTAL_API
 LDFLAGS_SHARED = $(shell $(PKGCONF) --libs libdpdk)
 LDFLAGS_STATIC = -Wl,-Bstatic $(shell $(PKGCONF) --static --libs libdpdk)
 
examples/ntb/meson.build +1 -0
index f5435fe12..ab449d093 100644
@@ -6,6 +6,7 @@
 # To build this example as a standalone application with an already-installed
 # DPDK instance, use 'make'
 
+allow_experimental_apis = true
 if host_machine.system() != 'linux'
 	build = false
 endif
examples/packet_ordering/Makefile +1 -0
index 261b7f06a..f5b68c97e 100644
@@ -51,6 +51,7 @@ include $(RTE_SDK)/mk/rte.vars.mk
 
 CFLAGS += -O3
 CFLAGS += $(WERROR_FLAGS)
+CFLAGS += -DALLOW_EXPERIMENTAL_API
 
 include $(RTE_SDK)/mk/rte.extapp.mk
 endif
examples/packet_ordering/meson.build +1 -0
index 6c2fccdcb..b38195914 100644
@@ -6,6 +6,7 @@
 # To build this example as a standalone application with an already-installed
 # DPDK instance, use 'make'
 
+allow_experimental_apis = true
 deps += 'reorder'
 sources = files(
 	'main.c'
examples/performance-thread/l3fwd-thread/Makefile +1 -0
index b14b21e30..c6cf05a43 100644
@@ -19,5 +19,6 @@ SRCS-y := main.c
 include $(RTE_SDK)/examples/performance-thread/common/common.mk
 
 CFLAGS += -O3 -g $(USER_FLAGS) $(INCLUDES) $(WERROR_FLAGS)
+CFLAGS += -DALLOW_EXPERIMENTAL_API
 
 include $(RTE_SDK)/mk/rte.extapp.mk
examples/performance-thread/l3fwd-thread/meson.build +1 -0
index 185fa59a4..99de24be7 100644
@@ -8,6 +8,7 @@
 
 build = dpdk_conf.has('RTE_ARCH_X86_64')
 deps += ['timer', 'lpm']
+allow_experimental_apis = true
 
 # get the performance thread (pt) architecture subdir
 if dpdk_conf.has('RTE_ARCH_ARM64')
examples/performance-thread/pthread_shim/Makefile +1 -0
index efd66febf..cdadf2cb7 100644
@@ -20,6 +20,7 @@ include $(RTE_SDK)/examples/performance-thread/common/common.mk
 
 CFLAGS += -g -O3 $(USER_FLAGS) $(INCLUDES)
 CFLAGS += $(WERROR_FLAGS)
+CFLAGS += -DALLOW_EXPERIMENTAL_API
 
 LDFLAGS += -lpthread
 
examples/performance-thread/pthread_shim/meson.build +1 -0
index 393fbd122..26ef78635 100644
@@ -8,6 +8,7 @@
 
 build = dpdk_conf.has('RTE_ARCH_X86_64') or dpdk_conf.has('RTE_ARCH_ARM64')
 deps += ['timer']
+allow_experimental_apis = true
 
 # get the performance thread (pt) architecture subdir
 if dpdk_conf.has('RTE_ARCH_ARM64')
examples/ptpclient/Makefile +1 -0
index 82d72b3e3..7cd36632a 100644
@@ -51,6 +51,7 @@ include $(RTE_SDK)/mk/rte.vars.mk
 
 CFLAGS += -O3
 CFLAGS += $(WERROR_FLAGS)
+CFLAGS += -DALLOW_EXPERIMENTAL_API
 
 # workaround for a gcc bug with noreturn attribute
 # http://gcc.gnu.org/bugzilla/show_bug.cgi?id=12603
examples/ptpclient/meson.build +1 -0
index fa0cbe93c..d4171a218 100644
@@ -6,6 +6,7 @@
 # To build this example as a standalone application with an already-installed
 # DPDK instance, use 'make'
 
+allow_experimental_apis = true
 sources = files(
 	'ptpclient.c'
 )
examples/qos_meter/Makefile +1 -0
index 7c2bf88a9..90e3533d1 100644
@@ -53,6 +53,7 @@ include $(RTE_SDK)/mk/rte.vars.mk
 
 CFLAGS += -O3
 CFLAGS += $(WERROR_FLAGS)
+CFLAGS += -DALLOW_EXPERIMENTAL_API
 
 # workaround for a gcc bug with noreturn attribute
 # http://gcc.gnu.org/bugzilla/show_bug.cgi?id=12603
examples/qos_meter/meson.build +1 -0
index ef7779f2f..2f9ab13af 100644
@@ -6,6 +6,7 @@
 # To build this example as a standalone application with an already-installed
 # DPDK instance, use 'make'
 
+allow_experimental_apis = true
 deps += 'meter'
 sources = files(
 	'main.c', 'rte_policer.c'
examples/qos_sched/Makefile +1 -0
index 525061ca0..92e3de79b 100644
@@ -58,6 +58,7 @@ else
 
 CFLAGS += -O3
 CFLAGS += $(WERROR_FLAGS)
+CFLAGS += -DALLOW_EXPERIMENTAL_API
 
 include $(RTE_SDK)/mk/rte.extapp.mk
 
examples/qos_sched/meson.build +1 -0
index 289b81ce8..ba59d3c9e 100644
@@ -6,6 +6,7 @@
 # To build this example as a standalone application with an already-installed
 # DPDK instance, use 'make'
 
+allow_experimental_apis = true
 deps += ['sched', 'cfgfile']
 sources = files(
 	'app_thread.c', 'args.c', 'cfg_file.c', 'cmdline.c',
examples/server_node_efd/node/Makefile +1 -0
index fffbe3576..ecc551e1d 100644
@@ -16,5 +16,6 @@ SRCS-y := node.c
 
 CFLAGS += $(WERROR_FLAGS) -O3
 CFLAGS += -I$(SRCDIR)/../shared
+CFLAGS += -DALLOW_EXPERIMENTAL_API
 
 include $(RTE_SDK)/mk/rte.extapp.mk
examples/server_node_efd/node/meson.build +1 -0
index 30f28761f..1c720968a 100644
@@ -8,6 +8,7 @@
 
 name = 'efd_node'
 
+allow_experimental_apis = true
 deps += ['hash']
 sources += files('node.c')
 includes += include_directories('../shared')
examples/server_node_efd/server/Makefile +1 -0
index 4837bd3ea..acbd12ae2 100644
@@ -25,5 +25,6 @@ INC := $(sort $(wildcard *.h))
 
 CFLAGS += $(WERROR_FLAGS) -O3
 CFLAGS += -I$(SRCDIR)/../shared
+CFLAGS += -DALLOW_EXPERIMENTAL_API
 
 include $(RTE_SDK)/mk/rte.extapp.mk
examples/server_node_efd/server/meson.build +1 -0
index 23e08d1ae..7abc333e1 100644
@@ -8,6 +8,7 @@
 
 name = 'efd_server'
 
+allow_experimental_apis = true
 deps += 'efd'
 sources += files('args.c', 'init.c', 'main.c')
 includes += include_directories('../shared')
examples/service_cores/Makefile +1 -0
index c47055813..aac207bd9 100644
@@ -50,6 +50,7 @@ RTE_TARGET ?= $(notdir $(abspath $(dir $(firstword $(wildcard $(RTE_SDK)/*/.conf
 include $(RTE_SDK)/mk/rte.vars.mk
 
 CFLAGS += $(WERROR_FLAGS)
+CFLAGS += -DALLOW_EXPERIMENTAL_API
 
 # workaround for a gcc bug with noreturn attribute
 # http://gcc.gnu.org/bugzilla/show_bug.cgi?id=12603
examples/service_cores/meson.build +1 -0
index c34e11e36..2b0a25036 100644
@@ -6,6 +6,7 @@
 # To build this example as a standalone application with an already-installed
 # DPDK instance, use 'make'
 
+allow_experimental_apis = true
 sources = files(
 	'main.c'
 )
examples/skeleton/Makefile +1 -0
index 2c29004d7..2612688c0 100644
@@ -50,6 +50,7 @@ RTE_TARGET ?= $(notdir $(abspath $(dir $(firstword $(wildcard $(RTE_SDK)/*/.conf
 include $(RTE_SDK)/mk/rte.vars.mk
 
 CFLAGS += $(WERROR_FLAGS)
+CFLAGS += -DALLOW_EXPERIMENTAL_API
 
 # workaround for a gcc bug with noreturn attribute
 # http://gcc.gnu.org/bugzilla/show_bug.cgi?id=12603
examples/skeleton/meson.build +1 -0
index 9bb9ec329..ef46b187e 100644
@@ -6,6 +6,7 @@
 # To build this example as a standalone application with an already-installed
 # DPDK instance, use 'make'
 
+allow_experimental_apis = true
 sources = files(
 	'basicfwd.c'
 )
examples/timer/Makefile +1 -0
index bf86339ab..e58e90a28 100644
@@ -51,6 +51,7 @@ include $(RTE_SDK)/mk/rte.vars.mk
 
 CFLAGS += -O3
 CFLAGS += $(WERROR_FLAGS)
+CFLAGS += -DALLOW_EXPERIMENTAL_API
 
 # workaround for a gcc bug with noreturn attribute
 # http://gcc.gnu.org/bugzilla/show_bug.cgi?id=12603
examples/timer/meson.build +1 -0
index c3d901637..87c21a867 100644
@@ -6,6 +6,7 @@
 # To build this example as a standalone application with an already-installed
 # DPDK instance, use 'make'
 
+allow_experimental_apis = true
 deps += 'timer'
 sources = files(
 	'main.c'
examples/vm_power_manager/Makefile +1 -0
index 2fdb991d7..65c2ad179 100644
@@ -28,6 +28,7 @@ endif
 
 CFLAGS += -O3 -I$(RTE_SDK)/lib/librte_power/
 CFLAGS += $(WERROR_FLAGS)
+CFLAGS += -DALLOW_EXPERIMENTAL_API
 
 LDLIBS += -lvirt
 
examples/vm_power_manager/meson.build +1 -0
index 20a4a05b3..54e2b584f 100644
@@ -25,6 +25,7 @@ if dpdk_conf.has('RTE_LIBRTE_IXGBE_PMD')
 	deps += ['pmd_ixgbe']
 endif
 
+allow_experimental_apis = true
 sources = files(
 	'channel_manager.c', 'channel_monitor.c', 'main.c', 'parse.c', 'power_manager.c', 'vm_power_cli.c'
 )
examples/vmdq/Makefile +1 -0
index 0767c715a..98e644fa7 100644
@@ -50,6 +50,7 @@ RTE_TARGET ?= $(notdir $(abspath $(dir $(firstword $(wildcard $(RTE_SDK)/*/.conf
 include $(RTE_SDK)/mk/rte.vars.mk
 
 CFLAGS += $(WERROR_FLAGS)
+CFLAGS += -DALLOW_EXPERIMENTAL_API
 
 EXTRA_CFLAGS += -O3
 
examples/vmdq/meson.build +1 -0
index c34e11e36..2b0a25036 100644
@@ -6,6 +6,7 @@
 # To build this example as a standalone application with an already-installed
 # DPDK instance, use 'make'
 
+allow_experimental_apis = true
 sources = files(
 	'main.c'
 )
examples/vmdq_dcb/Makefile +1 -0
index 2a9b04143..3eb7c9f43 100644
@@ -50,6 +50,7 @@ RTE_TARGET ?= $(notdir $(abspath $(dir $(firstword $(wildcard $(RTE_SDK)/*/.conf
 include $(RTE_SDK)/mk/rte.vars.mk
 
 CFLAGS += $(WERROR_FLAGS)
+CFLAGS += -DALLOW_EXPERIMENTAL_API
 
 # workaround for a gcc bug with noreturn attribute
 # http://gcc.gnu.org/bugzilla/show_bug.cgi?id=12603
examples/vmdq_dcb/meson.build +1 -0
index c34e11e36..2b0a25036 100644
@@ -6,6 +6,7 @@
 # To build this example as a standalone application with an already-installed
 # DPDK instance, use 'make'
 
+allow_experimental_apis = true
 sources = files(
 	'main.c'
 )
lib/librte_ethdev/Makefile +3 -0
index 943fb8c87..dbc03f264 100644
@@ -22,6 +22,7 @@ SRCS-y += rte_flow.c
 SRCS-y += rte_tm.c
 SRCS-y += rte_mtr.c
 SRCS-y += ethdev_profile.c
+SRCS-y += ethdev_trace_points.c
 
 #
 # Export include files
@@ -39,5 +40,7 @@ SYMLINK-y-include += rte_tm.h
 SYMLINK-y-include += rte_tm_driver.h
 SYMLINK-y-include += rte_mtr.h
 SYMLINK-y-include += rte_mtr_driver.h
+SYMLINK-y-include += rte_trace_ethdev.h
+SYMLINK-y-include += rte_trace_ethdev_fp.h
 
 include $(RTE_SDK)/mk/rte.lib.mk
lib/librte_ethdev/ethdev_trace_points.c new file +43 -0

43 lines not on this page · raw message

lib/librte_ethdev/meson.build +4 -1
index ab341d9c0..f73b760fc 100644
@@ -4,6 +4,7 @@
 name = 'ethdev'
 sources = files('ethdev_private.c',
 	'ethdev_profile.c',
+	'ethdev_trace_points.c',
 	'rte_class_eth.c',
 	'rte_ethdev.c',
 	'rte_flow.c',
@@ -22,6 +23,8 @@ headers = files('rte_ethdev.h',
 	'rte_mtr.h',
 	'rte_mtr_driver.h',
 	'rte_tm.h',
-	'rte_tm_driver.h')
+	'rte_tm_driver.h',
+	'rte_trace_ethdev.h',
+	'rte_trace_ethdev_fp.h')
 
 deps += ['net', 'kvargs', 'meter']
lib/librte_ethdev/rte_ethdev.c +12 -0
index 0854ef883..bf7d842cc 100644
@@ -39,6 +39,7 @@
 #include <rte_class.h>
 #include <rte_ether.h>
 
+#include "rte_trace_ethdev.h"
 #include "rte_ethdev.h"
 #include "rte_ethdev_driver.h"
 #include "ethdev_profile.h"
@@ -1470,6 +1471,7 @@ rte_eth_dev_configure(uint16_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q,
 		goto reset_queues;
 	}
 
+	rte_trace_lib_ethdev_configure(port_id, nb_rx_q, nb_tx_q, dev_conf, 0);
 	return 0;
 reset_queues:
 	rte_eth_dev_rx_queue_config(dev, 0);
@@ -1477,6 +1479,8 @@ rte_eth_dev_configure(uint16_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q,
 rollback:
 	memcpy(&dev->data->dev_conf, &orig_conf, sizeof(dev->data->dev_conf));
 
+	rte_trace_lib_ethdev_configure(port_id, nb_rx_q, nb_tx_q, dev_conf,
+				       ret);
 	return ret;
 }
 
@@ -1647,6 +1651,8 @@ rte_eth_dev_start(uint16_t port_id)
 		RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->link_update, -ENOTSUP);
 		(*dev->dev_ops->link_update)(dev, 0);
 	}
+
+	rte_trace_lib_ethdev_start(port_id);
 	return 0;
 }
 
@@ -1669,6 +1675,7 @@ rte_eth_dev_stop(uint16_t port_id)
 
 	dev->data->dev_started = 0;
 	(*dev->dev_ops->dev_stop)(dev);
+	rte_trace_lib_ethdev_stop(port_id);
 }
 
 int
@@ -1709,6 +1716,7 @@ rte_eth_dev_close(uint16_t port_id)
 	dev->data->dev_started = 0;
 	(*dev->dev_ops->dev_close)(dev);
 
+	rte_trace_lib_ethdev_close(port_id);
 	/* check behaviour flag - temporary for PMD migration */
 	if ((dev->data->dev_flags & RTE_ETH_DEV_CLOSE_REMOVE) != 0) {
 		/* new behaviour: send event + reset state + free all data */
@@ -1918,6 +1926,8 @@ rte_eth_rx_queue_setup(uint16_t port_id, uint16_t rx_queue_id,
 			dev->data->min_rx_buf_size = mbp_buf_size;
 	}
 
+	rte_trace_lib_ethdev_rxq_setup(port_id, rx_queue_id, nb_rx_desc, mp,
+				       rx_conf, ret);
 	return eth_err(port_id, ret);
 }
 
@@ -2088,6 +2098,8 @@ rte_eth_tx_queue_setup(uint16_t port_id, uint16_t tx_queue_id,
 		return -EINVAL;
 	}
 
+	rte_trace_lib_ethdev_txq_setup(port_id, tx_queue_id, nb_tx_desc,
+				       tx_conf);
 	return eth_err(port_id, (*dev->dev_ops->tx_queue_setup)(dev,
 		       tx_queue_id, nb_tx_desc, socket_id, &local_conf));
 }
lib/librte_ethdev/rte_ethdev.h +5 -0
index d1a593ad1..17cd1dda3 100644
@@ -158,6 +158,7 @@ extern "C" {
 #include <rte_config.h>
 #include <rte_ether.h>
 
+#include "rte_trace_ethdev_fp.h"
 #include "rte_dev_info.h"
 
 extern int rte_eth_dev_logtype;
@@ -4400,6 +4401,8 @@ rte_eth_rx_burst(uint16_t port_id, uint16_t queue_id,
 	}
 #endif
 
+	rte_trace_lib_ethdev_rx_burst(port_id, queue_id, (void **)rx_pkts,
+				      nb_rx);
 	return nb_rx;
 }
 
@@ -4663,6 +4666,8 @@ rte_eth_tx_burst(uint16_t port_id, uint16_t queue_id,
 	}
 #endif
 
+	rte_trace_lib_ethdev_tx_burst(port_id, queue_id, (void **)tx_pkts,
+				      nb_pkts);
 	return (*dev->tx_pkt_burst)(dev->data->tx_queues[queue_id], tx_pkts, nb_pkts);
 }
 
lib/librte_ethdev/rte_ethdev_version.map +10 -0
index 3f32fdecf..28c07117c 100644
@@ -230,4 +230,14 @@ EXPERIMENTAL {
 
 	# added in 20.02
 	rte_flow_dev_dump;
+
+	# added in 20.05
+	__rte_trace_lib_ethdev_configure;
+	__rte_trace_lib_ethdev_rxq_setup;
+	__rte_trace_lib_ethdev_txq_setup;
+	__rte_trace_lib_ethdev_start;
+	__rte_trace_lib_ethdev_stop;
+	__rte_trace_lib_ethdev_close;
+	__rte_trace_lib_ethdev_rx_burst;
+	__rte_trace_lib_ethdev_tx_burst;
 };
lib/librte_ethdev/rte_trace_ethdev.h new file +90 -0

90 lines not on this page · raw message

lib/librte_ethdev/rte_trace_ethdev_fp.h new file +40 -0
new file mode 100644
index 000000000..0f08f99df
@@ -0,0 +1,40 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(C) 2020 Marvell International Ltd.
+ */
+
+#ifndef _RTE_TRACE_ETHDEV_FP_H_
+#define _RTE_TRACE_ETHDEV_FP_H_
+
+/**
+ * @file
+ *
+ * API for ethdev trace support
+ */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <rte_trace.h>
+
+RTE_TRACE_POINT_FP(
+	rte_trace_lib_ethdev_rx_burst,
+	RTE_TRACE_POINT_ARGS(uint16_t port_id, uint16_t queue_id,
+			     void **pkt_tbl, uint16_t nb_rx),
+	rte_trace_ctf_u16(port_id); rte_trace_ctf_u16(queue_id);
+	rte_trace_ctf_ptr(pkt_tbl); rte_trace_ctf_u16(nb_rx);
+)
+
+RTE_TRACE_POINT_FP(
+	rte_trace_lib_ethdev_tx_burst,
+	RTE_TRACE_POINT_ARGS(uint16_t port_id, uint16_t queue_id,
+			     void **pkts_tbl, uint16_t nb_pkts),
+	rte_trace_ctf_u16(port_id); rte_trace_ctf_u16(queue_id);
+	rte_trace_ctf_ptr(pkts_tbl); rte_trace_ctf_u16(nb_pkts);
+)
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _RTE_TRACE_ETHDEV_FP_H_ */
Signature · 1 line
2.25.1
#224 lore raw

PATCH v5 30/33 eventdev: add tracepoints

In reply to [email protected]

From: Sunil Kumar Kori <[email protected]>

Add tracepoints at important and mandatory APIs for tracing support.

---
 lib/librte_eventdev/Makefile                  |   3 +
 lib/librte_eventdev/eventdev_trace_points.c   | 173 +++++++++++
 lib/librte_eventdev/meson.build               |   3 +
 .../rte_event_crypto_adapter.c                |  10 +
 .../rte_event_eth_rx_adapter.c                |  11 +
 .../rte_event_eth_tx_adapter.c                |  13 +-
 .../rte_event_eth_tx_adapter.h                |   2 +
 lib/librte_eventdev/rte_event_timer_adapter.c |   8 +-
 lib/librte_eventdev/rte_event_timer_adapter.h |   8 +
 lib/librte_eventdev/rte_eventdev.c            |   9 +
 lib/librte_eventdev/rte_eventdev.h            |   5 +-
 lib/librte_eventdev/rte_eventdev_version.map  |  42 +++
 lib/librte_eventdev/rte_trace_eventdev.h      | 278 ++++++++++++++++++
 lib/librte_eventdev/rte_trace_eventdev_fp.h   |  75 +++++
 14 files changed, 636 insertions(+), 4 deletions(-)
 create mode 100644 lib/librte_eventdev/eventdev_trace_points.c
 create mode 100644 lib/librte_eventdev/rte_trace_eventdev.h
 create mode 100644 lib/librte_eventdev/rte_trace_eventdev_fp.h
lib/librte_eventdev/Makefile +3 -0
index c85c0d3cf..843016893 100644
@@ -21,6 +21,7 @@ LDLIBS += -lrte_mbuf -lrte_cryptodev -lpthread
 # library source files
 SRCS-y += rte_eventdev.c
 SRCS-y += rte_event_ring.c
+SRCS-y += eventdev_trace_points.c
 SRCS-y += rte_event_eth_rx_adapter.c
 SRCS-y += rte_event_timer_adapter.c
 SRCS-y += rte_event_crypto_adapter.c
@@ -29,6 +30,8 @@ SRCS-y += rte_event_eth_tx_adapter.c
 # export include files
 SYMLINK-y-include += rte_eventdev.h
 SYMLINK-y-include += rte_eventdev_pmd.h
+SYMLINK-y-include += rte_trace_eventdev.h
+SYMLINK-y-include += rte_trace_eventdev_fp.h
 SYMLINK-y-include += rte_eventdev_pmd_pci.h
 SYMLINK-y-include += rte_eventdev_pmd_vdev.h
 SYMLINK-y-include += rte_event_ring.h
lib/librte_eventdev/eventdev_trace_points.c new file +173 -0

173 lines not on this page · raw message

lib/librte_eventdev/meson.build +3 -0
index 16d8240e9..a74c45d13 100644
@@ -9,12 +9,15 @@ endif
 
 sources = files('rte_eventdev.c',
 		'rte_event_ring.c',
+		'eventdev_trace_points.c',
 		'rte_event_eth_rx_adapter.c',
 		'rte_event_timer_adapter.c',
 		'rte_event_crypto_adapter.c',
 		'rte_event_eth_tx_adapter.c')
 headers = files('rte_eventdev.h',
 		'rte_eventdev_pmd.h',
+		'rte_trace_eventdev.h',
+		'rte_trace_eventdev_fp.h',
 		'rte_eventdev_pmd_pci.h',
 		'rte_eventdev_pmd_vdev.h',
 		'rte_event_ring.h',
lib/librte_eventdev/rte_event_crypto_adapter.c +10 -0
index 22d910816..5fbc75093 100644
@@ -16,6 +16,7 @@
 
 #include "rte_eventdev.h"
 #include "rte_eventdev_pmd.h"
+#include "rte_trace_eventdev.h"
 #include "rte_event_crypto_adapter.h"
 
 #define BATCH_SIZE 32
@@ -267,6 +268,8 @@ rte_event_crypto_adapter_create_ext(uint8_t id, uint8_t dev_id,
 
 	event_crypto_adapter[id] = adapter;
 
+	rte_trace_lib_event_crypto_adapter_create(id, dev_id, adapter, conf_arg,
+						  mode);
 	return 0;
 }
 
@@ -314,6 +317,7 @@ rte_event_crypto_adapter_free(uint8_t id)
 		return -EBUSY;
 	}
 
+	rte_trace_lib_event_crypto_adapter_free(id, adapter);
 	if (adapter->default_cb_arg)
 		rte_free(adapter->conf_arg);
 	rte_free(adapter->cdevs);
@@ -874,6 +878,8 @@ rte_event_crypto_adapter_queue_pair_add(uint8_t id,
 		rte_service_component_runstate_set(adapter->service_id, 1);
 	}
 
+	rte_trace_lib_event_crypto_adapter_queue_pair_add(id, cdev_id, event,
+							  queue_pair_id);
 	return 0;
 }
 
@@ -959,6 +965,8 @@ rte_event_crypto_adapter_queue_pair_del(uint8_t id, uint8_t cdev_id,
 				adapter->nb_qps);
 	}
 
+	rte_trace_lib_event_crypto_adapter_queue_pair_del(id, cdev_id,
+							  queue_pair_id, ret);
 	return ret;
 }
 
@@ -1014,12 +1022,14 @@ rte_event_crypto_adapter_start(uint8_t id)
 	if (adapter == NULL)
 		return -EINVAL;
 
+	rte_trace_lib_event_crypto_adapter_start(id, adapter);
 	return eca_adapter_ctrl(id, 1);
 }
 
 int
 rte_event_crypto_adapter_stop(uint8_t id)
 {
+	rte_trace_lib_event_crypto_adapter_stop(id);
 	return eca_adapter_ctrl(id, 0);
 }
 
lib/librte_eventdev/rte_event_eth_rx_adapter.c +11 -0
index 95dd47820..aca4f9d8a 100644
@@ -20,6 +20,7 @@
 
 #include "rte_eventdev.h"
 #include "rte_eventdev_pmd.h"
+#include "rte_trace_eventdev.h"
 #include "rte_event_eth_rx_adapter.h"
 
 #define BATCH_SIZE		32
@@ -1998,6 +1999,8 @@ rte_event_eth_rx_adapter_create_ext(uint8_t id, uint8_t dev_id,
 	event_eth_rx_adapter[id] = rx_adapter;
 	if (conf_cb == rxa_default_conf_cb)
 		rx_adapter->default_cb_arg = 1;
+	rte_trace_lib_event_eth_rx_adapter_create(id, dev_id, conf_cb,
+						  conf_arg);
 	return 0;
 }
 
@@ -2047,6 +2050,7 @@ rte_event_eth_rx_adapter_free(uint8_t id)
 	rte_free(rx_adapter);
 	event_eth_rx_adapter[id] = NULL;
 
+	rte_trace_lib_event_eth_rx_adapter_free(id);
 	return 0;
 }
 
@@ -2142,6 +2146,9 @@ rte_event_eth_rx_adapter_queue_add(uint8_t id,
 		rte_spinlock_unlock(&rx_adapter->rx_lock);
 	}
 
+	rte_trace_lib_event_eth_rx_adapter_queue_add(id, eth_dev_id,
+						     rx_queue_id, queue_conf,
+						     ret);
 	if (ret)
 		return ret;
 
@@ -2263,18 +2270,22 @@ rte_event_eth_rx_adapter_queue_del(uint8_t id, uint16_t eth_dev_id,
 				rxa_sw_adapter_queue_count(rx_adapter));
 	}
 
+	rte_trace_lib_event_eth_rx_adapter_queue_del(id, eth_dev_id,
+						     rx_queue_id, ret);
 	return ret;
 }
 
 int
 rte_event_eth_rx_adapter_start(uint8_t id)
 {
+	rte_trace_lib_event_eth_rx_adapter_start(id);
 	return rxa_ctrl(id, 1);
 }
 
 int
 rte_event_eth_rx_adapter_stop(uint8_t id)
 {
+	rte_trace_lib_event_eth_rx_adapter_stop(id);
 	return rxa_ctrl(id, 0);
 }
 
lib/librte_eventdev/rte_event_eth_tx_adapter.c +12 -1
index d02ef57f4..a6dbc655e 100644
@@ -6,6 +6,7 @@
 #include <rte_ethdev.h>
 
 #include "rte_eventdev_pmd.h"
+#include "rte_trace_eventdev.h"
 #include "rte_event_eth_tx_adapter.h"
 
 #define TXA_BATCH_SIZE		32
@@ -942,7 +943,8 @@ rte_event_eth_tx_adapter_create(uint8_t id, uint8_t dev_id,
 		txa_dev_id_array[id] = TXA_INVALID_DEV_ID;
 		return ret;
 	}
-
+	rte_trace_lib_event_eth_tx_adapter_create(id, dev_id, NULL, port_conf,
+						  ret);
 	txa_dev_id_array[id] = dev_id;
 	return 0;
 }
@@ -984,6 +986,8 @@ rte_event_eth_tx_adapter_create_ext(uint8_t id, uint8_t dev_id,
 		return ret;
 	}
 
+	rte_trace_lib_event_eth_tx_adapter_create(id, dev_id, conf_cb, conf_arg,
+						  ret);
 	txa_dev_id_array[id] = dev_id;
 	return 0;
 }
@@ -1012,6 +1016,7 @@ rte_event_eth_tx_adapter_free(uint8_t id)
 		ret = txa_service_adapter_free(id);
 	txa_dev_id_array[id] = TXA_INVALID_DEV_ID;
 
+	rte_trace_lib_event_eth_tx_adapter_free(id, ret);
 	return ret;
 }
 
@@ -1043,6 +1048,8 @@ rte_event_eth_tx_adapter_queue_add(uint8_t id,
 	else
 		ret = txa_service_queue_add(id, txa_evdev(id), eth_dev, queue);
 
+	rte_trace_lib_event_eth_tx_adapter_queue_add(id, eth_dev_id, queue,
+						     ret);
 	return ret;
 }
 
@@ -1073,6 +1080,8 @@ rte_event_eth_tx_adapter_queue_del(uint8_t id,
 	else
 		ret = txa_service_queue_del(id, eth_dev, queue);
 
+	rte_trace_lib_event_eth_tx_adapter_queue_del(id, eth_dev_id, queue,
+						     ret);
 	return ret;
 }
 
@@ -1094,6 +1103,7 @@ rte_event_eth_tx_adapter_start(uint8_t id)
 	ret = txa_dev_start(id) ? txa_dev_start(id)(id, txa_evdev(id)) : 0;
 	if (ret == 0)
 		ret = txa_service_start(id);
+	rte_trace_lib_event_eth_tx_adapter_start(id, ret);
 	return ret;
 }
 
@@ -1154,5 +1164,6 @@ rte_event_eth_tx_adapter_stop(uint8_t id)
 	ret = txa_dev_stop(id) ? txa_dev_stop(id)(id,  txa_evdev(id)) : 0;
 	if (ret == 0)
 		ret = txa_service_stop(id);
+	rte_trace_lib_event_eth_tx_adapter_stop(id, ret);
 	return ret;
 }
lib/librte_eventdev/rte_event_eth_tx_adapter.h +2 -0
index 93b717af9..f2154c01a 100644
@@ -369,6 +369,8 @@ rte_event_eth_tx_adapter_enqueue(uint8_t dev_id,
 		return 0;
 	}
 #endif
+	rte_trace_lib_event_eth_tx_adapter_enqueue(dev_id, port_id, ev,
+						   nb_events, flags);
 	if (flags)
 		return dev->txa_enqueue_same_dest(dev->data->ports[port_id],
 						  ev, nb_events);
lib/librte_eventdev/rte_event_timer_adapter.c +6 -2
index 161e21a68..700e10afd 100644
@@ -22,6 +22,7 @@
 
 #include "rte_eventdev.h"
 #include "rte_eventdev_pmd.h"
+#include "rte_trace_eventdev.h"
 #include "rte_event_timer_adapter.h"
 #include "rte_event_timer_adapter_pmd.h"
 
@@ -228,6 +229,8 @@ rte_event_timer_adapter_create_ext(
 
 	adapter->allocated = 1;
 
+	rte_trace_lib_event_timer_adapter_create(adapter_id, adapter, conf,
+						 conf_cb);
 	return adapter;
 
 free_memzone:
@@ -272,7 +275,7 @@ rte_event_timer_adapter_start(const struct rte_event_timer_adapter *adapter)
 		return ret;
 
 	adapter->data->started = 1;
-
+	rte_trace_lib_event_timer_adapter_start(adapter);
 	return 0;
 }
 
@@ -295,7 +298,7 @@ rte_event_timer_adapter_stop(const struct rte_event_timer_adapter *adapter)
 		return ret;
 
 	adapter->data->started = 0;
-
+	rte_trace_lib_event_timer_adapter_stop(adapter);
 	return 0;
 }
 
@@ -379,6 +382,7 @@ rte_event_timer_adapter_free(struct rte_event_timer_adapter *adapter)
 	adapter->data = NULL;
 	adapter->allocated = 0;
 
+	rte_trace_lib_event_timer_adapter_free(adapter);
 	return 0;
 }
 
lib/librte_eventdev/rte_event_timer_adapter.h +8 -0
index 7f6dc5c29..d338b7738 100644
@@ -115,6 +115,7 @@ extern "C" {
 #include <rte_memory.h>
 
 #include "rte_eventdev.h"
+#include "rte_trace_eventdev_fp.h"
 
 /**
  * Timer adapter clock source
@@ -579,6 +580,8 @@ rte_event_timer_arm_burst(const struct rte_event_timer_adapter *adapter,
 	ADAPTER_VALID_OR_ERR_RET(adapter, -EINVAL);
 	FUNC_PTR_OR_ERR_RET(adapter->arm_burst, -EINVAL);
 #endif
+	rte_trace_lib_event_timer_arm_burst(adapter, (void **)evtims,
+					    nb_evtims);
 	return adapter->arm_burst(adapter, evtims, nb_evtims);
 }
 
@@ -622,6 +625,9 @@ rte_event_timer_arm_tmo_tick_burst(
 	ADAPTER_VALID_OR_ERR_RET(adapter, -EINVAL);
 	FUNC_PTR_OR_ERR_RET(adapter->arm_tmo_tick_burst, -EINVAL);
 #endif
+	rte_trace_lib_event_timer_arm_tmo_tick_burst(adapter, timeout_ticks,
+						     (void **)evtims,
+						     nb_evtims);
 	return adapter->arm_tmo_tick_burst(adapter, evtims, timeout_ticks,
 					   nb_evtims);
 }
@@ -655,6 +661,8 @@ rte_event_timer_cancel_burst(const struct rte_event_timer_adapter *adapter,
 	ADAPTER_VALID_OR_ERR_RET(adapter, -EINVAL);
 	FUNC_PTR_OR_ERR_RET(adapter->cancel_burst, -EINVAL);
 #endif
+	rte_trace_lib_event_timer_cancel_burst(adapter, (void **)evtims,
+					       nb_evtims);
 	return adapter->cancel_burst(adapter, evtims, nb_evtims);
 }
 
lib/librte_eventdev/rte_eventdev.c +9 -0
index b987e0745..d0a3bdd7f 100644
@@ -35,6 +35,7 @@
 
 #include "rte_eventdev.h"
 #include "rte_eventdev_pmd.h"
+#include "rte_trace_eventdev.h"
 
 static struct rte_eventdev rte_event_devices[RTE_EVENT_MAX_DEVS];
 
@@ -524,6 +525,7 @@ rte_event_dev_configure(uint8_t dev_id,
 	}
 
 	dev->data->event_dev_cap = info.event_dev_cap;
+	rte_trace_lib_eventdev_configure(dev_id, dev_conf, diag);
 	return diag;
 }
 
@@ -650,6 +652,7 @@ rte_event_queue_setup(uint8_t dev_id, uint8_t queue_id,
 	}
 
 	dev->data->queues_cfg[queue_id] = *queue_conf;
+	rte_trace_lib_event_queue_setup(dev_id, queue_id, queue_conf);
 	return (*dev->dev_ops->queue_setup)(dev, queue_id, queue_conf);
 }
 
@@ -766,6 +769,7 @@ rte_event_port_setup(uint8_t dev_id, uint8_t port_id,
 	if (!diag)
 		diag = rte_event_port_unlink(dev_id, port_id, NULL, 0);
 
+	rte_trace_lib_event_port_setup(dev_id, port_id, port_conf, diag);
 	if (diag < 0)
 		return diag;
 
@@ -936,6 +940,7 @@ rte_event_port_link(uint8_t dev_id, uint8_t port_id,
 	for (i = 0; i < diag; i++)
 		links_map[queues[i]] = (uint8_t)priorities[i];
 
+	rte_trace_lib_event_port_link(dev_id, port_id, nb_links, diag);
 	return diag;
 }
 
@@ -1001,6 +1006,7 @@ rte_event_port_unlink(uint8_t dev_id, uint8_t port_id,
 	for (i = 0; i < diag; i++)
 		links_map[queues[i]] = EVENT_QUEUE_SERVICE_PRIORITY_INVALID;
 
+	rte_trace_lib_event_port_unlink(dev_id, port_id, nb_unlinks, diag);
 	return diag;
 }
 
@@ -1213,6 +1219,7 @@ rte_event_dev_start(uint8_t dev_id)
 	}
 
 	diag = (*dev->dev_ops->dev_start)(dev);
+	rte_trace_lib_eventdev_start(dev_id, diag);
 	if (diag == 0)
 		dev->data->dev_started = 1;
 	else
@@ -1257,6 +1264,7 @@ rte_event_dev_stop(uint8_t dev_id)
 
 	dev->data->dev_started = 0;
 	(*dev->dev_ops->dev_stop)(dev);
+	rte_trace_lib_eventdev_stop(dev_id);
 }
 
 int
@@ -1275,6 +1283,7 @@ rte_event_dev_close(uint8_t dev_id)
 		return -EBUSY;
 	}
 
+	rte_trace_lib_eventdev_close(dev_id);
 	return (*dev->dev_ops->dev_close)(dev);
 }
 
lib/librte_eventdev/rte_eventdev.h +4 -1
index 226f352ad..71d4fa6f1 100644
@@ -215,6 +215,8 @@ extern "C" {
 #include <rte_memory.h>
 #include <rte_errno.h>
 
+#include "rte_trace_eventdev_fp.h"
+
 struct rte_mbuf; /* we just use mbuf pointers; no need to include rte_mbuf.h */
 struct rte_event;
 
@@ -1343,6 +1345,7 @@ __rte_event_enqueue_burst(uint8_t dev_id, uint8_t port_id,
 		return 0;
 	}
 #endif
+	rte_trace_lib_event_enq_burst(dev_id, port_id, ev, nb_events, fn);
 	/*
 	 * Allow zero cost non burst mode routine invocation if application
 	 * requests nb_events as const one
@@ -1620,7 +1623,7 @@ rte_event_dequeue_burst(uint8_t dev_id, uint8_t port_id, struct rte_event ev[],
 		return 0;
 	}
 #endif
-
+	rte_trace_lib_event_deq_burst(dev_id, port_id, ev, nb_events);
 	/*
 	 * Allow zero cost non burst mode routine invocation if application
 	 * requests nb_events as const one
lib/librte_eventdev/rte_eventdev_version.map +42 -0

45 lines not on this page · raw message

lib/librte_eventdev/rte_trace_eventdev.h new file +278 -0

278 lines not on this page · raw message

lib/librte_eventdev/rte_trace_eventdev_fp.h new file +75 -0

75 lines not on this page · raw message

Signature · 1 line
2.25.1
#225 lore raw

PATCH v5 31/33 cryptodev: add tracepoints

In reply to [email protected]

From: Sunil Kumar Kori <[email protected]>

Add tracepoints at important and mandatory APIs for tracing support.

---
 lib/librte_cryptodev/Makefile                 |   4 +-
 lib/librte_cryptodev/cryptodev_trace_points.c |  70 +++++++++
 lib/librte_cryptodev/meson.build              |   6 +-
 lib/librte_cryptodev/rte_cryptodev.c          |  18 +++
 lib/librte_cryptodev/rte_cryptodev.h          |   6 +
 .../rte_cryptodev_version.map                 |  18 +++
 lib/librte_cryptodev/rte_trace_cryptodev.h    | 133 ++++++++++++++++++
 lib/librte_cryptodev/rte_trace_cryptodev_fp.h |  34 +++++
 8 files changed, 286 insertions(+), 3 deletions(-)
 create mode 100644 lib/librte_cryptodev/cryptodev_trace_points.c
 create mode 100644 lib/librte_cryptodev/rte_trace_cryptodev.h
 create mode 100644 lib/librte_cryptodev/rte_trace_cryptodev_fp.h
lib/librte_cryptodev/Makefile +3 -1
index 2ba0dbeec..10b993260 100644
@@ -13,7 +13,7 @@ LDLIBS += -lrte_eal -lrte_mempool -lrte_ring -lrte_mbuf
 LDLIBS += -lrte_kvargs
 
 # library source files
-SRCS-y += rte_cryptodev.c rte_cryptodev_pmd.c
+SRCS-y += rte_cryptodev.c rte_cryptodev_pmd.c cryptodev_trace_points.c
 
 # export include files
 SYMLINK-y-include += rte_crypto.h
@@ -21,6 +21,8 @@ SYMLINK-y-include += rte_crypto_sym.h
 SYMLINK-y-include += rte_cryptodev.h
 SYMLINK-y-include += rte_cryptodev_pmd.h
 SYMLINK-y-include += rte_crypto_asym.h
+SYMLINK-y-include += rte_trace_cryptodev.h
+SYMLINK-y-include += rte_trace_cryptodev_fp.h
 
 # versioning export map
 EXPORT_MAP := rte_cryptodev_version.map
lib/librte_cryptodev/cryptodev_trace_points.c new file +70 -0

70 lines not on this page · raw message

lib/librte_cryptodev/meson.build +4 -2
index 42825a810..9358b2811 100644
@@ -1,10 +1,12 @@
 # SPDX-License-Identifier: BSD-3-Clause
 # Copyright(c) 2017-2019 Intel Corporation
 
-sources = files('rte_cryptodev.c', 'rte_cryptodev_pmd.c')
+sources = files('rte_cryptodev.c', 'rte_cryptodev_pmd.c', 'cryptodev_trace_points.c')
 headers = files('rte_cryptodev.h',
 	'rte_cryptodev_pmd.h',
 	'rte_crypto.h',
 	'rte_crypto_sym.h',
-	'rte_crypto_asym.h')
+	'rte_crypto_asym.h',
+	'rte_trace_cryptodev.h',
+	'rte_trace_cryptodev_fp.h')
 deps += ['kvargs', 'mbuf']
lib/librte_cryptodev/rte_cryptodev.c +18 -0
index 6d1d0e9d3..66ab7a694 100644
@@ -40,6 +40,7 @@
 #include "rte_crypto.h"
 #include "rte_cryptodev.h"
 #include "rte_cryptodev_pmd.h"
+#include "rte_trace_cryptodev.h"
 
 static uint8_t nb_drivers;
 
@@ -905,6 +906,7 @@ rte_cryptodev_configure(uint8_t dev_id, struct rte_cryptodev_config *config)
 		return diag;
 	}
 
+	rte_trace_lib_cryptodev_configure(dev_id, config);
 	return (*dev->dev_ops->dev_configure)(dev, config);
 }
 
@@ -933,6 +935,7 @@ rte_cryptodev_start(uint8_t dev_id)
 	}
 
 	diag = (*dev->dev_ops->dev_start)(dev);
+	rte_trace_lib_cryptodev_start(dev_id, diag);
 	if (diag == 0)
 		dev->data->dev_started = 1;
 	else
@@ -962,6 +965,7 @@ rte_cryptodev_stop(uint8_t dev_id)
 	}
 
 	(*dev->dev_ops->dev_stop)(dev);
+	rte_trace_lib_cryptodev_stop(dev_id);
 	dev->data->dev_started = 0;
 }
 
@@ -998,6 +1002,7 @@ rte_cryptodev_close(uint8_t dev_id)
 
 	RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->dev_close, -ENOTSUP);
 	retval = (*dev->dev_ops->dev_close)(dev);
+	rte_trace_lib_cryptodev_close(dev_id, retval);
 
 	if (retval < 0)
 		return retval;
@@ -1067,6 +1072,8 @@ rte_cryptodev_queue_pair_setup(uint8_t dev_id, uint16_t queue_pair_id,
 
 	RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->queue_pair_setup, -ENOTSUP);
 
+	rte_trace_lib_cryptodev_queue_pair_setup(dev_id, queue_pair_id,
+						 qp_conf);
 	return (*dev->dev_ops->queue_pair_setup)(dev, queue_pair_id, qp_conf,
 			socket_id);
 }
@@ -1283,6 +1290,7 @@ rte_cryptodev_sym_session_init(uint8_t dev_id,
 		}
 	}
 
+	rte_trace_lib_cryptodev_sym_session_init(dev_id, sess, xforms, mp);
 	sess->sess_data[index].refcnt++;
 	return 0;
 }
@@ -1319,6 +1327,7 @@ rte_cryptodev_asym_session_init(uint8_t dev_id,
 		}
 	}
 
+	rte_trace_lib_cryptodev_asym_session_init(dev_id, sess, xforms, mp);
 	return 0;
 }
 
@@ -1359,6 +1368,9 @@ rte_cryptodev_sym_session_pool_create(const char *name, uint32_t nb_elts,
 	pool_priv->nb_drivers = nb_drivers;
 	pool_priv->user_data_sz = user_data_size;
 
+	rte_trace_lib_cryptodev_sym_session_pool_create(name, nb_elts,
+							elt_size, cache_size,
+							user_data_size, mp);
 	return mp;
 }
 
@@ -1403,6 +1415,7 @@ rte_cryptodev_sym_session_create(struct rte_mempool *mp)
 	memset(sess->sess_data, 0,
 			rte_cryptodev_sym_session_data_size(sess));
 
+	rte_trace_lib_cryptodev_sym_session_create(mp, sess);
 	return sess;
 }
 
@@ -1422,6 +1435,7 @@ rte_cryptodev_asym_session_create(struct rte_mempool *mp)
 	 */
 	memset(sess, 0, (sizeof(void *) * nb_drivers) + sizeof(uint8_t));
 
+	rte_trace_lib_cryptodev_asym_session_create(mp, sess);
 	return sess;
 }
 
@@ -1447,6 +1461,7 @@ rte_cryptodev_sym_session_clear(uint8_t dev_id,
 
 	dev->dev_ops->sym_session_clear(dev, sess);
 
+	rte_trace_lib_cryptodev_sym_session_clear(dev_id, sess);
 	return 0;
 }
 
@@ -1465,6 +1480,7 @@ rte_cryptodev_asym_session_clear(uint8_t dev_id,
 
 	dev->dev_ops->asym_session_clear(dev, sess);
 
+	rte_trace_lib_cryptodev_sym_session_clear(dev_id, sess);
 	return 0;
 }
 
@@ -1487,6 +1503,7 @@ rte_cryptodev_sym_session_free(struct rte_cryptodev_sym_session *sess)
 	sess_mp = rte_mempool_from_obj(sess);
 	rte_mempool_put(sess_mp, sess);
 
+	rte_trace_lib_cryptodev_sym_session_free(sess);
 	return 0;
 }
 
@@ -1511,6 +1528,7 @@ rte_cryptodev_asym_session_free(struct rte_cryptodev_asym_session *sess)
 	sess_mp = rte_mempool_from_obj(sess);
 	rte_mempool_put(sess_mp, sess);
 
+	rte_trace_lib_cryptodev_asym_session_free(sess);
 	return 0;
 }
 
lib/librte_cryptodev/rte_cryptodev.h +6 -0
index 437b8a9b3..9008b70b6 100644
@@ -24,6 +24,8 @@ extern "C" {
 #include <rte_common.h>
 #include <rte_config.h>
 
+#include "rte_trace_cryptodev_fp.h"
+
 extern const char **rte_cyptodev_names;
 
 /* Logging Macros */
@@ -924,6 +926,8 @@ rte_cryptodev_dequeue_burst(uint8_t dev_id, uint16_t qp_id,
 	nb_ops = (*dev->dequeue_burst)
 			(dev->data->queue_pairs[qp_id], ops, nb_ops);
 
+	rte_trace_lib_cryptodev_dequeue_burst(dev_id, qp_id, (void **)ops,
+					      nb_ops);
 	return nb_ops;
 }
 
@@ -964,6 +968,8 @@ rte_cryptodev_enqueue_burst(uint8_t dev_id, uint16_t qp_id,
 {
 	struct rte_cryptodev *dev = &rte_cryptodevs[dev_id];
 
+	rte_trace_lib_cryptodev_enqueue_burst(dev_id, qp_id, (void **)ops,
+					      nb_ops);
 	return (*dev->enqueue_burst)(
 			dev->data->queue_pairs[qp_id], ops, nb_ops);
 }
lib/librte_cryptodev/rte_cryptodev_version.map +18 -0
index 6e41b4be5..d023de7aa 100644
@@ -78,4 +78,22 @@ EXPERIMENTAL {
 	rte_cryptodev_sym_session_set_user_data;
 	rte_crypto_asym_op_strings;
 	rte_crypto_asym_xform_strings;
+
+	# added in 20.05
+	__rte_trace_lib_cryptodev_configure;
+	__rte_trace_lib_cryptodev_start;
+	__rte_trace_lib_cryptodev_stop;
+	__rte_trace_lib_cryptodev_close;
+	__rte_trace_lib_cryptodev_queue_pair_setup;
+	__rte_trace_lib_cryptodev_sym_session_pool_create;
+	__rte_trace_lib_cryptodev_sym_session_create;
+	__rte_trace_lib_cryptodev_asym_session_create;
+	__rte_trace_lib_cryptodev_sym_session_free;
+	__rte_trace_lib_cryptodev_asym_session_free;
+	__rte_trace_lib_cryptodev_sym_session_init;
+	__rte_trace_lib_cryptodev_asym_session_init;
+	__rte_trace_lib_cryptodev_sym_session_clear;
+	__rte_trace_lib_cryptodev_asym_session_clear;
+	__rte_trace_lib_cryptodev_dequeue_burst;
+	__rte_trace_lib_cryptodev_enqueue_burst;
 };
lib/librte_cryptodev/rte_trace_cryptodev.h new file +133 -0

133 lines not on this page · raw message

lib/librte_cryptodev/rte_trace_cryptodev_fp.h new file +34 -0
new file mode 100644
index 000000000..6fc7b24b0
@@ -0,0 +1,34 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(C) 2020 Marvell International Ltd.
+ */
+
+#ifndef _RTE_TRACE_CRYPTODEV_FP_H_
+#define _RTE_TRACE_CRYPTODEV_FP_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <rte_trace.h>
+
+RTE_TRACE_POINT_FP(
+	rte_trace_lib_cryptodev_enqueue_burst,
+	RTE_TRACE_POINT_ARGS(uint8_t dev_id, uint16_t qp_id, void **ops,
+			     uint16_t nb_ops),
+	rte_trace_ctf_u8(dev_id); rte_trace_ctf_u16(qp_id);
+	rte_trace_ctf_ptr(ops); rte_trace_ctf_u16(nb_ops);
+)
+
+RTE_TRACE_POINT_FP(
+	rte_trace_lib_cryptodev_dequeue_burst,
+	RTE_TRACE_POINT_ARGS(uint8_t dev_id, uint16_t qp_id, void **ops,
+			     uint16_t nb_ops),
+	rte_trace_ctf_u8(dev_id); rte_trace_ctf_u16(qp_id);
+	rte_trace_ctf_ptr(ops); rte_trace_ctf_u16(nb_ops);
+)
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _RTE_TRACE_CRYPTODEV_FP_H_ */
Signature · 1 line
2.25.1
#226 lore raw

PATCH v5 32/33 mempool: add tracepoints

In reply to [email protected]

From: Sunil Kumar Kori <[email protected]>

Add tracepoints at important and mandatory APIs for tracing support.

---
 lib/librte_mempool/Makefile                |   3 +
 lib/librte_mempool/mempool_trace_points.c  | 108 +++++++++++++++
 lib/librte_mempool/meson.build             |   5 +-
 lib/librte_mempool/rte_mempool.c           |  16 +++
 lib/librte_mempool/rte_mempool.h           |  13 ++
 lib/librte_mempool/rte_mempool_ops.c       |   7 +
 lib/librte_mempool/rte_mempool_version.map |  26 ++++
 lib/librte_mempool/rte_trace_mempool.h     | 148 +++++++++++++++++++++
 lib/librte_mempool/rte_trace_mempool_fp.h  | 102 ++++++++++++++
 9 files changed, 426 insertions(+), 2 deletions(-)
 create mode 100644 lib/librte_mempool/mempool_trace_points.c
 create mode 100644 lib/librte_mempool/rte_trace_mempool.h
 create mode 100644 lib/librte_mempool/rte_trace_mempool_fp.h
lib/librte_mempool/Makefile +3 -0
index 84aae6604..172e7bf50 100644
@@ -15,7 +15,10 @@ EXPORT_MAP := rte_mempool_version.map
 SRCS-$(CONFIG_RTE_LIBRTE_MEMPOOL) +=  rte_mempool.c
 SRCS-$(CONFIG_RTE_LIBRTE_MEMPOOL) +=  rte_mempool_ops.c
 SRCS-$(CONFIG_RTE_LIBRTE_MEMPOOL) +=  rte_mempool_ops_default.c
+SRCS-$(CONFIG_RTE_LIBRTE_MEMPOOL) +=  mempool_trace_points.c
 # install includes
 SYMLINK-$(CONFIG_RTE_LIBRTE_MEMPOOL)-include := rte_mempool.h
+SYMLINK-$(CONFIG_RTE_LIBRTE_MEMPOOL)-include += rte_trace_mempool.h
+SYMLINK-$(CONFIG_RTE_LIBRTE_MEMPOOL)-include += rte_trace_mempool_fp.h
 
 include $(RTE_SDK)/mk/rte.lib.mk
lib/librte_mempool/mempool_trace_points.c new file +108 -0

108 lines not on this page · raw message

lib/librte_mempool/meson.build +3 -2
index 45e0cb7ea..3e8d64c51 100644
@@ -10,6 +10,7 @@ foreach flag: extra_flags
 endforeach
 
 sources = files('rte_mempool.c', 'rte_mempool_ops.c',
-		'rte_mempool_ops_default.c')
-headers = files('rte_mempool.h')
+		'rte_mempool_ops_default.c', 'mempool_trace_points.c')
+headers = files('rte_mempool.h', 'rte_trace_mempool.h',
+		'rte_trace_mempool_fp.h')
 deps += ['ring']
lib/librte_mempool/rte_mempool.c +16 -0
index 712c839a0..6cc0c7209 100644
@@ -33,6 +33,7 @@
 #include <rte_tailq.h>
 
 #include "rte_mempool.h"
+#include "rte_trace_mempool.h"
 
 TAILQ_HEAD(rte_mempool_list, rte_tailq_entry);
 
@@ -377,6 +378,8 @@ rte_mempool_populate_iova(struct rte_mempool *mp, char *vaddr,
 	if (ret == 0)
 		ret = -EINVAL;
 
+	rte_trace_lib_mempool_populate_iova(mp, vaddr, iova, len, free_cb,
+					    opaque);
 	return ret;
 }
 
@@ -444,6 +447,8 @@ rte_mempool_populate_virt(struct rte_mempool *mp, char *addr,
 	if (cnt == 0)
 		return -EINVAL;
 
+	rte_trace_lib_mempool_populate_virt(mp, addr, len, pg_sz, free_cb,
+					    opaque);
 	return cnt;
 
  fail:
@@ -473,6 +478,7 @@ rte_mempool_get_page_size(struct rte_mempool *mp, size_t *pg_sz)
 	else
 		*pg_sz = getpagesize();
 
+	rte_trace_lib_mempool_get_page_size(mp, *pg_sz);
 	return 0;
 }
 
@@ -611,6 +617,7 @@ rte_mempool_populate_default(struct rte_mempool *mp)
 		}
 	}
 
+	rte_trace_lib_mempool_populate_default(mp);
 	return mp->size;
 
  fail:
@@ -701,6 +708,7 @@ rte_mempool_populate_anon(struct rte_mempool *mp)
 		goto fail;
 	}
 
+	rte_trace_lib_mempool_populate_anon(mp);
 	return mp->populated_size;
 
  fail:
@@ -732,6 +740,7 @@ rte_mempool_free(struct rte_mempool *mp)
 	}
 	rte_mcfg_tailq_write_unlock();
 
+	rte_trace_lib_mempool_free(mp);
 	rte_mempool_free_memchunks(mp);
 	rte_mempool_ops_free(mp);
 	rte_memzone_free(mp->mz);
@@ -770,6 +779,7 @@ rte_mempool_cache_create(uint32_t size, int socket_id)
 
 	mempool_cache_init(cache, size);
 
+	rte_trace_lib_mempool_cache_create(size, socket_id, cache);
 	return cache;
 }
 
@@ -781,6 +791,7 @@ rte_mempool_cache_create(uint32_t size, int socket_id)
 void
 rte_mempool_cache_free(struct rte_mempool_cache *cache)
 {
+	rte_trace_lib_mempool_cache_free(cache);
 	rte_free(cache);
 }
 
@@ -911,6 +922,8 @@ rte_mempool_create_empty(const char *name, unsigned n, unsigned elt_size,
 	rte_mcfg_tailq_write_unlock();
 	rte_mcfg_mempool_write_unlock();
 
+	rte_trace_lib_mempool_create_empty(name, n, elt_size, cache_size,
+					   private_data_size, flags, mp);
 	return mp;
 
 exit_unlock:
@@ -963,6 +976,9 @@ rte_mempool_create(const char *name, unsigned n, unsigned elt_size,
 	if (obj_init)
 		rte_mempool_obj_iter(mp, obj_init, obj_init_arg);
 
+	rte_trace_lib_mempool_create(name, n, elt_size, cache_size,
+				     private_data_size, mp_init, mp_init_arg,
+				     obj_init, obj_init_arg, flags, mp);
 	return mp;
 
  fail:
lib/librte_mempool/rte_mempool.h +13 -0
index c90cf3146..2d0b5ad46 100644
@@ -51,6 +51,8 @@
 #include <rte_memcpy.h>
 #include <rte_common.h>
 
+#include "rte_trace_mempool_fp.h"
+
 #ifdef __cplusplus
 extern "C" {
 #endif
@@ -736,6 +738,7 @@ rte_mempool_ops_dequeue_bulk(struct rte_mempool *mp,
 {
 	struct rte_mempool_ops *ops;
 
+	rte_trace_lib_mempool_ops_dequeue_bulk(mp, obj_table, n);
 	ops = rte_mempool_get_ops(mp->ops_index);
 	return ops->dequeue(mp, obj_table, n);
 }
@@ -761,6 +764,7 @@ rte_mempool_ops_dequeue_contig_blocks(struct rte_mempool *mp,
 
 	ops = rte_mempool_get_ops(mp->ops_index);
 	RTE_ASSERT(ops->dequeue_contig_blocks != NULL);
+	rte_trace_lib_mempool_ops_dequeue_contig_blocks(mp, first_obj_table, n);
 	return ops->dequeue_contig_blocks(mp, first_obj_table, n);
 }
 
@@ -783,6 +787,7 @@ rte_mempool_ops_enqueue_bulk(struct rte_mempool *mp, void * const *obj_table,
 {
 	struct rte_mempool_ops *ops;
 
+	rte_trace_lib_mempool_ops_enqueue_bulk(mp, obj_table, n);
 	ops = rte_mempool_get_ops(mp->ops_index);
 	return ops->enqueue(mp, obj_table, n);
 }
@@ -1264,6 +1269,8 @@ rte_mempool_default_cache(struct rte_mempool *mp, unsigned lcore_id)
 	if (lcore_id >= RTE_MAX_LCORE)
 		return NULL;
 
+	rte_trace_lib_mempool_default_cache(mp, lcore_id,
+					    &mp->local_cache[lcore_id]);
 	return &mp->local_cache[lcore_id];
 }
 
@@ -1283,6 +1290,7 @@ rte_mempool_cache_flush(struct rte_mempool_cache *cache,
 		cache = rte_mempool_default_cache(mp, rte_lcore_id());
 	if (cache == NULL || cache->len == 0)
 		return;
+	rte_trace_lib_mempool_cache_flush(cache, mp);
 	rte_mempool_ops_enqueue_bulk(mp, cache->objs, cache->len);
 	cache->len = 0;
 }
@@ -1362,6 +1370,7 @@ static __rte_always_inline void
 rte_mempool_generic_put(struct rte_mempool *mp, void * const *obj_table,
 			unsigned int n, struct rte_mempool_cache *cache)
 {
+	rte_trace_lib_mempool_generic_put(mp, obj_table, n, cache);
 	__mempool_check_cookies(mp, obj_table, n, 0);
 	__mempool_generic_put(mp, obj_table, n, cache);
 }
@@ -1386,6 +1395,7 @@ rte_mempool_put_bulk(struct rte_mempool *mp, void * const *obj_table,
 {
 	struct rte_mempool_cache *cache;
 	cache = rte_mempool_default_cache(mp, rte_lcore_id());
+	rte_trace_lib_mempool_put_bulk(mp, obj_table, n, cache);
 	rte_mempool_generic_put(mp, obj_table, n, cache);
 }
 
@@ -1507,6 +1517,7 @@ rte_mempool_generic_get(struct rte_mempool *mp, void **obj_table,
 	ret = __mempool_generic_get(mp, obj_table, n, cache);
 	if (ret == 0)
 		__mempool_check_cookies(mp, obj_table, n, 1);
+	rte_trace_lib_mempool_generic_get(mp, obj_table, n, cache);
 	return ret;
 }
 
@@ -1537,6 +1548,7 @@ rte_mempool_get_bulk(struct rte_mempool *mp, void **obj_table, unsigned int n)
 {
 	struct rte_mempool_cache *cache;
 	cache = rte_mempool_default_cache(mp, rte_lcore_id());
+	rte_trace_lib_mempool_get_bulk(mp, obj_table, n, cache);
 	return rte_mempool_generic_get(mp, obj_table, n, cache);
 }
 
@@ -1606,6 +1618,7 @@ rte_mempool_get_contig_blocks(struct rte_mempool *mp,
 		__MEMPOOL_CONTIG_BLOCKS_STAT_ADD(mp, get_fail, n);
 	}
 
+	rte_trace_lib_mempool_get_contig_blocks(mp, first_obj_table, n);
 	return ret;
 }
 
lib/librte_mempool/rte_mempool_ops.c +7 -0
index 22c5251eb..c1b24a1f3 100644
@@ -11,6 +11,8 @@
 #include <rte_errno.h>
 #include <rte_dev.h>
 
+#include "rte_trace_mempool.h"
+
 /* indirect jump table to support external memory pools. */
 struct rte_mempool_ops_table rte_mempool_ops_table = {
 	.sl =  RTE_SPINLOCK_INITIALIZER,
@@ -74,6 +76,7 @@ rte_mempool_ops_alloc(struct rte_mempool *mp)
 {
 	struct rte_mempool_ops *ops;
 
+	rte_trace_lib_mempool_ops_alloc(mp);
 	ops = rte_mempool_get_ops(mp->ops_index);
 	return ops->alloc(mp);
 }
@@ -84,6 +87,7 @@ rte_mempool_ops_free(struct rte_mempool *mp)
 {
 	struct rte_mempool_ops *ops;
 
+	rte_trace_lib_mempool_ops_free(mp);
 	ops = rte_mempool_get_ops(mp->ops_index);
 	if (ops->free == NULL)
 		return;
@@ -130,6 +134,8 @@ rte_mempool_ops_populate(struct rte_mempool *mp, unsigned int max_objs,
 
 	ops = rte_mempool_get_ops(mp->ops_index);
 
+	rte_trace_lib_mempool_ops_populate(mp, max_objs, vaddr, iova, len,
+					   obj_cb, obj_cb_arg);
 	if (ops->populate == NULL)
 		return rte_mempool_op_populate_default(mp, max_objs, vaddr,
 						       iova, len, obj_cb,
@@ -178,5 +184,6 @@ rte_mempool_set_ops_byname(struct rte_mempool *mp, const char *name,
 
 	mp->ops_index = i;
 	mp->pool_config = pool_config;
+	rte_trace_lib_mempool_set_ops_byname(mp, name, pool_config);
 	return 0;
 }
lib/librte_mempool/rte_mempool_version.map +26 -0
index d002dfc46..2d2594635 100644
@@ -45,4 +45,30 @@ EXPERIMENTAL {
 	rte_mempool_get_page_size;
 	rte_mempool_op_calc_mem_size_helper;
 	rte_mempool_op_populate_helper;
+
+	# added in 20.05
+	__rte_trace_lib_mempool_ops_dequeue_bulk;
+	__rte_trace_lib_mempool_ops_dequeue_contig_blocks;
+	__rte_trace_lib_mempool_ops_enqueue_bulk;
+	__rte_trace_lib_mempool_generic_put;
+	__rte_trace_lib_mempool_put_bulk;
+	__rte_trace_lib_mempool_generic_get;
+	__rte_trace_lib_mempool_get_bulk;
+	__rte_trace_lib_mempool_get_contig_blocks;
+	__rte_trace_lib_mempool_create;
+	__rte_trace_lib_mempool_create_empty;
+	__rte_trace_lib_mempool_free;
+	__rte_trace_lib_mempool_populate_iova;
+	__rte_trace_lib_mempool_populate_virt;
+	__rte_trace_lib_mempool_populate_default;
+	__rte_trace_lib_mempool_populate_anon;
+	__rte_trace_lib_mempool_cache_create;
+	__rte_trace_lib_mempool_cache_free;
+	__rte_trace_lib_mempool_default_cache;
+	__rte_trace_lib_mempool_get_page_size;
+	__rte_trace_lib_mempool_cache_flush;
+	__rte_trace_lib_mempool_ops_populate;
+	__rte_trace_lib_mempool_ops_alloc;
+	__rte_trace_lib_mempool_ops_free;
+	__rte_trace_lib_mempool_set_ops_byname;
 };
lib/librte_mempool/rte_trace_mempool.h new file +148 -0

148 lines not on this page · raw message

lib/librte_mempool/rte_trace_mempool_fp.h new file +102 -0

102 lines not on this page · raw message

Signature · 1 line
2.25.1
#227 lore raw

PATCH v5 33/33 doc: add trace library guide

In reply to [email protected]

From: Jerin Jacob <[email protected]>

Add programmar's guide for trace library support.

---
 MAINTAINERS                            |   1 +
 doc/guides/prog_guide/index.rst        |   1 +
 doc/guides/prog_guide/trace_lib.rst    | 334 +++++++++++++++++++++++++
 doc/guides/rel_notes/release_20_05.rst |   9 +
 4 files changed, 345 insertions(+)
 create mode 100644 doc/guides/prog_guide/trace_lib.rst
MAINTAINERS +1 -0
index 49a97e592..b15062270 100644
@@ -200,6 +200,7 @@ M: Sunil Kumar Kori <[email protected]>
 F: lib/librte_eal/include/rte_trace*.h
 F: lib/librte_eal/common/eal_common_trace*.c
 F: lib/librte_eal/common/eal_trace.h
+F: doc/guides/prog_guide/trace_lib.rst
 
 Memory Allocation
 M: Anatoly Burakov <[email protected]>
doc/guides/prog_guide/index.rst +1 -0
index fb250abf5..0daa08acc 100644
@@ -35,6 +35,7 @@ Programmer's Guide
     lpm_lib
     lpm6_lib
     flow_classify_lib
+    trace_lib
     packet_distrib_lib
     reorder_lib
     ip_fragment_reassembly_lib
doc/guides/prog_guide/trace_lib.rst new file +334 -0

334 lines not on this page · raw message

doc/guides/rel_notes/release_20_05.rst +9 -0
index 9059f9563..9af0eaaed 100644
@@ -68,6 +68,15 @@ New Features
   meson.build in app, lib and drivers instead enable ALLOW_EXPERIMENTAL_API
   flag globally.
 
+* **Added Trace Library and Tracepoints**
+
+  A native implementation of ``common trace format(CTF)`` based trace library added
+  to provide the ability to add tracepoints in application/library to get runtime
+  trace/debug information for control and fast APIs with minimum impact on
+  fast path performance. Typical trace overhead is ~20 cycles and instrumentation
+  overhead is 1 cycle. Added tracepoints in ``EAL``, ``ethdev``, ``cryptodev``,
+  ``eventdev`` and ``mempool`` libraries for important functions.
+
 
 Removed Items
 -------------
Signature · 1 line
2.25.1
#228 lore raw

Re: [dpdk-dev] [PATCH v5 33/33] doc: add trace library guide

Quoted 51 lines · On Mon, Apr 13, 2020 at 5:04 PM <[email protected]> wrote:
doc/guides/prog_guide/trace_lib.rst new file +45 -0
new file mode 100644
index 000000000..17f927584
@@ -0,0 +1,334 @@
+..  SPDX-License-Identifier: BSD-3-Clause
+    Copyright(C) 2020 Marvell International Ltd.
+
+Trace Library
+=============
+
+Overview
+--------
+
+*Tracing* is a technique used to understand what goes on in a running software
+system. The software used for tracing is called a *tracer*, which is conceptually
+similar to a tape recorder. When recording, specific instrumentation points
+placed in the software source code generate events that are saved on a giant
+tape: a trace file. The trace file then later can be opened in *trace viewers* to
+visualize and analyze the trace events with timestamps and multi-core views.
+Such a mechanism will be useful for resolving a wide range of problems such as
+multi-core synchronization issues, latency measurements, finding out the
+post analyses information like CPU idle time, etc that would otherwise be
+extremely challenging.
+
+Tracing is often compared to *logging*. However, tracers and loggers are two
+different tools, serving two different purposes. Tracers are designed to record
+much lower-level events that occur much more frequently than log messages, often
+in the range of thousands per second, with very little execution overhead.
+Logging is more appropriate for a very high-level analysis of less frequent
+events: user accesses, exceptional conditions (errors and warnings, for
+example), database transactions, instant messaging communications, and such.
+Simply put, logging is one of the many use cases that can be satisfied with
+tracing.
+
+DPDK tracing library features
+-----------------------------
+
+- A framework to add tracepoints in control and fast APIs with minimum impact on
+  performance. Typical trace overhead is ~20 cycles and instrumentation
+  overhead is 1 cycle.
+- Enable and disable the tracepoints at runtime.
+- Save the trace buffer to the filesystem at any point in time.
+- Supports ``overwrite`` and ``discard`` trace mode operations.
+- String-based tracepoint object lookup.
+- Enable and disable a set of tracepoints based on regular expression and/or
+  globbing.
+- Generate trace in ``common trace format(CTF)``. ``CTF`` is an open-source trace
+  format and it is compatible with ``LTTng``.
+  For detailed information, refer `Common Trace Format <https://diamon.org/ctf/>`_

doc/guides/prog_guide/trace_lib.rst line 55

Quoted 10 lines
doc/guides/prog_guide/trace_lib.rst new file +10 -0
+
+How to add a tracepoint?
+------------------------
+
+This section steps you through the details of adding a simple tracepoint.
+
+.. _create_provider_header_file:
+
+Create the tracepoint provider header file
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

General comment on this file.
Section titles should be separated from the rest with a new line.

Signature · 1 line
David Marchand
#229 lore raw
In reply to [email protected]

Thanks Jerin for this new version.

New round of comments.

- What do you think of splitting the API in two headers, thinking about who will use them?
* rte_trace.h (rte_trace_ prefix for all functions/macros/types) for users of the trace framework that want to
* get the status of the whole trace subsystem,
* enable/disable tracepoints by pattern/regexp,
* dump the current events,
* rte_tracepoint.h (rte_tracepoint_ prefix for all functions/macros/types) for developers that want to add tracepoints to their code

- Having functions "is_disabled" has little value when a "is_enabled" counterpart exists.

- What is the value of having a _public_ rte_trace_is_invalid() ? A final user would need to lookup by name to get a trace descriptor and we should hope that such a lookup returns a valid descriptor :-). A developer would already have the descriptor hook point in his own
code: by construction, if the tracepoint is registered, then the descriptor is valid, else, it is unknown.

- I did not get why we put the trace descriptors in a specific elf section, can you explain the benefits?

- I can see no protection on the tracepoint list. Could we have issues with control/application threads that dpdk does not control, dynamic loading of libraries.. ?

- Following comment on v4 and the removal of the mode per tracepoint api, don't we need to put the current select mode in each tracepoint descriptor when registering a trace point ?

Signature · 1 line
David Marchand
#230 lore raw

15/04/2020 15:26, David Marchand:

Quoted 10 lines

- What do you think of splitting the API in two headers, thinking about who will use them?
* rte_trace.h (rte_trace_ prefix for all functions/macros/types) for users of the trace framework that want to
* get the status of the whole trace subsystem,
* enable/disable tracepoints by pattern/regexp,
* dump the current events,
* rte_tracepoint.h (rte_tracepoint_ prefix for all functions/macros/types) for developers that want to add tracepoints to their code

I like this idea.

Quoted 2 lines

- Having functions "is_disabled" has little value when a "is_enabled" counterpart exists.

Yes, which one do we choose? is_enabled?

Quoted 20 lines

- What is the value of having a _public_ rte_trace_is_invalid() ? A final user would need to lookup by name to get a trace descriptor and we should hope that such a lookup returns a valid descriptor :-). A developer would already have the descriptor hook point in his own
code: by construction, if the tracepoint is registered, then the descriptor is valid, else, it is unknown.

- I did not get why we put the trace descriptors in a specific elf section, can you explain the benefits?

- I can see no protection on the tracepoint list. Could we have issues with control/application threads that dpdk does not control, dynamic loading of libraries.. ?

- Following comment on v4 and the removal of the mode per tracepoint api, don't we need to put the current select mode in each tracepoint descriptor when registering a trace point ?

#231 lore raw
In reply to David Marchand
Quoted 3 lines · David Marchand

Thanks Jerin for this new version.
New round of comments.

Thanks for the review.

Quoted 11 lines

- What do you think of splitting the API in two headers, thinking about who will use them?
* rte_trace.h (rte_trace_ prefix for all functions/macros/types) for users of the trace framework that want to
* get the status of the whole trace subsystem,
* enable/disable tracepoints by pattern/regexp,
* dump the current events,
* rte_tracepoint.h (rte_tracepoint_ prefix for all functions/macros/types) for developers that want to add tracepoints to their code

# Initially, I thought of doing the same.
Later realized that some of the definitions such as following

1)
/** The trace object. The trace APIs are based on this opaque object. */ typedef uint64_t rte_trace_t;

2) rte_trace_fp_is_enabled()

Used in both the header file. i.e rte_tracepoint.h needed to include rte_trace.h.
If that's is the case, I don't see any value.

# Regarding the API change the following to rte_tracepoint_*

#define rte_trace_ctf_u64(val)
#define rte_trace_ctf_i64(val)
#define rte_trace_ctf_u32(val)
#define rte_trace_ctf_i32(val)
#define rte_trace_ctf_u16(val)
#define rte_trace_ctf_i16(val)
#define rte_trace_ctf_u8(val)
#define rte_trace_ctf_i8(val)
#define rte_trace_ctf_int(val)
#define rte_trace_ctf_long(val)
#define rte_trace_ctf_float(val)
#define rte_trace_ctf_double(val)
#define rte_trace_ctf_ptr(val)
#define rte_trace_ctf_string(val)

It could be done. Just concerned the length of API will be more. like rte_trace_point_ctf_u64
If you have a strong opinion on this then I can change it.

Quoted 4 lines

- Having functions "is_disabled" has little value when a "is_enabled" counterpart exists.

I thought so. I like to have "is_enabled". But in the code, "is_disabled" has been used more.
Then finally added both in API. Please share your preference, I will do the same in v6.

Quoted 8 lines

- What is the value of having a _public_ rte_trace_is_invalid() ? A final user would need to lookup by name to get a trace descriptor and we should hope that such a lookup returns a valid descriptor :-). A developer would already have the descriptor hook point in his own
code: by construction, if the tracepoint is registered, then the descriptor is valid, else, it is unknown.

Yep. I will make rte_trace_is_invalid as internal trace_is_invalid() API.

Quoted 4 lines

- I did not get why we put the trace descriptors in a specific elf section, can you explain the benefits?

Those are global variables of size 8B. Since it is used in fastpath. I just want all of them to same area for
1) It is a mostly a read-only area. Not mix with other "write" global variables
2) Chances that same subsystem FP variables comes same fastpath cache line. In short, We will be more predictable performance number from build to build i.e not depended on other global variables from build to build.

Quoted 4 lines

- I can see no protection on the tracepoint list. Could we have issues with control/application threads that dpdk does not control, dynamic loading of libraries.. ?

Based on my understanding, all constructors in the .so file should be called in eal_plugins_init()
one by one. So there is no synchronization issue. eal_trace_init() which is called after
eal_plugins_init(). So all the .so files with constructor should be called in eal_plugins_init()
be it DPDK shared lib or non DPDK shared lib. rte_log_register() does the similar thing.

Quoted 5 lines

- Following comment on v4 and the removal of the mode per tracepoint api, don't we need to put the current select mode in each tracepoint descriptor when registering a trace point ?

RTE_TRACE_POINT_REGISTER has only trace and name.
RTE_TRACE_POINT_REGISTER(trace, name)

Not sure why we need to add "mode" in the trace register.

Reason for adding in the descriptor we discussed last time.
---------------------------------------------------------------

Quoted 9 lines

In fastpath, I tried to avoid reading multiple control variables to improve performance.
i.e the tracepoint(uint64_t) has all control information. So it has given a feature to control mode per tracepoint.
I thought it may be useful. No strong option here.

If you think, it is not usefull and creates more problems, I will change to the following:

Quoted 6 lines

1) Remove int rte_trace_mode_set(rte_trace_t trace, enum rte_trace_mode_e mode);
2) Change
From:
void rte_trace_global_mode_set(enum rte_trace_mode_e mode);
to:
void rte_trace_mode_set(enum rte_trace_mode_e mode);

Yes, you can keep the information in the tracepoint descriptor and expose a single api that impacts all tracepoints.
+1 for me.
--------------------------------------------------------------------

Quoted 5 lines

--
David Marchand

#232 lore raw
Quoted 11 lines · Jerin Jacob
Quoted 10 lines

- What do you think of splitting the API in two headers, thinking about who will use them?
* rte_trace.h (rte_trace_ prefix for all functions/macros/types) for users of the trace framework that want to
* get the status of the whole trace subsystem,
* enable/disable tracepoints by pattern/regexp,
* dump the current events,
* rte_tracepoint.h (rte_tracepoint_ prefix for all functions/macros/types) for developers that want to add tracepoints to their code

Quoted 6 lines

# Initially, I thought of doing the same.
Later realized that some of the definitions such as following

1)
/** The trace object. The trace APIs are based on this opaque object. */ typedef uint64_t rte_trace_t;

As a user, I would ask the trace framework to enable tracepoints by calling rte_trace_pattern()/rte_trace_regexp().
This does not require the tracepoint descriptor to be exposed in rte_trace.h.

If some application wants to store/manipulate the descriptors, then it will rely on rte_tracepoint.h where the rte_tracepoint_t opaque object and API are:
- rte_tracepoint_lookup (currently named rte_trace_by_name)
- rte_tracepoint_enable
- rte_tracepoint_disable
- rte_tracepoint_is_invalid (currently named rte_trace_id_is_invalid, should be private, as discussed)
- rte_tracepoint_is_enabled
- RTE_TRACEPOINT/_FP macros
- rte_tracepoint_register etc...

Quoted 2 lines

2) rte_trace_fp_is_enabled()

As a user, what information would this give me?
"Some fastpath tracepoints are not available"

Moving to rte_tracepoint.h is enough to me.

Quoted 11 lines

# Regarding the API change the following to rte_tracepoint_*

#define rte_trace_ctf_u64(val)
#define rte_trace_ctf_i64(val)
#define rte_trace_ctf_u32(val)
#define rte_trace_ctf_i32(val)
#define rte_trace_ctf_u16(val)
#define rte_trace_ctf_i16(val)
#define rte_trace_ctf_u8(val)
#define rte_trace_ctf_i8(val)
#define rte_trace_ctf_int(val)

Quoted 8 lines

#define rte_trace_ctf_long(val)
#define rte_trace_ctf_float(val)
#define rte_trace_ctf_double(val)
#define rte_trace_ctf_ptr(val)
#define rte_trace_ctf_string(val)
It could be done. Just concerned the length of API will be more. like rte_trace_point_ctf_u64
If you have a strong opinion on this then I can change it.

I don't like mentioning ctf here.

I went with a git grep -l rte_trace_ctf |xargs sed -i -e 's/rte_trace_ctf_/rte_tracepoint_emit_/g'.
If we keep one rte_tracepoint_emit_ per line in tracepoint declarations, the length is not an issue by looking at how they are used.

Example:
RTE_TRACEPOINT(

        rte_trace_lib_eal_intr_disable,
        RTE_TRACEPOINT_ARGS(const struct rte_intr_handle *handle, int rc),
        rte_tracepoint_emit_int(rc);
        rte_tracepoint_emit_int(handle->vfio_dev_fd);
        rte_tracepoint_emit_int(handle->fd);
        rte_tracepoint_emit_int(handle->type);
        rte_tracepoint_emit_u32(handle->max_intr);
        rte_tracepoint_emit_u32(handle->nb_efd);

)

Besides, we don't need to define all those rte_tracepoint_emit_(u|i)(8|16|32|64) helpers in rte_tracepoint_provider.h and rte_tracepoint_register.h.
If we define a helper rte_tracepoint_emit_data(type, in) in rte_tracepoint.h, then the "provider" and "register" headers must only define how to emit a header (generic and fp cases), then rte_tracepoint_emit_data and rte_tracepoint_emit_string.

Quoted 7 lines
Quoted 2 lines

- Having functions "is_disabled" has little value when a "is_enabled" counterpart exists.

I thought so. I like to have "is_enabled". But in the code, "is_disabled" has been used more.
Then finally added both in API. Please share your preference, I will do the same in v6.

is_enabled is enough.

Quoted 9 lines
Quoted 2 lines

- I did not get why we put the trace descriptors in a specific elf section, can you explain the benefits?

Those are global variables of size 8B. Since it is used in fastpath. I just want all of them to same area for
1) It is a mostly a read-only area. Not mix with other "write" global variables
2) Chances that same subsystem FP variables comes same fastpath cache line. In short, We will be more predictable performance number from build to build i.e not depended on other global variables from build to build.

Ok, thanks for the explanation.
It is worth a few words in the associated commitlog for posterity.

Quoted 4 lines
Quoted 3 lines

- I can see no protection on the tracepoint list. Could we have issues with control/application threads that dpdk does not control, dynamic loading of libraries.. ?

Quoted 8 lines

Based on my understanding, all constructors in the .so file should be called in eal_plugins_init()
one by one. So there is no synchronization issue. eal_trace_init() which is called after
eal_plugins_init(). So all the .so files with constructor should be called in eal_plugins_init()
be it DPDK shared lib or non DPDK shared lib. rte_log_register() does the similar thing.

As long as we register in constructor, this is ok. Time will tell us if users want to use this in a different way.

Quoted 8 lines
Quoted 3 lines

- Following comment on v4 and the removal of the mode per tracepoint api, don't we need to put the current select mode in each tracepoint descriptor when registering a trace point ?

RTE_TRACE_POINT_REGISTER has only trace and name.
RTE_TRACE_POINT_REGISTER(trace, name)

Not sure why we need to add "mode" in the trace register.

I thought of registers happening out of a constructor. But as long as we are in constructors and thanks to the eal_trace_init() after plugin load, the mode is set in all descriptors.
So we are fine.

Signature · 1 line
David Marchand
#233 lore raw
Quoted 25 lines · David Marchand
Quoted 11 lines · Jerin Jacob
Quoted 10 lines

- What do you think of splitting the API in two headers, thinking about who will use them?
* rte_trace.h (rte_trace_ prefix for all functions/macros/types) for users of the trace framework that want to
* get the status of the whole trace subsystem,
* enable/disable tracepoints by pattern/regexp,
* dump the current events,
* rte_tracepoint.h (rte_tracepoint_ prefix for all functions/macros/types) for developers that want to add tracepoints to their code

Quoted 6 lines

# Initially, I thought of doing the same.
Later realized that some of the definitions such as following

1)
/** The trace object. The trace APIs are based on this opaque object. */ typedef uint64_t rte_trace_t;

As a user, I would ask the trace framework to enable tracepoints by calling rte_trace_pattern()/rte_trace_regexp().
This does not require the tracepoint descriptor to be exposed in rte_trace.h.

Quoted 11 lines

If some application wants to store/manipulate the descriptors, then it will rely on rte_tracepoint.h where the rte_tracepoint_t opaque object and API are:
- rte_tracepoint_lookup (currently named rte_trace_by_name)
- rte_tracepoint_enable
- rte_tracepoint_disable
- rte_tracepoint_is_invalid (currently named rte_trace_id_is_invalid, should be private, as discussed)
- rte_tracepoint_is_enabled
- RTE_TRACEPOINT/_FP macros
- rte_tracepoint_register etc...

From the prototype onwards, Myself shuffled abound multiple times on the API name to satisfying
names.

If you would like to classify based on the tracepoint object dependency to a new header file, it is fine.
Let's go the last round for API naming details.

I think, trace being the domain, IMO, it better to call the trace point API with rte_trace_point_*
and trace point object to rte_trace_point_t (vs rte_tracepoint_t)

I will summarise the public API and file name details. Let's finalize.

# rte_trace.h will have

rte_trace_global_is_enabled
rte_trace_mode_set
rte_trace_mode_get
rte_trace_pattern
rte_trace_regexp
rte_trace_save
rte_trace_metadata_dump
rte_trace_dump

# rte_trace_point.h will have all operation related to rte_trace_point_t object
# rte_trace_provider.h renamed rte_trace_point_provider.h
# rte_trace_register.h renamed to rte_trace_point_register.h
# rte_trace_eal.h renamed to rte_trace_point_eal.h
Quoted 9 lines
Quoted 4 lines

2) rte_trace_fp_is_enabled()

As a user, what information would this give me?
"Some fastpath tracepoints are not available"

Moving to rte_tracepoint.h is enough to me.

IMO, semantically not correct as we are splitting based on some definition.

How about,
1) Not expose this API
OR
2) rte_trace_point.h includes the rte_trace.h

Quoted 22 lines
Quoted 13 lines

# Regarding the API change the following to rte_tracepoint_*

#define rte_trace_ctf_u64(val)
#define rte_trace_ctf_i64(val)
#define rte_trace_ctf_u32(val)
#define rte_trace_ctf_i32(val)
#define rte_trace_ctf_u16(val)
#define rte_trace_ctf_i16(val)
#define rte_trace_ctf_u8(val)
#define rte_trace_ctf_i8(val)
#define rte_trace_ctf_int(val)

Quoted 8 lines

#define rte_trace_ctf_long(val)
#define rte_trace_ctf_float(val)
#define rte_trace_ctf_double(val)
#define rte_trace_ctf_ptr(val)
#define rte_trace_ctf_string(val)
It could be done. Just concerned the length of API will be more. like rte_trace_point_ctf_u64
If you have a strong opinion on this then I can change it.

Quoted 7 lines

I don't like mentioning ctf here.

I went with a git grep -l rte_trace_ctf |xargs sed -i -e 's/rte_trace_ctf_/rte_tracepoint_emit_/g'.
If we keep one rte_tracepoint_emit_ per line in tracepoint declarations, the length is not an issue by looking at how they are used.

OK to remove ctf to make it as rte_trace_point_emit_*. OK?

Quoted 14 lines

Example:
RTE_TRACEPOINT(

        rte_trace_lib_eal_intr_disable,
        RTE_TRACEPOINT_ARGS(const struct rte_intr_handle *handle, int rc),
        rte_tracepoint_emit_int(rc);
        rte_tracepoint_emit_int(handle->vfio_dev_fd);
        rte_tracepoint_emit_int(handle->fd);
        rte_tracepoint_emit_int(handle->type);
        rte_tracepoint_emit_u32(handle->max_intr);
        rte_tracepoint_emit_u32(handle->nb_efd);

)

Quoted 7 lines

Besides, we don't need to define all those rte_tracepoint_emit_(u|i)(8|16|32|64) helpers in rte_tracepoint_provider.h and rte_tracepoint_register.h.
If we define a helper rte_tracepoint_emit_data(type, in) in rte_tracepoint.h, then the "provider" and "register" headers must only define how to emit a header (generic and fp cases), then rte_tracepoint_emit_data and rte_tracepoint_emit_string.

The reason for rte_tracepoint_emit_(u|i)(8|16|32|64) to get compile
to check to correct time type used.
See:
rte_trace_point_emit_u32 defintion has RTE_BUILD_BUG_ON(sizeof(type) != sizeof(typeof(uint32_t)));

Quoted 11 lines
Quoted 9 lines
Quoted 4 lines

- Having functions "is_disabled" has little value when a "is_enabled" counterpart exists.

I thought so. I like to have "is_enabled". But in the code, "is_disabled" has been used more.
Then finally added both in API. Please share your preference, I will do the same in v6.

is_enabled is enough.

OK. I will remove is_disabled()

Quoted 12 lines
Quoted 11 lines
Quoted 4 lines

- I did not get why we put the trace descriptors in a specific elf section, can you explain the benefits?

Those are global variables of size 8B. Since it is used in fastpath. I just want all of them to same area for
1) It is a mostly a read-only area. Not mix with other "write" global variables
2) Chances that same subsystem FP variables comes same fastpath cache line. In short, We will be more predictable performance number from build to build i.e not depended on other global variables from build to build.

Quoted 2 lines

Ok, thanks for the explanation.
It is worth a few words in the associated commitlog for posterity.

OK. I add it in git commit.

Quoted 1 line
#234 lore raw

16/04/2020 18:08, Jerin Jacob:

Quoted 74 lines
Quoted 25 lines · David Marchand
Quoted 11 lines · Jerin Jacob
Quoted 10 lines

- What do you think of splitting the API in two headers, thinking about who will use them?
* rte_trace.h (rte_trace_ prefix for all functions/macros/types) for users of the trace framework that want to
* get the status of the whole trace subsystem,
* enable/disable tracepoints by pattern/regexp,
* dump the current events,
* rte_tracepoint.h (rte_tracepoint_ prefix for all functions/macros/types) for developers that want to add tracepoints to their code

Quoted 6 lines

# Initially, I thought of doing the same.
Later realized that some of the definitions such as following

1)
/** The trace object. The trace APIs are based on this opaque object. */ typedef uint64_t rte_trace_t;

As a user, I would ask the trace framework to enable tracepoints by calling rte_trace_pattern()/rte_trace_regexp().
This does not require the tracepoint descriptor to be exposed in rte_trace.h.

Quoted 11 lines

If some application wants to store/manipulate the descriptors, then it will rely on rte_tracepoint.h where the rte_tracepoint_t opaque object and API are:
- rte_tracepoint_lookup (currently named rte_trace_by_name)
- rte_tracepoint_enable
- rte_tracepoint_disable
- rte_tracepoint_is_invalid (currently named rte_trace_id_is_invalid, should be private, as discussed)
- rte_tracepoint_is_enabled
- RTE_TRACEPOINT/_FP macros
- rte_tracepoint_register etc...

From the prototype onwards, Myself shuffled abound multiple times on the API name to satisfying
names.

If you would like to classify based on the tracepoint object dependency to a new header file, it is fine.
Let's go the last round for API naming details.

I think, trace being the domain, IMO, it better to call the trace point API with rte_trace_point_*
and trace point object to rte_trace_point_t (vs rte_tracepoint_t)

I will summarise the public API and file name details. Let's finalize.

# rte_trace.h will have

rte_trace_global_is_enabled
rte_trace_mode_set
rte_trace_mode_get
rte_trace_pattern
rte_trace_regexp
rte_trace_save
rte_trace_metadata_dump
rte_trace_dump

# rte_trace_point.h will have all operation related to rte_trace_point_t object
# rte_trace_provider.h renamed rte_trace_point_provider.h
# rte_trace_register.h renamed to rte_trace_point_register.h
# rte_trace_eal.h renamed to rte_trace_point_eal.h
Quoted 3 lines
Quoted 3 lines
Quoted 8 lines
Quoted 6 lines
Quoted 1 line

2) rte_trace_fp_is_enabled()

As a user, what information would this give me?
"Some fastpath tracepoints are not available"

Moving to rte_tracepoint.h is enough to me.

IMO, semantically not correct as we are splitting based on some definition.

Semantically, rte_trace.h must be the API for simple users enabling traces, while rte_trace_point.h would be used by those adding traces.

Quoted 60 lines

How about,
1) Not expose this API
OR
2) rte_trace_point.h includes the rte_trace.h

Quoted 22 lines
Quoted 13 lines

# Regarding the API change the following to rte_tracepoint_*

#define rte_trace_ctf_u64(val)
#define rte_trace_ctf_i64(val)
#define rte_trace_ctf_u32(val)
#define rte_trace_ctf_i32(val)
#define rte_trace_ctf_u16(val)
#define rte_trace_ctf_i16(val)
#define rte_trace_ctf_u8(val)
#define rte_trace_ctf_i8(val)
#define rte_trace_ctf_int(val)

Quoted 8 lines

#define rte_trace_ctf_long(val)
#define rte_trace_ctf_float(val)
#define rte_trace_ctf_double(val)
#define rte_trace_ctf_ptr(val)
#define rte_trace_ctf_string(val)
It could be done. Just concerned the length of API will be more. like rte_trace_point_ctf_u64
If you have a strong opinion on this then I can change it.

Quoted 7 lines

I don't like mentioning ctf here.

I went with a git grep -l rte_trace_ctf |xargs sed -i -e 's/rte_trace_ctf_/rte_tracepoint_emit_/g'.
If we keep one rte_tracepoint_emit_ per line in tracepoint declarations, the length is not an issue by looking at how they are used.

OK to remove ctf to make it as rte_trace_point_emit_*. OK?

Quoted 14 lines

Example:
RTE_TRACEPOINT(

        rte_trace_lib_eal_intr_disable,
        RTE_TRACEPOINT_ARGS(const struct rte_intr_handle *handle, int rc),
        rte_tracepoint_emit_int(rc);
        rte_tracepoint_emit_int(handle->vfio_dev_fd);
        rte_tracepoint_emit_int(handle->fd);
        rte_tracepoint_emit_int(handle->type);
        rte_tracepoint_emit_u32(handle->max_intr);
        rte_tracepoint_emit_u32(handle->nb_efd);

)

Quoted 7 lines

Besides, we don't need to define all those rte_tracepoint_emit_(u|i)(8|16|32|64) helpers in rte_tracepoint_provider.h and rte_tracepoint_register.h.
If we define a helper rte_tracepoint_emit_data(type, in) in rte_tracepoint.h, then the "provider" and "register" headers must only define how to emit a header (generic and fp cases), then rte_tracepoint_emit_data and rte_tracepoint_emit_string.

Quoted 5 lines

The reason for rte_tracepoint_emit_(u|i)(8|16|32|64) to get compile
to check to correct time type used.
See:
rte_trace_point_emit_u32 defintion has RTE_BUILD_BUG_ON(sizeof(type) != sizeof(typeof(uint32_t)));

Is it possible to implement it with a common helper as David suggests?

#235 lore raw
Quoted 81 lines · Thomas Monjalon

16/04/2020 18:08, Jerin Jacob:

Quoted 79 lines
Quoted 25 lines · David Marchand
Quoted 11 lines · Jerin Jacob
Quoted 10 lines

- What do you think of splitting the API in two headers, thinking about who will use them?
* rte_trace.h (rte_trace_ prefix for all functions/macros/types) for users of the trace framework that want to
* get the status of the whole trace subsystem,
* enable/disable tracepoints by pattern/regexp,
* dump the current events,
* rte_tracepoint.h (rte_tracepoint_ prefix for all functions/macros/types) for developers that want to add tracepoints to their code

Quoted 6 lines

# Initially, I thought of doing the same.
Later realized that some of the definitions such as following

1)
/** The trace object. The trace APIs are based on this opaque object. */ typedef uint64_t rte_trace_t;

As a user, I would ask the trace framework to enable tracepoints by calling rte_trace_pattern()/rte_trace_regexp().
This does not require the tracepoint descriptor to be exposed in rte_trace.h.

Quoted 11 lines

If some application wants to store/manipulate the descriptors, then it will rely on rte_tracepoint.h where the rte_tracepoint_t opaque object and API are:
- rte_tracepoint_lookup (currently named rte_trace_by_name)
- rte_tracepoint_enable
- rte_tracepoint_disable
- rte_tracepoint_is_invalid (currently named rte_trace_id_is_invalid, should be private, as discussed)
- rte_tracepoint_is_enabled
- RTE_TRACEPOINT/_FP macros
- rte_tracepoint_register etc...

From the prototype onwards, Myself shuffled abound multiple times on the API name to satisfying
names.

If you would like to classify based on the tracepoint object dependency to a new header file, it is fine.
Let's go the last round for API naming details.

I think, trace being the domain, IMO, it better to call the trace point API with rte_trace_point_*
and trace point object to rte_trace_point_t (vs rte_tracepoint_t)

I will summarise the public API and file name details. Let's finalize.

# rte_trace.h will have

rte_trace_global_is_enabled
rte_trace_mode_set
rte_trace_mode_get
rte_trace_pattern
rte_trace_regexp
rte_trace_save
rte_trace_metadata_dump
rte_trace_dump

# rte_trace_point.h will have all operation related to rte_trace_point_t object
# rte_trace_provider.h renamed rte_trace_point_provider.h
# rte_trace_register.h renamed to rte_trace_point_register.h
# rte_trace_eal.h renamed to rte_trace_point_eal.h
Quoted 8 lines
Quoted 4 lines

2) rte_trace_fp_is_enabled()

As a user, what information would this give me?
"Some fastpath tracepoints are not available"

Quoted 6 lines
Quoted 3 lines
Quoted 1 line

Moving to rte_tracepoint.h is enough to me.

IMO, semantically not correct as we are splitting based on some definition.

Semantically, rte_trace.h must be the API for simple users enabling traces, while rte_trace_point.h would be used by those adding traces.

Yes. The problem is where will be the definition of rte_trace_fp_is_enabled() come?
It is used for both needs.

Quoted 62 lines
Quoted 62 lines

How about,
1) Not expose this API
OR
2) rte_trace_point.h includes the rte_trace.h

Quoted 22 lines
Quoted 13 lines

# Regarding the API change the following to rte_tracepoint_*

#define rte_trace_ctf_u64(val)
#define rte_trace_ctf_i64(val)
#define rte_trace_ctf_u32(val)
#define rte_trace_ctf_i32(val)
#define rte_trace_ctf_u16(val)
#define rte_trace_ctf_i16(val)
#define rte_trace_ctf_u8(val)
#define rte_trace_ctf_i8(val)
#define rte_trace_ctf_int(val)

Quoted 8 lines

#define rte_trace_ctf_long(val)
#define rte_trace_ctf_float(val)
#define rte_trace_ctf_double(val)
#define rte_trace_ctf_ptr(val)
#define rte_trace_ctf_string(val)
It could be done. Just concerned the length of API will be more. like rte_trace_point_ctf_u64
If you have a strong opinion on this then I can change it.

Quoted 7 lines

I don't like mentioning ctf here.

I went with a git grep -l rte_trace_ctf |xargs sed -i -e 's/rte_trace_ctf_/rte_tracepoint_emit_/g'.
If we keep one rte_tracepoint_emit_ per line in tracepoint declarations, the length is not an issue by looking at how they are used.

OK to remove ctf to make it as rte_trace_point_emit_*. OK?

Quoted 21 lines

Example:
RTE_TRACEPOINT(

        rte_trace_lib_eal_intr_disable,
        RTE_TRACEPOINT_ARGS(const struct rte_intr_handle *handle, int rc),
        rte_tracepoint_emit_int(rc);
        rte_tracepoint_emit_int(handle->vfio_dev_fd);
        rte_tracepoint_emit_int(handle->fd);
        rte_tracepoint_emit_int(handle->type);
        rte_tracepoint_emit_u32(handle->max_intr);
        rte_tracepoint_emit_u32(handle->nb_efd);

)

Besides, we don't need to define all those rte_tracepoint_emit_(u|i)(8|16|32|64) helpers in rte_tracepoint_provider.h and rte_tracepoint_register.h.
If we define a helper rte_tracepoint_emit_data(type, in) in rte_tracepoint.h, then the "provider" and "register" headers must only define how to emit a header (generic and fp cases), then rte_tracepoint_emit_data and rte_tracepoint_emit_string.

Quoted 7 lines
Quoted 5 lines

The reason for rte_tracepoint_emit_(u|i)(8|16|32|64) to get compile
to check to correct time type used.
See:
rte_trace_point_emit_u32 defintion has RTE_BUILD_BUG_ON(sizeof(type) != sizeof(typeof(uint32_t)));

Is it possible to implement it with a common helper as David suggests?

It is already present.

See.

#define __rte_trace_emit_datatype(in, type)\

do {\
        RTE_BUILD_BUG_ON(sizeof(type) != sizeof(typeof(in)));\
        __rte_trace_emit_ctf_field(sizeof(type), RTE_STR(in), RTE_STR(type));\
} while (0)

#define rte_trace_ctf_u64(in) __rte_trace_emit_datatype(in, uint64_t) #define rte_trace_ctf_i64(in) __rte_trace_emit_datatype(in, int64_t) #define rte_trace_ctf_u32(in) __rte_trace_emit_datatype(in, uint32_t) #define rte_trace_ctf_i32(in) __rte_trace_emit_datatype(in, int32_t) #define rte_trace_ctf_u16(in) __rte_trace_emit_datatype(in, uint16_t) #define rte_trace_ctf_i16(in) __rte_trace_emit_datatype(in, int16_t) #define rte_trace_ctf_u8(in) __rte_trace_emit_datatype(in, uint8_t) #define rte_trace_ctf_i8(in) __rte_trace_emit_datatype(in, int8_t) #define rte_trace_ctf_int(in) __rte_trace_emit_datatype(in, int32_t) #define rte_trace_ctf_long(in) __rte_trace_emit_datatype(in, long) #define rte_trace_ctf_float(in) __rte_trace_emit_datatype(in, float) #define rte_trace_ctf_double(in) __rte_trace_emit_datatype(in, double) #define rte_trace_ctf_ptr(in) __rte_trace_emit_datatype(in, uintptr_t)

Quoted 3 lines
#236 lore raw
In reply to Jerin Jacob

Hello Jerin,

Quoted 11 lines · Jerin Jacob

From the prototype onwards, Myself shuffled abound multiple times on the API name to satisfying
names.

If you would like to classify based on the tracepoint object dependency to a new header file, it is fine.
Let's go the last round for API naming details.

I think, trace being the domain, IMO, it better to call the trace point API with rte_trace_point_*
and trace point object to rte_trace_point_t (vs rte_tracepoint_t)

Ok, let's go with rte_trace_point_.

Quoted 5 lines

I will summarise the public API and file name details. Let's finalize.

# rte_trace.h will have

rte_trace_global_is_enabled

global_ does not make sense anymore.

Quoted 8 lines

rte_trace_mode_set
rte_trace_mode_get
rte_trace_pattern
rte_trace_regexp
rte_trace_save
rte_trace_metadata_dump
rte_trace_dump

Quoted 5 lines
# rte_trace_point.h will have all operation related to rte_trace_point_t object
# rte_trace_provider.h renamed rte_trace_point_provider.h
# rte_trace_register.h renamed to rte_trace_point_register.h
# rte_trace_eal.h renamed to rte_trace_point_eal.h

Ok.

Quoted 8 lines
Quoted 6 lines
Quoted 1 line

2) rte_trace_fp_is_enabled()

As a user, what information would this give me?
"Some fastpath tracepoints are not available"

Moving to rte_tracepoint.h is enough to me.

IMO, semantically not correct as we are splitting based on some definition.

What is rte_trace_fp_is_enabled() supposed to do? "Test if the trace datapath compile-time option is enabled."

One implication is that dpdk must be compiled with RTE_ENABLE_TRACE_FP enabled for users to make use of fp tracepoints later.
It would impose restrictions to final users when they did not compile the dpdk package themselves.

Quoted 7 lines

How about,
1) Not expose this API
OR
2) rte_trace_point.h includes the rte_trace.h

My vote is 1).

On how to do without it, this should be enough in rte_trace_point_provider.h:

#ifdef RTE_ENABLE_TRACE_FP
#define __rte_trace_emit_header_fp(t) \

do { \
        RTE_SET_USED(t); \
        return; \
} while (0)
#else
#define __rte_trace_emit_header_fp(t) \
        __rte_trace_emit_header(t) \

#endif

This way, the user can choose where he enables fp tracepoints in his code by placing a #undef/#define RTE_ENABLE_TRACE_FP before including the tracepoints headers.

Quoted 22 lines
Quoted 22 lines
Quoted 11 lines

# Regarding the API change the following to rte_tracepoint_*

#define rte_trace_ctf_u64(val)
#define rte_trace_ctf_i64(val)
#define rte_trace_ctf_u32(val)
#define rte_trace_ctf_i32(val)
#define rte_trace_ctf_u16(val)
#define rte_trace_ctf_i16(val)
#define rte_trace_ctf_u8(val)
#define rte_trace_ctf_i8(val)
#define rte_trace_ctf_int(val)

Quoted 8 lines

#define rte_trace_ctf_long(val)
#define rte_trace_ctf_float(val)
#define rte_trace_ctf_double(val)
#define rte_trace_ctf_ptr(val)
#define rte_trace_ctf_string(val)
It could be done. Just concerned the length of API will be more. like rte_trace_point_ctf_u64
If you have a strong opinion on this then I can change it.

I don't like mentioning ctf here.

Quoted 7 lines
Quoted 5 lines

I went with a git grep -l rte_trace_ctf |xargs sed -i -e 's/rte_trace_ctf_/rte_tracepoint_emit_/g'.
If we keep one rte_tracepoint_emit_ per line in tracepoint declarations, the length is not an issue by looking at how they are used.

OK to remove ctf to make it as rte_trace_point_emit_*. OK?

Ok.

Quoted 15 lines
Quoted 12 lines

Example:
RTE_TRACEPOINT(

        rte_trace_lib_eal_intr_disable,
        RTE_TRACEPOINT_ARGS(const struct rte_intr_handle *handle, int rc),
        rte_tracepoint_emit_int(rc);
        rte_tracepoint_emit_int(handle->vfio_dev_fd);
        rte_tracepoint_emit_int(handle->fd);
        rte_tracepoint_emit_int(handle->type);
        rte_tracepoint_emit_u32(handle->max_intr);
        rte_tracepoint_emit_u32(handle->nb_efd);
Quoted 3 lines

)

Reading again what I wrote.

Quoted 3 lines
Quoted 3 lines

Besides, we don't need to define all those rte_tracepoint_emit_(u|i)(8|16|32|64) helpers in rte_tracepoint_provider.h and rte_tracepoint_register.h.

This part still stands.

Quoted 4 lines
Quoted 4 lines

If we define a helper rte_tracepoint_emit_data(type, in) in rte_tracepoint.h, then the "provider" and "register" headers must only define how to emit a header (generic and fp cases), then rte_tracepoint_emit_data and rte_tracepoint_emit_string.

But this part is inconsistent, I will blame my son (EINTR/EAGAIN).

I meant: we can have all per-type helpers in rte_trace_point.h.

rte_trace_point_register.h and rte_trace_point_provider.h both define a macro (with a common signature) rte_trace_point_emit_data(type, in).

This way, the rte_trace_point_emit_data implementation in rte_trace_point_register.h can do the type checking. rte_trace_point_provider.h macro just ignores the type argument.

If you don't like it, let's drop this last part.
Thanks.

Signature · 1 line
David Marchand
#237 lore raw
Quoted 2 lines · David Marchand

Hello Jerin,

Hello David,

Quoted 10 lines · Jerin Jacob
Quoted 8 lines

From the prototype onwards, Myself shuffled abound multiple times on the API name to satisfying
names.

If you would like to classify based on the tracepoint object dependency to a new header file, it is fine.
Let's go the last round for API naming details.

Quoted 5 lines
Quoted 3 lines

I think, trace being the domain, IMO, it better to call the trace point API with rte_trace_point_*
and trace point object to rte_trace_point_t (vs rte_tracepoint_t)

Ok, let's go with rte_trace_point_.

Ack.

Quoted 9 lines
Quoted 7 lines

I will summarise the public API and file name details. Let's finalize.

# rte_trace.h will have

rte_trace_global_is_enabled

global_ does not make sense anymore.

Ack. I will change to rte_trace_is_enabled().

Quoted 38 lines
Quoted 10 lines

rte_trace_mode_set
rte_trace_mode_get
rte_trace_pattern
rte_trace_regexp
rte_trace_save
rte_trace_metadata_dump
rte_trace_dump

Quoted 5 lines
# rte_trace_point.h will have all operation related to rte_trace_point_t object
# rte_trace_provider.h renamed rte_trace_point_provider.h
# rte_trace_register.h renamed to rte_trace_point_register.h
# rte_trace_eal.h renamed to rte_trace_point_eal.h

Ok.

Quoted 8 lines
Quoted 6 lines
Quoted 1 line

2) rte_trace_fp_is_enabled()

As a user, what information would this give me?
"Some fastpath tracepoints are not available"

Moving to rte_tracepoint.h is enough to me.

IMO, semantically not correct as we are splitting based on some definition.

What is rte_trace_fp_is_enabled() supposed to do? "Test if the trace datapath compile-time option is enabled."

One implication is that dpdk must be compiled with RTE_ENABLE_TRACE_FP enabled for users to make use of fp tracepoints later.
It would impose restrictions to final users when they did not compile the dpdk package themselves.

Quoted 1 line
Quoted 8 lines
Quoted 6 lines

How about,
1) Not expose this API
OR
2) rte_trace_point.h includes the rte_trace.h

My vote is 1).

OK. +1

Quoted 12 lines

On how to do without it, this should be enough in rte_trace_point_provider.h:

#ifdef RTE_ENABLE_TRACE_FP
#define __rte_trace_emit_header_fp(t) \

do { \
        RTE_SET_USED(t); \
        return; \
} while (0)
#else
#define __rte_trace_emit_header_fp(t) \
        __rte_trace_emit_header(t) \
Quoted 5 lines

#endif

This way, the user can choose where he enables fp tracepoints in his code by placing a #undef/#define RTE_ENABLE_TRACE_FP before including the tracepoints headers.

I will make the internal. I prefer to have if (0) c style scheme so that both sections
of the code goes through the compilation phase. aka No compilation issue when RTE_ENABLE_TRACE_FP enabled.
We have a separate macro declaration for RTE_TRACE_POINT and RTE_TRACE_POINT_FP for
Tracepoint selection.

Quoted 66 lines
Quoted 24 lines
Quoted 24 lines
Quoted 13 lines

# Regarding the API change the following to rte_tracepoint_*

#define rte_trace_ctf_u64(val)
#define rte_trace_ctf_i64(val)
#define rte_trace_ctf_u32(val)
#define rte_trace_ctf_i32(val)
#define rte_trace_ctf_u16(val)
#define rte_trace_ctf_i16(val)
#define rte_trace_ctf_u8(val)
#define rte_trace_ctf_i8(val)
#define rte_trace_ctf_int(val)

Quoted 8 lines

#define rte_trace_ctf_long(val)
#define rte_trace_ctf_float(val)
#define rte_trace_ctf_double(val)
#define rte_trace_ctf_ptr(val)
#define rte_trace_ctf_string(val)
It could be done. Just concerned the length of API will be more. like rte_trace_point_ctf_u64
If you have a strong opinion on this then I can change it.

I don't like mentioning ctf here.

Quoted 7 lines
Quoted 5 lines

I went with a git grep -l rte_trace_ctf |xargs sed -i -e 's/rte_trace_ctf_/rte_tracepoint_emit_/g'.
If we keep one rte_tracepoint_emit_ per line in tracepoint declarations, the length is not an issue by looking at how they are used.

OK to remove ctf to make it as rte_trace_point_emit_*. OK?

Ok.

Quoted 15 lines
Quoted 12 lines

Example:
RTE_TRACEPOINT(

        rte_trace_lib_eal_intr_disable,
        RTE_TRACEPOINT_ARGS(const struct rte_intr_handle *handle, int rc),
        rte_tracepoint_emit_int(rc);
        rte_tracepoint_emit_int(handle->vfio_dev_fd);
        rte_tracepoint_emit_int(handle->fd);
        rte_tracepoint_emit_int(handle->type);
        rte_tracepoint_emit_u32(handle->max_intr);
        rte_tracepoint_emit_u32(handle->nb_efd);
Quoted 3 lines

)

Reading again what I wrote.

Quoted 3 lines
Quoted 3 lines

Besides, we don't need to define all those rte_tracepoint_emit_(u|i)(8|16|32|64) helpers in rte_tracepoint_provider.h and rte_tracepoint_register.h.

This part still stands.

Quoted 4 lines
Quoted 4 lines

If we define a helper rte_tracepoint_emit_data(type, in) in rte_tracepoint.h, then the "provider" and "register" headers must only define how to emit a header (generic and fp cases), then rte_tracepoint_emit_data and rte_tracepoint_emit_string.

But this part is inconsistent, I will blame my son (EINTR/EAGAIN).

Quoted 8 lines

I meant: we can have all per-type helpers in rte_trace_point.h.

rte_trace_point_register.h and rte_trace_point_provider.h both define a macro (with a common signature) rte_trace_point_emit_data(type, in).

This way, the rte_trace_point_emit_data implementation in rte_trace_point_register.h can do the type checking. rte_trace_point_provider.h macro just ignores the type argument.

Yes, if we have rte_trace_point.h as a separate file. I will work on this. Let me see if I can get it right.

Quoted 3 lines

If you don't like it, let's drop this last part.
Thanks.

Thanks for the review.

Quoted 5 lines

--
David Marchand

#238 lore raw

v6 cover DPDK Trace support

In reply to [email protected]

From: Jerin Jacob <[email protected]>

v6
~~

Following changes are based on David's feedback.

1) Changed rte_trace_t to rte_trace_point_t
2) Reworked the header file to have following API name and filename changes rte_trace.h has following trace control APIs
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a) rte_trace_is_enabled()
b) rte_trace_mode_set()
c) rte_trace_mode_get()
d) rte_trace_pattern()
e) rte_trace_regexp()
f) rte_trace_save()
g) rte_trace_metadata_dump()
h) rte_trace_dump()

rte_trace_point.h has following tracepoint related APIs
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a) rte_trace_point_enable()
b) rte_trace_point_disable()
c) rte_trace_point_is_enabled()
d) rte_trace_point_lookup()
e) rte_trace_point_emit_*()
f) RTE_TRACE_POINT_* macros

3) made rte_trace_fp_enabled() as internal.

4) Added common macros to have rte_trace_point_emit_* definition at single place a.k.a more common code now.

5) git grep -l rte_trace_ctf |xargs sed -i -e
's/rte_trace_ctf_/rte_tracepoint_emit_/g'.

6) Added the reason new section for tracepoint in git commit log
7) Sorted symbols alphabetic order in rte_eal_version.map file.
8) Fix snprint return handling bug in __rte_trace_point_emit_field() function.
9) Doc: added newline for section titles.
10) ctf_field and ctf_count made it as static.

v5
~~

Following API rework based David and Thomas feedback.

1) Rename - "Shell pattern" to "Globbing pattern"
2) Remove the log "level" notion from trace library.
3) Remove rte_trace_global_[level/mode]* API from trace library.
4) EAL command line arg to --trace=regex/globing from --trace-level=regex/globing:level
5) Remove "@b EXPERIMENTAL: this API may change without prior notice" from each functions.
6) Use FP instead of DP for fastpath reference.
7) Updated documentation to reflect the above rework.
8) Updated UT to to reflect the above rework.
8) Updated UT for a FP trace point emit.
9) Updated performance test case for a FP trace point emission.
10) Updated git commit comments to reflect the above rework.

v4:
~~

1) Rebased to master.

2) Adapted to latest EAL directory structure change.

3) Fix possible build issue with out of tree application wherein it does not define -DALLOW_EXPERIMENTAL_API. Fixed by making fast path trace functions as NOP as it was getting included in the inline functions of ethdev,mempool, cryptodev, etc(David)

4) Removed DALLOW_EXPERIMENTAL_API definition from individual driver files. Now it set as global using http://patches.dpdk.org/patch/67758/ patch (David)

5) Added new meson option(-Denable_trace_dp=true)for enabling the datapath trace point (David, Bruce)

6) Changed the authorship and Rewrote the programmer's guide based on the below feedback(Thomas)
http://patches.dpdk.org/patch/67352/

v3:
~~

1) Fix the following build issues reported by CI
http://mails.dpdk.org/archives/test-report/2020-March/122060.html

a) clang + i686 meson build issue(Fixed in the the patch meson: add libatomic as a global dependency for i686 clang)
b) fixed build issue with FreeBSD with top of tree change.
c) fixed missing experimental API for iavf and ice with meson build in avx512 files.

v2:
~~
Addressed the following review comments from Mattias Rönnblom:

1) Changed

from:

	typedef uint64_t* rte_trace_t;

to
typedef uint64_t rte_trace_t;

Initially thought to make the handle as
struct rte_trace {
uint64_t val;
}

but changed to uint64_t for the following reasons
a) It is opaque to the application and it will fix the compile-time type check as well.
b) The handle has an index that will point to an internal slow-path structure so no ABI change required in the future.
c) RTE_TRACE_POINT_DEFINE need to expose trace object. So it is better to keep as uint64_t and avoid one more indirection for no use.

2)
Changed:
from:

	enum rte_trace_mode_e {
to:
	enum rte_trace_mode {

3) removed [out] "found" param from rte_trace_pattern() and rte_trace_regexp()

4) Changed rte_trace_from_name to rte_trace_by_name

5) rte_trace_is_dp_enabled() return bool now

6) in __rte_trace_point_register() the argument fn change to register_fn

7) removed !! from rte_trace_is_enabled()

8) Remove uninitialized "rc warning" from rte_trace_pattern() and rte_trace_regexp()

9) fixup bool return type for trace_entry_compare()

10) fixup calloc casting in trace_mkdir()

11) check fclose() return in trace_meta_save() and trace_mem_save()

12) rte_trace_ctf_* macro cleanup

13) added release notes

14) fix build issues reported by CI
http://mails.dpdk.org/archives/test-report/2020-March/121235.html

This patch set contains
~~~~~~~~~~~~~~~~~~~~~~~~

# The native implementation of common trace format(CTF)[1] based tracer # Public API to create the trace points.
# Add tracepoints to eal, ethdev, mempool, eventdev and cryptodev library for tracing support
# A unit test case
# Performance test case to measure the trace overhead. (See eal/trace:

# add trace performance test cases, patch)
# Programmers guide for Trace support(See doc: add trace library guide,
# patch)

# Tested OS:
~~~~~~~~~~~
- Linux
- FreeBSD

# Tested open source CTF trace viewers
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- Babeltrace
- Tracecompass

# Trace overhead comparison with LTTng
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

trace overhead data on x86:[2]
# 236 cycles with LTTng(>100ns)
# 18 cycles(7ns) with Native DPDK CTF emitter.(See eal/trace: add trace

# performance test cases patch)

trace overhead data on arm64:
# 312 cycles to 1100 cycles with LTTng based on the class of arm64 CPU. # 11 cycles to 13 cycles with Native DPDK CTF emitter based on the class of arm64 CPU.

18 cycles(on x86) vs 11 cycles(on arm64) is due to rdtsc() overhead in x86. It seems rdtsc takes around 15cycles in x86.

More details:
~~~~~~~~~~~~~

# The Native DPDK CTF trace support does not have any dependency on third-party library.
The generated output file is compatible with LTTng as both are using CTF trace format.

The performance gain comes from:
1) exploit dpdk worker thread usage model to avoid atomics and use per core variables
2) use hugepage,
3) avoid a lot function pointers in fast-path etc
4) avoid unaligned store for arm64 etc

Features:
~~~~~~~~~
- No specific limit on the events. A string-based event like rte_log for pattern matching
- Dynamic enable/disable support.
- Instructmention overhead is ~1 cycle. i.e cost of adding the code wth out using trace feature.
- Timestamp support for all the events using DPDK rte_rtdsc
- No dependency on another library. Clean room native implementation of CTF.

Functional test case:
a) echo "trace_autotest" | sudo ./build/app/test/dpdk-test -c 0x3 --trace=.*

The above command emits the following trace events <code>

        uint8_t i;

        rte_trace_lib_eal_generic_void();
        rte_trace_lib_eal_generic_u64(0x10000000000000);
        rte_trace_lib_eal_generic_u32(0x10000000);
        rte_trace_lib_eal_generic_u16(0xffee);
        rte_trace_lib_eal_generic_u8(0xc);
        rte_trace_lib_eal_generic_i64(-1234);
        rte_trace_lib_eal_generic_i32(-1234567);
        rte_trace_lib_eal_generic_i16(12);
        rte_trace_lib_eal_generic_i8(-3);
        rte_trace_lib_eal_generic_string("my string");
        rte_trace_lib_eal_generic_function(__func__);

</code>

Install babeltrace package in Linux and point the generated trace file to babel trace. By default trace file created under <user>/dpdk-traces/time_stamp/

example:

# babeltrace /root/dpdk-traces/rte-2020-02-15-PM-02-56-51 | more

[13:27:36.138468807] (+?.?????????) lib.eal.generic.void: { cpu_id =0, name = "dpdk-test" }, { } [13:27:36.138468851] (+0.000000044) lib.eal.generic.u64: { cpu_id = 0, name = "dpdk-test" }, { in = 4503599627370496 } [13:27:36.138468860] (+0.000000009) lib.eal.generic.u32: { cpu_id = 0, name = "dpdk-test" }, { in = 268435456 } [13:27:36.138468934] (+0.000000074) lib.eal.generic.u16: { cpu_id = 0, name = "dpdk-test" }, { in = 65518 } [13:27:36.138468949] (+0.000000015) lib.eal.generic.u8: { cpu_id = 0, name = "dpdk-test" }, { in = 12 } [13:27:36.138468956] (+0.000000007) lib.eal.generic.i64: { cpu_id = 0, name = "dpdk-test" }, { in = -1234 } [13:27:36.138468963] (+0.000000007) lib.eal.generic.i32: { cpu_id = 0, name = "dpdk-test" }, { in = -1234567 } [13:27:36.138469024] (+0.000000061) lib.eal.generic.i16: { cpu_id = 0, name = "dpdk-test" }, { in = 12 } [13:27:36.138469044] (+0.000000020) lib.eal.generic.i8: { cpu_id = 0, name = "dpdk-test" }, { in = -3 } [13:27:36.138469051] (+0.000000007) lib.eal.generic.string: { cpu_id = 0, name = "dpdk-test" }, { str = "my string" } [13:27:36.138469203] (+0.000000152) lib.eal.generic.func: { cpu_id = 0, name = "dpdk-test" }, { func = "test_trace_points" }

# There is a GUI based trace viewer available in Windows, Linux and Mac. It is called as tracecompass.(https://www.eclipse.org/tracecompass/)

The example screenshot and Histogram of above DPDK trace using Tracecompass.

https://github.com/jerinjacobk/share/blob/master/dpdk_trace.JPG

File walk through:
~~~~~~~~~~~~~~~~~~

lib/librte_eal/common/include/rte_trace.h - Public API for Trace provider and Trace control lib/librte_eal/common/eal_common_trace.c - main trace implementation lib/librte_eal/common/eal_common_trace_ctf.c - CTF metadata spec implementation lib/librte_eal/common/eal_common_trace_utils.c - command line utils and filesystem operations. lib/librte_eal/common/eal_common_trace_points.c - trace points for EAL library
lib/librte_eal/common/include/rte_trace_eal.h - EAL tracepoint public API.
lib/librte_eal/common/eal_trace.h - Private trace header file.

[1] https://diamon.org/ctf/

[2] The above test is ported to LTTng for finding the LTTng trace overhead. It available at
https://github.com/jerinjacobk/lttng-overhead
https://github.com/jerinjacobk/lttng-overhead/blob/master/README

Jerin Jacob (22):
eal: introduce API for getting thread name eal/trace: define the public API for trace support eal/trace: implement trace register API eal/trace: implement trace operation APIs eal/trace: add internal trace init and fini interface eal/trace: get bootup timestamp for trace eal/trace: create CTF TDSL metadata in memory eal/trace: implement trace memory allocation eal/trace: implement debug dump function eal/trace: implement trace save
eal/trace: implement registration payload eal/trace: implement provider payload eal/trace: hook internal trace APIs to Linux eal/trace: hook internal trace APIs to FreeBSD eal/trace: add generic tracepoints eal/trace: add alarm tracepoints
eal/trace: add memory tracepoints
eal/trace: add memzone tracepoints eal/trace: add thread tracepoints
eal/trace: add interrupt tracepoints eal/trace: add trace performance test cases
doc: add trace library guide

Pavan Nikhilesh (1):
meson: add libatomic as a global dependency for i686 clang

Sunil Kumar Kori (10):
eal/trace: handle CTF keyword collision eal/trace: add trace configuration parameter eal/trace: add trace dir configuration parameter eal/trace: add trace bufsize configuration parameter eal/trace: add trace mode configuration parameter eal/trace: add unit test cases
ethdev: add tracepoints
eventdev: add tracepoints
cryptodev: add tracepoints
mempool: add tracepoints

 MAINTAINERS                                   |   8 +
 app/test/Makefile                             |   4 +-
 app/test/meson.build                          |   3 +
 app/test/test_trace.c                         | 223 ++++++++
 app/test/test_trace.h                         |  15 +
 app/test/test_trace_perf.c                    | 183 +++++++
 app/test/test_trace_register.c                |  17 +
 config/common_base                            |   1 +
 config/meson.build                            |   9 +
 doc/api/doxy-api-index.md                     |   4 +-
 doc/guides/linux_gsg/eal_args.include.rst     |  52 ++
 doc/guides/prog_guide/build-sdk-meson.rst     |   5 +
 doc/guides/prog_guide/index.rst               |   1 +
 doc/guides/prog_guide/trace_lib.rst           | 346 ++++++++++++
 doc/guides/rel_notes/release_20_05.rst        |   9 +
 drivers/event/octeontx/meson.build            |   5 -
 drivers/event/octeontx2/meson.build           |   5 -
 drivers/event/opdl/meson.build                |   5 -
 examples/cmdline/Makefile                     |   1 +
 examples/cmdline/meson.build                  |   1 +
 examples/distributor/Makefile                 |   1 +
 examples/distributor/meson.build              |   1 +
 examples/ethtool/ethtool-app/Makefile         |   1 +
 examples/eventdev_pipeline/meson.build        |   1 +
 examples/flow_filtering/Makefile              |   1 +
 examples/flow_filtering/meson.build           |   1 +
 examples/helloworld/Makefile                  |   1 +
 examples/helloworld/meson.build               |   1 +
 examples/ioat/Makefile                        |   1 +
 examples/ioat/meson.build                     |   1 +
 examples/ip_fragmentation/Makefile            |   2 +
 examples/ip_fragmentation/meson.build         |   1 +
 examples/ip_reassembly/Makefile               |   1 +
 examples/ip_reassembly/meson.build            |   1 +
 examples/ipv4_multicast/Makefile              |   1 +
 examples/ipv4_multicast/meson.build           |   1 +
 examples/l2fwd-cat/Makefile                   |   1 +
 examples/l2fwd-cat/meson.build                |   1 +
 examples/l2fwd-event/Makefile                 |   1 +
 examples/l2fwd-event/meson.build              |   6 +-
 examples/l2fwd-jobstats/Makefile              |   1 +
 examples/l2fwd-jobstats/meson.build           |   1 +
 examples/l2fwd-keepalive/Makefile             |   1 +
 examples/l2fwd-keepalive/ka-agent/Makefile    |   1 +
 examples/l2fwd-keepalive/meson.build          |   1 +
 examples/l3fwd-acl/Makefile                   |   1 +
 examples/l3fwd-acl/meson.build                |   1 +
 examples/l3fwd/Makefile                       |   1 +
 examples/l3fwd/meson.build                    |   1 +
 examples/link_status_interrupt/Makefile       |   1 +
 examples/link_status_interrupt/meson.build    |   1 +
 .../client_server_mp/mp_client/Makefile       |   1 +
 .../client_server_mp/mp_client/meson.build    |   1 +
 .../client_server_mp/mp_server/meson.build    |   1 +
 examples/multi_process/hotplug_mp/Makefile    |   1 +
 examples/multi_process/hotplug_mp/meson.build |   1 +
 examples/multi_process/simple_mp/Makefile     |   1 +
 examples/multi_process/simple_mp/meson.build  |   1 +
 examples/multi_process/symmetric_mp/Makefile  |   1 +
 .../multi_process/symmetric_mp/meson.build    |   1 +
 examples/ntb/Makefile                         |   1 +
 examples/ntb/meson.build                      |   1 +
 examples/packet_ordering/Makefile             |   1 +
 examples/packet_ordering/meson.build          |   1 +
 .../performance-thread/l3fwd-thread/Makefile  |   1 +
 .../l3fwd-thread/meson.build                  |   1 +
 .../performance-thread/pthread_shim/Makefile  |   1 +
 .../pthread_shim/meson.build                  |   1 +
 examples/ptpclient/Makefile                   |   1 +
 examples/ptpclient/meson.build                |   1 +
 examples/qos_meter/Makefile                   |   1 +
 examples/qos_meter/meson.build                |   1 +
 examples/qos_sched/Makefile                   |   1 +
 examples/qos_sched/meson.build                |   1 +
 examples/server_node_efd/node/Makefile        |   1 +
 examples/server_node_efd/node/meson.build     |   1 +
 examples/server_node_efd/server/Makefile      |   1 +
 examples/server_node_efd/server/meson.build   |   1 +
 examples/service_cores/Makefile               |   1 +
 examples/service_cores/meson.build            |   1 +
 examples/skeleton/Makefile                    |   1 +
 examples/skeleton/meson.build                 |   1 +
 examples/timer/Makefile                       |   1 +
 examples/timer/meson.build                    |   1 +
 examples/vm_power_manager/Makefile            |   1 +
 examples/vm_power_manager/meson.build         |   1 +
 examples/vmdq/Makefile                        |   1 +
 examples/vmdq/meson.build                     |   1 +
 examples/vmdq_dcb/Makefile                    |   1 +
 examples/vmdq_dcb/meson.build                 |   1 +
 lib/librte_cryptodev/Makefile                 |   4 +-
 lib/librte_cryptodev/cryptodev_trace_points.c |  70 +++
 lib/librte_cryptodev/meson.build              |   6 +-
 lib/librte_cryptodev/rte_cryptodev.c          |  18 +
 lib/librte_cryptodev/rte_cryptodev.h          |   6 +
 .../rte_cryptodev_version.map                 |  18 +
 lib/librte_cryptodev/rte_trace_cryptodev.h    | 148 ++++++
 lib/librte_cryptodev/rte_trace_cryptodev_fp.h |  38 ++
 lib/librte_distributor/meson.build            |   5 -
 lib/librte_eal/common/eal_common_memzone.c    |   9 +
 lib/librte_eal/common/eal_common_options.c    |  65 +++
 lib/librte_eal/common/eal_common_thread.c     |   4 +-
 lib/librte_eal/common/eal_common_trace.c      | 500 ++++++++++++++++++
 lib/librte_eal/common/eal_common_trace_ctf.c  | 488 +++++++++++++++++
 .../common/eal_common_trace_points.c          | 115 ++++
 .../common/eal_common_trace_utils.c           | 478 +++++++++++++++++
 lib/librte_eal/common/eal_options.h           |   8 +
 lib/librte_eal/common/eal_private.h           |   5 +
 lib/librte_eal/common/eal_trace.h             | 122 +++++
 lib/librte_eal/common/meson.build             |   4 +
 lib/librte_eal/common/rte_malloc.c            |  60 ++-
 lib/librte_eal/freebsd/Makefile               |   4 +
 lib/librte_eal/freebsd/eal.c                  |  10 +
 lib/librte_eal/freebsd/eal_alarm.c            |   3 +
 lib/librte_eal/freebsd/eal_interrupts.c       |  54 +-
 lib/librte_eal/freebsd/eal_thread.c           |  21 +-
 lib/librte_eal/include/meson.build            |   5 +
 lib/librte_eal/include/rte_lcore.h            |  17 +
 lib/librte_eal/include/rte_trace.h            | 141 +++++
 lib/librte_eal/include/rte_trace_eal.h        | 278 ++++++++++
 lib/librte_eal/include/rte_trace_point.h      | 306 +++++++++++
 .../include/rte_trace_point_provider.h        | 131 +++++
 .../include/rte_trace_point_register.h        |  39 ++
 lib/librte_eal/linux/Makefile                 |   4 +
 lib/librte_eal/linux/eal.c                    |   9 +
 lib/librte_eal/linux/eal_alarm.c              |   4 +
 lib/librte_eal/linux/eal_interrupts.c         |  84 +--
 lib/librte_eal/linux/eal_thread.c             |  27 +-
 lib/librte_eal/rte_eal_version.map            |  50 ++
 lib/librte_ethdev/Makefile                    |   3 +
 lib/librte_ethdev/ethdev_trace_points.c       |  43 ++
 lib/librte_ethdev/meson.build                 |   5 +-
 lib/librte_ethdev/rte_ethdev.c                |  12 +
 lib/librte_ethdev/rte_ethdev.h                |   5 +
 lib/librte_ethdev/rte_ethdev_version.map      |  10 +
 lib/librte_ethdev/rte_trace_ethdev.h          |  97 ++++
 lib/librte_ethdev/rte_trace_ethdev_fp.h       |  44 ++
 lib/librte_eventdev/Makefile                  |   3 +
 lib/librte_eventdev/eventdev_trace_points.c   | 173 ++++++
 lib/librte_eventdev/meson.build               |   3 +
 .../rte_event_crypto_adapter.c                |  10 +
 .../rte_event_eth_rx_adapter.c                |  11 +
 .../rte_event_eth_tx_adapter.c                |  13 +-
 .../rte_event_eth_tx_adapter.h                |   2 +
 lib/librte_eventdev/rte_event_timer_adapter.c |   8 +-
 lib/librte_eventdev/rte_event_timer_adapter.h |   8 +
 lib/librte_eventdev/rte_eventdev.c            |   9 +
 lib/librte_eventdev/rte_eventdev.h            |   5 +-
 lib/librte_eventdev/rte_eventdev_version.map  |  42 ++
 lib/librte_eventdev/rte_trace_eventdev.h      | 311 +++++++++++
 lib/librte_eventdev/rte_trace_eventdev_fp.h   |  85 +++
 lib/librte_mempool/Makefile                   |   3 +
 lib/librte_mempool/mempool_trace_points.c     | 108 ++++
 lib/librte_mempool/meson.build                |   5 +-
 lib/librte_mempool/rte_mempool.c              |  16 +
 lib/librte_mempool/rte_mempool.h              |  13 +
 lib/librte_mempool/rte_mempool_ops.c          |   7 +
 lib/librte_mempool/rte_mempool_version.map    |  26 +
 lib/librte_mempool/rte_trace_mempool.h        | 178 +++++++
 lib/librte_mempool/rte_trace_mempool_fp.h     | 116 ++++
 lib/librte_rcu/meson.build                    |   5 -
 meson_options.txt                             |   2 +
 162 files changed, 5607 insertions(+), 105 deletions(-)
 create mode 100644 app/test/test_trace.c
 create mode 100644 app/test/test_trace.h
 create mode 100644 app/test/test_trace_perf.c
 create mode 100644 app/test/test_trace_register.c
 create mode 100644 doc/guides/prog_guide/trace_lib.rst
 create mode 100644 lib/librte_cryptodev/cryptodev_trace_points.c
 create mode 100644 lib/librte_cryptodev/rte_trace_cryptodev.h
 create mode 100644 lib/librte_cryptodev/rte_trace_cryptodev_fp.h
 create mode 100644 lib/librte_eal/common/eal_common_trace.c
 create mode 100644 lib/librte_eal/common/eal_common_trace_ctf.c
 create mode 100644 lib/librte_eal/common/eal_common_trace_points.c
 create mode 100644 lib/librte_eal/common/eal_common_trace_utils.c
 create mode 100644 lib/librte_eal/common/eal_trace.h
 create mode 100644 lib/librte_eal/include/rte_trace.h
 create mode 100644 lib/librte_eal/include/rte_trace_eal.h
 create mode 100644 lib/librte_eal/include/rte_trace_point.h
 create mode 100644 lib/librte_eal/include/rte_trace_point_provider.h
 create mode 100644 lib/librte_eal/include/rte_trace_point_register.h
 create mode 100644 lib/librte_ethdev/ethdev_trace_points.c
 create mode 100644 lib/librte_ethdev/rte_trace_ethdev.h
 create mode 100644 lib/librte_ethdev/rte_trace_ethdev_fp.h
 create mode 100644 lib/librte_eventdev/eventdev_trace_points.c
 create mode 100644 lib/librte_eventdev/rte_trace_eventdev.h
 create mode 100644 lib/librte_eventdev/rte_trace_eventdev_fp.h
 create mode 100644 lib/librte_mempool/mempool_trace_points.c
 create mode 100644 lib/librte_mempool/rte_trace_mempool.h
 create mode 100644 lib/librte_mempool/rte_trace_mempool_fp.h
Signature · 1 line
2.25.1
#239 lore raw

PATCH v6 1/33 meson: add libatomic as a global dependency for i686 clang

From: Pavan Nikhilesh <[email protected]>

Add libatomic as a global dependency when compiling for 32-bit using clang. As we need libatomic for 64-bit atomic ops.

---
 config/meson.build                  | 8 ++++++++
 drivers/event/octeontx/meson.build  | 5 -----
 drivers/event/octeontx2/meson.build | 5 -----
 drivers/event/opdl/meson.build      | 5 -----
 examples/l2fwd-event/meson.build    | 5 -----
 lib/librte_distributor/meson.build  | 5 -----
 lib/librte_rcu/meson.build          | 5 -----
 7 files changed, 8 insertions(+), 30 deletions(-)
config/meson.build +8 -0
index 58421342b..8a4c692a9 100644
@@ -173,6 +173,14 @@ if pcap_dep.found() and cc.has_header('pcap.h', dependencies: pcap_dep)
 	dpdk_extra_ldflags += '-lpcap'
 endif
 
+
+# for clang 32-bit compiles we need libatomic for 64-bit atomic ops
+if cc.get_id() == 'clang' and dpdk_conf.get('RTE_ARCH_64') == false
+	atomic_dep = cc.find_library('atomic', required: true)
+	add_project_link_arguments('-latomic', language: 'c')
+	dpdk_extra_ldflags += '-latomic'
+endif
+
 # add -include rte_config to cflags
 add_project_arguments('-include', 'rte_config.h', language: 'c')
 
drivers/event/octeontx/meson.build +0 -5
index 73118a485..2b74bb62d 100644
@@ -11,8 +11,3 @@ sources = files('ssovf_worker.c',
 )
 
 deps += ['common_octeontx', 'mempool_octeontx', 'bus_vdev', 'pmd_octeontx']
-
-# for clang 32-bit compiles we need libatomic for 64-bit atomic ops
-if cc.get_id() == 'clang' and dpdk_conf.get('RTE_ARCH_64') == false
-	ext_deps += cc.find_library('atomic')
-endif
drivers/event/octeontx2/meson.build +0 -5
index 4b938416b..0ade51cec 100644
@@ -18,11 +18,6 @@ if not dpdk_conf.get('RTE_ARCH_64')
 	extra_flags += ['-Wno-int-to-pointer-cast', '-Wno-pointer-to-int-cast']
 endif
 
-# for clang 32-bit compiles we need libatomic for 64-bit atomic ops
-if cc.get_id() == 'clang' and dpdk_conf.get('RTE_ARCH_64') == false
-	ext_deps += cc.find_library('atomic')
-endif
-
 foreach flag: extra_flags
 	if cc.has_argument(flag)
 		cflags += flag
drivers/event/opdl/meson.build +0 -5
index 1fe034ea1..cc6029c6f 100644
@@ -9,8 +9,3 @@ sources = files(
 	'opdl_test.c',
 )
 deps += ['bus_vdev']
-
-# for clang 32-bit compiles we need libatomic for 64-bit atomic ops
-if cc.get_id() == 'clang' and dpdk_conf.get('RTE_ARCH_64') == false
-	ext_deps += cc.find_library('atomic')
-endif
examples/l2fwd-event/meson.build +0 -5
index c4664c3a3..4e9a069d6 100644
@@ -16,8 +16,3 @@ sources = files(
 	'l2fwd_event_internal_port.c',
 	'l2fwd_event_generic.c'
 )
-
-# for clang 32-bit compiles we need libatomic for 64-bit atomic ops
-if cc.get_id() == 'clang' and dpdk_conf.get('RTE_ARCH_64') == false
-	ext_deps += cc.find_library('atomic')
-endif
lib/librte_distributor/meson.build +0 -5
index 266af6434..bd12ddb2f 100644
@@ -9,8 +9,3 @@ else
 endif
 headers = files('rte_distributor.h')
 deps += ['mbuf']
-
-# for clang 32-bit compiles we need libatomic for 64-bit atomic ops
-if cc.get_id() == 'clang' and dpdk_conf.get('RTE_ARCH_64') == false
-	ext_deps += cc.find_library('atomic')
-endif
lib/librte_rcu/meson.build +0 -5
index 5929bd3a7..c009ae4b7 100644
@@ -3,8 +3,3 @@
 
 sources = files('rte_rcu_qsbr.c')
 headers = files('rte_rcu_qsbr.h')
-
-# for clang 32-bit compiles we need libatomic for 64-bit atomic ops
-if cc.get_id() == 'clang' and dpdk_conf.get('RTE_ARCH_64') == false
-	ext_deps += cc.find_library('atomic')
-endif
Signature · 1 line
2.25.1
#240 lore raw

PATCH v6 2/33 eal: introduce API for getting thread name

In reply to [email protected]

From: Jerin Jacob <[email protected]>

Introduce rte_thread_getname() API to get the thread name and implement it for Linux and FreeBSD.

FreeBSD does not support getting the thread name.

One of the consumers of this API will be the trace subsystem where it used as an informative purpose.

---
 lib/librte_eal/freebsd/eal_thread.c |  9 +++++++++
 lib/librte_eal/include/rte_lcore.h  | 17 +++++++++++++++++
 lib/librte_eal/linux/eal_thread.c   | 15 +++++++++++++++
 lib/librte_eal/rte_eal_version.map  |  1 +
 4 files changed, 42 insertions(+)
lib/librte_eal/freebsd/eal_thread.c +9 -0
index f21eddd93..d802c1d2e 100644
@@ -175,3 +175,12 @@ int rte_thread_setname(pthread_t id, const char *name)
 	pthread_set_name_np(id, name);
 	return 0;
 }
+
+int rte_thread_getname(pthread_t id, char *name, size_t len)
+{
+	RTE_SET_USED(id);
+	RTE_SET_USED(name);
+	RTE_SET_USED(len);
+
+	return -ENOTSUP;
+}
lib/librte_eal/include/rte_lcore.h +17 -0
index 476b8ef3a..339046bc8 100644
@@ -240,6 +240,23 @@ void rte_thread_get_affinity(rte_cpuset_t *cpusetp);
  */
 int rte_thread_setname(pthread_t id, const char *name);
 
+/**
+ * Get thread name.
+ *
+ * @note It fails with glibc < 2.12.
+ *
+ * @param id
+ *   Thread id.
+ * @param name
+ *   Thread name to set.
+ * @param len
+ *   Thread name buffer length.
+ * @return
+ *   On success, return 0; otherwise return a negative value.
+ */
+__rte_experimental
+int rte_thread_getname(pthread_t id, char *name, size_t len);
+
 /**
  * Create a control thread.
  *
lib/librte_eal/linux/eal_thread.c +15 -0
index 2fa5806b8..61fb2ed45 100644
@@ -186,3 +186,18 @@ int rte_thread_setname(pthread_t id, const char *name)
 	RTE_SET_USED(name);
 	return -ret;
 }
+
+int rte_thread_getname(pthread_t id, char *name, size_t len)
+{
+	int ret = ENOSYS;
+#if defined(__GLIBC__) && defined(__GLIBC_PREREQ)
+#if __GLIBC_PREREQ(2, 12)
+	ret = pthread_getname_np(id, name, len);
+#endif
+#endif
+	RTE_SET_USED(id);
+	RTE_SET_USED(name);
+	RTE_SET_USED(len);
+	return -ret;
+
+}
lib/librte_eal/rte_eal_version.map +1 -0
index f9ede5b41..71098581f 100644
@@ -338,4 +338,5 @@ EXPERIMENTAL {
 
 	# added in 20.05
 	rte_log_can_log;
+	rte_thread_getname;
 };
Signature · 1 line
2.25.1
#241 lore raw

PATCH v6 3/33 eal/trace: define the public API for trace support

In reply to [email protected]

From: Jerin Jacob <[email protected]>

Define the public API for trace support.
This patch also adds support for the build infrastructure and update the MAINTAINERS file for the trace subsystem.

The tracepoint object is of size 8B, it a global variable and used in fastpath. Created a new __rte_trace_point section to store the tracepoint objects as,
- It is a mostly read-only data and not to mix with other "write" global variables.
- Chances that the same subsystem Fast path variables come in the same fast path cache line. i.e, it will enable a more predictable performance number from build to build.

---
 MAINTAINERS                               |   6 +
 config/common_base                        |   1 +
 config/meson.build                        |   1 +
 doc/api/doxy-api-index.md                 |   4 +-
 doc/guides/prog_guide/build-sdk-meson.rst |   5 +
 lib/librte_eal/common/eal_common_trace.c  |   7 +
 lib/librte_eal/common/meson.build         |   1 +
 lib/librte_eal/freebsd/Makefile           |   1 +
 lib/librte_eal/include/meson.build        |   2 +
 lib/librte_eal/include/rte_trace.h        | 141 +++++++++++++
 lib/librte_eal/include/rte_trace_point.h  | 234 ++++++++++++++++++++++
 lib/librte_eal/linux/Makefile             |   1 +
 meson_options.txt                         |   2 +
 13 files changed, 405 insertions(+), 1 deletion(-)
 create mode 100644 lib/librte_eal/common/eal_common_trace.c
 create mode 100644 lib/librte_eal/include/rte_trace.h
 create mode 100644 lib/librte_eal/include/rte_trace_point.h
MAINTAINERS +6 -0
index 1bf00d7e5..bd76ec23f 100644
@@ -194,6 +194,12 @@ F: app/test/test_string_fns.c
 F: app/test/test_tailq.c
 F: app/test/test_version.c
 
+Trace - EXPERIMENTAL
+M: Jerin Jacob <[email protected]>
+M: Sunil Kumar Kori <[email protected]>
+F: lib/librte_eal/include/rte_trace*.h
+F: lib/librte_eal/common/eal_common_trace*.c
+
 Memory Allocation
 M: Anatoly Burakov <[email protected]>
 F: lib/librte_eal/include/rte_fbarray.h
config/common_base +1 -0
index c31175f9d..ac5257b8e 100644
@@ -99,6 +99,7 @@ CONFIG_RTE_MAX_MEMZONE=2560
 CONFIG_RTE_MAX_TAILQ=32
 CONFIG_RTE_ENABLE_ASSERT=n
 CONFIG_RTE_LOG_DP_LEVEL=RTE_LOG_INFO
+CONFIG_RTE_ENABLE_TRACE_FP=n
 CONFIG_RTE_LOG_HISTORY=256
 CONFIG_RTE_BACKTRACE=y
 CONFIG_RTE_LIBEAL_USE_HPET=n
config/meson.build +1 -0
index 8a4c692a9..f416be23e 100644
@@ -230,6 +230,7 @@ dpdk_conf.set('RTE_MAX_LCORE', get_option('max_lcores'))
 dpdk_conf.set('RTE_MAX_NUMA_NODES', get_option('max_numa_nodes'))
 dpdk_conf.set('RTE_MAX_ETHPORTS', get_option('max_ethports'))
 dpdk_conf.set('RTE_LIBEAL_USE_HPET', get_option('use_hpet'))
+dpdk_conf.set('RTE_ENABLE_TRACE_FP', get_option('enable_trace_fp'))
 # values which have defaults which may be overridden
 dpdk_conf.set('RTE_MAX_VFIO_GROUPS', 64)
 dpdk_conf.set('RTE_DRIVER_MEMPOOL_BUCKET_SIZE_KB', 64)
doc/api/doxy-api-index.md +3 -1
index dff496be0..845a53491 100644
@@ -174,7 +174,9 @@ The public API headers are grouped by topics:
   [hexdump]            (@ref rte_hexdump.h),
   [debug]              (@ref rte_debug.h),
   [log]                (@ref rte_log.h),
-  [errno]              (@ref rte_errno.h)
+  [errno]              (@ref rte_errno.h),
+  [trace]              (@ref rte_trace.h),
+  [trace_point]        (@ref rte_trace_point.h)
 
 - **misc**:
   [EAL config]         (@ref rte_eal.h),
doc/guides/prog_guide/build-sdk-meson.rst +5 -0
index e34daab91..a036299da 100644
@@ -87,6 +87,9 @@ Project-specific options are passed used -Doption=value::
 	meson -Ddisable_drivers=event/*,net/tap  # disable tap driver and all
 					# eventdev PMDs for a smaller build
 
+	meson -Denable_trace_fp=true tracebuild # build with fastpath trace
+					#enabled
+
 Examples of setting some of the same options using meson configure::
 
 	meson configure -Dwerror=true
@@ -97,6 +100,8 @@ Examples of setting some of the same options using meson configure::
 
 	meson configure -Dmax_lcores=8
 
+	meson configure -Denable_trace_fp=true
+
 NOTE: once meson has been run to configure a build in a directory, it
 cannot be run again on the same directory. Instead ``meson configure``
 should be used to change the build settings within the directory, and when
lib/librte_eal/common/eal_common_trace.c new file +7 -0
new file mode 100644
index 000000000..33a6e563a
@@ -0,0 +1,7 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(C) 2020 Marvell International Ltd.
+ */
+
+#include <rte_trace.h>
+#include <rte_trace_point.h>
+
lib/librte_eal/common/meson.build +1 -0
index 02d9280cc..429e89f99 100644
@@ -42,6 +42,7 @@ sources += files(
 	'eal_common_tailqs.c',
 	'eal_common_thread.c',
 	'eal_common_timer.c',
+	'eal_common_trace.c',
 	'eal_common_uuid.c',
 	'hotplug_mp.c',
 	'malloc_elem.c',
lib/librte_eal/freebsd/Makefile +1 -0
index 2d53ce9ee..500afc578 100644
@@ -59,6 +59,7 @@ SRCS-$(CONFIG_RTE_EXEC_ENV_FREEBSD) += eal_common_thread.c
 SRCS-$(CONFIG_RTE_EXEC_ENV_FREEBSD) += eal_common_proc.c
 SRCS-$(CONFIG_RTE_EXEC_ENV_FREEBSD) += eal_common_fbarray.c
 SRCS-$(CONFIG_RTE_EXEC_ENV_FREEBSD) += eal_common_uuid.c
+SRCS-$(CONFIG_RTE_EXEC_ENV_FREEBSD) += eal_common_trace.c
 SRCS-$(CONFIG_RTE_EXEC_ENV_FREEBSD) += rte_malloc.c
 SRCS-$(CONFIG_RTE_EXEC_ENV_FREEBSD) += hotplug_mp.c
 SRCS-$(CONFIG_RTE_EXEC_ENV_FREEBSD) += malloc_elem.c
lib/librte_eal/include/meson.build +2 -0
index 6fd427494..126455d1c 100644
@@ -40,6 +40,8 @@ headers += files(
 	'rte_string_fns.h',
 	'rte_tailq.h',
 	'rte_time.h',
+	'rte_trace.h',
+	'rte_trace_point.h',
 	'rte_uuid.h',
 	'rte_version.h',
 	'rte_vfio.h',
lib/librte_eal/include/rte_trace.h new file +141 -0

141 lines not on this page · raw message

lib/librte_eal/include/rte_trace_point.h new file +234 -0

234 lines not on this page · raw message

lib/librte_eal/linux/Makefile +1 -0
index fc2316667..2ced2085b 100644
@@ -66,6 +66,7 @@ SRCS-$(CONFIG_RTE_EXEC_ENV_LINUX) += eal_common_thread.c
 SRCS-$(CONFIG_RTE_EXEC_ENV_LINUX) += eal_common_proc.c
 SRCS-$(CONFIG_RTE_EXEC_ENV_LINUX) += eal_common_fbarray.c
 SRCS-$(CONFIG_RTE_EXEC_ENV_LINUX) += eal_common_uuid.c
+SRCS-$(CONFIG_RTE_EXEC_ENV_LINUX) += eal_common_trace.c
 SRCS-$(CONFIG_RTE_EXEC_ENV_LINUX) += rte_malloc.c
 SRCS-$(CONFIG_RTE_EXEC_ENV_LINUX) += hotplug_mp.c
 SRCS-$(CONFIG_RTE_EXEC_ENV_LINUX) += malloc_elem.c
meson_options.txt +2 -0
index 9e4923a4f..3578a23ab 100644
@@ -30,6 +30,8 @@ option('max_lcores', type: 'integer', value: 128,
 	description: 'maximum number of cores/threads supported by EAL')
 option('max_numa_nodes', type: 'integer', value: 4,
 	description: 'maximum number of NUMA nodes supported by EAL')
+option('enable_trace_fp', type: 'boolean', value: false,
+	description: 'enable fastpath trace points.')
 option('tests', type: 'boolean', value: true,
 	description: 'build unit tests')
 option('use_hpet', type: 'boolean', value: false,
Signature · 1 line
2.25.1
#242 lore raw

PATCH v6 4/33 eal/trace: implement trace register API

In reply to [email protected]

From: Jerin Jacob <[email protected]>

The consumers of trace API defines the tracepoint and registers to eal. Internally these tracepoints will be stored in STAILQ for future use. This patch implements the tracepoint registration function.

---
 MAINTAINERS                                   |   1 +
 lib/librte_eal/common/eal_common_trace.c      | 100 +++++++++++++++++-
 lib/librte_eal/common/eal_trace.h             |  37 +++++++
 lib/librte_eal/include/meson.build            |   2 +
 lib/librte_eal/include/rte_trace_point.h      |  26 +++++
 .../include/rte_trace_point_provider.h        |  21 ++++
 .../include/rte_trace_point_register.h        |  20 ++++
 lib/librte_eal/rte_eal_version.map            |   2 +
 8 files changed, 207 insertions(+), 2 deletions(-)
 create mode 100644 lib/librte_eal/common/eal_trace.h
 create mode 100644 lib/librte_eal/include/rte_trace_point_provider.h
 create mode 100644 lib/librte_eal/include/rte_trace_point_register.h
MAINTAINERS +1 -0
index bd76ec23f..4592abede 100644
@@ -199,6 +199,7 @@ M: Jerin Jacob <[email protected]>
 M: Sunil Kumar Kori <[email protected]>
 F: lib/librte_eal/include/rte_trace*.h
 F: lib/librte_eal/common/eal_common_trace*.c
+F: lib/librte_eal/common/eal_trace.h
 
 Memory Allocation
 M: Anatoly Burakov <[email protected]>
lib/librte_eal/common/eal_common_trace.c +98 -2

104 lines not on this page · raw message

lib/librte_eal/common/eal_trace.h new file +37 -0
new file mode 100644
index 000000000..4f1792768
@@ -0,0 +1,37 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(C) 2020 Marvell International Ltd.
+ */
+
+#ifndef __EAL_TRACE_H
+#define __EAL_TRACE_H
+
+#include <rte_trace.h>
+#include <rte_trace_point.h>
+
+#define trace_err(fmt, args...)\
+	RTE_LOG(ERR, EAL, "%s():%u " fmt "\n",\
+		__func__, __LINE__, ## args)
+
+#define trace_crit(fmt, args...)\
+	RTE_LOG(CRIT, EAL, "%s():%u " fmt "\n",\
+		__func__, __LINE__, ## args)
+
+#define TRACE_CTF_FIELD_SIZE 384
+#define TRACE_POINT_NAME_SIZE 64
+
+struct trace_point {
+	STAILQ_ENTRY(trace_point) next;
+	rte_trace_point_t *handle;
+	char name[TRACE_POINT_NAME_SIZE];
+	char ctf_field[TRACE_CTF_FIELD_SIZE];
+};
+
+struct trace {
+	int register_errno;
+	uint32_t nb_trace_points;
+};
+
+/* Trace point list functions */
+STAILQ_HEAD(trace_point_head, trace_point);
+
+#endif /* __EAL_TRACE_H */
lib/librte_eal/include/meson.build +2 -0
index 126455d1c..ce360615f 100644
@@ -42,6 +42,8 @@ headers += files(
 	'rte_time.h',
 	'rte_trace.h',
 	'rte_trace_point.h',
+	'rte_trace_point_provider.h',
+	'rte_trace_point_register.h',
 	'rte_uuid.h',
 	'rte_version.h',
 	'rte_vfio.h',
lib/librte_eal/include/rte_trace_point.h +26 -0
index 9d11830f6..f9924225a 100644
@@ -227,6 +227,32 @@ __rte_trace_point_fp_is_enabled(void)
 #endif
 }
 
+/**
+ * @internal
+ *
+ * Helper function to register a dynamic tracepoint.
+ * Use RTE_TRACE_POINT_REGISTER macro for tracepoint registration.
+ *
+ * @param trace
+ *   The tracepoint object created using RTE_TRACE_POINT_DEFINE.
+ * @param name
+ *   The name of the tracepoint object.
+ * @param register_fn
+ *   Trace registration function.
+ * @return
+ *   - 0: Successfully registered the tracepoint.
+ *   - <0: Failure to register the tracepoint.
+ */
+__rte_experimental
+int __rte_trace_point_register(rte_trace_point_t *trace, const char *name,
+			       void (*register_fn)(void));
+
+#ifdef RTE_TRACE_POINT_REGISTER_SELECT
+#include <rte_trace_point_register.h>
+#else
+#include <rte_trace_point_provider.h>
+#endif
+
 #ifdef __cplusplus
 }
 #endif
lib/librte_eal/include/rte_trace_point_provider.h new file +21 -0
new file mode 100644
index 000000000..45a113c0d
@@ -0,0 +1,21 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(C) 2020 Marvell International Ltd.
+ */
+
+#ifndef _RTE_TRACE_POINT_H_
+#error do not include this file directly, use <rte_trace_point.h> instead
+#endif
+
+#ifndef _RTE_TRACE_POINT_PROVIDER_H_
+#define _RTE_TRACE_POINT_PROVIDER_H_
+
+#define __RTE_TRACE_EVENT_HEADER_ID_SHIFT (48)
+
+#define __RTE_TRACE_FIELD_SIZE_SHIFT 0
+#define __RTE_TRACE_FIELD_SIZE_MASK (0xffffULL << __RTE_TRACE_FIELD_SIZE_SHIFT)
+#define __RTE_TRACE_FIELD_ID_SHIFT (16)
+#define __RTE_TRACE_FIELD_ID_MASK (0xffffULL << __RTE_TRACE_FIELD_ID_SHIFT)
+#define __RTE_TRACE_FIELD_ENABLE_MASK (1ULL << 63)
+#define __RTE_TRACE_FIELD_ENABLE_DISCARD (1ULL << 62)
+
+#endif /* _RTE_TRACE_POINT_PROVIDER_H_ */
lib/librte_eal/include/rte_trace_point_register.h new file +20 -0
new file mode 100644
index 000000000..b21302c3d
@@ -0,0 +1,20 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(C) 2020 Marvell International Ltd.
+ */
+
+#ifndef _RTE_TRACE_POINT_H_
+#error do not include this file directly, use <rte_trace_point.h> instead
+#endif
+
+#ifndef _RTE_TRACE_POINT_REGISTER_H_
+#define _RTE_TRACE_POINT_REGISTER_H_
+
+#include <rte_per_lcore.h>
+
+RTE_DECLARE_PER_LCORE(volatile int, trace_point_sz);
+
+#define RTE_TRACE_POINT_REGISTER(trace, name)\
+	__rte_trace_point_register(&__##trace, RTE_STR(name),\
+				   (void (*)(void)) trace)
+
+#endif /* _RTE_TRACE_POINT_REGISTER_H_ */
lib/librte_eal/rte_eal_version.map +2 -0
index 71098581f..02a595126 100644
@@ -337,6 +337,8 @@ EXPERIMENTAL {
 	rte_thread_is_intr;
 
 	# added in 20.05
+	__rte_trace_point_register;
+	per_lcore_trace_point_sz;
 	rte_log_can_log;
 	rte_thread_getname;
 };
Signature · 1 line
2.25.1
#243 lore raw

PATCH v6 5/33 eal/trace: implement trace operation APIs

In reply to [email protected]

From: Jerin Jacob <[email protected]>

This patch implements the following public trace APIs.

- rte_trace_is_enabled()
- rte_trace_mode_get()
- rte_trace_mode_set()
- rte_trace_pattern()
- rte_trace_point_disable()
- rte_trace_point_enable()
- rte_trace_point_is_enabled()
- rte_trace_point_lookup()
- rte_trace_regexp()

---
 lib/librte_eal/common/eal_common_trace.c | 147 +++++++++++++++++++++++
 lib/librte_eal/common/eal_trace.h        |  10 ++
 lib/librte_eal/rte_eal_version.map       |   9 ++
 3 files changed, 166 insertions(+)
lib/librte_eal/common/eal_common_trace.c +147 -0
index 5c5cbd2a1..1ca702f68 100644
@@ -3,7 +3,9 @@
  */
 
 #include <inttypes.h>
+#include <fnmatch.h>
 #include <sys/queue.h>
+#include <regex.h>
 
 #include <rte_common.h>
 #include <rte_errno.h>
@@ -20,6 +22,151 @@ static RTE_DEFINE_PER_LCORE(int, ctf_count);
 static struct trace_point_head tp_list = STAILQ_HEAD_INITIALIZER(tp_list);
 static struct trace trace;
 
+bool
+rte_trace_is_enabled(void)
+{
+	return trace.status;
+}
+
+static void
+trace_mode_set(rte_trace_point_t *trace, enum rte_trace_mode mode)
+{
+	if (mode == RTE_TRACE_MODE_OVERWRITE)
+		__atomic_and_fetch(trace, ~__RTE_TRACE_FIELD_ENABLE_DISCARD,
+				   __ATOMIC_RELEASE);
+	else
+		__atomic_or_fetch(trace, __RTE_TRACE_FIELD_ENABLE_DISCARD,
+				  __ATOMIC_RELEASE);
+}
+
+void
+rte_trace_mode_set(enum rte_trace_mode mode)
+{
+	struct trace_point *tp;
+
+	if (rte_trace_is_enabled() == false)
+		return;
+
+	STAILQ_FOREACH(tp, &tp_list, next)
+		trace_mode_set(tp->handle, mode);
+
+	trace.mode = mode;
+}
+
+enum
+rte_trace_mode rte_trace_mode_get(void)
+{
+	return trace.mode;
+}
+
+static bool
+trace_point_is_invalid(rte_trace_point_t *t)
+{
+	if (t == NULL)
+		return false;
+
+	if (trace_id_get(t) >= trace.nb_trace_points)
+		return true;
+
+	return false;
+}
+
+bool
+rte_trace_point_is_enabled(rte_trace_point_t *trace)
+{
+	uint64_t val;
+
+	if (trace_point_is_invalid(trace))
+		return false;
+
+	val = __atomic_load_n(trace, __ATOMIC_ACQUIRE);
+	return val & __RTE_TRACE_FIELD_ENABLE_MASK;
+}
+
+int
+rte_trace_point_enable(rte_trace_point_t *trace)
+{
+	if (trace_point_is_invalid(trace))
+		return -ERANGE;
+
+	__atomic_or_fetch(trace, __RTE_TRACE_FIELD_ENABLE_MASK,
+			  __ATOMIC_RELEASE);
+	return 0;
+}
+
+int
+rte_trace_point_disable(rte_trace_point_t *trace)
+{
+	if (trace_point_is_invalid(trace))
+		return -ERANGE;
+
+	__atomic_and_fetch(trace, ~__RTE_TRACE_FIELD_ENABLE_MASK,
+			   __ATOMIC_RELEASE);
+	return 0;
+}
+
+int
+rte_trace_pattern(const char *pattern, bool enable)
+{
+	struct trace_point *tp;
+	int rc = 0, found = 0;
+
+	STAILQ_FOREACH(tp, &tp_list, next) {
+		if (fnmatch(pattern, tp->name, 0) == 0) {
+			if (enable)
+				rc = rte_trace_point_enable(tp->handle);
+			else
+				rc = rte_trace_point_disable(tp->handle);
+			found = 1;
+		}
+		if (rc < 0)
+			return rc;
+	}
+
+	return rc | found;
+}
+
+int
+rte_trace_regexp(const char *regex, bool enable)
+{
+	struct trace_point *tp;
+	int rc = 0, found = 0;
+	regex_t r;
+
+	if (regcomp(&r, regex, 0) != 0)
+		return -EINVAL;
+
+	STAILQ_FOREACH(tp, &tp_list, next) {
+		if (regexec(&r, tp->name, 0, NULL, 0) == 0) {
+			if (enable)
+				rc = rte_trace_point_enable(tp->handle);
+			else
+				rc = rte_trace_point_disable(tp->handle);
+			found = 1;
+		}
+		if (rc < 0)
+			return rc;
+	}
+	regfree(&r);
+
+	return rc | found;
+}
+
+rte_trace_point_t *
+rte_trace_point_lookup(const char *name)
+{
+	struct trace_point *tp;
+
+	if (name == NULL)
+		return NULL;
+
+	STAILQ_FOREACH(tp, &tp_list, next)
+		if (strncmp(tp->name, name, TRACE_POINT_NAME_SIZE) == 0)
+			return tp->handle;
+
+	return NULL;
+}
+
 int
 __rte_trace_point_register(rte_trace_point_t *handle, const char *name,
 			   void (*register_fn)(void))
lib/librte_eal/common/eal_trace.h +10 -0
index 4f1792768..ebf7914ff 100644
@@ -28,9 +28,19 @@ struct trace_point {
 
 struct trace {
 	int register_errno;
+	bool status;
+	enum rte_trace_mode mode;
 	uint32_t nb_trace_points;
 };
 
+/* Helper functions */
+static inline uint16_t
+trace_id_get(rte_trace_point_t *trace)
+{
+	return (*trace & __RTE_TRACE_FIELD_ID_MASK) >>
+		__RTE_TRACE_FIELD_ID_SHIFT;
+}
+
 /* Trace point list functions */
 STAILQ_HEAD(trace_point_head, trace_point);
 
lib/librte_eal/rte_eal_version.map +9 -0
index 02a595126..2e6aacc17 100644
@@ -341,4 +341,13 @@ EXPERIMENTAL {
 	per_lcore_trace_point_sz;
 	rte_log_can_log;
 	rte_thread_getname;
+	rte_trace_is_enabled;
+	rte_trace_mode_get;
+	rte_trace_mode_set;
+	rte_trace_pattern;
+	rte_trace_point_disable;
+	rte_trace_point_enable;
+	rte_trace_point_is_enabled;
+	rte_trace_point_lookup;
+	rte_trace_regexp;
 };
Signature · 1 line
2.25.1
#244 lore raw

Re: [dpdk-dev] [PATCH v6 05/33] eal/trace: implement trace operation APIs

lib/librte_eal/common/eal_common_trace.c line 8

Quoted 11 lines · On Sun, Apr 19, 2020 at 12:02 PM <[email protected]> wrote:
lib/librte_eal/common/eal_common_trace.c +2 -0
index 5c5cbd2a1..1ca702f68 100644
@@ -3,7 +3,9 @@
  */
 
 #include <inttypes.h>
+#include <fnmatch.h>
 #include <sys/queue.h>
+#include <regex.h>

Alphabetical sort when possible.

Quoted 21 lines
lib/librte_eal/common/eal_common_trace.c +14 -0
 #include <rte_common.h>
 #include <rte_errno.h>
@@ -20,6 +22,151 @@ static RTE_DEFINE_PER_LCORE(int, ctf_count);
 static struct trace_point_head tp_list = STAILQ_HEAD_INITIALIZER(tp_list);
 static struct trace trace;
 
+bool
+rte_trace_is_enabled(void)
+{
+       return trace.status;
+}
+
+static void
+trace_mode_set(rte_trace_point_t *trace, enum rte_trace_mode mode)
+{
+       if (mode == RTE_TRACE_MODE_OVERWRITE)
+               __atomic_and_fetch(trace, ~__RTE_TRACE_FIELD_ENABLE_DISCARD,
+                                  __ATOMIC_RELEASE);
+       else
+               __atomic_or_fetch(trace, __RTE_TRACE_FIELD_ENABLE_DISCARD,

lib/librte_eal/common/eal_common_trace.c static RTE_DEFINE_PER_LCORE(int, ctf_count); · line 48

Quoted 10 lines
lib/librte_eal/common/eal_common_trace.c +10 -0
+                                 __ATOMIC_RELEASE);
+}
+
+void
+rte_trace_mode_set(enum rte_trace_mode mode)
+{
+       struct trace_point *tp;
+
+       if (rte_trace_is_enabled() == false)
+               return;

rte_trace_is_enabled() returns a boolean, no need to test its value, should be:
if (!rte_trace_is_enabled())

Quoted 8 lines
lib/librte_eal/common/eal_common_trace.c +8 -0
+
+       STAILQ_FOREACH(tp, &tp_list, next)
+               trace_mode_set(tp->handle, mode);
+
+       trace.mode = mode;
+}
+
+enum

lib/librte_eal/common/eal_common_trace.c static RTE_DEFINE_PER_LCORE(int, ctf_count); · line 66

Quoted 10 lines
lib/librte_eal/common/eal_common_trace.c +10 -0
+rte_trace_mode rte_trace_mode_get(void)
+{
+       return trace.mode;
+}
+
+static bool
+trace_point_is_invalid(rte_trace_point_t *t)
+{
+       if (t == NULL)
+               return false;

Should be "return true"?

Or maybe simply rewrite as:

static bool
trace_point_is_invalid(rte_trace_point_t *t)

{
        return (t == NULL) || (trace_id_get(t) >= trace.nb_trace_points);
}
Quoted 7 lines
lib/librte_eal/common/eal_common_trace.c +7 -0
+
+       if (trace_id_get(t) >= trace.nb_trace_points)
+               return true;
+
+       return false;
+}
+

lib/librte_eal/common/eal_common_trace.c static RTE_DEFINE_PER_LCORE(int, ctf_count); · line 83

Quoted 10 lines
lib/librte_eal/common/eal_common_trace.c +10 -0
+bool
+rte_trace_point_is_enabled(rte_trace_point_t *trace)
+{
+       uint64_t val;
+
+       if (trace_point_is_invalid(trace))
+               return false;
+
+       val = __atomic_load_n(trace, __ATOMIC_ACQUIRE);
+       return val & __RTE_TRACE_FIELD_ENABLE_MASK;

We return a boolean, should be
return (val & __RTE_TRACE_FIELD_ENABLE_MASK) != 0;

Quoted 13 lines
lib/librte_eal/common/eal_common_trace.c +13 -0
+}
+
+int
+rte_trace_point_enable(rte_trace_point_t *trace)
+{
+       if (trace_point_is_invalid(trace))
+               return -ERANGE;
+
+       __atomic_or_fetch(trace, __RTE_TRACE_FIELD_ENABLE_MASK,
+                         __ATOMIC_RELEASE);
+       return 0;
+}
+

lib/librte_eal/common/eal_common_trace.c static RTE_DEFINE_PER_LCORE(int, ctf_count); · line 106

Quoted 10 lines
lib/librte_eal/common/eal_common_trace.c +10 -0
+int
+rte_trace_point_disable(rte_trace_point_t *trace)
+{
+       if (trace_point_is_invalid(trace))
+               return -ERANGE;
+
+       __atomic_and_fetch(trace, ~__RTE_TRACE_FIELD_ENABLE_MASK,
+                          __ATOMIC_RELEASE);
+       return 0;
+}

For both rte_trace_point_enable/disable, we only check tracepoint validity. Can't we just return a boolean, do we expect many error codes?

Quoted 37 lines
lib/librte_eal/common/eal_common_trace.c +37 -0
+
+int
+rte_trace_pattern(const char *pattern, bool enable)
+{
+       struct trace_point *tp;
+       int rc = 0, found = 0;
+
+       STAILQ_FOREACH(tp, &tp_list, next) {
+               if (fnmatch(pattern, tp->name, 0) == 0) {
+                       if (enable)
+                               rc = rte_trace_point_enable(tp->handle);
+                       else
+                               rc = rte_trace_point_disable(tp->handle);
+                       found = 1;
+               }
+               if (rc < 0)
+                       return rc;
+       }
+
+       return rc | found;
+}
+
+int
+rte_trace_regexp(const char *regex, bool enable)
+{
+       struct trace_point *tp;
+       int rc = 0, found = 0;
+       regex_t r;
+
+       if (regcomp(&r, regex, 0) != 0)
+               return -EINVAL;
+
+       STAILQ_FOREACH(tp, &tp_list, next) {
+               if (regexec(&r, tp->name, 0, NULL, 0) == 0) {
+                       if (enable)
+                               rc = rte_trace_point_enable(tp->handle);
+                       else

lib/librte_eal/common/eal_common_trace.c static RTE_DEFINE_PER_LCORE(int, ctf_count); · line 153

Quoted 10 lines
lib/librte_eal/common/eal_common_trace.c +10 -0
+                               rc = rte_trace_point_disable(tp->handle);
+                       found = 1;
+               }
+               if (rc < 0)
+                       return rc;
+       }
+       regfree(&r);
+
+       return rc | found;
+}

For both rte_trace_pattern/rte_trace_regexp, tp is a member of tp_list. It means this tracepoint went through proper registration. Hence, checking for a return value from rte_trace_point_(en|dis)able is unneeded.

Signature · 1 line
David Marchand
#245 lore raw

Re: [dpdk-dev] [PATCH v6 05/33] eal/trace: implement trace operation APIs

Quoted 9 lines · David Marchand
Quoted 7 lines · On Sun, Apr 19, 2020 at 12:02 PM <[email protected]> wrote:
lib/librte_eal/common/eal_common_trace.c +0 -0
index 5c5cbd2a1..1ca702f68 100644
@@ -3,7 +3,9 @@
  */
 
Quoted 6 lines

lib/librte_eal/common/eal_common_trace.c line 8

Quoted 4 lines
lib/librte_eal/common/eal_common_trace.c +2 -0
 #include <inttypes.h>
+#include <fnmatch.h>
 #include <sys/queue.h>
+#include <regex.h>

Alphabetical sort when possible.

Ack. Wil fix it v7

Quoted 27 lines
Quoted 27 lines
lib/librte_eal/common/eal_common_trace.c +19 -0
 #include <rte_common.h>
 #include <rte_errno.h>
@@ -20,6 +22,151 @@ static RTE_DEFINE_PER_LCORE(int, ctf_count);
 static struct trace_point_head tp_list = STAILQ_HEAD_INITIALIZER(tp_list);
 static struct trace trace;
 
+bool
+rte_trace_is_enabled(void)
+{
+       return trace.status;
+}
+
+static void
+trace_mode_set(rte_trace_point_t *trace, enum rte_trace_mode mode)
+{
+       if (mode == RTE_TRACE_MODE_OVERWRITE)
+               __atomic_and_fetch(trace, ~__RTE_TRACE_FIELD_ENABLE_DISCARD,
+                                  __ATOMIC_RELEASE);
+       else
+               __atomic_or_fetch(trace, __RTE_TRACE_FIELD_ENABLE_DISCARD,
+                                 __ATOMIC_RELEASE);
+}
+
+void
+rte_trace_mode_set(enum rte_trace_mode mode)
Quoted 8 lines

lib/librte_eal/common/eal_common_trace.c static RTE_DEFINE_PER_LCORE(int, ctf_count); · line 48

Quoted 5 lines
lib/librte_eal/common/eal_common_trace.c +5 -0
+{
+       struct trace_point *tp;
+
+       if (rte_trace_is_enabled() == false)
+               return;

rte_trace_is_enabled() returns a boolean, no need to test its value, should be:
if (!rte_trace_is_enabled())

I like the ! scheme. I thought, DPDK community like == false scheme. I will change it in v7.

Quoted 23 lines
Quoted 10 lines
lib/librte_eal/common/eal_common_trace.c +8 -0
+
+       STAILQ_FOREACH(tp, &tp_list, next)
+               trace_mode_set(tp->handle, mode);
+
+       trace.mode = mode;
+}
+
+enum

lib/librte_eal/common/eal_common_trace.c static RTE_DEFINE_PER_LCORE(int, ctf_count); · line 66

Quoted 10 lines
lib/librte_eal/common/eal_common_trace.c +10 -0
+rte_trace_mode rte_trace_mode_get(void)
+{
+       return trace.mode;
+}
+
+static bool
+trace_point_is_invalid(rte_trace_point_t *t)
+{
+       if (t == NULL)
+               return false;

Should be "return true"?

Quoted 7 lines

Or maybe simply rewrite as:

static bool
trace_point_is_invalid(rte_trace_point_t *t)

{
        return (t == NULL) || (trace_id_get(t) >= trace.nb_trace_points);
}

Ack.

Quoted 13 lines
Quoted 13 lines
lib/librte_eal/common/eal_common_trace.c +12 -0
+
+       if (trace_id_get(t) >= trace.nb_trace_points)
+               return true;
+
+       return false;
+}
+
+bool
+rte_trace_point_is_enabled(rte_trace_point_t *trace)
+{
+       uint64_t val;
+
Quoted 8 lines

lib/librte_eal/common/eal_common_trace.c static RTE_DEFINE_PER_LCORE(int, ctf_count); · line 83

Quoted 5 lines
lib/librte_eal/common/eal_common_trace.c +5 -0
+       if (trace_point_is_invalid(trace))
+               return false;
+
+       val = __atomic_load_n(trace, __ATOMIC_ACQUIRE);
+       return val & __RTE_TRACE_FIELD_ENABLE_MASK;

We return a boolean, should be
return (val & __RTE_TRACE_FIELD_ENABLE_MASK) != 0;

Ack.

Quoted 20 lines
Quoted 20 lines
lib/librte_eal/common/eal_common_trace.c +18 -0
+}
+
+int
+rte_trace_point_enable(rte_trace_point_t *trace)
+{
+       if (trace_point_is_invalid(trace))
+               return -ERANGE;
+
+       __atomic_or_fetch(trace, __RTE_TRACE_FIELD_ENABLE_MASK,
+                         __ATOMIC_RELEASE);
+       return 0;
+}
+
+int
+rte_trace_point_disable(rte_trace_point_t *trace)
+{
+       if (trace_point_is_invalid(trace))
+               return -ERANGE;
Quoted 8 lines

lib/librte_eal/common/eal_common_trace.c static RTE_DEFINE_PER_LCORE(int, ctf_count); · line 106

Quoted 5 lines
lib/librte_eal/common/eal_common_trace.c +5 -0
+
+       __atomic_and_fetch(trace, ~__RTE_TRACE_FIELD_ENABLE_MASK,
+                          __ATOMIC_RELEASE);
+       return 0;
+}

For both rte_trace_point_enable/disable, we only check tracepoint validity. Can't we just return a boolean, do we expect many error codes?

I think, it is better to return "int" so that we may not ABI the change in future.

Quoted 46 lines
Quoted 46 lines
lib/librte_eal/common/eal_common_trace.c +44 -0
+
+int
+rte_trace_pattern(const char *pattern, bool enable)
+{
+       struct trace_point *tp;
+       int rc = 0, found = 0;
+
+       STAILQ_FOREACH(tp, &tp_list, next) {
+               if (fnmatch(pattern, tp->name, 0) == 0) {
+                       if (enable)
+                               rc = rte_trace_point_enable(tp->handle);
+                       else
+                               rc = rte_trace_point_disable(tp->handle);
+                       found = 1;
+               }
+               if (rc < 0)
+                       return rc;
+       }
+
+       return rc | found;
+}
+
+int
+rte_trace_regexp(const char *regex, bool enable)
+{
+       struct trace_point *tp;
+       int rc = 0, found = 0;
+       regex_t r;
+
+       if (regcomp(&r, regex, 0) != 0)
+               return -EINVAL;
+
+       STAILQ_FOREACH(tp, &tp_list, next) {
+               if (regexec(&r, tp->name, 0, NULL, 0) == 0) {
+                       if (enable)
+                               rc = rte_trace_point_enable(tp->handle);
+                       else
+                               rc = rte_trace_point_disable(tp->handle);
+                       found = 1;
+               }
+               if (rc < 0)
+                       return rc;
+       }
+       regfree(&r);
Quoted 8 lines

lib/librte_eal/common/eal_common_trace.c static RTE_DEFINE_PER_LCORE(int, ctf_count); · line 127

Quoted 3 lines
lib/librte_eal/common/eal_common_trace.c +3 -0
+
+       return rc | found;
+}

For both rte_trace_pattern/rte_trace_regexp, tp is a member of tp_list. It means this tracepoint went through proper registration. Hence, checking for a return value from rte_trace_point_(en|dis)able is unneeded.

Yes. I thought of it, But I think, it is safe to check the return code as it absorbs any
future rte_trace_point_enable() changes. It slow-path code, so it OK IMO.

Quoted 5 lines

--
David Marchand

#246 lore raw

Re: [dpdk-dev] [PATCH v6 05/33] eal/trace: implement trace operation APIs

Quoted 32 lines · Jerin Jacob
Quoted 23 lines
Quoted 23 lines
lib/librte_eal/common/eal_common_trace.c +19 -0
@@ -20,6 +22,151 @@ static RTE_DEFINE_PER_LCORE(int, ctf_count);
 static struct trace_point_head tp_list = STAILQ_HEAD_INITIALIZER(tp_list);
 static struct trace trace;
 
+bool
+rte_trace_is_enabled(void)
+{
+       return trace.status;
+}
+
+static void
+trace_mode_set(rte_trace_point_t *trace, enum rte_trace_mode mode)
+{
+       if (mode == RTE_TRACE_MODE_OVERWRITE)
+               __atomic_and_fetch(trace, ~__RTE_TRACE_FIELD_ENABLE_DISCARD,
+                                  __ATOMIC_RELEASE);
+       else
+               __atomic_or_fetch(trace, __RTE_TRACE_FIELD_ENABLE_DISCARD,
+                                 __ATOMIC_RELEASE);
+}
+
+void
+rte_trace_mode_set(enum rte_trace_mode mode)
Quoted 8 lines

lib/librte_eal/common/eal_common_trace.c static RTE_DEFINE_PER_LCORE(int, ctf_count); · line 48

Quoted 5 lines
lib/librte_eal/common/eal_common_trace.c +5 -0
+{
+       struct trace_point *tp;
+
+       if (rte_trace_is_enabled() == false)
+               return;

rte_trace_is_enabled() returns a boolean, no need to test its value, should be:
if (!rte_trace_is_enabled())

Quoted 2 lines

I like the ! scheme. I thought, DPDK community like == false scheme. I will change it in v7.

Not obvious, but I understand this part as talking about the boolean case:
https://doc.dpdk.org/guides/contributing/coding_style.html#null-pointers

"Do not use ! for tests unless it is a boolean, for example, use:"

Quoted 25 lines
Quoted 16 lines
Quoted 16 lines
lib/librte_eal/common/eal_common_trace.c +16 -0
+int
+rte_trace_point_enable(rte_trace_point_t *trace)
+{
+       if (trace_point_is_invalid(trace))
+               return -ERANGE;
+
+       __atomic_or_fetch(trace, __RTE_TRACE_FIELD_ENABLE_MASK,
+                         __ATOMIC_RELEASE);
+       return 0;
+}
+
+int
+rte_trace_point_disable(rte_trace_point_t *trace)
+{
+       if (trace_point_is_invalid(trace))
+               return -ERANGE;
Quoted 8 lines

lib/librte_eal/common/eal_common_trace.c static RTE_DEFINE_PER_LCORE(int, ctf_count); · line 106

Quoted 5 lines
lib/librte_eal/common/eal_common_trace.c +5 -0
+
+       __atomic_and_fetch(trace, ~__RTE_TRACE_FIELD_ENABLE_MASK,
+                          __ATOMIC_RELEASE);
+       return 0;
+}

For both rte_trace_point_enable/disable, we only check tracepoint validity. Can't we just return a boolean, do we expect many error codes?

Quoted 2 lines

I think, it is better to return "int" so that we may not ABI the change in future.

Ok, fair enough.

Quoted 53 lines
Quoted 44 lines
Quoted 44 lines
lib/librte_eal/common/eal_common_trace.c +44 -0
+
+int
+rte_trace_pattern(const char *pattern, bool enable)
+{
+       struct trace_point *tp;
+       int rc = 0, found = 0;
+
+       STAILQ_FOREACH(tp, &tp_list, next) {
+               if (fnmatch(pattern, tp->name, 0) == 0) {
+                       if (enable)
+                               rc = rte_trace_point_enable(tp->handle);
+                       else
+                               rc = rte_trace_point_disable(tp->handle);
+                       found = 1;
+               }
+               if (rc < 0)
+                       return rc;
+       }
+
+       return rc | found;
+}
+
+int
+rte_trace_regexp(const char *regex, bool enable)
+{
+       struct trace_point *tp;
+       int rc = 0, found = 0;
+       regex_t r;
+
+       if (regcomp(&r, regex, 0) != 0)
+               return -EINVAL;
+
+       STAILQ_FOREACH(tp, &tp_list, next) {
+               if (regexec(&r, tp->name, 0, NULL, 0) == 0) {
+                       if (enable)
+                               rc = rte_trace_point_enable(tp->handle);
+                       else
+                               rc = rte_trace_point_disable(tp->handle);
+                       found = 1;
+               }
+               if (rc < 0)
+                       return rc;
+       }
+       regfree(&r);
Quoted 8 lines

lib/librte_eal/common/eal_common_trace.c static RTE_DEFINE_PER_LCORE(int, ctf_count); · line 127

Quoted 3 lines
lib/librte_eal/common/eal_common_trace.c +3 -0
+
+       return rc | found;
+}

For both rte_trace_pattern/rte_trace_regexp, tp is a member of tp_list. It means this tracepoint went through proper registration. Hence, checking for a return value from rte_trace_point_(en|dis)able is unneeded.

Quoted 3 lines

Yes. I thought of it, But I think, it is safe to check the return code as it absorbs any
future rte_trace_point_enable() changes. It slow-path code, so it OK IMO.

Would be odd to predict what happened if we broke for this loop on one tracepoint error, but ok to leave as is.

Signature · 1 line
David Marchand
#247 lore raw

PATCH v6 6/33 eal/trace: add internal trace init and fini interface

In reply to [email protected]

From: Jerin Jacob <[email protected]>

Define eal_trace_init() and eal_trace_fini() EAL interface functions that rte_eal_init() and rte_eal_cleanup() function can be use to initialize and finalize the trace subsystem. eal_trace_init() function will add the following functionality if trace is enabled through EAL command line param.

- Test for trace registration failure.
- Test for duplicate trace name registration
- Generate UUID ver 4.
- Create a trace directory

---
 lib/librte_eal/common/eal_common_trace.c      |  54 ++++++
 .../common/eal_common_trace_utils.c           | 173 ++++++++++++++++++
 lib/librte_eal/common/eal_trace.h             |  22 +++
 lib/librte_eal/common/meson.build             |   1 +
 lib/librte_eal/freebsd/Makefile               |   1 +
 lib/librte_eal/linux/Makefile                 |   1 +
 6 files changed, 252 insertions(+)
 create mode 100644 lib/librte_eal/common/eal_common_trace_utils.c
lib/librte_eal/common/eal_common_trace.c +54 -0
index 1ca702f68..557054c65 100644
@@ -22,6 +22,60 @@ static RTE_DEFINE_PER_LCORE(int, ctf_count);
 static struct trace_point_head tp_list = STAILQ_HEAD_INITIALIZER(tp_list);
 static struct trace trace;
 
+struct trace*
+trace_obj_get(void)
+{
+	return &trace;
+}
+
+struct trace_point_head *
+trace_list_head_get(void)
+{
+	return &tp_list;
+}
+
+int
+eal_trace_init(void)
+{
+	/* One of the Trace registration failed */
+	if (trace.register_errno) {
+		rte_errno = trace.register_errno;
+		goto fail;
+	}
+
+	if (rte_trace_is_enabled() == false)
+		return 0;
+
+	rte_spinlock_init(&trace.lock);
+
+	/* Is duplicate trace name registered */
+	if (trace_has_duplicate_entry())
+		goto fail;
+
+	/* Generate UUID ver 4 with total size of events and number of events */
+	trace_uuid_generate();
+
+	/* Create trace directory */
+	if (trace_mkdir())
+		goto fail;
+
+
+	rte_trace_mode_set(trace.mode);
+
+	return 0;
+
+fail:
+	trace_err("failed to initialize trace [%s]", rte_strerror(rte_errno));
+	return -rte_errno;
+}
+
+void
+eal_trace_fini(void)
+{
+	if (rte_trace_is_enabled() == false)
+		return;
+}
+
 bool
 rte_trace_is_enabled(void)
 {
lib/librte_eal/common/eal_common_trace_utils.c new file +173 -0

173 lines not on this page · raw message

lib/librte_eal/common/eal_trace.h +22 -0
index ebf7914ff..deb57dd4c 100644
@@ -5,8 +5,10 @@
 #ifndef __EAL_TRACE_H
 #define __EAL_TRACE_H
 
+#include <rte_spinlock.h>
 #include <rte_trace.h>
 #include <rte_trace_point.h>
+#include <rte_uuid.h>
 
 #define trace_err(fmt, args...)\
 	RTE_LOG(ERR, EAL, "%s():%u " fmt "\n",\
@@ -16,6 +18,8 @@
 	RTE_LOG(CRIT, EAL, "%s():%u " fmt "\n",\
 		__func__, __LINE__, ## args)
 
+#define TRACE_PREFIX_LEN 12
+#define TRACE_DIR_STR_LEN (sizeof("YYYY-mm-dd-AM-HH-MM-SS") + TRACE_PREFIX_LEN)
 #define TRACE_CTF_FIELD_SIZE 384
 #define TRACE_POINT_NAME_SIZE 64
 
@@ -27,10 +31,15 @@ struct trace_point {
 };
 
 struct trace {
+	char dir[PATH_MAX];
+	int dir_offset;
 	int register_errno;
 	bool status;
 	enum rte_trace_mode mode;
+	rte_uuid_t uuid;
+	uint32_t buff_len;
 	uint32_t nb_trace_points;
+	rte_spinlock_t lock;
 };
 
 /* Helper functions */
@@ -41,7 +50,20 @@ trace_id_get(rte_trace_point_t *trace)
 		__RTE_TRACE_FIELD_ID_SHIFT;
 }
 
+/* Trace object functions */
+struct trace *trace_obj_get(void);
+
 /* Trace point list functions */
 STAILQ_HEAD(trace_point_head, trace_point);
+struct trace_point_head *trace_list_head_get(void);
+
+/* Util functions */
+bool trace_has_duplicate_entry(void);
+void trace_uuid_generate(void);
+int trace_mkdir(void);
+
+/* EAL interface */
+int eal_trace_init(void);
+void eal_trace_fini(void);
 
 #endif /* __EAL_TRACE_H */
lib/librte_eal/common/meson.build +1 -0
index 429e89f99..3dc320327 100644
@@ -43,6 +43,7 @@ sources += files(
 	'eal_common_thread.c',
 	'eal_common_timer.c',
 	'eal_common_trace.c',
+	'eal_common_trace_utils.c',
 	'eal_common_uuid.c',
 	'hotplug_mp.c',
 	'malloc_elem.c',
lib/librte_eal/freebsd/Makefile +1 -0
index 500afc578..ae59c8c19 100644
@@ -60,6 +60,7 @@ SRCS-$(CONFIG_RTE_EXEC_ENV_FREEBSD) += eal_common_proc.c
 SRCS-$(CONFIG_RTE_EXEC_ENV_FREEBSD) += eal_common_fbarray.c
 SRCS-$(CONFIG_RTE_EXEC_ENV_FREEBSD) += eal_common_uuid.c
 SRCS-$(CONFIG_RTE_EXEC_ENV_FREEBSD) += eal_common_trace.c
+SRCS-$(CONFIG_RTE_EXEC_ENV_FREEBSD) += eal_common_trace_utils.c
 SRCS-$(CONFIG_RTE_EXEC_ENV_FREEBSD) += rte_malloc.c
 SRCS-$(CONFIG_RTE_EXEC_ENV_FREEBSD) += hotplug_mp.c
 SRCS-$(CONFIG_RTE_EXEC_ENV_FREEBSD) += malloc_elem.c
lib/librte_eal/linux/Makefile +1 -0
index 2ced2085b..7992500a9 100644
@@ -67,6 +67,7 @@ SRCS-$(CONFIG_RTE_EXEC_ENV_LINUX) += eal_common_proc.c
 SRCS-$(CONFIG_RTE_EXEC_ENV_LINUX) += eal_common_fbarray.c
 SRCS-$(CONFIG_RTE_EXEC_ENV_LINUX) += eal_common_uuid.c
 SRCS-$(CONFIG_RTE_EXEC_ENV_LINUX) += eal_common_trace.c
+SRCS-$(CONFIG_RTE_EXEC_ENV_LINUX) += eal_common_trace_utils.c
 SRCS-$(CONFIG_RTE_EXEC_ENV_LINUX) += rte_malloc.c
 SRCS-$(CONFIG_RTE_EXEC_ENV_LINUX) += hotplug_mp.c
 SRCS-$(CONFIG_RTE_EXEC_ENV_LINUX) += malloc_elem.c
Signature · 1 line
2.25.1
#248 lore raw

PATCH v6 7/33 eal/trace: get bootup timestamp for trace

In reply to [email protected]

From: Jerin Jacob <[email protected]>

Find epoch_sec, epoch_nsec and uptime_ticks time information on eal_trace_init()/bootup to derive the time in the trace.

---
 lib/librte_eal/common/eal_common_trace.c      |  3 +++
 .../common/eal_common_trace_utils.c           | 22 +++++++++++++++++++
 lib/librte_eal/common/eal_trace.h             |  5 +++++
 3 files changed, 30 insertions(+)
lib/librte_eal/common/eal_common_trace.c +3 -0
index 557054c65..bbfc4fc2f 100644
@@ -59,6 +59,9 @@ eal_trace_init(void)
 	if (trace_mkdir())
 		goto fail;
 
+	/* Save current epoch timestamp for future use */
+	if (trace_epoch_time_save() < 0)
+		goto fail;
 
 	rte_trace_mode_set(trace.mode);
 
lib/librte_eal/common/eal_common_trace_utils.c +22 -0
index d2ab8f845..f7700934b 100644
@@ -98,6 +98,28 @@ trace_session_name_generate(char *trace_dir)
 	return -rte_errno;
 }
 
+int
+trace_epoch_time_save(void)
+{
+	struct trace *trace = trace_obj_get();
+	struct timespec epoch = { 0, 0 };
+	uint64_t avg, start, end;
+
+	start = rte_get_tsc_cycles();
+	if (clock_gettime(CLOCK_REALTIME, &epoch) < 0) {
+		trace_err("failed to get the epoch time");
+		return -1;
+	}
+	end = rte_get_tsc_cycles();
+	avg = (start + end) >> 1;
+
+	trace->epoch_sec = (uint64_t) epoch.tv_sec;
+	trace->epoch_nsec = (uint64_t) epoch.tv_nsec;
+	trace->uptime_ticks = avg;
+
+	return 0;
+}
+
 static int
 trace_dir_default_path_get(char *dir_path)
 {
lib/librte_eal/common/eal_trace.h +5 -0
index deb57dd4c..493163c1c 100644
@@ -5,6 +5,7 @@
 #ifndef __EAL_TRACE_H
 #define __EAL_TRACE_H
 
+#include <rte_cycles.h>
 #include <rte_spinlock.h>
 #include <rte_trace.h>
 #include <rte_trace_point.h>
@@ -39,6 +40,9 @@ struct trace {
 	rte_uuid_t uuid;
 	uint32_t buff_len;
 	uint32_t nb_trace_points;
+	uint64_t epoch_sec;
+	uint64_t epoch_nsec;
+	uint64_t uptime_ticks;
 	rte_spinlock_t lock;
 };
 
@@ -61,6 +65,7 @@ struct trace_point_head *trace_list_head_get(void);
 bool trace_has_duplicate_entry(void);
 void trace_uuid_generate(void);
 int trace_mkdir(void);
+int trace_epoch_time_save(void);
 
 /* EAL interface */
 int eal_trace_init(void);
Signature · 1 line
2.25.1
#249 lore raw

PATCH v6 8/33 eal/trace: create CTF TDSL metadata in memory

In reply to [email protected]

From: Jerin Jacob <[email protected]>

Common trace format(CTF) defines the metadata[1][2] for trace events, This patch creates the metadata for the DPDK events in memory and latter this will be saved to trace directory on rte_trace_save() invocation.

[1] https://diamon.org/ctf/#specification
[2] https://diamon.org/ctf/#examples

---
 lib/librte_eal/common/eal_common_trace.c     |   9 +-
 lib/librte_eal/common/eal_common_trace_ctf.c | 302 +++++++++++++++++++
 lib/librte_eal/common/eal_trace.h            |   7 +
 lib/librte_eal/common/meson.build            |   1 +
 lib/librte_eal/freebsd/Makefile              |   1 +
 lib/librte_eal/linux/Makefile                |   1 +
 6 files changed, 320 insertions(+), 1 deletion(-)
 create mode 100644 lib/librte_eal/common/eal_common_trace_ctf.c
lib/librte_eal/common/eal_common_trace.c +8 -1
index bbfc4fc2f..8bbc07c03 100644
@@ -55,9 +55,13 @@ eal_trace_init(void)
 	/* Generate UUID ver 4 with total size of events and number of events */
 	trace_uuid_generate();
 
+	/* Generate CTF TDSL metadata */
+	if (trace_metadata_create() < 0)
+		goto fail;
+
 	/* Create trace directory */
 	if (trace_mkdir())
-		goto fail;
+		goto free_meta;
 
 	/* Save current epoch timestamp for future use */
 	if (trace_epoch_time_save() < 0)
@@ -67,6 +71,8 @@ eal_trace_init(void)
 
 	return 0;
 
+free_meta:
+	trace_metadata_destroy();
 fail:
 	trace_err("failed to initialize trace [%s]", rte_strerror(rte_errno));
 	return -rte_errno;
@@ -77,6 +83,7 @@ eal_trace_fini(void)
 {
 	if (rte_trace_is_enabled() == false)
 		return;
+	trace_metadata_destroy();
 }
 
 bool
lib/librte_eal/common/eal_common_trace_ctf.c new file +302 -0

302 lines not on this page · raw message

lib/librte_eal/common/eal_trace.h +7 -0
index 493163c1c..8e8d1160e 100644
@@ -43,6 +43,11 @@ struct trace {
 	uint64_t epoch_sec;
 	uint64_t epoch_nsec;
 	uint64_t uptime_ticks;
+	char *ctf_meta;
+	uint32_t ctf_meta_offset_freq;
+	uint32_t ctf_meta_offset_freq_off_s;
+	uint32_t ctf_meta_offset_freq_off;
+	uint16_t ctf_fixup_done;
 	rte_spinlock_t lock;
 };
 
@@ -64,6 +69,8 @@ struct trace_point_head *trace_list_head_get(void);
 /* Util functions */
 bool trace_has_duplicate_entry(void);
 void trace_uuid_generate(void);
+int trace_metadata_create(void);
+void trace_metadata_destroy(void);
 int trace_mkdir(void);
 int trace_epoch_time_save(void);
 
lib/librte_eal/common/meson.build +1 -0
index 3dc320327..d2ac44313 100644
@@ -43,6 +43,7 @@ sources += files(
 	'eal_common_thread.c',
 	'eal_common_timer.c',
 	'eal_common_trace.c',
+	'eal_common_trace_ctf.c',
 	'eal_common_trace_utils.c',
 	'eal_common_uuid.c',
 	'hotplug_mp.c',
lib/librte_eal/freebsd/Makefile +1 -0
index ae59c8c19..539ad44a7 100644
@@ -60,6 +60,7 @@ SRCS-$(CONFIG_RTE_EXEC_ENV_FREEBSD) += eal_common_proc.c
 SRCS-$(CONFIG_RTE_EXEC_ENV_FREEBSD) += eal_common_fbarray.c
 SRCS-$(CONFIG_RTE_EXEC_ENV_FREEBSD) += eal_common_uuid.c
 SRCS-$(CONFIG_RTE_EXEC_ENV_FREEBSD) += eal_common_trace.c
+SRCS-$(CONFIG_RTE_EXEC_ENV_FREEBSD) += eal_common_trace_ctf.c
 SRCS-$(CONFIG_RTE_EXEC_ENV_FREEBSD) += eal_common_trace_utils.c
 SRCS-$(CONFIG_RTE_EXEC_ENV_FREEBSD) += rte_malloc.c
 SRCS-$(CONFIG_RTE_EXEC_ENV_FREEBSD) += hotplug_mp.c
lib/librte_eal/linux/Makefile +1 -0
index 7992500a9..f00588d6e 100644
@@ -67,6 +67,7 @@ SRCS-$(CONFIG_RTE_EXEC_ENV_LINUX) += eal_common_proc.c
 SRCS-$(CONFIG_RTE_EXEC_ENV_LINUX) += eal_common_fbarray.c
 SRCS-$(CONFIG_RTE_EXEC_ENV_LINUX) += eal_common_uuid.c
 SRCS-$(CONFIG_RTE_EXEC_ENV_LINUX) += eal_common_trace.c
+SRCS-$(CONFIG_RTE_EXEC_ENV_LINUX) += eal_common_trace_ctf.c
 SRCS-$(CONFIG_RTE_EXEC_ENV_LINUX) += eal_common_trace_utils.c
 SRCS-$(CONFIG_RTE_EXEC_ENV_LINUX) += rte_malloc.c
 SRCS-$(CONFIG_RTE_EXEC_ENV_LINUX) += hotplug_mp.c
Signature · 1 line
2.25.1
#250 lore raw

PATCH v6 9/33 eal/trace: handle CTF keyword collision

In reply to [email protected]

From: Sunil Kumar Kori <[email protected]>

Some of the keyword like align, event, "." and "->" etc will be used in CTF metadata syntax. This patch support for handling those keywords with DPDK events name.

---
 lib/librte_eal/common/eal_common_trace_ctf.c | 119 +++++++++++++++++++
 1 file changed, 119 insertions(+)
lib/librte_eal/common/eal_common_trace_ctf.c +119 -0
index 5ad44cc8d..c4f00bf22 100644
@@ -215,12 +215,131 @@ meta_stream_emit(char **meta, int *offset)
 	return meta_copy(meta, offset, str, rc);
 }
 
+static void
+string_fixed_replace(char *input, const char *search, const char *replace)
+{
+	char *found;
+	size_t len;
+
+	found = strstr(input, search);
+	if (found == NULL)
+		return;
+
+	if (strlen(found) != strlen(search))
+		return;
+
+	len = strlen(replace);
+	memcpy(found, replace, len);
+	found[len] = '\0';
+}
+
+static void
+ctf_fixup_align(char *str)
+{
+	string_fixed_replace(str, "align", "_align");
+}
+
+static void
+ctf_fixup_arrow_deref(char *str)
+{
+	const char *replace = "_";
+	const char *search = "->";
+	char *found;
+	size_t len;
+
+	found = strstr(str, search);
+	if (found == NULL)
+		return;
+
+	do {
+		memcpy(found, replace, strlen(replace));
+		len = strlen(found + 2);
+		memcpy(found + 1, found + 2, len);
+		found[len + 1] = '\0';
+		found = strstr(str, search);
+	} while (found != NULL);
+}
+
+static void
+ctf_fixup_dot_deref(char *str)
+{
+	const char *replace = "_";
+	const char *search = ".";
+	char *found;
+	size_t len;
+
+	found = strstr(str, search);
+	if (found == NULL)
+		return;
+
+	len = strlen(replace);
+	do {
+		memcpy(found, replace, len);
+		found = strstr(str, search);
+	} while (found != NULL);
+}
+
+static void
+ctf_fixup_event(char *str)
+{
+	string_fixed_replace(str, "event", "_event");
+}
+
+static int
+ctf_fixup_keyword(char *str)
+{
+	char dup_str[TRACE_CTF_FIELD_SIZE];
+	char input[TRACE_CTF_FIELD_SIZE];
+	const char *delim = ";";
+	char *from;
+	int len;
+
+	if (str == NULL)
+		return 0;
+
+	len = strlen(str);
+	if (len >= TRACE_CTF_FIELD_SIZE) {
+		trace_err("ctf_field reached its maximum limit");
+		return -EMSGSIZE;
+	}
+
+	/* Create duplicate string */
+	strcpy(dup_str, str);
+
+	len = 0;
+	from = strtok(dup_str, delim);
+	while (from != NULL) {
+		strcpy(input, from);
+		ctf_fixup_align(input);
+		ctf_fixup_dot_deref(input);
+		ctf_fixup_arrow_deref(input);
+		ctf_fixup_event(input);
+
+		strcpy(&input[strlen(input)], delim);
+		if ((len + strlen(input)) >= TRACE_CTF_FIELD_SIZE) {
+			trace_err("ctf_field reached its maximum limit");
+			return -EMSGSIZE;
+		}
+
+		strcpy(str + len, input);
+		len += strlen(input);
+		from = strtok(NULL, delim);
+	}
+
+	return 0;
+}
+
 static int
 meta_event_emit(char **meta, int *offset, struct trace_point *tp)
 {
 	char *str = NULL;
 	int rc;
 
+	/* Fixup ctf field string in case it using reserved ctf keywords */
+	rc = ctf_fixup_keyword(tp->ctf_field);
+	if (rc)
+		return rc;
+
 	rc = metadata_printf(&str,
 		"event {\n"
 		"    id = %d;\n"
Signature · 1 line
2.25.1
#251 lore raw

PATCH v6 10/33 eal/trace: implement trace memory allocation

In reply to [email protected]

From: Jerin Jacob <[email protected]>

Trace memory will be allocated per thread to enable lockless trace events updates to the memory. The allocator will first attempt to allocate from hugepage, if not available from hugepage then fallback to malloc memory.

Later in the patches series, This API will be hooked to DPDK fastpath and control plane thread creation API. It is possible for non DPDK thread to use trace events, in that case, trace memory will be allocated on the first event emission.

---
 lib/librte_eal/common/eal_common_trace.c      | 97 +++++++++++++++++++
 .../common/eal_common_trace_utils.c           | 20 ++++
 lib/librte_eal/common/eal_trace.h             | 28 ++++++
 lib/librte_eal/include/rte_trace_point.h      |  9 ++
 .../include/rte_trace_point_provider.h        | 20 ++++
 lib/librte_eal/rte_eal_version.map            |  2 +
 6 files changed, 176 insertions(+)
lib/librte_eal/common/eal_common_trace.c +97 -0
index 8bbc07c03..4c03a676a 100644
@@ -16,6 +16,7 @@
 #include "eal_trace.h"
 
 RTE_DEFINE_PER_LCORE(volatile int, trace_point_sz);
+RTE_DEFINE_PER_LCORE(void *, trace_mem);
 static RTE_DEFINE_PER_LCORE(char, ctf_field[TRACE_CTF_FIELD_SIZE]);
 static RTE_DEFINE_PER_LCORE(int, ctf_count);
 
@@ -37,6 +38,9 @@ trace_list_head_get(void)
 int
 eal_trace_init(void)
 {
+	/* Trace memory should start with 8B aligned for natural alignment */
+	RTE_BUILD_BUG_ON((offsetof(struct __rte_trace_header, mem) % 8) != 0);
+
 	/* One of the Trace registration failed */
 	if (trace.register_errno) {
 		rte_errno = trace.register_errno;
@@ -83,6 +87,7 @@ eal_trace_fini(void)
 {
 	if (rte_trace_is_enabled() == false)
 		return;
+	trace_mem_per_thread_free();
 	trace_metadata_destroy();
 }
 
@@ -231,6 +236,98 @@ rte_trace_point_lookup(const char *name)
 	return NULL;
 }
 
+static inline size_t
+list_sz(uint32_t index)
+{
+	return sizeof(struct thread_mem_meta) * (index + 1);
+}
+
+void
+__rte_trace_mem_per_thread_alloc(void)
+{
+	struct trace *trace = trace_obj_get();
+	struct __rte_trace_header *header;
+	uint32_t count;
+
+	if (rte_trace_is_enabled() == false)
+		return;
+
+	if (RTE_PER_LCORE(trace_mem))
+		return;
+
+	rte_spinlock_lock(&trace->lock);
+
+	count = trace->nb_trace_mem_list;
+
+	/* Allocate room for storing the thread trace mem meta */
+	trace->lcore_meta = realloc(trace->lcore_meta, list_sz(count));
+
+	/* Provide dummy space for fastpath to consume */
+	if (trace->lcore_meta == NULL) {
+		trace_crit("trace mem meta memory realloc failed");
+		header = NULL; goto fail;
+	}
+
+	/* First attempt from huge page */
+	header = rte_malloc(NULL, trace_mem_sz(trace->buff_len), 8);
+	if (header) {
+		trace->lcore_meta[count].area = TRACE_AREA_HUGEPAGE;
+		goto found;
+	}
+
+	/* Second attempt from heap */
+	header = malloc(trace_mem_sz(trace->buff_len));
+	if (header == NULL) {
+		trace_crit("trace mem malloc attempt failed");
+		header = NULL; goto fail;
+
+	}
+
+	/* Second attempt from heap is success */
+	trace->lcore_meta[count].area = TRACE_AREA_HEAP;
+
+	/* Initialize the trace header */
+found:
+	header->offset = 0;
+	header->len = trace->buff_len;
+	header->stream_header.magic = TRACE_CTF_MAGIC;
+	rte_uuid_copy(header->stream_header.uuid, trace->uuid);
+	header->stream_header.lcore_id = rte_lcore_id();
+
+	/* Store the thread name */
+	char *name = header->stream_header.thread_name;
+	memset(name, 0, __RTE_TRACE_EMIT_STRING_LEN_MAX);
+	rte_thread_getname(pthread_self(), name,
+			   __RTE_TRACE_EMIT_STRING_LEN_MAX);
+
+	trace->lcore_meta[count].mem = header;
+	trace->nb_trace_mem_list++;
+fail:
+	RTE_PER_LCORE(trace_mem) = header;
+	rte_spinlock_unlock(&trace->lock);
+}
+
+void
+trace_mem_per_thread_free(void)
+{
+	struct trace *trace = trace_obj_get();
+	uint32_t count;
+	void *mem;
+
+	if (rte_trace_is_enabled() == false)
+		return;
+
+	rte_spinlock_lock(&trace->lock);
+	for (count = 0; count < trace->nb_trace_mem_list; count++) {
+		mem = trace->lcore_meta[count].mem;
+		if (trace->lcore_meta[count].area == TRACE_AREA_HUGEPAGE)
+			rte_free(mem);
+		else if (trace->lcore_meta[count].area == TRACE_AREA_HEAP)
+			free(mem);
+	}
+	rte_spinlock_unlock(&trace->lock);
+}
+
 int
 __rte_trace_point_register(rte_trace_point_t *handle, const char *name,
 			   void (*register_fn)(void))
lib/librte_eal/common/eal_common_trace_utils.c +20 -0
index f7700934b..de8d43661 100644
@@ -14,6 +14,26 @@
 #include "eal_filesystem.h"
 #include "eal_trace.h"
 
+const char *
+trace_mode_to_string(enum rte_trace_mode mode)
+{
+	switch (mode) {
+	case RTE_TRACE_MODE_OVERWRITE: return "overwrite";
+	case RTE_TRACE_MODE_DISCARD: return "discard";
+	default: return "unknown";
+	}
+}
+
+const char *
+trace_area_to_string(enum trace_area_e area)
+{
+	switch (area) {
+	case TRACE_AREA_HEAP: return "heap";
+	case TRACE_AREA_HUGEPAGE: return "hugepage";
+	default: return "unknown";
+	}
+}
+
 static bool
 trace_entry_compare(const char *name)
 {
lib/librte_eal/common/eal_trace.h +28 -0
index 8e8d1160e..e2538d24a 100644
@@ -6,11 +6,16 @@
 #define __EAL_TRACE_H
 
 #include <rte_cycles.h>
+#include <rte_log.h>
+#include <rte_malloc.h>
 #include <rte_spinlock.h>
 #include <rte_trace.h>
 #include <rte_trace_point.h>
 #include <rte_uuid.h>
 
+#include "eal_private.h"
+#include "eal_thread.h"
+
 #define trace_err(fmt, args...)\
 	RTE_LOG(ERR, EAL, "%s():%u " fmt "\n",\
 		__func__, __LINE__, ## args)
@@ -23,6 +28,8 @@
 #define TRACE_DIR_STR_LEN (sizeof("YYYY-mm-dd-AM-HH-MM-SS") + TRACE_PREFIX_LEN)
 #define TRACE_CTF_FIELD_SIZE 384
 #define TRACE_POINT_NAME_SIZE 64
+#define TRACE_CTF_MAGIC 0xC1FC1FC1
+
 
 struct trace_point {
 	STAILQ_ENTRY(trace_point) next;
@@ -31,6 +38,16 @@ struct trace_point {
 	char ctf_field[TRACE_CTF_FIELD_SIZE];
 };
 
+enum trace_area_e {
+	TRACE_AREA_HEAP,
+	TRACE_AREA_HUGEPAGE,
+};
+
+struct thread_mem_meta {
+	void *mem;
+	enum trace_area_e area;
+};
+
 struct trace {
 	char dir[PATH_MAX];
 	int dir_offset;
@@ -40,6 +57,8 @@ struct trace {
 	rte_uuid_t uuid;
 	uint32_t buff_len;
 	uint32_t nb_trace_points;
+	uint32_t nb_trace_mem_list;
+	struct thread_mem_meta *lcore_meta;
 	uint64_t epoch_sec;
 	uint64_t epoch_nsec;
 	uint64_t uptime_ticks;
@@ -59,6 +78,12 @@ trace_id_get(rte_trace_point_t *trace)
 		__RTE_TRACE_FIELD_ID_SHIFT;
 }
 
+static inline size_t
+trace_mem_sz(uint32_t len)
+{
+	return len + sizeof(struct __rte_trace_header);
+}
+
 /* Trace object functions */
 struct trace *trace_obj_get(void);
 
@@ -67,12 +92,15 @@ STAILQ_HEAD(trace_point_head, trace_point);
 struct trace_point_head *trace_list_head_get(void);
 
 /* Util functions */
+const char *trace_mode_to_string(enum rte_trace_mode mode);
+const char *trace_area_to_string(enum trace_area_e area);
 bool trace_has_duplicate_entry(void);
 void trace_uuid_generate(void);
 int trace_metadata_create(void);
 void trace_metadata_destroy(void);
 int trace_mkdir(void);
 int trace_epoch_time_save(void);
+void trace_mem_per_thread_free(void);
 
 /* EAL interface */
 int eal_trace_init(void);
lib/librte_eal/include/rte_trace_point.h +9 -0
index f9924225a..8e37f971e 100644
@@ -227,6 +227,15 @@ __rte_trace_point_fp_is_enabled(void)
 #endif
 }
 
+/**
+ * @internal
+ *
+ * Allocate trace memory buffer per thread.
+ *
+ */
+__rte_experimental
+void __rte_trace_mem_per_thread_alloc(void);
+
 /**
  * @internal
  *
lib/librte_eal/include/rte_trace_point_provider.h +20 -0
index 45a113c0d..b8d727387 100644
@@ -9,6 +9,10 @@
 #ifndef _RTE_TRACE_POINT_PROVIDER_H_
 #define _RTE_TRACE_POINT_PROVIDER_H_
 
+#include <rte_per_lcore.h>
+#include <rte_string_fns.h>
+#include <rte_uuid.h>
+
 #define __RTE_TRACE_EVENT_HEADER_ID_SHIFT (48)
 
 #define __RTE_TRACE_FIELD_SIZE_SHIFT 0
@@ -18,4 +22,20 @@
 #define __RTE_TRACE_FIELD_ENABLE_MASK (1ULL << 63)
 #define __RTE_TRACE_FIELD_ENABLE_DISCARD (1ULL << 62)
 
+struct __rte_trace_stream_header {
+	uint32_t magic;
+	rte_uuid_t uuid;
+	uint32_t lcore_id;
+	char thread_name[__RTE_TRACE_EMIT_STRING_LEN_MAX];
+} __rte_packed;
+
+struct __rte_trace_header {
+	uint32_t offset;
+	uint32_t len;
+	struct __rte_trace_stream_header stream_header;
+	uint8_t mem[];
+};
+
+RTE_DECLARE_PER_LCORE(void *, trace_mem);
+
 #endif /* _RTE_TRACE_POINT_PROVIDER_H_ */
lib/librte_eal/rte_eal_version.map +2 -0
index 2e6aacc17..98e0f8413 100644
@@ -337,7 +337,9 @@ EXPERIMENTAL {
 	rte_thread_is_intr;
 
 	# added in 20.05
+	__rte_trace_mem_per_thread_alloc;
 	__rte_trace_point_register;
+	per_lcore_trace_mem;
 	per_lcore_trace_point_sz;
 	rte_log_can_log;
 	rte_thread_getname;
Signature · 1 line
2.25.1
#252 lore raw

PATCH v6 11/33 eal/trace: implement debug dump function

In reply to [email protected]

From: Jerin Jacob <[email protected]>

Implement rte_trace_metadata_dump() and rte_trace_dump() functions. Former one used to dump the CTF metadata file and the latter one to dump all the registered events and its status.

---
 lib/librte_eal/common/eal_common_trace.c     | 57 +++++++++++++++++
 lib/librte_eal/common/eal_common_trace_ctf.c | 67 ++++++++++++++++++++
 lib/librte_eal/rte_eal_version.map           |  2 +
 3 files changed, 126 insertions(+)
lib/librte_eal/common/eal_common_trace.c +57 -0
index 4c03a676a..e8e1bc693 100644
@@ -236,6 +236,63 @@ rte_trace_point_lookup(const char *name)
 	return NULL;
 }
 
+static void
+trace_point_dump(FILE *f, struct trace_point *tp)
+{
+	rte_trace_point_t *handle = tp->handle;
+
+	fprintf(f, "\tid %d, %s, size is %d, %s\n",
+		trace_id_get(handle), tp->name,
+		(uint16_t)(*handle & __RTE_TRACE_FIELD_SIZE_MASK),
+		rte_trace_point_is_enabled(handle) ? "enabled" : "disabled");
+}
+
+static void
+trace_lcore_mem_dump(FILE *f)
+{
+	struct trace *trace = trace_obj_get();
+	struct __rte_trace_header *header;
+	uint32_t count;
+
+	if (trace->nb_trace_mem_list == 0)
+		return;
+
+	rte_spinlock_lock(&trace->lock);
+	fprintf(f, "nb_trace_mem_list = %d\n", trace->nb_trace_mem_list);
+	fprintf(f, "\nTrace mem info\n--------------\n");
+	for (count = 0; count < trace->nb_trace_mem_list; count++) {
+		header = trace->lcore_meta[count].mem;
+		fprintf(f, "\tid %d, mem=%p, area=%s, lcore_id=%d, name=%s\n",
+		count, header,
+		trace_area_to_string(trace->lcore_meta[count].area),
+		header->stream_header.lcore_id,
+		header->stream_header.thread_name);
+	}
+	rte_spinlock_unlock(&trace->lock);
+}
+
+void
+rte_trace_dump(FILE *f)
+{
+	struct trace_point_head *tp_list = trace_list_head_get();
+	struct trace *trace = trace_obj_get();
+	struct trace_point *tp;
+
+	fprintf(f, "\nGlobal info\n-----------\n");
+	fprintf(f, "status = %s\n",
+		rte_trace_is_enabled() ? "enabled" : "disabled");
+	fprintf(f, "mode = %s\n",
+		trace_mode_to_string(rte_trace_mode_get()));
+	fprintf(f, "dir = %s\n", trace->dir);
+	fprintf(f, "buffer len = %d\n", trace->buff_len);
+	fprintf(f, "number of trace points = %d\n", trace->nb_trace_points);
+
+	trace_lcore_mem_dump(f);
+	fprintf(f, "\nTrace point info\n----------------\n");
+	STAILQ_FOREACH(tp, tp_list, next)
+		trace_point_dump(f, tp);
+}
+
 static inline size_t
 list_sz(uint32_t index)
 {
lib/librte_eal/common/eal_common_trace_ctf.c +67 -0

70 lines not on this page · raw message

lib/librte_eal/rte_eal_version.map +2 -0
index 98e0f8413..7bda1704c 100644
@@ -343,7 +343,9 @@ EXPERIMENTAL {
 	per_lcore_trace_point_sz;
 	rte_log_can_log;
 	rte_thread_getname;
+	rte_trace_dump;
 	rte_trace_is_enabled;
+	rte_trace_metadata_dump;
 	rte_trace_mode_get;
 	rte_trace_mode_set;
 	rte_trace_pattern;
Signature · 1 line
2.25.1
#253 lore raw

PATCH v6 12/33 eal/trace: implement trace save

In reply to [email protected]

From: Jerin Jacob <[email protected]>

Implement rte_trace_save(), which will save the metadata file and trace memory snapshot to the trace directory.

---
 .../common/eal_common_trace_utils.c           | 80 +++++++++++++++++++
 lib/librte_eal/rte_eal_version.map            |  1 +
 2 files changed, 81 insertions(+)
lib/librte_eal/common/eal_common_trace_utils.c +80 -0
index de8d43661..bbe099473 100644
@@ -213,3 +213,83 @@ trace_mkdir(void)
 	return 0;
 }
 
+static int
+trace_meta_save(struct trace *trace)
+{
+	char file_name[PATH_MAX];
+	FILE *f;
+	int rc;
+
+	rc = snprintf(file_name, PATH_MAX, "%s/metadata", trace->dir);
+	if (rc < 0)
+		return rc;
+
+	f = fopen(file_name, "w");
+	if (f == NULL)
+		return -errno;
+
+	rc = rte_trace_metadata_dump(f);
+
+	if (fclose(f))
+		rc = -errno;
+
+	return rc;
+}
+
+
+static inline int
+trace_file_sz(struct __rte_trace_header *hdr)
+{
+	return sizeof(struct __rte_trace_stream_header) + hdr->offset;
+}
+
+static int
+trace_mem_save(struct trace *trace, struct __rte_trace_header *hdr,
+	       uint32_t cnt)
+{
+	char file_name[PATH_MAX];
+	FILE *f;
+	int rc;
+
+	rc = snprintf(file_name, PATH_MAX, "%s/channel0_%d", trace->dir, cnt);
+	if (rc < 0)
+		return rc;
+
+	f = fopen(file_name, "w");
+	if (f == NULL)
+		return -errno;
+
+	rc = fwrite(&hdr->stream_header, trace_file_sz(hdr), 1, f);
+	rc = (rc == 1) ?  0 : -EACCES;
+
+	if (fclose(f))
+		rc = -errno;
+
+	return rc;
+}
+
+int
+rte_trace_save(void)
+{
+	struct trace *trace = trace_obj_get();
+	struct __rte_trace_header *header;
+	uint32_t count;
+	int rc = 0;
+
+	if (trace->nb_trace_mem_list == 0)
+		return rc;
+
+	rc = trace_meta_save(trace);
+	if (rc)
+		return rc;
+
+	rte_spinlock_lock(&trace->lock);
+	for (count = 0; count < trace->nb_trace_mem_list; count++) {
+		header = trace->lcore_meta[count].mem;
+		rc =  trace_mem_save(trace, header, count);
+		if (rc)
+			break;
+	}
+	rte_spinlock_unlock(&trace->lock);
+	return rc;
+}
lib/librte_eal/rte_eal_version.map +1 -0
index 7bda1704c..b4b3a92e5 100644
@@ -354,4 +354,5 @@ EXPERIMENTAL {
 	rte_trace_point_is_enabled;
 	rte_trace_point_lookup;
 	rte_trace_regexp;
+	rte_trace_save;
 };
Signature · 1 line
2.25.1
#254 lore raw

PATCH v6 13/33 eal/trace: implement registration payload

In reply to [email protected]

From: Jerin Jacob <[email protected]>

The trace function payloads such as rte_trace_point_emit_* have dual functions. The first to emit the payload for the registration function and the second one to act as trace memory emitters.

When it used as registration payload, it will do the following to fulfill the registration job.
- Find out the size of the event
- Generate metadata field string using __rte_trace_point_emit_field().

---
 lib/librte_eal/common/eal_common_trace.c      | 19 +++++++++++++++++++
 lib/librte_eal/include/rte_trace_point.h      | 19 +++++++++++++++++++
 .../include/rte_trace_point_register.h        | 19 +++++++++++++++++++
 lib/librte_eal/rte_eal_version.map            |  1 +
 4 files changed, 58 insertions(+)
lib/librte_eal/common/eal_common_trace.c +19 -0
index e8e1bc693..d55a23df1 100644
@@ -385,6 +385,25 @@ trace_mem_per_thread_free(void)
 	rte_spinlock_unlock(&trace->lock);
 }
 
+void
+__rte_trace_point_emit_field(size_t sz, const char *in, const char *datatype)
+{
+	char *field = RTE_PER_LCORE(ctf_field);
+	int count = RTE_PER_LCORE(ctf_count);
+	size_t size;
+	int rc;
+
+	size = RTE_MAX(0, TRACE_CTF_FIELD_SIZE - 1 - count);
+	RTE_PER_LCORE(trace_point_sz) += sz;
+	rc = snprintf(RTE_PTR_ADD(field, count), size, "%s %s;", datatype, in);
+	if (rc <= 0 || (size_t)rc >= size) {
+		RTE_PER_LCORE(trace_point_sz) = 0;
+		trace_crit("CTF field is too long");
+		return;
+	}
+	RTE_PER_LCORE(ctf_count) += rc;
+}
+
 int
 __rte_trace_point_register(rte_trace_point_t *handle, const char *name,
 			   void (*register_fn)(void))
lib/librte_eal/include/rte_trace_point.h +19 -0
index 8e37f971e..f4e6d7e42 100644
@@ -236,6 +236,25 @@ __rte_trace_point_fp_is_enabled(void)
 __rte_experimental
 void __rte_trace_mem_per_thread_alloc(void);
 
+/**
+ * @internal
+ *
+ * Helper function to emit field.
+ *
+ * @param sz
+ *   The tracepoint size.
+ * @param field
+ *   The name of the trace event.
+ * @param type
+ *   The datatype of the trace event as string.
+ * @return
+ *   - 0: Success.
+ *   - <0: Failure.
+ */
+__rte_experimental
+void __rte_trace_point_emit_field(size_t sz, const char *field,
+				  const char *type);
+
 /**
  * @internal
  *
lib/librte_eal/include/rte_trace_point_register.h +19 -0
index b21302c3d..3f61f8346 100644
@@ -17,4 +17,23 @@ RTE_DECLARE_PER_LCORE(volatile int, trace_point_sz);
 	__rte_trace_point_register(&__##trace, RTE_STR(name),\
 				   (void (*)(void)) trace)
 
+#define __rte_trace_point_emit_header_generic(t)\
+	RTE_PER_LCORE(trace_point_sz) = __RTE_TRACE_EVENT_HEADER_SZ
+
+#define __rte_trace_point_emit_header_fp(t) \
+	__rte_trace_point_emit_header_generic(t)
+
+#define __rte_trace_point_emit(in, type)\
+do {\
+	RTE_BUILD_BUG_ON(sizeof(type) != sizeof(typeof(in)));\
+	__rte_trace_point_emit_field(sizeof(type), RTE_STR(in), RTE_STR(type));\
+} while (0)
+
+#define rte_trace_point_emit_string(in)\
+do {\
+	RTE_SET_USED(in);\
+	__rte_trace_point_emit_field(__RTE_TRACE_EMIT_STRING_LEN_MAX,\
+				   RTE_STR(in)"[32]", "string_bounded_t");\
+} while (0)
+
 #endif /* _RTE_TRACE_POINT_REGISTER_H_ */
lib/librte_eal/rte_eal_version.map +1 -0
index b4b3a92e5..8b51c8a5b 100644
@@ -338,6 +338,7 @@ EXPERIMENTAL {
 
 	# added in 20.05
 	__rte_trace_mem_per_thread_alloc;
+	__rte_trace_point_emit_field;
 	__rte_trace_point_register;
 	per_lcore_trace_mem;
 	per_lcore_trace_point_sz;
Signature · 1 line
2.25.1
#255 lore raw

PATCH v6 14/33 eal/trace: implement provider payload

In reply to [email protected]

From: Jerin Jacob <[email protected]>

The trace function payloads such as rte_trace_point_emit_* have dual functions. The first to emit the payload for the registration function and the second one to act as trace mem emitters a.k.a provider payload.

When it used as provider payload, those function copy the trace field to trace memory based on the tracing mode.

Added payload definitions under ALLOW_EXPERIMENTAL define to allow the out_of_tree application to compile with out ALLOW_EXPERIMENTAL flag.

---
 lib/librte_eal/include/rte_trace_point.h      | 18 ++++
 .../include/rte_trace_point_provider.h        | 90 +++++++++++++++++++
 2 files changed, 108 insertions(+)
lib/librte_eal/include/rte_trace_point.h +18 -0
index f4e6d7e42..eca48db72 100644
@@ -281,6 +281,24 @@ int __rte_trace_point_register(rte_trace_point_t *trace, const char *name,
 #include <rte_trace_point_provider.h>
 #endif
 
+#ifndef __DOXYGEN__
+
+#define rte_trace_point_emit_u64(in) __rte_trace_point_emit(in, uint64_t)
+#define rte_trace_point_emit_i64(in) __rte_trace_point_emit(in, int64_t)
+#define rte_trace_point_emit_u32(in) __rte_trace_point_emit(in, uint32_t)
+#define rte_trace_point_emit_i32(in) __rte_trace_point_emit(in, int32_t)
+#define rte_trace_point_emit_u16(in) __rte_trace_point_emit(in, uint16_t)
+#define rte_trace_point_emit_i16(in) __rte_trace_point_emit(in, int16_t)
+#define rte_trace_point_emit_u8(in) __rte_trace_point_emit(in, uint8_t)
+#define rte_trace_point_emit_i8(in) __rte_trace_point_emit(in, int8_t)
+#define rte_trace_point_emit_int(in) __rte_trace_point_emit(in, int32_t)
+#define rte_trace_point_emit_long(in) __rte_trace_point_emit(in, long)
+#define rte_trace_point_emit_float(in) __rte_trace_point_emit(in, float)
+#define rte_trace_point_emit_double(in) __rte_trace_point_emit(in, double)
+#define rte_trace_point_emit_ptr(in) __rte_trace_point_emit(in, uintptr_t)
+
+#endif
+
 #ifdef __cplusplus
 }
 #endif
lib/librte_eal/include/rte_trace_point_provider.h +90 -0

100 lines not on this page · raw message

Signature · 1 line
2.25.1
#256 lore raw

PATCH v6 15/33 eal/trace: hook internal trace APIs to Linux

In reply to [email protected]

From: Jerin Jacob <[email protected]>

Connect the internal trace interface API to Linux EAL.

---
 lib/librte_eal/common/eal_common_thread.c | 4 +++-
 lib/librte_eal/linux/eal.c                | 9 +++++++++
 lib/librte_eal/linux/eal_thread.c         | 4 ++++
 3 files changed, 16 insertions(+), 1 deletion(-)
lib/librte_eal/common/eal_common_thread.c +3 -1
index 99fe1aa4e..52c908b9e 100644
@@ -15,6 +15,8 @@
 #include <rte_lcore.h>
 #include <rte_memory.h>
 #include <rte_log.h>
+#include <rte_trace.h>
+#include <rte_trace_point.h>
 
 #include "eal_internal_cfg.h"
 #include "eal_private.h"
@@ -165,7 +167,7 @@ static void *rte_thread_init(void *arg)
 		pthread_barrier_destroy(&params->configured);
 		free(params);
 	}
-
+	__rte_trace_mem_per_thread_alloc();
 	return start_routine(routine_arg);
 }
 
lib/librte_eal/linux/eal.c +9 -0
index d1e532fc1..937d867aa 100644
@@ -58,6 +58,7 @@
 #include "eal_filesystem.h"
 #include "eal_hugepages.h"
 #include "eal_memcfg.h"
+#include "eal_trace.h"
 #include "eal_options.h"
 #include "eal_vfio.h"
 #include "hotplug_mp.h"
@@ -1012,6 +1013,12 @@ rte_eal_init(int argc, char **argv)
 		return -1;
 	}
 
+	if (eal_trace_init() < 0) {
+		rte_eal_init_alert("Cannot init trace");
+		rte_errno = EFAULT;
+		return -1;
+	}
+
 	if (eal_option_device_parse()) {
 		rte_errno = ENODEV;
 		rte_atomic32_clear(&run_once);
@@ -1327,6 +1334,8 @@ rte_eal_cleanup(void)
 		rte_memseg_walk(mark_freeable, NULL);
 	rte_service_finalize();
 	rte_mp_channel_cleanup();
+	rte_trace_save();
+	eal_trace_fini();
 	eal_cleanup_config(&internal_config);
 	return 0;
 }
lib/librte_eal/linux/eal_thread.c +4 -0
index 61fb2ed45..24772fc3d 100644
@@ -20,6 +20,8 @@
 #include <rte_per_lcore.h>
 #include <rte_eal.h>
 #include <rte_lcore.h>
+#include <rte_trace.h>
+#include <rte_trace_point.h>
 
 #include "eal_private.h"
 #include "eal_thread.h"
@@ -124,6 +126,8 @@ eal_thread_loop(__rte_unused void *arg)
 	RTE_LOG(DEBUG, EAL, "lcore %u is ready (tid=%zx;cpuset=[%s%s])\n",
 		lcore_id, (uintptr_t)thread_id, cpuset, ret == 0 ? "" : "...");
 
+	__rte_trace_mem_per_thread_alloc();
+
 	/* read on our pipe to get commands */
 	while (1) {
 		void *fct_arg;
Signature · 1 line
2.25.1
#257 lore raw

PATCH v6 16/33 eal/trace: hook internal trace APIs to FreeBSD

In reply to [email protected]

From: Jerin Jacob <[email protected]>

Connect the internal trace interface API to FreeBSD EAL.

---
 lib/librte_eal/freebsd/eal.c        | 10 ++++++++++
 lib/librte_eal/freebsd/eal_thread.c |  4 ++++
 2 files changed, 14 insertions(+)
lib/librte_eal/freebsd/eal.c +10 -0
index 80dc9aa78..540b7d38c 100644
@@ -52,6 +52,7 @@
 #include "eal_hugepages.h"
 #include "eal_options.h"
 #include "eal_memcfg.h"
+#include "eal_trace.h"
 
 #define MEMSIZE_IF_NO_HUGE_PAGE (64ULL * 1024ULL * 1024ULL)
 
@@ -751,6 +752,13 @@ rte_eal_init(int argc, char **argv)
 		return -1;
 	}
 
+	if (eal_trace_init() < 0) {
+		rte_eal_init_alert("Cannot init trace");
+		rte_errno = EFAULT;
+		rte_atomic32_clear(&run_once);
+		return -1;
+	}
+
 	if (eal_option_device_parse()) {
 		rte_errno = ENODEV;
 		rte_atomic32_clear(&run_once);
@@ -966,6 +974,8 @@ rte_eal_cleanup(void)
 {
 	rte_service_finalize();
 	rte_mp_channel_cleanup();
+	rte_trace_save();
+	eal_trace_fini();
 	eal_cleanup_config(&internal_config);
 	return 0;
 }
lib/librte_eal/freebsd/eal_thread.c +4 -0
index d802c1d2e..c25b4a019 100644
@@ -20,6 +20,8 @@
 #include <rte_per_lcore.h>
 #include <rte_eal.h>
 #include <rte_lcore.h>
+#include <rte_trace.h>
+#include <rte_trace_point.h>
 
 #include "eal_private.h"
 #include "eal_thread.h"
@@ -124,6 +126,8 @@ eal_thread_loop(__rte_unused void *arg)
 	RTE_LOG(DEBUG, EAL, "lcore %u is ready (tid=%p;cpuset=[%s%s])\n",
 		lcore_id, thread_id, cpuset, ret == 0 ? "" : "...");
 
+	__rte_trace_mem_per_thread_alloc();
+
 	/* read on our pipe to get commands */
 	while (1) {
 		void *fct_arg;
Signature · 1 line
2.25.1
#258 lore raw

PATCH v6 17/33 eal/trace: add generic tracepoints

In reply to [email protected]

From: Jerin Jacob <[email protected]>

This patch creates the following generic tracepoint for generic tracing when there is no dedicated tracepoint is available.

- rte_trace_lib_eal_generic_void()
- rte_trace_lib_eal_generic_u64()
- rte_trace_lib_eal_generic_u32()
- rte_trace_lib_eal_generic_u16()
- rte_trace_lib_eal_generic_u8()
- rte_trace_lib_eal_generic_i64()
- rte_trace_lib_eal_generic_i32()
- rte_trace_lib_eal_generic_i16()
- rte_trace_lib_eal_generic_i8()
- rte_trace_lib_eal_generic_int()
- rte_trace_lib_eal_generic_long()
- rte_trace_lib_eal_generic_float()
- rte_trace_lib_eal_generic_double()
- rte_trace_lib_eal_generic_ptr()
- rte_trace_lib_eal_generic_str()

For example, if an application wishes to emit an int datatype, it can call rte_trace_lib_eal_generic_int(val) to emit the trace.

---
 .../common/eal_common_trace_points.c          |  60 +++++++++
 lib/librte_eal/common/meson.build             |   1 +
 lib/librte_eal/freebsd/Makefile               |   1 +
 lib/librte_eal/include/meson.build            |   1 +
 lib/librte_eal/include/rte_trace_eal.h        | 122 ++++++++++++++++++
 lib/librte_eal/linux/Makefile                 |   1 +
 lib/librte_eal/rte_eal_version.map            |  17 +++
 7 files changed, 203 insertions(+)
 create mode 100644 lib/librte_eal/common/eal_common_trace_points.c
 create mode 100644 lib/librte_eal/include/rte_trace_eal.h
lib/librte_eal/common/eal_common_trace_points.c new file +60 -0
new file mode 100644
index 000000000..cd70fc1e3
@@ -0,0 +1,60 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(C) 2020 Marvell International Ltd.
+ */
+
+#define RTE_TRACE_POINT_REGISTER_SELECT /* Select trace point register macros */
+
+#include <rte_trace_eal.h>
+
+RTE_TRACE_POINT_DEFINE(rte_trace_lib_eal_generic_void);
+RTE_TRACE_POINT_DEFINE(rte_trace_lib_eal_generic_u64);
+RTE_TRACE_POINT_DEFINE(rte_trace_lib_eal_generic_u32);
+RTE_TRACE_POINT_DEFINE(rte_trace_lib_eal_generic_u16);
+RTE_TRACE_POINT_DEFINE(rte_trace_lib_eal_generic_u8);
+RTE_TRACE_POINT_DEFINE(rte_trace_lib_eal_generic_i64);
+RTE_TRACE_POINT_DEFINE(rte_trace_lib_eal_generic_i32);
+RTE_TRACE_POINT_DEFINE(rte_trace_lib_eal_generic_i16);
+RTE_TRACE_POINT_DEFINE(rte_trace_lib_eal_generic_i8);
+RTE_TRACE_POINT_DEFINE(rte_trace_lib_eal_generic_int);
+RTE_TRACE_POINT_DEFINE(rte_trace_lib_eal_generic_long);
+RTE_TRACE_POINT_DEFINE(rte_trace_lib_eal_generic_float);
+RTE_TRACE_POINT_DEFINE(rte_trace_lib_eal_generic_double);
+RTE_TRACE_POINT_DEFINE(rte_trace_lib_eal_generic_ptr);
+RTE_TRACE_POINT_DEFINE(rte_trace_lib_eal_generic_str);
+RTE_TRACE_POINT_DEFINE(rte_trace_lib_eal_generic_func);
+
+RTE_INIT(eal_trace_init)
+{
+	RTE_TRACE_POINT_REGISTER(rte_trace_lib_eal_generic_void,
+				 lib.eal.generic.void);
+	RTE_TRACE_POINT_REGISTER(rte_trace_lib_eal_generic_u64,
+				 lib.eal.generic.u64);
+	RTE_TRACE_POINT_REGISTER(rte_trace_lib_eal_generic_u32,
+				 lib.eal.generic.u32);
+	RTE_TRACE_POINT_REGISTER(rte_trace_lib_eal_generic_u16,
+				 lib.eal.generic.u16);
+	RTE_TRACE_POINT_REGISTER(rte_trace_lib_eal_generic_u8,
+				 lib.eal.generic.u8);
+	RTE_TRACE_POINT_REGISTER(rte_trace_lib_eal_generic_i64,
+				 lib.eal.generic.i64);
+	RTE_TRACE_POINT_REGISTER(rte_trace_lib_eal_generic_i32,
+				 lib.eal.generic.i32);
+	RTE_TRACE_POINT_REGISTER(rte_trace_lib_eal_generic_i16,
+				 lib.eal.generic.i16);
+	RTE_TRACE_POINT_REGISTER(rte_trace_lib_eal_generic_i8,
+				 lib.eal.generic.i8);
+	RTE_TRACE_POINT_REGISTER(rte_trace_lib_eal_generic_int,
+				 lib.eal.generic.int);
+	RTE_TRACE_POINT_REGISTER(rte_trace_lib_eal_generic_long,
+				 lib.eal.generic.long);
+	RTE_TRACE_POINT_REGISTER(rte_trace_lib_eal_generic_float,
+				 lib.eal.generic.float);
+	RTE_TRACE_POINT_REGISTER(rte_trace_lib_eal_generic_double,
+				 lib.eal.generic.double);
+	RTE_TRACE_POINT_REGISTER(rte_trace_lib_eal_generic_ptr,
+				 lib.eal.generic.ptr);
+	RTE_TRACE_POINT_REGISTER(rte_trace_lib_eal_generic_str,
+				 lib.eal.generic.string);
+	RTE_TRACE_POINT_REGISTER(rte_trace_lib_eal_generic_func,
+				 lib.eal.generic.func);
+}
lib/librte_eal/common/meson.build +1 -0
index d2ac44313..155da29b4 100644
@@ -44,6 +44,7 @@ sources += files(
 	'eal_common_timer.c',
 	'eal_common_trace.c',
 	'eal_common_trace_ctf.c',
+	'eal_common_trace_points.c',
 	'eal_common_trace_utils.c',
 	'eal_common_uuid.c',
 	'hotplug_mp.c',
lib/librte_eal/freebsd/Makefile +1 -0
index 539ad44a7..a8400f20a 100644
@@ -61,6 +61,7 @@ SRCS-$(CONFIG_RTE_EXEC_ENV_FREEBSD) += eal_common_fbarray.c
 SRCS-$(CONFIG_RTE_EXEC_ENV_FREEBSD) += eal_common_uuid.c
 SRCS-$(CONFIG_RTE_EXEC_ENV_FREEBSD) += eal_common_trace.c
 SRCS-$(CONFIG_RTE_EXEC_ENV_FREEBSD) += eal_common_trace_ctf.c
+SRCS-$(CONFIG_RTE_EXEC_ENV_FREEBSD) += eal_common_trace_points.c
 SRCS-$(CONFIG_RTE_EXEC_ENV_FREEBSD) += eal_common_trace_utils.c
 SRCS-$(CONFIG_RTE_EXEC_ENV_FREEBSD) += rte_malloc.c
 SRCS-$(CONFIG_RTE_EXEC_ENV_FREEBSD) += hotplug_mp.c
lib/librte_eal/include/meson.build +1 -0
index ce360615f..67448c27f 100644
@@ -41,6 +41,7 @@ headers += files(
 	'rte_tailq.h',
 	'rte_time.h',
 	'rte_trace.h',
+	'rte_trace_eal.h',
 	'rte_trace_point.h',
 	'rte_trace_point_provider.h',
 	'rte_trace_point_register.h',
lib/librte_eal/include/rte_trace_eal.h new file +122 -0

122 lines not on this page · raw message

lib/librte_eal/linux/Makefile +1 -0
index f00588d6e..a77eb1757 100644
@@ -68,6 +68,7 @@ SRCS-$(CONFIG_RTE_EXEC_ENV_LINUX) += eal_common_fbarray.c
 SRCS-$(CONFIG_RTE_EXEC_ENV_LINUX) += eal_common_uuid.c
 SRCS-$(CONFIG_RTE_EXEC_ENV_LINUX) += eal_common_trace.c
 SRCS-$(CONFIG_RTE_EXEC_ENV_LINUX) += eal_common_trace_ctf.c
+SRCS-$(CONFIG_RTE_EXEC_ENV_LINUX) += eal_common_trace_points.c
 SRCS-$(CONFIG_RTE_EXEC_ENV_LINUX) += eal_common_trace_utils.c
 SRCS-$(CONFIG_RTE_EXEC_ENV_LINUX) += rte_malloc.c
 SRCS-$(CONFIG_RTE_EXEC_ENV_LINUX) += hotplug_mp.c
lib/librte_eal/rte_eal_version.map +17 -0
index 8b51c8a5b..c333ac900 100644
@@ -356,4 +356,21 @@ EXPERIMENTAL {
 	rte_trace_point_lookup;
 	rte_trace_regexp;
 	rte_trace_save;
+
+	__rte_trace_lib_eal_generic_double;
+	__rte_trace_lib_eal_generic_float;
+	__rte_trace_lib_eal_generic_func;
+	__rte_trace_lib_eal_generic_i16;
+	__rte_trace_lib_eal_generic_i32;
+	__rte_trace_lib_eal_generic_i64;
+	__rte_trace_lib_eal_generic_i8;
+	__rte_trace_lib_eal_generic_int;
+	__rte_trace_lib_eal_generic_long;
+	__rte_trace_lib_eal_generic_ptr;
+	__rte_trace_lib_eal_generic_str;
+	__rte_trace_lib_eal_generic_u16;
+	__rte_trace_lib_eal_generic_u32;
+	__rte_trace_lib_eal_generic_u64;
+	__rte_trace_lib_eal_generic_u8;
+	__rte_trace_lib_eal_generic_void;
 };
Signature · 1 line
2.25.1
#259 lore raw

PATCH v6 18/33 eal/trace: add alarm tracepoints

In reply to [email protected]

From: Jerin Jacob <[email protected]>

Add following alarm related trace points.

- rte_trace_lib_eal_alarm_set()
- rte_trace_lib_eal_alarm_cancel()

---
 .../common/eal_common_trace_points.c          |  9 ++++++++
 lib/librte_eal/freebsd/eal_alarm.c            |  3 +++
 lib/librte_eal/include/rte_trace_eal.h        | 21 +++++++++++++++++++
 lib/librte_eal/linux/eal_alarm.c              |  4 ++++
 lib/librte_eal/rte_eal_version.map            |  2 ++
 5 files changed, 39 insertions(+)
lib/librte_eal/common/eal_common_trace_points.c +9 -0
index cd70fc1e3..50c255034 100644
@@ -23,6 +23,9 @@ RTE_TRACE_POINT_DEFINE(rte_trace_lib_eal_generic_ptr);
 RTE_TRACE_POINT_DEFINE(rte_trace_lib_eal_generic_str);
 RTE_TRACE_POINT_DEFINE(rte_trace_lib_eal_generic_func);
 
+RTE_TRACE_POINT_DEFINE(rte_trace_lib_eal_alarm_set);
+RTE_TRACE_POINT_DEFINE(rte_trace_lib_eal_alarm_cancel);
+
 RTE_INIT(eal_trace_init)
 {
 	RTE_TRACE_POINT_REGISTER(rte_trace_lib_eal_generic_void,
@@ -57,4 +60,10 @@ RTE_INIT(eal_trace_init)
 				 lib.eal.generic.string);
 	RTE_TRACE_POINT_REGISTER(rte_trace_lib_eal_generic_func,
 				 lib.eal.generic.func);
+
+	RTE_TRACE_POINT_REGISTER(rte_trace_lib_eal_alarm_set,
+				 lib.eal.alarm.set);
+	RTE_TRACE_POINT_REGISTER(rte_trace_lib_eal_alarm_cancel,
+				 lib.eal.alarm.cancel);
+
 }
lib/librte_eal/freebsd/eal_alarm.c +3 -0
index 51ea4b8c0..5f03ab4c4 100644
@@ -17,6 +17,7 @@
 #include <rte_errno.h>
 #include <rte_interrupts.h>
 #include <rte_spinlock.h>
+#include <rte_trace_eal.h>
 
 #include "eal_private.h"
 #include "eal_alarm_private.h"
@@ -223,6 +224,7 @@ rte_eal_alarm_set(uint64_t us, rte_eal_alarm_callback cb_fn, void *cb_arg)
 
 	rte_spinlock_unlock(&alarm_list_lk);
 
+	rte_trace_lib_eal_alarm_set(us, cb_fn, cb_arg, ret);
 	return ret;
 }
 
@@ -310,5 +312,6 @@ rte_eal_alarm_cancel(rte_eal_alarm_callback cb_fn, void *cb_arg)
 
 	rte_spinlock_unlock(&alarm_list_lk);
 
+	rte_trace_lib_eal_alarm_cancel(cb_fn, cb_arg, count);
 	return count;
 }
lib/librte_eal/include/rte_trace_eal.h +21 -0
index 674c33d38..d1be9100e 100644
@@ -15,6 +15,7 @@
 extern "C" {
 #endif
 
+#include <rte_alarm.h>
 #include <rte_trace_point.h>
 
 /* Generic */
@@ -115,6 +116,26 @@ RTE_TRACE_POINT(
 
 #define RTE_TRACE_LIB_EAL_GENERIC_FUNC rte_trace_lib_eal_generic_func(__func__)
 
+/* Alarm */
+RTE_TRACE_POINT(
+	rte_trace_lib_eal_alarm_set,
+	RTE_TRACE_POINT_ARGS(uint64_t us, rte_eal_alarm_callback cb_fn,
+			     void *cb_arg, int rc),
+	rte_trace_point_emit_u64(us);
+	rte_trace_point_emit_ptr(cb_fn);
+	rte_trace_point_emit_ptr(cb_arg);
+	rte_trace_point_emit_int(rc);
+)
+
+RTE_TRACE_POINT(
+	rte_trace_lib_eal_alarm_cancel,
+	RTE_TRACE_POINT_ARGS(rte_eal_alarm_callback cb_fn, void *cb_arg,
+			     int count),
+	rte_trace_point_emit_ptr(cb_fn);
+	rte_trace_point_emit_ptr(cb_arg);
+	rte_trace_point_emit_int(count);
+)
+
 #ifdef __cplusplus
 }
 #endif
lib/librte_eal/linux/eal_alarm.c +4 -0
index 0924c9205..9fef3e6c8 100644
@@ -20,6 +20,8 @@
 #include <rte_lcore.h>
 #include <rte_errno.h>
 #include <rte_spinlock.h>
+#include <rte_trace_eal.h>
+
 #include <eal_private.h>
 
 #ifndef	TFD_NONBLOCK
@@ -172,6 +174,7 @@ rte_eal_alarm_set(uint64_t us, rte_eal_alarm_callback cb_fn, void *cb_arg)
 	}
 	rte_spinlock_unlock(&alarm_list_lk);
 
+	rte_trace_lib_eal_alarm_set(us, cb_fn, cb_arg, ret);
 	return ret;
 }
 
@@ -240,5 +243,6 @@ rte_eal_alarm_cancel(rte_eal_alarm_callback cb_fn, void *cb_arg)
 	else if (err)
 		rte_errno = err;
 
+	rte_trace_lib_eal_alarm_cancel(cb_fn, cb_arg, count);
 	return count;
 }
lib/librte_eal/rte_eal_version.map +2 -0
index c333ac900..4cba9a55d 100644
@@ -357,6 +357,8 @@ EXPERIMENTAL {
 	rte_trace_regexp;
 	rte_trace_save;
 
+	__rte_trace_lib_eal_alarm_cancel;
+	__rte_trace_lib_eal_alarm_set;
 	__rte_trace_lib_eal_generic_double;
 	__rte_trace_lib_eal_generic_float;
 	__rte_trace_lib_eal_generic_func;
Signature · 1 line
2.25.1
#260 lore raw

PATCH v6 19/33 eal/trace: add memory tracepoints

In reply to [email protected]

From: Jerin Jacob <[email protected]>

Add the following memory-related tracepoints.

- rte_trace_lib_eal_mem_zmalloc()
- rte_trace_lib_eal_mem_malloc()
- rte_trace_lib_eal_mem_realloc()
- rte_trace_lib_eal_mem_free()

rte_malloc() and rte_free() has been used in the trace implementation, in order to avoid tracing implementation specific events, added an internal no trace version rte_malloc() and rte_free().

---
 lib/librte_eal/common/eal_common_trace.c      |  4 +-
 .../common/eal_common_trace_points.c          | 14 +++++
 lib/librte_eal/common/eal_private.h           |  5 ++
 lib/librte_eal/common/rte_malloc.c            | 60 ++++++++++++++++---
 lib/librte_eal/include/rte_trace_eal.h        | 39 ++++++++++++
 lib/librte_eal/rte_eal_version.map            |  4 ++
 6 files changed, 115 insertions(+), 11 deletions(-)
lib/librte_eal/common/eal_common_trace.c +2 -2
index d55a23df1..73277ae80 100644
@@ -326,7 +326,7 @@ __rte_trace_mem_per_thread_alloc(void)
 	}
 
 	/* First attempt from huge page */
-	header = rte_malloc(NULL, trace_mem_sz(trace->buff_len), 8);
+	header = eal_malloc_no_trace(NULL, trace_mem_sz(trace->buff_len), 8);
 	if (header) {
 		trace->lcore_meta[count].area = TRACE_AREA_HUGEPAGE;
 		goto found;
@@ -378,7 +378,7 @@ trace_mem_per_thread_free(void)
 	for (count = 0; count < trace->nb_trace_mem_list; count++) {
 		mem = trace->lcore_meta[count].mem;
 		if (trace->lcore_meta[count].area == TRACE_AREA_HUGEPAGE)
-			rte_free(mem);
+			eal_free_no_trace(mem);
 		else if (trace->lcore_meta[count].area == TRACE_AREA_HEAP)
 			free(mem);
 	}
lib/librte_eal/common/eal_common_trace_points.c +14 -0
index 50c255034..5a8444f07 100644
@@ -26,6 +26,11 @@ RTE_TRACE_POINT_DEFINE(rte_trace_lib_eal_generic_func);
 RTE_TRACE_POINT_DEFINE(rte_trace_lib_eal_alarm_set);
 RTE_TRACE_POINT_DEFINE(rte_trace_lib_eal_alarm_cancel);
 
+RTE_TRACE_POINT_DEFINE(rte_trace_lib_eal_mem_zmalloc);
+RTE_TRACE_POINT_DEFINE(rte_trace_lib_eal_mem_malloc);
+RTE_TRACE_POINT_DEFINE(rte_trace_lib_eal_mem_realloc);
+RTE_TRACE_POINT_DEFINE(rte_trace_lib_eal_mem_free);
+
 RTE_INIT(eal_trace_init)
 {
 	RTE_TRACE_POINT_REGISTER(rte_trace_lib_eal_generic_void,
@@ -66,4 +71,13 @@ RTE_INIT(eal_trace_init)
 	RTE_TRACE_POINT_REGISTER(rte_trace_lib_eal_alarm_cancel,
 				 lib.eal.alarm.cancel);
 
+	RTE_TRACE_POINT_REGISTER(rte_trace_lib_eal_mem_zmalloc,
+				 lib.eal.mem.zmalloc);
+	RTE_TRACE_POINT_REGISTER(rte_trace_lib_eal_mem_malloc,
+				 lib.eal.mem.malloc);
+	RTE_TRACE_POINT_REGISTER(rte_trace_lib_eal_mem_realloc,
+				 lib.eal.mem.realloc);
+	RTE_TRACE_POINT_REGISTER(rte_trace_lib_eal_mem_free,
+				 lib.eal.mem.free);
+
 }
lib/librte_eal/common/eal_private.h +5 -0
index 8536ed70b..ecf827914 100644
@@ -443,4 +443,9 @@ rte_option_usage(void);
 uint64_t
 eal_get_baseaddr(void);
 
+void *
+eal_malloc_no_trace(const char *type, size_t size, unsigned int align);
+
+void eal_free_no_trace(void *addr);
+
 #endif /* _EAL_PRIVATE_H_ */
lib/librte_eal/common/rte_malloc.c +51 -9

105 lines not on this page · raw message

lib/librte_eal/include/rte_trace_eal.h +39 -0
index d1be9100e..bd236ad65 100644
@@ -136,6 +136,45 @@ RTE_TRACE_POINT(
 	rte_trace_point_emit_int(count);
 )
 
+/* Memory */
+RTE_TRACE_POINT(
+	rte_trace_lib_eal_mem_zmalloc,
+	RTE_TRACE_POINT_ARGS(const char *type, size_t size, unsigned int align,
+			     int socket, void *ptr),
+	rte_trace_point_emit_string(type);
+	rte_trace_point_emit_long(size);
+	rte_trace_point_emit_u32(align);
+	rte_trace_point_emit_int(socket);
+	rte_trace_point_emit_ptr(ptr);
+)
+
+RTE_TRACE_POINT(
+	rte_trace_lib_eal_mem_malloc,
+	RTE_TRACE_POINT_ARGS(const char *type, size_t size, unsigned int align,
+			     int socket, void *ptr),
+	rte_trace_point_emit_string(type);
+	rte_trace_point_emit_long(size);
+	rte_trace_point_emit_u32(align);
+	rte_trace_point_emit_int(socket);
+	rte_trace_point_emit_ptr(ptr);
+)
+
+RTE_TRACE_POINT(
+	rte_trace_lib_eal_mem_realloc,
+	RTE_TRACE_POINT_ARGS(size_t size, unsigned int align,
+			     int socket, void *ptr),
+	rte_trace_point_emit_long(size);
+	rte_trace_point_emit_u32(align);
+	rte_trace_point_emit_int(socket);
+	rte_trace_point_emit_ptr(ptr);
+)
+
+RTE_TRACE_POINT(
+	rte_trace_lib_eal_mem_free,
+	RTE_TRACE_POINT_ARGS(void *ptr),
+	rte_trace_point_emit_ptr(ptr);
+)
+
 #ifdef __cplusplus
 }
 #endif
lib/librte_eal/rte_eal_version.map +4 -0
index 4cba9a55d..909a8ba56 100644
@@ -375,4 +375,8 @@ EXPERIMENTAL {
 	__rte_trace_lib_eal_generic_u64;
 	__rte_trace_lib_eal_generic_u8;
 	__rte_trace_lib_eal_generic_void;
+	__rte_trace_lib_eal_mem_free;
+	__rte_trace_lib_eal_mem_malloc;
+	__rte_trace_lib_eal_mem_realloc;
+	__rte_trace_lib_eal_mem_zmalloc;
 };
Signature · 1 line
2.25.1
#261 lore raw

PATCH v6 20/33 eal/trace: add memzone tracepoints

In reply to [email protected]

From: Jerin Jacob <[email protected]>

Add the following memzone related tracepoints.

- rte_trace_lib_eal_memzone_reserve()
- rte_trace_lib_eal_memzone_lookup()
- rte_trace_lib_eal_memzone_free()

---
 lib/librte_eal/common/eal_common_memzone.c    |  9 ++++++
 .../common/eal_common_trace_points.c          | 10 ++++++
 lib/librte_eal/include/rte_trace_eal.h        | 31 +++++++++++++++++++
 lib/librte_eal/rte_eal_version.map            |  3 ++
 4 files changed, 53 insertions(+)
lib/librte_eal/common/eal_common_memzone.c +9 -0
index 86f61369b..0f6556714 100644
@@ -19,6 +19,7 @@
 #include <rte_errno.h>
 #include <rte_string_fns.h>
 #include <rte_common.h>
+#include <rte_trace_eal.h>
 
 #include "malloc_heap.h"
 #include "malloc_elem.h"
@@ -201,6 +202,9 @@ rte_memzone_reserve_thread_safe(const char *name, size_t len, int socket_id,
 	mz = memzone_reserve_aligned_thread_unsafe(
 		name, len, socket_id, flags, align, bound);
 
+	rte_trace_lib_eal_memzone_reserve(name, len, socket_id, flags, align,
+					  bound, mz);
+
 	rte_rwlock_write_unlock(&mcfg->mlock);
 
 	return mz;
@@ -246,6 +250,7 @@ rte_memzone_reserve(const char *name, size_t len, int socket_id,
 int
 rte_memzone_free(const struct rte_memzone *mz)
 {
+	char name[RTE_MEMZONE_NAMESIZE];
 	struct rte_mem_config *mcfg;
 	struct rte_fbarray *arr;
 	struct rte_memzone *found_mz;
@@ -256,6 +261,7 @@ rte_memzone_free(const struct rte_memzone *mz)
 	if (mz == NULL)
 		return -EINVAL;
 
+	rte_strlcpy(name, mz->name, RTE_MEMZONE_NAMESIZE);
 	mcfg = rte_eal_get_configuration()->mem_config;
 	arr = &mcfg->memzones;
 
@@ -280,6 +286,8 @@ rte_memzone_free(const struct rte_memzone *mz)
 	if (addr != NULL)
 		rte_free(addr);
 
+	rte_trace_lib_eal_memzone_free(name, addr, ret);
+
 	return ret;
 }
 
@@ -300,6 +308,7 @@ rte_memzone_lookup(const char *name)
 
 	rte_rwlock_read_unlock(&mcfg->mlock);
 
+	rte_trace_lib_eal_memzone_lookup(name, memzone);
 	return memzone;
 }
 
lib/librte_eal/common/eal_common_trace_points.c +10 -0
index 5a8444f07..a3c9bc01b 100644
@@ -31,6 +31,10 @@ RTE_TRACE_POINT_DEFINE(rte_trace_lib_eal_mem_malloc);
 RTE_TRACE_POINT_DEFINE(rte_trace_lib_eal_mem_realloc);
 RTE_TRACE_POINT_DEFINE(rte_trace_lib_eal_mem_free);
 
+RTE_TRACE_POINT_DEFINE(rte_trace_lib_eal_memzone_reserve);
+RTE_TRACE_POINT_DEFINE(rte_trace_lib_eal_memzone_lookup);
+RTE_TRACE_POINT_DEFINE(rte_trace_lib_eal_memzone_free);
+
 RTE_INIT(eal_trace_init)
 {
 	RTE_TRACE_POINT_REGISTER(rte_trace_lib_eal_generic_void,
@@ -80,4 +84,10 @@ RTE_INIT(eal_trace_init)
 	RTE_TRACE_POINT_REGISTER(rte_trace_lib_eal_mem_free,
 				 lib.eal.mem.free);
 
+	RTE_TRACE_POINT_REGISTER(rte_trace_lib_eal_memzone_reserve,
+				 lib.eal.memzone.reserve);
+	RTE_TRACE_POINT_REGISTER(rte_trace_lib_eal_memzone_lookup,
+				 lib.eal.memzone.lookup);
+	RTE_TRACE_POINT_REGISTER(rte_trace_lib_eal_memzone_free,
+				 lib.eal.memzone.free);
 }
lib/librte_eal/include/rte_trace_eal.h +31 -0
index bd236ad65..d13b434ca 100644
@@ -175,6 +175,37 @@ RTE_TRACE_POINT(
 	rte_trace_point_emit_ptr(ptr);
 )
 
+/* Memzone */
+RTE_TRACE_POINT(
+	rte_trace_lib_eal_memzone_reserve,
+	RTE_TRACE_POINT_ARGS(const char *name, size_t len, int socket_id,
+			     unsigned int flags, unsigned int align,
+			     unsigned int bound, const void *mz),
+	rte_trace_point_emit_string(name);
+	rte_trace_point_emit_long(len);
+	rte_trace_point_emit_int(socket_id);
+	rte_trace_point_emit_u32(flags);
+	rte_trace_point_emit_u32(align);
+	rte_trace_point_emit_u32(bound);
+	rte_trace_point_emit_ptr(mz);
+)
+
+RTE_TRACE_POINT(
+	rte_trace_lib_eal_memzone_lookup,
+	RTE_TRACE_POINT_ARGS(const char *name, const void *memzone),
+	rte_trace_point_emit_string(name);
+	rte_trace_point_emit_ptr(memzone);
+)
+
+RTE_TRACE_POINT(
+	rte_trace_lib_eal_memzone_free,
+	RTE_TRACE_POINT_ARGS(const char *name, void *addr, int rc),
+	rte_trace_point_emit_string(name);
+	rte_trace_point_emit_ptr(addr);
+	rte_trace_point_emit_int(rc);
+)
+
+
 #ifdef __cplusplus
 }
 #endif
lib/librte_eal/rte_eal_version.map +3 -0
index 909a8ba56..22455c7c0 100644
@@ -379,4 +379,7 @@ EXPERIMENTAL {
 	__rte_trace_lib_eal_mem_malloc;
 	__rte_trace_lib_eal_mem_realloc;
 	__rte_trace_lib_eal_mem_zmalloc;
+	__rte_trace_lib_eal_memzone_free;
+	__rte_trace_lib_eal_memzone_lookup;
+	__rte_trace_lib_eal_memzone_reserve;
 };
Signature · 1 line
2.25.1
#262 lore raw

PATCH v6 21/33 eal/trace: add thread tracepoints

In reply to [email protected]

From: Jerin Jacob <[email protected]>

Add the following thread related tracepoints.

- rte_trace_lib_eal_thread_remote_launch()
- rte_trace_lib_eal_thread_lcore_ready()

---
 lib/librte_eal/common/eal_common_trace_points.c |  8 ++++++++
 lib/librte_eal/freebsd/eal_interrupts.c         |  2 +-
 lib/librte_eal/freebsd/eal_thread.c             | 12 ++++++++----
 lib/librte_eal/include/rte_trace_eal.h          | 17 +++++++++++++++++
 lib/librte_eal/linux/eal_thread.c               | 12 ++++++++----
 lib/librte_eal/rte_eal_version.map              |  2 ++
 6 files changed, 44 insertions(+), 9 deletions(-)
lib/librte_eal/common/eal_common_trace_points.c +8 -0
index a3c9bc01b..9cecd8206 100644
@@ -35,6 +35,9 @@ RTE_TRACE_POINT_DEFINE(rte_trace_lib_eal_memzone_reserve);
 RTE_TRACE_POINT_DEFINE(rte_trace_lib_eal_memzone_lookup);
 RTE_TRACE_POINT_DEFINE(rte_trace_lib_eal_memzone_free);
 
+RTE_TRACE_POINT_DEFINE(rte_trace_lib_eal_thread_remote_launch);
+RTE_TRACE_POINT_DEFINE(rte_trace_lib_eal_thread_lcore_ready);
+
 RTE_INIT(eal_trace_init)
 {
 	RTE_TRACE_POINT_REGISTER(rte_trace_lib_eal_generic_void,
@@ -90,4 +93,9 @@ RTE_INIT(eal_trace_init)
 				 lib.eal.memzone.lookup);
 	RTE_TRACE_POINT_REGISTER(rte_trace_lib_eal_memzone_free,
 				 lib.eal.memzone.free);
+
+	RTE_TRACE_POINT_REGISTER(rte_trace_lib_eal_thread_remote_launch,
+				 lib.eal.thread.remote.launch);
+	RTE_TRACE_POINT_REGISTER(rte_trace_lib_eal_thread_lcore_ready,
+				 lib.eal.thread.lcore.ready);
 }
lib/librte_eal/freebsd/eal_interrupts.c +1 -1
index 00991f26a..7def3189b 100644
@@ -85,7 +85,7 @@ rte_intr_callback_register(const struct rte_intr_handle *intr_handle,
 {
 	struct rte_intr_callback *callback;
 	struct rte_intr_source *src;
-	int ret, add_event = 0;
+	int ret = 0, add_event = 0;
 
 	/* first do parameter checking */
 	if (intr_handle == NULL || intr_handle->fd < 0 || cb == NULL) {
lib/librte_eal/freebsd/eal_thread.c +8 -4
index c25b4a019..d6d0e3af2 100644
@@ -20,8 +20,7 @@
 #include <rte_per_lcore.h>
 #include <rte_eal.h>
 #include <rte_lcore.h>
-#include <rte_trace.h>
-#include <rte_trace_point.h>
+#include <rte_trace_eal.h>
 
 #include "eal_private.h"
 #include "eal_thread.h"
@@ -42,9 +41,10 @@ rte_eal_remote_launch(int (*f)(void *), void *arg, unsigned slave_id)
 	char c = 0;
 	int m2s = lcore_config[slave_id].pipe_master2slave[1];
 	int s2m = lcore_config[slave_id].pipe_slave2master[0];
+	int rc = -EBUSY;
 
 	if (lcore_config[slave_id].state != WAIT)
-		return -EBUSY;
+		goto finish;
 
 	lcore_config[slave_id].f = f;
 	lcore_config[slave_id].arg = arg;
@@ -64,7 +64,10 @@ rte_eal_remote_launch(int (*f)(void *), void *arg, unsigned slave_id)
 	if (n <= 0)
 		rte_panic("cannot read on configuration pipe\n");
 
-	return 0;
+	rc = 0;
+finish:
+	rte_trace_lib_eal_thread_remote_launch(f, arg, slave_id, rc);
+	return rc;
 }
 
 /* set affinity for current thread */
@@ -127,6 +130,7 @@ eal_thread_loop(__rte_unused void *arg)
 		lcore_id, thread_id, cpuset, ret == 0 ? "" : "...");
 
 	__rte_trace_mem_per_thread_alloc();
+	rte_trace_lib_eal_thread_lcore_ready(lcore_id, cpuset);
 
 	/* read on our pipe to get commands */
 	while (1) {
lib/librte_eal/include/rte_trace_eal.h +17 -0
index d13b434ca..da805e804 100644
@@ -205,6 +205,23 @@ RTE_TRACE_POINT(
 	rte_trace_point_emit_int(rc);
 )
 
+/* Thread */
+RTE_TRACE_POINT(
+	rte_trace_lib_eal_thread_remote_launch,
+	RTE_TRACE_POINT_ARGS(int (*f)(void *), void *arg,
+			     unsigned int slave_id, int rc),
+	rte_trace_point_emit_ptr(f);
+	rte_trace_point_emit_ptr(arg);
+	rte_trace_point_emit_u32(slave_id);
+	rte_trace_point_emit_int(rc);
+)
+RTE_TRACE_POINT(
+	rte_trace_lib_eal_thread_lcore_ready,
+	RTE_TRACE_POINT_ARGS(unsigned int lcore_id, const char *cpuset),
+	rte_trace_point_emit_u32(lcore_id);
+	rte_trace_point_emit_string(cpuset);
+)
+
 
 #ifdef __cplusplus
 }
lib/librte_eal/linux/eal_thread.c +8 -4
index 24772fc3d..c2940bc4a 100644
@@ -20,8 +20,7 @@
 #include <rte_per_lcore.h>
 #include <rte_eal.h>
 #include <rte_lcore.h>
-#include <rte_trace.h>
-#include <rte_trace_point.h>
+#include <rte_trace_eal.h>
 
 #include "eal_private.h"
 #include "eal_thread.h"
@@ -42,9 +41,10 @@ rte_eal_remote_launch(int (*f)(void *), void *arg, unsigned slave_id)
 	char c = 0;
 	int m2s = lcore_config[slave_id].pipe_master2slave[1];
 	int s2m = lcore_config[slave_id].pipe_slave2master[0];
+	int rc = -EBUSY;
 
 	if (lcore_config[slave_id].state != WAIT)
-		return -EBUSY;
+		goto finish;
 
 	lcore_config[slave_id].f = f;
 	lcore_config[slave_id].arg = arg;
@@ -64,7 +64,10 @@ rte_eal_remote_launch(int (*f)(void *), void *arg, unsigned slave_id)
 	if (n <= 0)
 		rte_panic("cannot read on configuration pipe\n");
 
-	return 0;
+	rc = 0;
+finish:
+	rte_trace_lib_eal_thread_remote_launch(f, arg, slave_id, rc);
+	return rc;
 }
 
 /* set affinity for current EAL thread */
@@ -127,6 +130,7 @@ eal_thread_loop(__rte_unused void *arg)
 		lcore_id, (uintptr_t)thread_id, cpuset, ret == 0 ? "" : "...");
 
 	__rte_trace_mem_per_thread_alloc();
+	rte_trace_lib_eal_thread_lcore_ready(lcore_id, cpuset);
 
 	/* read on our pipe to get commands */
 	while (1) {
lib/librte_eal/rte_eal_version.map +2 -0
index 22455c7c0..83fb686f4 100644
@@ -382,4 +382,6 @@ EXPERIMENTAL {
 	__rte_trace_lib_eal_memzone_free;
 	__rte_trace_lib_eal_memzone_lookup;
 	__rte_trace_lib_eal_memzone_reserve;
+	__rte_trace_lib_eal_thread_lcore_ready;
+	__rte_trace_lib_eal_thread_remote_launch;
 };
Signature · 1 line
2.25.1