Skip to contentSkip to conversation

Improve docs on getting info on running process

PATCH Superseded Bruce Richardson 9 participants 30 messages Jun 13, 2023 – Jul 25, 2023

lore
Share & tools
lore
#0 lore raw

cover Improve docs on getting info on running process

Add details to our documentation on how to register logging for a component. Also provide guidelines on when to use logs vs tracing vs telemetry.

Feedback welcome on the guidelines.

Bruce Richardson (2):
doc/contributing: provide coding details for dynamic logging doc/contributing: guidelines for logging, tracing and telemetry

 doc/guides/contributing/coding_style.rst | 19 +++++++++++++
 doc/guides/contributing/design.rst       | 34 ++++++++++++++++++++++++
 doc/guides/prog_guide/telemetry_lib.rst  |  2 ++
 doc/guides/prog_guide/trace_lib.rst      |  2 ++
 lib/cfgfile/rte_cfgfile.c                |  2 ++
 5 files changed, 59 insertions(+)

--
2.39.2

#1 lore raw

PATCH 1/2 doc/contributing: provide coding details for dynamic logging

While the section on dynamic logging in the contributors guide covered the details of the logging naming scheme, it failed to cover exactly how the component developer, i.e. the contributor, could actually use dynamic logging in their component.

Fix this by splitting the details of the naming scheme into a separate subsection, and adding to the introduction on logging, a recommendation (and example) to use RTE_LOG_REGISTER_DEFAULT.

Similarly, when discussing specialization, include a reference to the RTE_LOG_REGISTER_SUFFIX macro.

---
 doc/guides/contributing/coding_style.rst | 17 +++++++++++++++++
 lib/cfgfile/rte_cfgfile.c                |  2 ++
 2 files changed, 19 insertions(+)
doc/guides/contributing/coding_style.rst +17 -0
index 00d6270624..f50a78a346 100644
@@ -803,6 +803,21 @@ logging of a particular topic, the ``--log-level`` parameter can be provided
 to EAL, which will change the log level. DPDK code can register topics,
 which allows the user to adjust the log verbosity for that specific topic.
 
+To register a library or driver for dynamic logging,
+using the standardized naming scheme described below,
+use ``RTE_LOG_REGISTER_DEFAULT`` macro to define a log-type variable inside your component's main C file.
+Thereafter, it is usual to define a macro or macros inside your component to make logging more convenient.
+
+For example, the ``rte_cfgfile`` library defines:
+
+.. literalinclude:: ../../../lib/cfgfile/rte_cfgfile.c
+    :language: c
+    :start-after: Setting up dynamic logging 8<
+    :end-before: >8 End of setting up dynamic logging
+
+Dynamic Logging Naming Scheme
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
 In general, the naming scheme is as follows: ``type.section.name``
 
  * Type is the type of component, where ``lib``, ``pmd``, ``bus`` and ``user``
@@ -837,6 +852,8 @@ A specialization looks like this:
  * Initialization output: ``type.section.name.init``
  * PF/VF mailbox output: ``type.section.name.mbox``
 
+These specializations are created using the ``RTE_LOG_REGISTER_SUFFIX`` macro.
+
 A real world example is the i40e poll mode driver which exposes two
 specializations, one for initialization ``pmd.net.i40e.init`` and the other for
 the remaining driver logs ``pmd.net.i40e.driver``.
lib/cfgfile/rte_cfgfile.c +2 -0
index 9fa7d010ef..eefba6e408 100644
@@ -27,11 +27,13 @@ struct rte_cfgfile {
 	struct rte_cfgfile_section *sections;
 };
 
+/* Setting up dynamic logging 8< */
 RTE_LOG_REGISTER_DEFAULT(cfgfile_logtype, INFO);
 
 #define CFG_LOG(level, fmt, args...)					\
 	rte_log(RTE_LOG_ ## level, cfgfile_logtype, "%s(): " fmt "\n",	\
 		__func__, ## args)
+/* >8 End of setting up dynamic logging */
 
 /** when we resize a file structure, how many extra entries
  * for new sections do we add in */
Signature · 1 line
2.39.2
#2 lore raw

PATCH 2/2 doc/contributing: guidelines for logging, tracing and telemetry

In reply to Bruce Richardson

As discussed by DPDK technical board [1], out contributor guide should include some details as to when to use logging vs tracing vs telemetry to provide the end user with information about the running process and the DPDK libraries it uses.

[1] https://mails.dpdk.org/archives/dev/2023-March/265204.html

---
 doc/guides/contributing/coding_style.rst |  2 ++
 doc/guides/contributing/design.rst       | 34 ++++++++++++++++++++++++
 doc/guides/prog_guide/telemetry_lib.rst  |  2 ++
 doc/guides/prog_guide/trace_lib.rst      |  2 ++
 4 files changed, 40 insertions(+)
doc/guides/contributing/coding_style.rst +2 -0
index f50a78a346..13b2390d9e 100644
@@ -794,6 +794,8 @@ Control Statements
                  /* NOTREACHED */
          }
 
+.. _dynamic_logging:
+
 Dynamic Logging
 ---------------
 
doc/guides/contributing/design.rst +34 -0
index d24a7ff6a0..9edf3ea43b 100644
@@ -4,6 +4,40 @@
 Design
 ======
 
+Runtime Information - Logging, Tracing and Telemetry
+-------------------------------------------------------
+
+It is often desirable to provide information to the end-user as to what is happening to the application at runtime.
+DPDK provides a number of built-in mechanisms to provide this introspection:
+
+* :ref:`Logging<dynamic_logging>`
+* :ref:`Tracing<trace_library>`
+* :ref:`Telemetry<telemetry_library>`
+
+Each of these has it's own strengths and suitabilities for use within DPDK components.
+
+Below are some guidelines for when each should be used:
+
+* For reporting error conditions, or other abnormal runtime issues, *logging* should be used.
+  Depending on the severity of the issue, the appropriate log level, for example,
+  ``ERROR``, ``WARNING`` or ``NOTICE``, should be used.
+* In general, it is not recommended that the DPDK logging functions should be used for debugging.
+  Although the ``DEBUG`` log level may be used in components, it should only be used sparingly,
+  and the *tracing* functionality used instead.
+  More specifically:
+
+  * for cases where a path through the code is only likely to be taken once,
+    for example, initialization code, either *logging* at ``DEBUG`` level or *tracing* may be used -
+    though tracing is preferred.
+  * where a path is to be taken multiple times within a short timeframe, for example,
+    datapath or regular control plane code, *tracing* should be used.
+
+* For numerical or statistical data generated by a component, for example, per-packet statistics,
+  *telemetry* should be used.
+* For any data where the data may need to be gathered at any point in the execution to help assess the state of the application component,
+  for example, core configuration, device information, *telemetry* should be used.
+
+
 Environment or Architecture-specific Sources
 --------------------------------------------
 
doc/guides/prog_guide/telemetry_lib.rst +2 -0
index 32f525a67f..71f8bd735e 100644
@@ -1,6 +1,8 @@
 ..  SPDX-License-Identifier: BSD-3-Clause
     Copyright(c) 2020 Intel Corporation.
 
+.. _telemetry_library:
+
 Telemetry Library
 =================
 
doc/guides/prog_guide/trace_lib.rst +2 -0
index e5718feddc..a3b8a7c2eb 100644
@@ -1,6 +1,8 @@
 ..  SPDX-License-Identifier: BSD-3-Clause
     Copyright(C) 2020 Marvell International Ltd.
 
+.. _trace_library:
+
 Trace Library
 =============
 
Signature · 1 line
2.39.2
#3 lore raw

Re: [PATCH 2/2] doc/contributing: guidelines for logging, tracing and telemetry

Quoted 5 lines · On Tue, 13 Jun 2023 15:33:55 +0100 Bruce Richardson…
doc/guides/contributing/design.rst +5 -0
+Below are some guidelines for when each should be used:
+
+* For reporting error conditions, or other abnormal runtime issues, *logging* should be used.
+  Depending on the severity of the issue, the appropriate log level, for example,
+  ``ERROR``, ``WARNING`` or ``NOTICE``, should be used.

doc/guides/contributing/design.rst line 33

