Skip to content

Detect superfluous newline in logs

David Marchand dpdk-dev 5 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v5 Latest13 patches 5 repliesIn review
  2. v414 patches 6 repliesSuperseded
  3. v314 patches 1 replySuperseded
Earlier versions · 2
VersionPostedPatchesRepliesStatus
v2 RFC14 patches40 repliesSuperseded
v1 RFC3 patches7 repliesSuperseded

Changes in v5 from the cover letter

- fixed build with -pedantic,
- reworked patch 12 so it introduce new logging helpers (like for rcu),
- moved the transition to RTE_LOG_LINE previously in patch 12 to the last patch of this v5 series,

Patches in v5 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/13hash: remove some dead codelib/hash/rte_cuckoo_hash.h+0 -112 replies
2/13regexdev: fix logtype registerlib/regexdev/rte_regexdev.c+1 -10 replies
3/13lib: use dedicated logtypes and macroslib/cryptodev/rte_cryptodev.c lib/ethdev/ethdev_driver.c lib/ethdev/ethdev_private.c +5 more+17 -170 replies
4/13lib: add newline in logslib/eal/common/eal_common_options.c lib/eal/linux/eal_hugepage_info.c lib/eal/linux/eal_interrupts.c +5 more+31 -310 replies
5/13lib: remove redundant newline from logsdrivers/crypto/ipsec_mb/ipsec_mb_ops.c lib/bbdev/rte_bbdev.c lib/cfgfile/rte_cfgfile.c +24 more+135 -1350 replies
6/13eal/linux: remove log paraphrasing the doclib/eal/linux/eal_timer.c+1 -50 replies
7/13bpf: remove log level in internal helperlib/bpf/bpf_validate.c+5 -50 replies
8/13lib: simplify multilines log messageslib/acl/tb_mem.c lib/bpf/bpf_stub.c lib/eal/windows/eal_hugepages.c +1 more+10 -160 replies
9/13lib: add more logging helperslib/acl/acl_bld.c lib/acl/acl_gen.c lib/acl/acl_log.h +136 more+2435 -23150 replies
10/13vhost: improve log for memory dumping configurationlib/vhost/iotlb.c lib/vhost/vhost.h lib/vhost/vhost_user.c+23 -230 replies
11/13log: add a per line log helperdevtools/checkpatches.sh lib/log/rte_log.h+29 -01 reply
12/13lib: replace logging helperslib/bpf/bpf.c lib/bpf/bpf_convert.c lib/bpf/bpf_exec.c +47 more+1429 -14140 replies
13/13lib: use per line logging in helperslib/acl/acl_log.h lib/bbdev/rte_bbdev.c lib/bpf/bpf_impl.h +47 more+133 -1290 replies

Reviews trailers per patch

12 of 13 patches have a Reviewed-by or Acked-by.

PatchStephen HemmingerTyler RetzlaffOri KamAndrew RybchenkoChengwen FengMattias RönnblomRuifeng Wang
1/13R-b R-b R-b R-b
2/13R-b R-b A-b
3/13R-b R-b R-b
4/13A-b R-b R-b
5/13A-b R-b A-b
6/13A-b A-b
7/13A-b A-b
8/13A-b R-b
9/13
10/13A-b
11/13A-b A-b
12/13R-b
13/13R-b R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 7 reviewers.

Read the v5 thread

Cover letter [PATCH v5 00/13] Detect superfluous newline in logs

Getting readable and consistent logs is important when running a DPDK application, especially when troubleshooting.
A common issue with logs is when a DPDK change do not add (or on the contrary add too many \n) in the format string.

This issue would only get noticed when actually hitting this log (which may be a situation hard to reach).

This series proposes to introduce a new RTE_LOG_LINE helper that is responsible for logging a one line message and spews a build error (with gcc) if any \n is part of the format string.

Since the v1 discussion on the cover letter, I changed my mind, and made the choice to break existing logging helpers exported in the public API. The reasoning is that those should not be used in the first place:
logs should be produced only by the library that registers the logtype.

Some multiline logging for debugging and the test assert macros are still present, but in this case an explicit call to RTE_LOG() is done. This can be checked with a simple:

$ git grep -E 'RTE_LOG(_DP)?\(' -- lib/ :^lib/log/
lib/acl/acl_bld.c:      RTE_LOG(DEBUG, ACL, "Build phase for ACL \"%s\":\n"
lib/acl/acl_gen.c:      RTE_LOG(DEBUG, ACL, "Gen phase for ACL \"%s\":\n"
lib/bpf/bpf_validate.c: RTE_LOG(DEBUG, BPF, "%s(%p) stats:\n"
lib/bpf/bpf_validate.c: RTE_LOG(DEBUG, BPF,
lib/eal/common/eal_common_debug.c:              RTE_LOG(CRIT, EAL, "Error - exiting with code: %d\n"
lib/eal/include/rte_test.h:             RTE_LOG(ERR, EAL, "Test assert %s line %d failed: "           \
lib/ip_frag/ip_frag_common.h:#define    IP_FRAG_LOG(lvl, fmt, args...)  RTE_LOG(lvl, IPFRAG, fmt, ##args)
lib/sched/rte_sched.c:  RTE_LOG(DEBUG, SCHED, "Low level config for pipe profile %u:\n"
lib/sched/rte_sched.c:  RTE_LOG(DEBUG, SCHED, "Low level config for subport profile %u:\n"
lib/vhost/vhost.h:      RTE_LOG_DP(DEBUG, VHOST_DATA, "VHOST_DATA: (%s) %s", dev->ifname, packet); \

Changes since v4:
- fixed build with -pedantic,
- reworked patch 12 so it introduce new logging helpers (like for rcu),
- moved the transition to RTE_LOG_LINE previously in patch 12 to the last patch of this v5 series,

Changes since v3:
- fixed some checkpatch complaints,

Changes since RFC v2:
- sent as non RFC,
- fixed format string crossing line boundaries,
- avoided potential collision with BPF_ namespace,

Changes since RFC v1:
- rebased after Stephen log changes,
- added more fixes as I was making progress on the topic,
- added a check so dpdk developers stop using RTE_LOG(),
- added preparation patches, like "lib: replace logging helpers",
- converted all libraries, keeping some special cases with explicit calls to RTE_LOG,

Signature · 242 lines
David Marchand

David Marchand (13):
  hash: remove some dead code
  regexdev: fix logtype register
  lib: use dedicated logtypes and macros
  lib: add newline in logs
  lib: remove redundant newline from logs
  eal/linux: remove log paraphrasing the doc
  bpf: remove log level in internal helper
  lib: simplify multilines log messages
  lib: add more logging helpers
  vhost: improve log for memory dumping configuration
  log: add a per line log helper
  lib: replace logging helpers
  lib: use per line logging in helpers

 devtools/checkpatches.sh                   |   8 +
 drivers/crypto/ipsec_mb/ipsec_mb_ops.c     |   2 +-
 lib/acl/acl_bld.c                          |  28 +-
 lib/acl/acl_gen.c                          |   8 +-
 lib/acl/acl_log.h                          |   2 +
 lib/acl/rte_acl.c                          |   8 +-
 lib/acl/tb_mem.c                           |   4 +-
 lib/bbdev/rte_bbdev.c                      |  11 +-
 lib/bpf/bpf.c                              |   2 +-
 lib/bpf/bpf_convert.c                      |  16 +-
 lib/bpf/bpf_exec.c                         |  12 +-
 lib/bpf/bpf_impl.h                         |   5 +-
 lib/bpf/bpf_jit_arm64.c                    |   8 +-
 lib/bpf/bpf_jit_x86.c                      |   4 +-
 lib/bpf/bpf_load.c                         |   2 +-
 lib/bpf/bpf_load_elf.c                     |  24 +-
 lib/bpf/bpf_pkt.c                          |   4 +-
 lib/bpf/bpf_stub.c                         |   6 +-
 lib/bpf/bpf_validate.c                     |  44 +-
 lib/cfgfile/rte_cfgfile.c                  |  18 +-
 lib/compressdev/rte_compressdev_internal.h |   5 +-
 lib/compressdev/rte_compressdev_pmd.c      |   4 +-
 lib/cryptodev/rte_cryptodev.c              |   4 +-
 lib/cryptodev/rte_cryptodev.h              |  22 +-
 lib/dispatcher/rte_dispatcher.c            |  12 +-
 lib/dmadev/rte_dmadev.c                    |   8 +-
 lib/eal/common/eal_common_bus.c            |  22 +-
 lib/eal/common/eal_common_class.c          |   6 +-
 lib/eal/common/eal_common_config.c         |   2 +-
 lib/eal/common/eal_common_debug.c          |   8 +-
 lib/eal/common/eal_common_dev.c            |  80 +-
 lib/eal/common/eal_common_devargs.c        |  18 +-
 lib/eal/common/eal_common_dynmem.c         |  34 +-
 lib/eal/common/eal_common_fbarray.c        |  12 +-
 lib/eal/common/eal_common_interrupts.c     |  39 +-
 lib/eal/common/eal_common_lcore.c          |  26 +-
 lib/eal/common/eal_common_memalloc.c       |  12 +-
 lib/eal/common/eal_common_memory.c         |  66 +-
 lib/eal/common/eal_common_memzone.c        |  24 +-
 lib/eal/common/eal_common_options.c        | 236 +++---
 lib/eal/common/eal_common_proc.c           | 112 +--
 lib/eal/common/eal_common_tailqs.c         |  12 +-
 lib/eal/common/eal_common_thread.c         |  12 +-
 lib/eal/common/eal_common_timer.c          |   6 +-
 lib/eal/common/eal_common_trace_utils.c    |   3 +-
 lib/eal/common/eal_private.h               |   4 +
 lib/eal/common/eal_trace.h                 |   4 +-
 lib/eal/common/hotplug_mp.c                |  54 +-
 lib/eal/common/malloc_elem.c               |   6 +-
 lib/eal/common/malloc_heap.c               |  40 +-
 lib/eal/common/malloc_mp.c                 |  72 +-
 lib/eal/common/rte_keepalive.c             |   4 +-
 lib/eal/common/rte_malloc.c                |  10 +-
 lib/eal/common/rte_service.c               |   8 +-
 lib/eal/freebsd/eal.c                      |  75 +-
 lib/eal/freebsd/eal_alarm.c                |   2 +-
 lib/eal/freebsd/eal_dev.c                  |  10 +-
 lib/eal/freebsd/eal_hugepage_info.c        |  22 +-
 lib/eal/freebsd/eal_interrupts.c           |  60 +-
 lib/eal/freebsd/eal_lcore.c                |   2 +-
 lib/eal/freebsd/eal_memalloc.c             |  11 +-
 lib/eal/freebsd/eal_memory.c               |  34 +-
 lib/eal/freebsd/eal_thread.c               |   2 +-
 lib/eal/freebsd/eal_timer.c                |  10 +-
 lib/eal/linux/eal.c                        | 122 +--
 lib/eal/linux/eal_alarm.c                  |   2 +-
 lib/eal/linux/eal_dev.c                    |  40 +-
 lib/eal/linux/eal_hugepage_info.c          |  38 +-
 lib/eal/linux/eal_interrupts.c             | 116 +--
 lib/eal/linux/eal_lcore.c                  |   4 +-
 lib/eal/linux/eal_memalloc.c               | 120 +--
 lib/eal/linux/eal_memory.c                 | 208 ++---
 lib/eal/linux/eal_thread.c                 |   6 +-
 lib/eal/linux/eal_timer.c                  |  14 +-
 lib/eal/linux/eal_vfio.c                   | 270 +++----
 lib/eal/linux/eal_vfio_mp_sync.c           |   5 +-
 lib/eal/riscv/rte_cycles.c                 |   4 +-
 lib/eal/unix/eal_filesystem.c              |  14 +-
 lib/eal/unix/eal_firmware.c                |   3 +-
 lib/eal/unix/eal_unix_memory.c             |   8 +-
 lib/eal/unix/rte_thread.c                  |  36 +-
 lib/eal/windows/eal.c                      |  36 +-
 lib/eal/windows/eal_alarm.c                |  13 +-
 lib/eal/windows/eal_debug.c                |  10 +-
 lib/eal/windows/eal_dev.c                  |  10 +-
 lib/eal/windows/eal_hugepages.c            |  10 +-
 lib/eal/windows/eal_interrupts.c           |  10 +-
 lib/eal/windows/eal_lcore.c                |   7 +-
 lib/eal/windows/eal_memalloc.c             |  50 +-
 lib/eal/windows/eal_memory.c               |  22 +-
 lib/eal/windows/eal_windows.h              |   6 +-
 lib/eal/windows/include/rte_windows.h      |   6 +-
 lib/eal/windows/rte_thread.c               |  29 +-
 lib/efd/rte_efd.c                          |  60 +-
 lib/ethdev/ethdev_driver.c                 |  44 +-
 lib/ethdev/ethdev_pci.h                    |   2 +-
 lib/ethdev/ethdev_private.c                |  10 +-
 lib/ethdev/rte_class_eth.c                 |   2 +-
 lib/ethdev/rte_ethdev.c                    | 854 ++++++++++-----------
 lib/ethdev/rte_ethdev.h                    |  51 +-
 lib/ethdev/rte_ethdev_cman.c               |  16 +-
 lib/ethdev/rte_ethdev_telemetry.c          |  44 +-
 lib/ethdev/rte_flow.c                      |  64 +-
 lib/ethdev/rte_flow.h                      |   3 -
 lib/ethdev/sff_telemetry.c                 |  30 +-
 lib/eventdev/eventdev_pmd.h                |  18 +-
 lib/eventdev/rte_event_crypto_adapter.c    |  12 +-
 lib/eventdev/rte_event_dma_adapter.c       |  18 +-
 lib/eventdev/rte_event_eth_rx_adapter.c    |  40 +-
 lib/eventdev/rte_event_eth_tx_adapter.c    |   2 +-
 lib/eventdev/rte_event_timer_adapter.c     |  21 +-
 lib/eventdev/rte_eventdev.c                |  10 +-
 lib/fib/fib_log.h                          |   4 +-
 lib/fib/rte_fib.c                          |  14 +-
 lib/fib/rte_fib6.c                         |  14 +-
 lib/gpudev/gpudev.c                        |   6 +-
 lib/graph/graph_private.h                  |   7 +-
 lib/hash/rte_cuckoo_hash.c                 |  54 +-
 lib/hash/rte_cuckoo_hash.h                 |  11 -
 lib/hash/rte_fbk_hash.c                    |   6 +-
 lib/hash/rte_hash_crc.c                    |  14 +-
 lib/hash/rte_thash.c                       |  22 +-
 lib/hash/rte_thash_gfni.c                  |  10 +-
 lib/ip_frag/ip_frag_common.h               |   3 +
 lib/ip_frag/rte_ip_frag_common.c           |   8 +-
 lib/latencystats/rte_latencystats.c        |  43 +-
 lib/log/rte_log.h                          |  21 +
 lib/lpm/lpm_log.h                          |   2 +
 lib/lpm/rte_lpm.c                          |  12 +-
 lib/lpm/rte_lpm6.c                         |  10 +-
 lib/mbuf/mbuf_log.h                        |   2 +
 lib/mbuf/rte_mbuf.c                        |  14 +-
 lib/mbuf/rte_mbuf_dyn.c                    |  14 +-
 lib/mbuf/rte_mbuf_pool_ops.c               |   4 +-
 lib/member/member.h                        |  14 +
 lib/member/rte_member.c                    |  15 +-
 lib/member/rte_member.h                    |   9 -
 lib/member/rte_member_heap.h               |  39 +-
 lib/member/rte_member_ht.c                 |  13 +-
 lib/member/rte_member_sketch.c             |  41 +-
 lib/member/rte_member_vbf.c                |   9 +-
 lib/mempool/rte_mempool.c                  |  24 +-
 lib/mempool/rte_mempool.h                  |   4 +-
 lib/mempool/rte_mempool_ops.c              |  10 +-
 lib/metrics/rte_metrics_telemetry.c        |   6 +-
 lib/mldev/rte_mldev.c                      | 102 +--
 lib/mldev/rte_mldev.h                      |   5 +-
 lib/net/rte_net_crc.c                      |  14 +-
 lib/node/ethdev_rx.c                       |   4 +-
 lib/node/ip4_lookup.c                      |   2 +-
 lib/node/ip6_lookup.c                      |   2 +-
 lib/node/kernel_rx.c                       |   8 +-
 lib/node/kernel_tx.c                       |   4 +-
 lib/node/node_private.h                    |   8 +-
 lib/pdump/rte_pdump.c                      | 113 ++-
 lib/pipeline/rte_pipeline.c                | 231 +++---
 lib/port/port_log.h                        |   9 +
 lib/port/rte_port_ethdev.c                 |  20 +-
 lib/port/rte_port_eventdev.c               |  20 +-
 lib/port/rte_port_fd.c                     |  26 +-
 lib/port/rte_port_frag.c                   |  16 +-
 lib/port/rte_port_ras.c                    |  14 +-
 lib/port/rte_port_ring.c                   |  20 +-
 lib/port/rte_port_sched.c                  |  14 +-
 lib/port/rte_port_source_sink.c            |  50 +-
 lib/port/rte_port_sym_crypto.c             |  20 +-
 lib/power/guest_channel.c                  |  38 +-
 lib/power/power_acpi_cpufreq.c             | 116 +--
 lib/power/power_amd_pstate_cpufreq.c       | 132 ++--
 lib/power/power_common.c                   |  14 +-
 lib/power/power_common.h                   |  10 +-
 lib/power/power_cppc_cpufreq.c             | 130 ++--
 lib/power/power_intel_uncore.c             |  72 +-
 lib/power/power_kvm_vm.c                   |  22 +-
 lib/power/power_pstate_cpufreq.c           | 156 ++--
 lib/power/rte_power.c                      |  22 +-
 lib/power/rte_power_pmd_mgmt.c             |  34 +-
 lib/power/rte_power_uncore.c               |  14 +-
 lib/rawdev/rte_rawdev_pmd.h                |   4 +-
 lib/rcu/rte_rcu_qsbr.c                     |  66 +-
 lib/rcu/rte_rcu_qsbr.h                     |  17 +-
 lib/regexdev/rte_regexdev.c                |  88 +--
 lib/regexdev/rte_regexdev.h                |  13 +-
 lib/reorder/rte_reorder.c                  |  34 +-
 lib/rib/rib_log.h                          |   6 +-
 lib/rib/rte_rib.c                          |  13 +-
 lib/rib/rte_rib6.c                         |  10 +-
 lib/ring/rte_ring.c                        |  26 +-
 lib/sched/rte_pie.c                        |  18 +-
 lib/sched/rte_sched.c                      | 274 +++----
 lib/sched/rte_sched_log.h                  |   2 +
 lib/stack/rte_stack.c                      |   8 +-
 lib/stack/stack_pvt.h                      |   4 +-
 lib/table/rte_table_acl.c                  |  74 +-
 lib/table/rte_table_array.c                |  18 +-
 lib/table/rte_table_hash_cuckoo.c          |  24 +-
 lib/table/rte_table_hash_ext.c             |  24 +-
 lib/table/rte_table_hash_key16.c           |  40 +-
 lib/table/rte_table_hash_key32.c           |  40 +-
 lib/table/rte_table_hash_key8.c            |  40 +-
 lib/table/rte_table_hash_lru.c             |  24 +-
 lib/table/rte_table_lpm.c                  |  44 +-
 lib/table/rte_table_lpm_ipv6.c             |  46 +-
 lib/table/rte_table_stub.c                 |   6 +-
 lib/table/table_log.h                      |   9 +
 lib/telemetry/telemetry.c                  |  39 +-
 lib/vhost/fd_man.c                         |  10 +-
 lib/vhost/iotlb.c                          |  36 +-
 lib/vhost/socket.c                         | 102 +--
 lib/vhost/vdpa.c                           |   8 +-
 lib/vhost/vduse.c                          | 120 +--
 lib/vhost/vduse.h                          |   4 +-
 lib/vhost/vhost.c                          | 118 +--
 lib/vhost/vhost.h                          |  24 +-
 lib/vhost/vhost_crypto.c                   |  12 +-
 lib/vhost/vhost_user.c                     | 530 ++++++-------
 lib/vhost/virtio_net.c                     | 188 ++---
 lib/vhost/virtio_net_ctrl.c                |  38 +-
 218 files changed, 4120 insertions(+), 3973 deletions(-)
 create mode 100644 lib/member/member.h
 create mode 100644 lib/port/port_log.h
 create mode 100644 lib/table/table_log.h

-- 
2.43.0