Quoted 10 lines
doc/guides/contributing/design.rst +10 -0
+* In general, it is not recommended that the DPDK logging functions should be used for debugging.
+  Although the ``DEBUG`` log level may be used in components, it should only be used sparingly,
+  and the *tracing* functionality used instead.
+  More specifically:
+
+  * for cases where a path through the code is only likely to be taken once,
+    for example, initialization code, either *logging* at ``DEBUG`` level or *tracing* may be used -
+    though tracing is preferred.
+  * where a path is to be taken multiple times within a short timeframe, for example,
+    datapath or regular control plane code, *tracing* should be used.

When a new feature, bus or device type is added it *must* not log when not present. No new messages for existing users please.

Acked-by on v1 2/2
#4 lore raw

RE: [PATCH 2/2] doc/contributing: guidelines for logging, tracing and telemetry

In reply to Bruce Richardson
Quoted 4 lines

From: Bruce Richardson [mailto:[email protected]]
Sent: Tuesday, 13 June 2023 16.34

As discussed by DPDK technical board [1], out contributor guide should

Typo: out -> our

Quoted 8 lines

include some details as to when to use logging vs tracing vs telemetry to provide the end user with information about the running process and the DPDK libraries it uses.

[1] https://mails.dpdk.org/archives/dev/2023-March/265204.html

---

Debug logging can be more verbose than trace in the one-off cases, so I have a slightly different personal preference. But perhaps this is mainly relevant in the abnormal execution paths, and thus already covered.

Anyway, I agree with everything in this patch.

You might also consider mentioning the xyz_dump(FILE *f) functions such as rte_mempool_list_dump(FILE *f).

I find this type of semi-structured verbose dumping very useful for investigating the state of systems in production. Our debug CLI provides access to these _dump() functions, including some of our own, from various subsystems in the application.

#5 lore raw

Re: [PATCH 2/2] doc/contributing: guidelines for logging, tracing and telemetry

Quoted 11 lines · Morten Brørup
Quoted 4 lines

From: Bruce Richardson [mailto:[email protected]]
Sent: Tuesday, 13 June 2023 16.34

As discussed by DPDK technical board [1], out contributor guide should

Typo: out -> our

Quoted 4 lines

include some details as to when to use logging vs tracing vs telemetry to provide the end user with information about the running process and the DPDK libraries it uses.

Quoted 7 lines
Quoted 4 lines

[1] https://mails.dpdk.org/archives/dev/2023-March/265204.html

---

Debug logging can be more verbose than trace in the one-off cases, so I have a slightly different personal preference. But perhaps this is mainly relevant in the abnormal execution paths, and thus already covered.

Feel free to suggest alternate wordings if you have any. That particular item is hard to come up with good guidelines for - especially ones that are not pages long! :-)

Quoted 4 lines

Anyway, I agree with everything in this patch.

Thanks.

Quoted 4 lines

You might also consider mentioning the xyz_dump(FILE *f) functions such as rte_mempool_list_dump(FILE *f).

I find this type of semi-structured verbose dumping very useful for investigating the state of systems in production. Our debug CLI provides access to these _dump() functions, including some of our own, from various subsystems in the application.

I'll try and put some mention of that in V2.

/Bruce

#6 lore raw

RE: [PATCH 2/2] doc/contributing: guidelines for logging, tracing and telemetry

Quoted 20 lines

From: Bruce Richardson [mailto:[email protected]]
Sent: Wednesday, 14 June 2023 10.37

Quoted 16 lines · Morten Brørup
Quoted 4 lines

From: Bruce Richardson [mailto:[email protected]]
Sent: Tuesday, 13 June 2023 16.34

As discussed by DPDK technical board [1], out contributor guide should

Typo: out -> our

Quoted 8 lines

include some details as to when to use logging vs tracing vs telemetry to provide the end user with information about the running process and the DPDK libraries it uses.

[1] https://mails.dpdk.org/archives/dev/2023-March/265204.html

---

Quoted 8 lines
Quoted 1 line

Debug logging can be more verbose than trace in the one-off cases, so I have

a slightly different personal preference. But perhaps this is mainly relevant in the abnormal execution paths, and thus already covered.

Quoted 1 line

Feel free to suggest alternate wordings if you have any. That particular item is hard to come up with good guidelines for - especially ones that are not pages long! :-)

+ * For cases where a path through the code is only likely to be taken once,
+ for example, initialization code, either *logging* at ``DEBUG`` level or *tracing* may be used -
+ though tracing is preferred.

How about adding this sentence at the end of the bullet:
+ though tracing is preferred. When conveying a lot of information, *logging* with more details can supplement *tracing* with the basic details.

+ * Where a path is to be taken multiple times within a short timeframe, for example,
+ datapath or regular control plane code, *tracing* should be used.

Capitalize the first letter at the bullets: "* for"->"* For" and "* where"->"* Where"

Quoted 20 lines
Quoted 5 lines

Anyway, I agree with everything in this patch.

Thanks.

Quoted 1 line

You might also consider mentioning the xyz_dump(FILE *f) functions such as

rte_mempool_list_dump(FILE *f).

Quoted 2 lines

I find this type of semi-structured verbose dumping very useful for

investigating the state of systems in production. Our debug CLI provides access to these _dump() functions, including some of our own, from various subsystems in the application.

Quoted 1 line

I'll try and put some mention of that in V2.

/Bruce

#7 lore raw

Re: [PATCH 2/2] doc/contributing: guidelines for logging, tracing and telemetry

In reply to Bruce Richardson
Quoted 33 lines · Bruce Richardson

As discussed by DPDK technical board [1], out contributor guide should include some details as to when to use logging vs tracing vs telemetry to provide the end user with information about the running process and the DPDK libraries it uses.

[1] https://mails.dpdk.org/archives/dev/2023-March/265204.html

---
 doc/guides/contributing/coding_style.rst |  2 ++
 doc/guides/contributing/design.rst       | 34 ++++++++++++++++++++++++
 doc/guides/prog_guide/telemetry_lib.rst  |  2 ++
 doc/guides/prog_guide/trace_lib.rst      |  2 ++
 4 files changed, 40 insertions(+)
doc/guides/contributing/coding_style.rst +2 -0
index f50a78a346..13b2390d9e 100644
@@ -794,6 +794,8 @@ Control Statements
                  /* NOTREACHED */
          }
 
+.. _dynamic_logging:
+
 Dynamic Logging
 ---------------
 
doc/guides/contributing/design.rst +0 -0
index d24a7ff6a0..9edf3ea43b 100644

doc/guides/contributing/design.rst line 11

Quoted 8 lines
doc/guides/contributing/design.rst +4 -0
@@ -4,6 +4,40 @@
 Design
 ======
 
+Runtime Information - Logging, Tracing and Telemetry
+-------------------------------------------------------
+
+It is often desirable to provide information to the end-user as to what is happening to the application at runtime.
 

I think target audience matters, who is consumer of the runtime information, possible candidates I can think of:
- dev-ops engineer deploys and maintains a dpdk application
- DPDK based application developer
- DPDK developer

Should we distinguish them? Like I guess telemetry output can be more useful to dev-ops engineer, but debug output can be more useful to application developer.

To roughly set target consumer for each method may help developer to decide which one to use, but not sure if we can narrow it like this.

doc/guides/contributing/design.rst line 23

Quoted 13 lines
doc/guides/contributing/design.rst +13 -0
+DPDK provides a number of built-in mechanisms to provide this introspection:
+
+* :ref:`Logging<dynamic_logging>`
+* :ref:`Tracing<trace_library>`
+* :ref:`Telemetry<telemetry_library>`
+
+Each of these has it's own strengths and suitabilities for use within DPDK components.
+
+Below are some guidelines for when each should be used:
+
+* For reporting error conditions, or other abnormal runtime issues, *logging* should be used.
+  Depending on the severity of the issue, the appropriate log level, for example,
+  ``ERROR``, ``WARNING`` or ``NOTICE``, should be used.

+1

doc/guides/contributing/design.rst line 26

Quoted 3 lines
doc/guides/contributing/design.rst +3 -0
+* In general, it is not recommended that the DPDK logging functions should be used for debugging.
+  Although the ``DEBUG`` log level may be used in components, it should only be used sparingly,
+  and the *tracing* functionality used instead.

I think DEBUG logging is still useful for control path, 'tracing' is missing the custom message, so I found it more useful for to analyze order and frequency of a function call, which suits more to datapath.

doc/guides/contributing/design.rst

Quoted 5 lines
doc/guides/contributing/design.rst +5 -0
+  More specifically:
+
+  * for cases where a path through the code is only likely to be taken once,
+    for example, initialization code, either *logging* at ``DEBUG`` level or *tracing* may be used -
+    though tracing is preferred.>

I am for preferring 'logging' for this case, because there is extra effort required to analyze the trace output, but logs are simple and just there.

doc/guides/contributing/design.rst line 43

Quoted 4 lines
doc/guides/contributing/design.rst +3 -0
+  * where a path is to be taken multiple times within a short timeframe, for example,
+    datapath or regular control plane code, *tracing* should be used.
+
 

+1 to use tracing mainly for datapath

Also there is logging support for datapath, it would be nice to clarify that usage too. Datapath logging used:
a) RTE_LOG_DP macros where code compiled out based on selected log level
b) 'RTE_ETHDEV_DEBUG_RX' & 'RTE_ETHDEV_DEBUG_TX' macros

ethdev layer use b for logging,
drivers use combination of a & b

Tracing helps on datapath to get profiling etc, but there are cases driver needs to log some variables, like descriptor details to ensure *functionality* is correct.

I suggest to remove/deprecate RTE_LOG_DP [1], and use 'RTE_ETHDEV_DEBUG_x' macros for developer logging, and use tracing for profiling. What do you think?

[1]
Intention is good with RTE_LOG_DP macro to set the desired log level and compile out not used logs so that they won't take extra cycle. But every time log level changed, it requires compiling again anyway, and in practice there is no multiple level logging need for datapath, most of the time single macro to enable/disable logging is sufficient. That why I believe simpler to use an explicit macro to enable/disable datapath logging, like 'RTE_ETHDEV_DEBUG_RX' & 'RTE_ETHDEV_DEBUG_TX'.

doc/guides/contributing/design.rst line 43

Quoted 3 lines
doc/guides/contributing/design.rst +2 -0
+* For numerical or statistical data generated by a component, for example, per-packet statistics,
+  *telemetry* should be used.
 

+1

doc/guides/contributing/design.rst line 39

Quoted 3 lines
doc/guides/contributing/design.rst +3 -0
+* For any data where the data may need to be gathered at any point in the execution to help assess the state of the application component,
+  for example, core configuration, device information, *telemetry* should be used.
+

+1

Should we explicitly state that telemetry only used as readonly? I think it implicitly states, but since there was a patch in the past, I wonder if this needs to be highlighted?

#8 lore raw

Re: [PATCH 2/2] doc/contributing: guidelines for logging, tracing and telemetry

In reply to Bruce Richardson
Quoted 54 lines · Bruce Richardson

As discussed by DPDK technical board [1], out contributor guide should include some details as to when to use logging vs tracing vs telemetry to provide the end user with information about the running process and the DPDK libraries it uses.

[1] https://mails.dpdk.org/archives/dev/2023-March/265204.html

---
 doc/guides/contributing/coding_style.rst |  2 ++
 doc/guides/contributing/design.rst       | 34 ++++++++++++++++++++++++
 doc/guides/prog_guide/telemetry_lib.rst  |  2 ++
 doc/guides/prog_guide/trace_lib.rst      |  2 ++
 4 files changed, 40 insertions(+)
doc/guides/contributing/coding_style.rst +2 -0
index f50a78a346..13b2390d9e 100644
@@ -794,6 +794,8 @@ Control Statements
                  /* NOTREACHED */
          }
 
+.. _dynamic_logging:
+
 Dynamic Logging
 ---------------
 
doc/guides/contributing/design.rst +17 -0
index d24a7ff6a0..9edf3ea43b 100644
@@ -4,6 +4,40 @@
 Design
 ======
 
+Runtime Information - Logging, Tracing and Telemetry
+-------------------------------------------------------
+
+It is often desirable to provide information to the end-user as to what is happening to the application at runtime.
+DPDK provides a number of built-in mechanisms to provide this introspection:
+
+* :ref:`Logging<dynamic_logging>`
+* :ref:`Tracing<trace_library>`
+* :ref:`Telemetry<telemetry_library>`
+
+Each of these has it's own strengths and suitabilities for use within DPDK components.
+
+Below are some guidelines for when each should be used:
+
+* For reporting error conditions, or other abnormal runtime issues, *logging* should be used.
+  Depending on the severity of the issue, the appropriate log level, for example,
+  ``ERROR``, ``WARNING`` or ``NOTICE``, should be used.

doc/guides/contributing/design.rst line 33

Quoted 10 lines
doc/guides/contributing/design.rst +10 -0
+* In general, it is not recommended that the DPDK logging functions should be used for debugging.
+  Although the ``DEBUG`` log level may be used in components, it should only be used sparingly,
+  and the *tracing* functionality used instead.
+  More specifically:
+
+  * for cases where a path through the code is only likely to be taken once,
+    for example, initialization code, either *logging* at ``DEBUG`` level or *tracing* may be used -
+    though tracing is preferred.
+  * where a path is to be taken multiple times within a short timeframe, for example,
+    datapath or regular control plane code, *tracing* should be used.

If you think it makes sense, the following point may be added for trace. # Since trace is using CommonTraceFormat, it is possible to write _reusable_ post-processing tools with
https://babeltrace.org/docs/v1.5/python/babeltrace/ like finding idle CPU time etc.

Rest looks good to me.

Quoted 39 lines
doc/guides/contributing/design.rst +7 -0
+
+* For numerical or statistical data generated by a component, for example, per-packet statistics,
+  *telemetry* should be used.
+* For any data where the data may need to be gathered at any point in the execution to help assess the state of the application component,
+  for example, core configuration, device information, *telemetry* should be used.
+
+
 Environment or Architecture-specific Sources
 --------------------------------------------
 
doc/guides/prog_guide/telemetry_lib.rst +2 -0
index 32f525a67f..71f8bd735e 100644
@@ -1,6 +1,8 @@
 ..  SPDX-License-Identifier: BSD-3-Clause
     Copyright(c) 2020 Intel Corporation.
 
+.. _telemetry_library:
+
 Telemetry Library
 =================
 
doc/guides/prog_guide/trace_lib.rst +2 -1
index e5718feddc..a3b8a7c2eb 100644
@@ -1,6 +1,8 @@
 ..  SPDX-License-Identifier: BSD-3-Clause
     Copyright(C) 2020 Marvell International Ltd.
 
+.. _trace_library:
+
 Trace Library
 =============
 
--

2.39.2

#9 lore raw

v2 cover Improve docs on getting info on running process

In reply to Bruce Richardson

Add details to our documentation on how to register logging for a component. Also provide guidelines on when to use logs vs tracing vs telemetry.

V2: extended second patch based on the feedback provided.
Hopefully, we can keep this section short and clear as the revisions roll! :-)

Bruce Richardson (2):
doc/contributing: provide coding details for dynamic logging doc/contributing: guidelines for logging, tracing and telemetry

 doc/guides/contributing/coding_style.rst | 19 ++++++++++
 doc/guides/contributing/design.rst       | 47 ++++++++++++++++++++++++
 doc/guides/prog_guide/telemetry_lib.rst  |  2 +
 doc/guides/prog_guide/trace_lib.rst      |  2 +
 lib/cfgfile/rte_cfgfile.c                |  2 +
 5 files changed, 72 insertions(+)

--
2.39.2

#10 lore raw

PATCH v2 1/2 doc/contributing: provide coding details for dynamic logging

While the section on dynamic logging in the contributors guide covered the details of the logging naming scheme, it failed to cover exactly how the component developer, i.e. the contributor, could actually use dynamic logging in their component.

Fix this by splitting the details of the naming scheme into a separate subsection, and adding to the introduction on logging, a recommendation (and example) to use RTE_LOG_REGISTER_DEFAULT.

Similarly, when discussing specialization, include a reference to the RTE_LOG_REGISTER_SUFFIX macro.

---
 doc/guides/contributing/coding_style.rst | 17 +++++++++++++++++
 lib/cfgfile/rte_cfgfile.c                |  2 ++
 2 files changed, 19 insertions(+)
doc/guides/contributing/coding_style.rst +17 -0
index 89db6260cf..307c7deb9a 100644
@@ -803,6 +803,21 @@ logging of a particular topic, the ``--log-level`` parameter can be provided
 to EAL, which will change the log level. DPDK code can register topics,
 which allows the user to adjust the log verbosity for that specific topic.
 
+To register a library or driver for dynamic logging,
+using the standardized naming scheme described below,
+use ``RTE_LOG_REGISTER_DEFAULT`` macro to define a log-type variable inside your component's main C file.
+Thereafter, it is usual to define a macro or macros inside your component to make logging more convenient.
+
+For example, the ``rte_cfgfile`` library defines:
+
+.. literalinclude:: ../../../lib/cfgfile/rte_cfgfile.c
+    :language: c
+    :start-after: Setting up dynamic logging 8<
+    :end-before: >8 End of setting up dynamic logging
+
+Dynamic Logging Naming Scheme
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
 In general, the naming scheme is as follows: ``type.section.name``
 
  * Type is the type of component, where ``lib``, ``pmd``, ``bus`` and ``user``
@@ -837,6 +852,8 @@ A specialization looks like this:
  * Initialization output: ``type.section.name.init``
  * PF/VF mailbox output: ``type.section.name.mbox``
 
+These specializations are created using the ``RTE_LOG_REGISTER_SUFFIX`` macro.
+
 A real world example is the i40e poll mode driver which exposes two
 specializations, one for initialization ``pmd.net.i40e.init`` and the other for
 the remaining driver logs ``pmd.net.i40e.driver``.
lib/cfgfile/rte_cfgfile.c +2 -0
index 9fa7d010ef..eefba6e408 100644
@@ -27,11 +27,13 @@ struct rte_cfgfile {
 	struct rte_cfgfile_section *sections;
 };
 
+/* Setting up dynamic logging 8< */
 RTE_LOG_REGISTER_DEFAULT(cfgfile_logtype, INFO);
 
 #define CFG_LOG(level, fmt, args...)					\
 	rte_log(RTE_LOG_ ## level, cfgfile_logtype, "%s(): " fmt "\n",	\
 		__func__, ## args)
+/* >8 End of setting up dynamic logging */
 
 /** when we resize a file structure, how many extra entries
  * for new sections do we add in */
Signature · 1 line
2.39.2
Acked-by on v2 1/2
#11 lore raw

Re: [PATCH v2 1/2] doc/contributing: provide coding details for dynamic logging

Quoted 14 lines · Bruce Richardson

While the section on dynamic logging in the contributors guide covered the details of the logging naming scheme, it failed to cover exactly how the component developer, i.e. the contributor, could actually use dynamic logging in their component.

Fix this by splitting the details of the naming scheme into a separate subsection, and adding to the introduction on logging, a recommendation (and example) to use RTE_LOG_REGISTER_DEFAULT.

Similarly, when discussing specialization, include a reference to the RTE_LOG_REGISTER_SUFFIX macro.

---

...

Reviewed-by on v2 1/2
#12 lore raw

Re: [PATCH v2 1/2] doc/contributing: provide coding details for dynamic logging

In reply to Bruce Richardson
Quoted 24 lines · Bruce Richardson

While the section on dynamic logging in the contributors guide covered the details of the logging naming scheme, it failed to cover exactly how the component developer, i.e. the contributor, could actually use dynamic logging in their component.

Fix this by splitting the details of the naming scheme into a separate subsection, and adding to the introduction on logging, a recommendation (and example) to use RTE_LOG_REGISTER_DEFAULT.

Similarly, when discussing specialization, include a reference to the RTE_LOG_REGISTER_SUFFIX macro.

---
 doc/guides/contributing/coding_style.rst | 17 +++++++++++++++++
 lib/cfgfile/rte_cfgfile.c                |  2 ++
 2 files changed, 19 insertions(+)
doc/guides/contributing/coding_style.rst +0 -0
index 89db6260cf..307c7deb9a 100644

doc/guides/contributing/coding_style.rst logging of a particular topic, the ``--log-level`` parameter can be provided · line 806

Quoted 4 lines
doc/guides/contributing/coding_style.rst +1 -0
@@ -803,6 +803,21 @@ logging of a particular topic, the ``--log-level`` parameter can be provided
 to EAL, which will change the log level. DPDK code can register topics,
 which allows the user to adjust the log verbosity for that specific topic.
 
+To register a library or driver for dynamic logging,

Nit: no need for a line break here, it can be fixed when applying.

Quoted 45 lines
doc/guides/contributing/coding_style.rst +16 -0
+using the standardized naming scheme described below,
+use ``RTE_LOG_REGISTER_DEFAULT`` macro to define a log-type variable inside your component's main C file.
+Thereafter, it is usual to define a macro or macros inside your component to make logging more convenient.
+
+For example, the ``rte_cfgfile`` library defines:
+
+.. literalinclude:: ../../../lib/cfgfile/rte_cfgfile.c
+    :language: c
+    :start-after: Setting up dynamic logging 8<
+    :end-before: >8 End of setting up dynamic logging
+
+Dynamic Logging Naming Scheme
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
 In general, the naming scheme is as follows: ``type.section.name``
 
  * Type is the type of component, where ``lib``, ``pmd``, ``bus`` and ``user``
@@ -837,6 +852,8 @@ A specialization looks like this:
  * Initialization output: ``type.section.name.init``
  * PF/VF mailbox output: ``type.section.name.mbox``
 
+These specializations are created using the ``RTE_LOG_REGISTER_SUFFIX`` macro.
+
 A real world example is the i40e poll mode driver which exposes two
 specializations, one for initialization ``pmd.net.i40e.init`` and the other for
 the remaining driver logs ``pmd.net.i40e.driver``.
lib/cfgfile/rte_cfgfile.c +2 -1
index 9fa7d010ef..eefba6e408 100644
@@ -27,11 +27,13 @@ struct rte_cfgfile {
        struct rte_cfgfile_section *sections;
 };
 
+/* Setting up dynamic logging 8< */
 RTE_LOG_REGISTER_DEFAULT(cfgfile_logtype, INFO);
 
 #define CFG_LOG(level, fmt, args...)                                   \
        rte_log(RTE_LOG_ ## level, cfgfile_logtype, "%s(): " fmt "\n",  \
                __func__, ## args)
+/* >8 End of setting up dynamic logging */
 
 /** when we resize a file structure, how many extra entries
  * for new sections do we add in */
--
Quoted 2 lines

2.39.2

Thanks, this doc patch is a good addition in its current form.

Stephen used a little trick with a #define RTE_LOGTYPE_$type
${type}_logtype so that RTE_LOG() is directly usable.
This makes conversion from static to dynamic logtypes rather easy.
Example: https://patchwork.dpdk.org/project/dpdk/patch/[email protected]/
It could be something we advertise in this doc later.

Maybe some consistency cleanup (and guidance) would be good too, as many components have close-yet-somewhat-different log formats (some log the function name, others write the line number etc...).

Signature · 1 line
David Marchand
#13 lore raw

PATCH v2 2/2 doc/contributing: guidelines for logging, tracing and telemetry

In reply to Bruce Richardson

As discussed by DPDK technical board [1], our contributor guide should include some details as to when to use logging vs tracing vs telemetry to provide the end user with information about the running process and the DPDK libraries it uses.

[1] https://mails.dpdk.org/archives/dev/2023-March/265204.html

---
V2:
* Added note about not logging from unused drivers
* Reworked bullets/sub-bullets on tracing vs debug logs for debugging.
- Consensus in replies was that people liked having debug logs for single-use, e.g. init cases.
- Kept recommendation for tracing for data-path only
* Added short discussion of *_dump() functions at end of section
* Added sentence to indicate that telemetry should be read-only
* Added mention of common trace format and that other tools are available for it.

---
 doc/guides/contributing/coding_style.rst |  2 +
 doc/guides/contributing/design.rst       | 47 ++++++++++++++++++++++++
 doc/guides/prog_guide/telemetry_lib.rst  |  2 +
 doc/guides/prog_guide/trace_lib.rst      |  2 +
 4 files changed, 53 insertions(+)
doc/guides/contributing/coding_style.rst +2 -0
index 307c7deb9a..0861305dc6 100644
@@ -794,6 +794,8 @@ Control Statements
                  /* NOTREACHED */
          }
 
+.. _dynamic_logging:
+
 Dynamic Logging
 ---------------
 
doc/guides/contributing/design.rst +47 -0

53 lines not on this page · raw message

doc/guides/prog_guide/telemetry_lib.rst +2 -0
index 32f525a67f..71f8bd735e 100644
@@ -1,6 +1,8 @@
 ..  SPDX-License-Identifier: BSD-3-Clause
     Copyright(c) 2020 Intel Corporation.
 
+.. _telemetry_library:
+
 Telemetry Library
 =================
 
doc/guides/prog_guide/trace_lib.rst +2 -0
index e5718feddc..a3b8a7c2eb 100644
@@ -1,6 +1,8 @@
 ..  SPDX-License-Identifier: BSD-3-Clause
     Copyright(C) 2020 Marvell International Ltd.
 
+.. _trace_library:
+
 Trace Library
 =============
 
Signature · 1 line
2.39.2
Reviewed-by on v2 2/2
#14 lore raw

Re: [PATCH v2 2/2] doc/contributing: guidelines for logging, tracing and telemetry

Quoted 47 lines · Bruce Richardson

As discussed by DPDK technical board [1], our contributor guide should include some details as to when to use logging vs tracing vs telemetry to provide the end user with information about the running process and the DPDK libraries it uses.

[1] https://mails.dpdk.org/archives/dev/2023-March/265204.html

---
V2:
* Added note about not logging from unused drivers
* Reworked bullets/sub-bullets on tracing vs debug logs for debugging.
- Consensus in replies was that people liked having debug logs for single-use, e.g. init cases.
- Kept recommendation for tracing for data-path only
* Added short discussion of *_dump() functions at end of section
* Added sentence to indicate that telemetry should be read-only
* Added mention of common trace format and that other tools are available for it.

---
 doc/guides/contributing/coding_style.rst |  2 +
 doc/guides/contributing/design.rst       | 47 ++++++++++++++++++++++++
 doc/guides/prog_guide/telemetry_lib.rst  |  2 +
 doc/guides/prog_guide/trace_lib.rst      |  2 +
 4 files changed, 53 insertions(+)
doc/guides/contributing/coding_style.rst +2 -0
index 307c7deb9a..0861305dc6 100644
@@ -794,6 +794,8 @@ Control Statements
                  /* NOTREACHED */
          }
 
+.. _dynamic_logging:
+
 Dynamic Logging
 ---------------
 
doc/guides/contributing/design.rst +0 -0
index d24a7ff6a0..30104e0bfb 100644

doc/guides/contributing/design.rst line 8

Quoted 5 lines
doc/guides/contributing/design.rst +2 -0
@@ -4,6 +4,53 @@
 Design
 ======
 
+Runtime Information - Logging, Tracing and Telemetry
+-------------------------------------------------------

I would put this section right before the statistics section (since telemetry and stats are somehow related).

doc/guides/contributing/design.rst line 17

Quoted 9 lines
doc/guides/contributing/design.rst +9 -0
+
+It is often desirable to provide information to the end-user as to what is happening to the application at runtime.
+DPDK provides a number of built-in mechanisms to provide this introspection:
+
+* :ref:`Logging<dynamic_logging>`
+* :ref:`Tracing<trace_library>`
+* :ref:`Telemetry<telemetry_library>`
+
+Each of these has it's own strengths and suitabilities for use within DPDK components.

Nit: its* ?

doc/guides/contributing/design.rst line 27

Quoted 10 lines
doc/guides/contributing/design.rst +10 -0
+
+Below are some guidelines for when each should be used:
+
+* For reporting error conditions, or other abnormal runtime issues, *logging* should be used.
+  Depending on the severity of the issue, the appropriate log level, for example,
+  ``ERROR``, ``WARNING`` or ``NOTICE``, should be used.
+
+.. note::
+
+    Drivers off all classes, including both bus and device drivers,

Nit: of*

Quoted 56 lines
doc/guides/contributing/design.rst +26 -0
+    should not output any log information if the hardware they support is not present.
+    This is to avoid any changes in output for existing users when a new driver is added to DPDK.
+
+* For component initialization, or other cases where a path through the code is only likely to be taken once,
+  either *logging* at ``DEBUG`` level or *tracing* may be used, or potentially both.
+  In the latter case, tracing can provide basic information as to the code path taken,
+  with debug-level logging providing additional details on internal state,
+  not possible to emit via tracing.
+
+* For a component's data-path, where a path is to be taken multiple times within a short timeframe,
+  *tracing* should be used.
+  Since DPDK tracing uses `Common Trace Format <https://diamon.org/ctf/>`_ for its tracing logs,
+  post-analysis can be done using a range of external tools.
+
+* For numerical or statistical data generated by a component, for example, per-packet statistics,
+  *telemetry* should be used.
+
+* For any data where the data may need to be gathered at any point in the execution to help assess the state of the application component,
+  for example, core configuration, device information, *telemetry* should be used.
+  Telemetry callbacks should not modify any program state, but be "read-only".
+
+Many libraries also include a ``rte_<libname>_dump()`` function as part of their API,
+writing verbose internal details to a given file-handle.
+New libraries are encouraged to provide such functions where it makes sense to do so,
+as they provide an additional application-controlled mechanism to get details of the internals of a DPDK component.
+
 Environment or Architecture-specific Sources
 --------------------------------------------
 
doc/guides/prog_guide/telemetry_lib.rst +2 -0
index 32f525a67f..71f8bd735e 100644
@@ -1,6 +1,8 @@
 ..  SPDX-License-Identifier: BSD-3-Clause
     Copyright(c) 2020 Intel Corporation.
 
+.. _telemetry_library:
+
 Telemetry Library
 =================
 
doc/guides/prog_guide/trace_lib.rst +2 -1
index e5718feddc..a3b8a7c2eb 100644
@@ -1,6 +1,8 @@
 ..  SPDX-License-Identifier: BSD-3-Clause
     Copyright(C) 2020 Marvell International Ltd.
 
+.. _trace_library:
+
 Trace Library
 =============
 
--
Quoted 2 lines

2.39.2

Signature · 1 line
David Marchand
#15 lore raw

v3 cover Improve docs on getting info on running process

In reply to Bruce Richardson

Add details to our documentation on how to register logging for a component. Also provide guidelines on when to use logs vs tracing vs telemetry.

V3: Moved new doc section on runtime info, and other minor changes flagged
by David on review.

V2: extended second patch based on the feedback provided.
Hopefully, we can keep this section short and clear as the revisions roll! :-)

Bruce Richardson (2):
doc/contributing: provide coding details for dynamic logging doc/contributing: guidelines for logging, tracing and telemetry

 doc/guides/contributing/coding_style.rst | 18 +++++++++
 doc/guides/contributing/design.rst       | 49 ++++++++++++++++++++++++
 doc/guides/prog_guide/telemetry_lib.rst  |  2 +
 doc/guides/prog_guide/trace_lib.rst      |  2 +
 lib/cfgfile/rte_cfgfile.c                |  2 +
 5 files changed, 73 insertions(+)

--
2.39.2

#16 lore raw

PATCH v3 1/2 doc/contributing: provide coding details for dynamic logging

While the section on dynamic logging in the contributors guide covered the details of the logging naming scheme, it failed to cover exactly how the component developer, i.e. the contributor, could actually use dynamic logging in their component.

Fix this by splitting the details of the naming scheme into a separate subsection, and adding to the introduction on logging, a recommendation (and example) to use RTE_LOG_REGISTER_DEFAULT.

Similarly, when discussing specialization, include a reference to the RTE_LOG_REGISTER_SUFFIX macro.

---
 doc/guides/contributing/coding_style.rst | 16 ++++++++++++++++
 lib/cfgfile/rte_cfgfile.c                |  2 ++
 2 files changed, 18 insertions(+)
doc/guides/contributing/coding_style.rst +16 -0
index 00d6270624..f41f88c632 100644
@@ -803,6 +803,20 @@ logging of a particular topic, the ``--log-level`` parameter can be provided
 to EAL, which will change the log level. DPDK code can register topics,
 which allows the user to adjust the log verbosity for that specific topic.
 
+To register a library or driver for dynamic logging, using the standardized naming scheme described below,
+use ``RTE_LOG_REGISTER_DEFAULT`` macro to define a log-type variable inside your component's main C file.
+Thereafter, it is usual to define a macro or macros inside your component to make logging more convenient.
+
+For example, the ``rte_cfgfile`` library defines:
+
+.. literalinclude:: ../../../lib/cfgfile/rte_cfgfile.c
+    :language: c
+    :start-after: Setting up dynamic logging 8<
+    :end-before: >8 End of setting up dynamic logging
+
+Dynamic Logging Naming Scheme
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
 In general, the naming scheme is as follows: ``type.section.name``
 
  * Type is the type of component, where ``lib``, ``pmd``, ``bus`` and ``user``
@@ -837,6 +851,8 @@ A specialization looks like this:
  * Initialization output: ``type.section.name.init``
  * PF/VF mailbox output: ``type.section.name.mbox``
 
+These specializations are created using the ``RTE_LOG_REGISTER_SUFFIX`` macro.
+
 A real world example is the i40e poll mode driver which exposes two
 specializations, one for initialization ``pmd.net.i40e.init`` and the other for
 the remaining driver logs ``pmd.net.i40e.driver``.
lib/cfgfile/rte_cfgfile.c +2 -0
index 9fa7d010ef..eefba6e408 100644
@@ -27,11 +27,13 @@ struct rte_cfgfile {
 	struct rte_cfgfile_section *sections;
 };
 
+/* Setting up dynamic logging 8< */
 RTE_LOG_REGISTER_DEFAULT(cfgfile_logtype, INFO);
 
 #define CFG_LOG(level, fmt, args...)					\
 	rte_log(RTE_LOG_ ## level, cfgfile_logtype, "%s(): " fmt "\n",	\
 		__func__, ## args)
+/* >8 End of setting up dynamic logging */
 
 /** when we resize a file structure, how many extra entries
  * for new sections do we add in */
Signature · 1 line
2.39.2
Acked-by on v3 1/2
#17 lore raw

Re: [PATCH v3 1/2] doc/contributing: provide coding details for dynamic logging

Quoted 9 lines · Bruce Richardson

While the section on dynamic logging in the contributors guide covered the details of the logging naming scheme, it failed to cover exactly how the component developer, i.e. the contributor, could actually use dynamic logging in their component.

Fix this by splitting the details of the naming scheme into a separate subsection, and adding to the introduction on logging, a recommendation (and example) to use RTE_LOG_REGISTER_DEFAULT.

Quoted 7 lines

Similarly, when discussing specialization, include a reference to the RTE_LOG_REGISTER_SUFFIX macro.

#18 lore raw

PATCH v3 2/2 doc/contributing: guidelines for logging, tracing and telemetry

In reply to Bruce Richardson

As discussed by DPDK technical board [1], our contributor guide should include some details as to when to use logging vs tracing vs telemetry to provide the end user with information about the running process and the DPDK libraries it uses.

[1] https://mails.dpdk.org/archives/dev/2023-March/265204.html

---
 doc/guides/contributing/coding_style.rst |  2 +
 doc/guides/contributing/design.rst       | 49 ++++++++++++++++++++++++
 doc/guides/prog_guide/telemetry_lib.rst  |  2 +
 doc/guides/prog_guide/trace_lib.rst      |  2 +
 4 files changed, 55 insertions(+)
doc/guides/contributing/coding_style.rst +2 -0
index f41f88c632..2d8d9a1469 100644
@@ -794,6 +794,8 @@ Control Statements
                  /* NOTREACHED */
          }
 
+.. _dynamic_logging:
+
 Dynamic Logging
 ---------------
 
doc/guides/contributing/design.rst +49 -0

61 lines not on this page · raw message

doc/guides/prog_guide/telemetry_lib.rst +2 -0
index 32f525a67f..71f8bd735e 100644
@@ -1,6 +1,8 @@
 ..  SPDX-License-Identifier: BSD-3-Clause
     Copyright(c) 2020 Intel Corporation.
 
+.. _telemetry_library:
+
 Telemetry Library
 =================
 
doc/guides/prog_guide/trace_lib.rst +2 -0
index e5718feddc..a3b8a7c2eb 100644
@@ -1,6 +1,8 @@
 ..  SPDX-License-Identifier: BSD-3-Clause
     Copyright(C) 2020 Marvell International Ltd.
 
+.. _trace_library:
+
 Trace Library
 =============
 
Signature · 1 line
2.39.2
Acked-by on v3 2/2
#19 lore raw

Re: [PATCH v3 2/2] doc/contributing: guidelines for logging, tracing and telemetry

Quoted 11 lines · Bruce Richardson

As discussed by DPDK technical board [1], our contributor guide should include some details as to when to use logging vs tracing vs telemetry to provide the end user with information about the running process and the DPDK libraries it uses.

[1] https://mails.dpdk.org/archives/dev/2023-March/265204.html

Quoted 50 lines
---
 doc/guides/contributing/coding_style.rst |  2 +
 doc/guides/contributing/design.rst       | 49 ++++++++++++++++++++++++
 doc/guides/prog_guide/telemetry_lib.rst  |  2 +
 doc/guides/prog_guide/trace_lib.rst      |  2 +
 4 files changed, 55 insertions(+)
doc/guides/contributing/coding_style.rst +2 -0
index f41f88c632..2d8d9a1469 100644
@@ -794,6 +794,8 @@ Control Statements
                  /* NOTREACHED */
          }
 
+.. _dynamic_logging:
+
 Dynamic Logging
 ---------------
 
doc/guides/contributing/design.rst +15 -0
index d24a7ff6a0..5a4c4b7ed1 100644
@@ -4,6 +4,7 @@
 Design
 ======
 
+
 Environment or Architecture-specific Sources
 --------------------------------------------
 
@@ -68,6 +69,54 @@ Adding a new static field or flag must be an exception matching many criteria
 like (non exhaustive): wide usage, performance, size.
 
 
+Runtime Information - Logging, Tracing and Telemetry
+-------------------------------------------------------
+
+It is often desirable to provide information to the end-user as to what is happening to the application at runtime.
+DPDK provides a number of built-in mechanisms to provide this introspection:
+
+* :ref:`Logging<dynamic_logging>`
+* :ref:`Tracing<trace_library>`
+* :ref:`Telemetry<telemetry_library>`
+
+Each of these has its own strengths and suitabilities for use within DPDK components.
+
+Below are some guidelines for when each should be used:
+

doc/guides/contributing/design.rst Adding a new static field or flag must be an exception matching many criteria · line 95

Quoted 10 lines
doc/guides/contributing/design.rst +10 -0
+* For reporting error conditions, or other abnormal runtime issues, *logging* should be used.
+  Depending on the severity of the issue, the appropriate log level, for example,
+  ``ERROR``, ``WARNING`` or ``NOTICE``, should be used.
+
+.. note::
+
+    Drivers of all classes, including both bus and device drivers,
+    should not output any log information if the hardware they support is not present.
+    This is to avoid any changes in output for existing users when a new driver is added to DPDK.
+

+1 to note, this is a good addition.

Quoted 8 lines
doc/guides/contributing/design.rst +8 -0
+* For component initialization, or other cases where a path through the code is only likely to be taken once,
+  either *logging* at ``DEBUG`` level or *tracing* may be used, or potentially both.
+  In the latter case, tracing can provide basic information as to the code path taken,
+  with debug-level logging providing additional details on internal state,
+  not possible to emit via tracing.
+
+* For a component's data-path, where a path is to be taken multiple times within a short timeframe,
+  *tracing* should be used.

doc/guides/contributing/design.rst Adding a new static field or flag must be an exception matching many criteria · line 113

Quoted 10 lines
doc/guides/contributing/design.rst +10 -0
+  Since DPDK tracing uses `Common Trace Format <https://diamon.org/ctf/>`_ for its tracing logs,
+  post-analysis can be done using a range of external tools.
+
+* For numerical or statistical data generated by a component, for example, per-packet statistics,
+  *telemetry* should be used.
+
+* For any data where the data may need to be gathered at any point in the execution to help assess the state of the application component,
+  for example, core configuration, device information, *telemetry* should be used.
+  Telemetry callbacks should not modify any program state, but be "read-only".
+

+1

Quoted 35 lines
doc/guides/contributing/design.rst +6 -0
+Many libraries also include a ``rte_<libname>_dump()`` function as part of their API,
+writing verbose internal details to a given file-handle.
+New libraries are encouraged to provide such functions where it makes sense to do so,
+as they provide an additional application-controlled mechanism to get details of the internals of a DPDK component.
+
+
 Library Statistics
 ------------------
 
doc/guides/prog_guide/telemetry_lib.rst +2 -0
index 32f525a67f..71f8bd735e 100644
@@ -1,6 +1,8 @@
 ..  SPDX-License-Identifier: BSD-3-Clause
     Copyright(c) 2020 Intel Corporation.
 
+.. _telemetry_library:
+
 Telemetry Library
 =================
 
doc/guides/prog_guide/trace_lib.rst +2 -0
index e5718feddc..a3b8a7c2eb 100644
@@ -1,6 +1,8 @@
 ..  SPDX-License-Identifier: BSD-3-Clause
     Copyright(C) 2020 Marvell International Ltd.
 
+.. _trace_library:
+
 Trace Library
 =============
 
Acked-by on v3 2/2
#20 lore raw

Re: [PATCH v3 2/2] doc/contributing: guidelines for logging, tracing and telemetry

In reply to Bruce Richardson
Quoted 83 lines · Bruce Richardson

As discussed by DPDK technical board [1], our contributor guide should include some details as to when to use logging vs tracing vs telemetry to provide the end user with information about the running process and the DPDK libraries it uses.

[1] https://mails.dpdk.org/archives/dev/2023-March/265204.html

---
  doc/guides/contributing/coding_style.rst |  2 +
  doc/guides/contributing/design.rst       | 49 ++++++++++++++++++++++++
  doc/guides/prog_guide/telemetry_lib.rst  |  2 +
  doc/guides/prog_guide/trace_lib.rst      |  2 +
  4 files changed, 55 insertions(+)
doc/guides/contributing/coding_style.rst +2 -0
index f41f88c632..2d8d9a1469 100644
@@ -794,6 +794,8 @@ Control Statements
                   /* NOTREACHED */
           }
 
+.. _dynamic_logging:
+
  Dynamic Logging
  ---------------
 
doc/guides/contributing/design.rst +38 -0
index d24a7ff6a0..5a4c4b7ed1 100644
@@ -4,6 +4,7 @@
  Design
  ======
 
+
  Environment or Architecture-specific Sources
  --------------------------------------------
 
@@ -68,6 +69,54 @@ Adding a new static field or flag must be an exception matching many criteria
  like (non exhaustive): wide usage, performance, size.
 
 
+Runtime Information - Logging, Tracing and Telemetry
+-------------------------------------------------------
+
+It is often desirable to provide information to the end-user as to what is happening to the application at runtime.
+DPDK provides a number of built-in mechanisms to provide this introspection:
+
+* :ref:`Logging<dynamic_logging>`
+* :ref:`Tracing<trace_library>`
+* :ref:`Telemetry<telemetry_library>`
+
+Each of these has its own strengths and suitabilities for use within DPDK components.
+
+Below are some guidelines for when each should be used:
+
+* For reporting error conditions, or other abnormal runtime issues, *logging* should be used.
+  Depending on the severity of the issue, the appropriate log level, for example,
+  ``ERROR``, ``WARNING`` or ``NOTICE``, should be used.
+
+.. note::
+
+    Drivers of all classes, including both bus and device drivers,
+    should not output any log information if the hardware they support is not present.
+    This is to avoid any changes in output for existing users when a new driver is added to DPDK.
+
+* For component initialization, or other cases where a path through the code is only likely to be taken once,
+  either *logging* at ``DEBUG`` level or *tracing* may be used, or potentially both.
+  In the latter case, tracing can provide basic information as to the code path taken,
+  with debug-level logging providing additional details on internal state,
+  not possible to emit via tracing.
+
+* For a component's data-path, where a path is to be taken multiple times within a short timeframe,
+  *tracing* should be used.
+  Since DPDK tracing uses `Common Trace Format <https://diamon.org/ctf/>`_ for its tracing logs,
+  post-analysis can be done using a range of external tools.
+
+* For numerical or statistical data generated by a component, for example, per-packet statistics,
+  *telemetry* should be used.

doc/guides/contributing/design.rst Adding a new static field or flag must be an exception matching many criteria · line 118

Quoted 10 lines
doc/guides/contributing/design.rst +10 -0
+
+* For any data where the data may need to be gathered at any point in the execution to help assess the state of the application component,
+  for example, core configuration, device information, *telemetry* should be used.
+  Telemetry callbacks should not modify any program state, but be "read-only".
+
+Many libraries also include a ``rte_<libname>_dump()`` function as part of their API,
+writing verbose internal details to a given file-handle.
+New libraries are encouraged to provide such functions where it makes sense to do so,
+as they provide an additional application-controlled mechanism to get details of the internals of a DPDK component.
+

+1 now more clear

Quoted 30 lines
doc/guides/contributing/design.rst +1 -0
+
  Library Statistics
  ------------------
 
doc/guides/prog_guide/telemetry_lib.rst +2 -0
index 32f525a67f..71f8bd735e 100644
@@ -1,6 +1,8 @@
  ..  SPDX-License-Identifier: BSD-3-Clause
      Copyright(c) 2020 Intel Corporation.
 
+.. _telemetry_library:
+
  Telemetry Library
  =================
 
doc/guides/prog_guide/trace_lib.rst +2 -0
index e5718feddc..a3b8a7c2eb 100644
@@ -1,6 +1,8 @@
  ..  SPDX-License-Identifier: BSD-3-Clause
      Copyright(C) 2020 Marvell International Ltd.
 
+.. _trace_library:
+
  Trace Library
  =============
 
Acked-by
#21 lore raw

Re: [PATCH v3 2/2] doc/contributing: guidelines for logging, tracing and telemetry

Quoted 8 lines · lihuisong (C)
Quoted 5 lines · Bruce Richardson

As discussed by DPDK technical board [1], our contributor guide should include some details as to when to use logging vs tracing vs telemetry to provide the end user with information about the running process and the DPDK libraries it uses.

Quoted 5 lines
Quoted 5 lines

[1] https://mails.dpdk.org/archives/dev/2023-March/265204.html

#22 lore raw
In reply to Bruce Richardson
Quoted 22 lines · On Tue, 18 Jul 2023 17:48:00 +0100 Bruce Richardson…

Add details to our documentation on how to register logging for a component. Also provide guidelines on when to use logs vs tracing vs telemetry.

V3: Moved new doc section on runtime info, and other minor changes flagged
by David on review.

V2: extended second patch based on the feedback provided.
Hopefully, we can keep this section short and clear as the revisions roll! :-)

Bruce Richardson (2):
doc/contributing: provide coding details for dynamic logging doc/contributing: guidelines for logging, tracing and telemetry

 doc/guides/contributing/coding_style.rst | 18 +++++++++
 doc/guides/contributing/design.rst       | 49 ++++++++++++++++++++++++
 doc/guides/prog_guide/telemetry_lib.rst  |  2 +
 doc/guides/prog_guide/trace_lib.rst      |  2 +
 lib/cfgfile/rte_cfgfile.c                |  2 +
 5 files changed, 73 insertions(+)
Quoted 3 lines

--
2.39.2

Should we add explicit statements about:
- Static logtypes (especially LOGTYPE_PMD) should not be used.
- New static logtypes must not be added.

#23 lore raw
Quoted 25 lines · Stephen Hemminger
Quoted 22 lines · On Tue, 18 Jul 2023 17:48:00 +0100 Bruce Richardson…

Add details to our documentation on how to register logging for a component. Also provide guidelines on when to use logs vs tracing vs telemetry.

V3: Moved new doc section on runtime info, and other minor changes flagged
by David on review.

V2: extended second patch based on the feedback provided.
Hopefully, we can keep this section short and clear as the revisions roll! :-)

Bruce Richardson (2):
doc/contributing: provide coding details for dynamic logging doc/contributing: guidelines for logging, tracing and telemetry

 doc/guides/contributing/coding_style.rst | 18 +++++++++
 doc/guides/contributing/design.rst       | 49 ++++++++++++++++++++++++
 doc/guides/prog_guide/telemetry_lib.rst  |  2 +
 doc/guides/prog_guide/trace_lib.rst      |  2 +
 lib/cfgfile/rte_cfgfile.c                |  2 +
 5 files changed, 73 insertions(+)
Quoted 7 lines
Quoted 3 lines

--
2.39.2

Should we add explicit statements about:
- Static logtypes (especially LOGTYPE_PMD) should not be used.
- New static logtypes must not be added.

I would hope that should not be necessary especially since this section talks about dynamic logging only. However, no harm in adding a one-line note about it. I'll see if I can get a few minutes to spin a V4 with an extra note, but if not I think this set is good to go as-is.

/Bruce

#24 lore raw
In reply to Stephen Hemminger
Quoted 25 lines · Stephen Hemminger
Quoted 22 lines · On Tue, 18 Jul 2023 17:48:00 +0100 Bruce Richardson…

Add details to our documentation on how to register logging for a component. Also provide guidelines on when to use logs vs tracing vs telemetry.

V3: Moved new doc section on runtime info, and other minor changes flagged
by David on review.

V2: extended second patch based on the feedback provided.
Hopefully, we can keep this section short and clear as the revisions roll! :-)

Bruce Richardson (2):
doc/contributing: provide coding details for dynamic logging doc/contributing: guidelines for logging, tracing and telemetry

 doc/guides/contributing/coding_style.rst | 18 +++++++++
 doc/guides/contributing/design.rst       | 49 ++++++++++++++++++++++++
 doc/guides/prog_guide/telemetry_lib.rst  |  2 +
 doc/guides/prog_guide/trace_lib.rst      |  2 +
 lib/cfgfile/rte_cfgfile.c                |  2 +
 5 files changed, 73 insertions(+)
Quoted 7 lines
Quoted 3 lines

--
2.39.2

Should we add explicit statements about:
- Static logtypes (especially LOGTYPE_PMD) should not be used.
- New static logtypes must not be added.

How about:

+.. note::
+

+   The statically-defined log types defined in ``rte_log.h`` are for legacy components,
+   and they will likely be removed in a future release.
+   Do not add new entries to this file.

+

Any suggested rewording before I spin a new patch?

/Bruce

#25 lore raw

v4 cover Improve docs on getting info on running process

In reply to Bruce Richardson

Add details to our documentation on how to register logging for a component. Also provide guidelines on when to use logs vs tracing vs telemetry.

V4: Added note to patch 1 saying not to use the old static logging method

V3: Moved new doc section on runtime info, and other minor changes flagged
by David on review.

V2: extended second patch based on the feedback provided.

Bruce Richardson (2):
doc/contributing: provide coding details for dynamic logging doc/contributing: guidelines for logging, tracing and telemetry

 doc/guides/contributing/coding_style.rst | 24 ++++++++++++
 doc/guides/contributing/design.rst       | 49 ++++++++++++++++++++++++
 doc/guides/prog_guide/telemetry_lib.rst  |  2 +
 doc/guides/prog_guide/trace_lib.rst      |  2 +
 lib/cfgfile/rte_cfgfile.c                |  2 +
 5 files changed, 79 insertions(+)

--
2.39.2

#26 lore raw

PATCH v4 1/2 doc/contributing: provide coding details for dynamic logging

While the section on dynamic logging in the contributors guide covered the details of the logging naming scheme, it failed to cover exactly how the component developer, i.e. the contributor, could actually use dynamic logging in their component.

Fix this by splitting the details of the naming scheme into a separate subsection, and adding to the introduction on logging, a recommendation (and example) to use RTE_LOG_REGISTER_DEFAULT.

Similarly, when discussing specialization, include a reference to the RTE_LOG_REGISTER_SUFFIX macro.

---
 doc/guides/contributing/coding_style.rst | 22 ++++++++++++++++++++++
 lib/cfgfile/rte_cfgfile.c                |  2 ++
 2 files changed, 24 insertions(+)
doc/guides/contributing/coding_style.rst +22 -0
index 00d6270624..383942a601 100644
@@ -803,6 +803,26 @@ logging of a particular topic, the ``--log-level`` parameter can be provided
 to EAL, which will change the log level. DPDK code can register topics,
 which allows the user to adjust the log verbosity for that specific topic.
 
+To register a library or driver for dynamic logging, using the standardized naming scheme described below,
+use ``RTE_LOG_REGISTER_DEFAULT`` macro to define a log-type variable inside your component's main C file.
+Thereafter, it is usual to define a macro or macros inside your component to make logging more convenient.
+
+For example, the ``rte_cfgfile`` library defines:
+
+.. literalinclude:: ../../../lib/cfgfile/rte_cfgfile.c
+    :language: c
+    :start-after: Setting up dynamic logging 8<
+    :end-before: >8 End of setting up dynamic logging
+
+.. note::
+
+   The statically-defined log types defined in ``rte_log.h`` are for legacy components,
+   and they will likely be removed in a future release.
+   Do not add new entries to this file.
+
+Dynamic Logging Naming Scheme
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
 In general, the naming scheme is as follows: ``type.section.name``
 
  * Type is the type of component, where ``lib``, ``pmd``, ``bus`` and ``user``
@@ -837,6 +857,8 @@ A specialization looks like this:
  * Initialization output: ``type.section.name.init``
  * PF/VF mailbox output: ``type.section.name.mbox``
 
+These specializations are created using the ``RTE_LOG_REGISTER_SUFFIX`` macro.
+
 A real world example is the i40e poll mode driver which exposes two
 specializations, one for initialization ``pmd.net.i40e.init`` and the other for
 the remaining driver logs ``pmd.net.i40e.driver``.
lib/cfgfile/rte_cfgfile.c +2 -0
index 9fa7d010ef..eefba6e408 100644
@@ -27,11 +27,13 @@ struct rte_cfgfile {
 	struct rte_cfgfile_section *sections;
 };
 
+/* Setting up dynamic logging 8< */
 RTE_LOG_REGISTER_DEFAULT(cfgfile_logtype, INFO);
 
 #define CFG_LOG(level, fmt, args...)					\
 	rte_log(RTE_LOG_ ## level, cfgfile_logtype, "%s(): " fmt "\n",	\
 		__func__, ## args)
+/* >8 End of setting up dynamic logging */
 
 /** when we resize a file structure, how many extra entries
  * for new sections do we add in */
Signature · 1 line
2.39.2
#27 lore raw

PATCH v4 2/2 doc/contributing: guidelines for logging, tracing and telemetry

In reply to Bruce Richardson

As discussed by DPDK technical board [1], our contributor guide should include some details as to when to use logging vs tracing vs telemetry to provide the end user with information about the running process and the DPDK libraries it uses.

[1] https://mails.dpdk.org/archives/dev/2023-March/265204.html

---
 doc/guides/contributing/coding_style.rst |  2 +
 doc/guides/contributing/design.rst       | 49 ++++++++++++++++++++++++
 doc/guides/prog_guide/telemetry_lib.rst  |  2 +
 doc/guides/prog_guide/trace_lib.rst      |  2 +
 4 files changed, 55 insertions(+)
doc/guides/contributing/coding_style.rst +2 -0
index 383942a601..37e2cc5efb 100644
@@ -794,6 +794,8 @@ Control Statements
                  /* NOTREACHED */
          }
 
+.. _dynamic_logging:
+
 Dynamic Logging
 ---------------
 
doc/guides/contributing/design.rst +49 -0

61 lines not on this page · raw message

doc/guides/prog_guide/telemetry_lib.rst +2 -0
index 32f525a67f..71f8bd735e 100644
@@ -1,6 +1,8 @@
 ..  SPDX-License-Identifier: BSD-3-Clause
     Copyright(c) 2020 Intel Corporation.
 
+.. _telemetry_library:
+
 Telemetry Library
 =================
 
doc/guides/prog_guide/trace_lib.rst +2 -0
index e5718feddc..a3b8a7c2eb 100644
@@ -1,6 +1,8 @@
 ..  SPDX-License-Identifier: BSD-3-Clause
     Copyright(C) 2020 Marvell International Ltd.
 
+.. _trace_library:
+
 Trace Library
 =============
 
Signature · 1 line
2.39.2
#28 lore raw

Re: [PATCH v4 2/2] doc/contributing: guidelines for logging, tracing and telemetry

20/07/2023 13:05, Bruce Richardson:

doc/guides/prog_guide/telemetry_lib.rst line 7

Quoted 10 lines
doc/guides/prog_guide/telemetry_lib.rst +2 -0
@@ -1,6 +1,8 @@
 ..  SPDX-License-Identifier: BSD-3-Clause
     Copyright(c) 2020 Intel Corporation.
 
+.. _telemetry_library:
+
 Telemetry Library
 =================

No need to add such anchor at the beginning of a file. The syntax :doc: can be used to reference such page. I fix it while applying.

Applied, thanks.

Acked-by on the v4 series
#29 lore raw
In reply to Bruce Richardson
Quoted 6 lines · Bruce Richardson

Add details to our documentation on how to register logging for a component. Also provide guidelines on when to use logs vs tracing vs telemetry.

V4: Added note to patch 1 saying not to use the old static logging method

Quoted 9 lines

V3: Moved new doc section on runtime info, and other minor changes flagged
by David on review.

V2: extended second patch based on the feedback provided.

Bruce Richardson (2):
doc/contributing: provide coding details for dynamic logging doc/contributing: guidelines for logging, tracing and telemetry

For series,