From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 8253445DE3; Fri, 6 Dec 2024 20:30:35 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id D5CFA40E4D; Fri, 6 Dec 2024 20:30:27 +0100 (CET) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id CB1584064F for ; Fri, 6 Dec 2024 20:30:22 +0100 (CET) Received: by linux.microsoft.com (Postfix, from userid 1213) id CCEA820ACD7B; Fri, 6 Dec 2024 11:30:21 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com CCEA820ACD7B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1733513421; bh=YvvUc7cpmK+OOLh42eWszWzfbGyMkkY/bvTT14M0GWQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PyvxvxWpXf/jpqddcIwJdQayzeoCfNX5a7Phy3s7jjsyJQxaB8AAn/ooLPlwW5r79 Wb1l93rXM5Pm0BPtaKMnFVAZY2p4rSfySssRfN6bQmxfdvCX2XdSG5xXYba98sNkKM tnY/uI7y/+gy8V0nv4Dko/C5atdbXDFBtcf5WYn8= From: Andre Muezerie To: Chengwen Feng , Kevin Laatz , Bruce Richardson Cc: dev@dpdk.org, Andre Muezerie Subject: [PATCH 1/2] lib/dmadev: eliminate undefined behavior Date: Fri, 6 Dec 2024 11:27:52 -0800 Message-Id: <1733513273-25550-2-git-send-email-andremue@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1733513273-25550-1-git-send-email-andremue@linux.microsoft.com> References: <1733513273-25550-1-git-send-email-andremue@linux.microsoft.com> X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org MSVC compiler issues warnings like the one below: lib\dmadev\rte_dmadev_trace_fp.h(36): warning C5101: use of preprocessor directive in function-like macro argument list is undefined behavior Indeed, looking at C99 section 6.10.3 Macro replacement, paragraph 11: "If there are sequences of preprocessing tokens within the list of arguments that would otherwise act as preprocessing directives, the behavior is undefined." The fix proposed in this patch moves the ifdef to the outside. This results in no perf impact, but some lines end up being duplicated, which seems to be a reasonable trade-off. Signed-off-by: Andre Muezerie --- lib/dmadev/rte_dmadev_trace.h | 62 ++++++++++++++++++++++++++++---- lib/dmadev/rte_dmadev_trace_fp.h | 52 +++++++++++++++++++++++---- 2 files changed, 102 insertions(+), 12 deletions(-) diff --git a/lib/dmadev/rte_dmadev_trace.h b/lib/dmadev/rte_dmadev_trace.h index be089c065c..264a464928 100644 --- a/lib/dmadev/rte_dmadev_trace.h +++ b/lib/dmadev/rte_dmadev_trace.h @@ -19,13 +19,12 @@ extern "C" { #endif +#ifdef _RTE_TRACE_POINT_REGISTER_H_ RTE_TRACE_POINT( rte_dma_trace_info_get, RTE_TRACE_POINT_ARGS(int16_t dev_id, struct rte_dma_info *dev_info), -#ifdef _RTE_TRACE_POINT_REGISTER_H_ struct rte_dma_info __dev_info = {0}; dev_info = &__dev_info; -#endif /* _RTE_TRACE_POINT_REGISTER_H_ */ rte_trace_point_emit_i16(dev_id); rte_trace_point_emit_string(dev_info->dev_name); rte_trace_point_emit_u64(dev_info->dev_capa); @@ -37,15 +36,30 @@ RTE_TRACE_POINT( rte_trace_point_emit_u16(dev_info->nb_vchans); rte_trace_point_emit_u16(dev_info->nb_priorities); ) +#else +RTE_TRACE_POINT( + rte_dma_trace_info_get, + RTE_TRACE_POINT_ARGS(int16_t dev_id, struct rte_dma_info *dev_info), + rte_trace_point_emit_i16(dev_id); + rte_trace_point_emit_string(dev_info->dev_name); + rte_trace_point_emit_u64(dev_info->dev_capa); + rte_trace_point_emit_u16(dev_info->max_vchans); + rte_trace_point_emit_u16(dev_info->max_desc); + rte_trace_point_emit_u16(dev_info->min_desc); + rte_trace_point_emit_u16(dev_info->max_sges); + rte_trace_point_emit_i16(dev_info->numa_node); + rte_trace_point_emit_u16(dev_info->nb_vchans); + rte_trace_point_emit_u16(dev_info->nb_priorities); +) +#endif /* _RTE_TRACE_POINT_REGISTER_H_ */ +#ifdef _RTE_TRACE_POINT_REGISTER_H_ RTE_TRACE_POINT( rte_dma_trace_configure, RTE_TRACE_POINT_ARGS(int16_t dev_id, const struct rte_dma_conf *dev_conf, int ret), -#ifdef _RTE_TRACE_POINT_REGISTER_H_ const struct rte_dma_conf __dev_conf = {0}; dev_conf = &__dev_conf; -#endif /* _RTE_TRACE_POINT_REGISTER_H_ */ int enable_silent = (int)dev_conf->enable_silent; rte_trace_point_emit_i16(dev_id); rte_trace_point_emit_u16(dev_conf->nb_vchans); @@ -53,6 +67,19 @@ RTE_TRACE_POINT( rte_trace_point_emit_int(enable_silent); rte_trace_point_emit_int(ret); ) +#else +RTE_TRACE_POINT( + rte_dma_trace_configure, + RTE_TRACE_POINT_ARGS(int16_t dev_id, const struct rte_dma_conf *dev_conf, + int ret), + int enable_silent = (int)dev_conf->enable_silent; + rte_trace_point_emit_i16(dev_id); + rte_trace_point_emit_u16(dev_conf->nb_vchans); + rte_trace_point_emit_u16(dev_conf->priority); + rte_trace_point_emit_int(enable_silent); + rte_trace_point_emit_int(ret); +) +#endif /* _RTE_TRACE_POINT_REGISTER_H_ */ RTE_TRACE_POINT( rte_dma_trace_start, @@ -75,14 +102,13 @@ RTE_TRACE_POINT( rte_trace_point_emit_int(ret); ) +#ifdef _RTE_TRACE_POINT_REGISTER_H_ RTE_TRACE_POINT( rte_dma_trace_vchan_setup, RTE_TRACE_POINT_ARGS(int16_t dev_id, uint16_t vchan, const struct rte_dma_vchan_conf *conf, int ret), -#ifdef _RTE_TRACE_POINT_REGISTER_H_ const struct rte_dma_vchan_conf __conf = {0}; conf = &__conf; -#endif /* _RTE_TRACE_POINT_REGISTER_H_ */ int src_port_type = conf->src_port.port_type; int dst_port_type = conf->dst_port.port_type; int direction = conf->direction; @@ -101,6 +127,30 @@ RTE_TRACE_POINT( rte_trace_point_emit_ptr(conf->auto_free.m2d.pool); rte_trace_point_emit_int(ret); ) +#else +RTE_TRACE_POINT( + rte_dma_trace_vchan_setup, + RTE_TRACE_POINT_ARGS(int16_t dev_id, uint16_t vchan, + const struct rte_dma_vchan_conf *conf, int ret), + int src_port_type = conf->src_port.port_type; + int dst_port_type = conf->dst_port.port_type; + int direction = conf->direction; + uint64_t src_pcie_cfg; + uint64_t dst_pcie_cfg; + rte_trace_point_emit_i16(dev_id); + rte_trace_point_emit_u16(vchan); + rte_trace_point_emit_int(direction); + rte_trace_point_emit_u16(conf->nb_desc); + rte_trace_point_emit_int(src_port_type); + memcpy(&src_pcie_cfg, &conf->src_port.pcie, sizeof(uint64_t)); + rte_trace_point_emit_u64(src_pcie_cfg); + memcpy(&dst_pcie_cfg, &conf->dst_port.pcie, sizeof(uint64_t)); + rte_trace_point_emit_int(dst_port_type); + rte_trace_point_emit_u64(dst_pcie_cfg); + rte_trace_point_emit_ptr(conf->auto_free.m2d.pool); + rte_trace_point_emit_int(ret); +) +#endif /* _RTE_TRACE_POINT_REGISTER_H_ */ RTE_TRACE_POINT( rte_dma_trace_stats_reset, diff --git a/lib/dmadev/rte_dmadev_trace_fp.h b/lib/dmadev/rte_dmadev_trace_fp.h index f5b96838bc..0f26f71c80 100644 --- a/lib/dmadev/rte_dmadev_trace_fp.h +++ b/lib/dmadev/rte_dmadev_trace_fp.h @@ -29,20 +29,31 @@ RTE_TRACE_POINT_FP( rte_trace_point_emit_int(ret); ) +#ifdef _RTE_TRACE_POINT_REGISTER_H_ RTE_TRACE_POINT_FP( rte_dma_trace_vchan_status, RTE_TRACE_POINT_ARGS(int16_t dev_id, uint16_t vchan, enum rte_dma_vchan_status *status, int ret), -#ifdef _RTE_TRACE_POINT_REGISTER_H_ enum rte_dma_vchan_status __status = 0; status = &__status; -#endif /* _RTE_TRACE_POINT_REGISTER_H_ */ int vchan_status = *status; rte_trace_point_emit_i16(dev_id); rte_trace_point_emit_u16(vchan); rte_trace_point_emit_int(vchan_status); rte_trace_point_emit_int(ret); ) +#else +RTE_TRACE_POINT_FP( + rte_dma_trace_vchan_status, + RTE_TRACE_POINT_ARGS(int16_t dev_id, uint16_t vchan, + enum rte_dma_vchan_status *status, int ret), + int vchan_status = *status; + rte_trace_point_emit_i16(dev_id); + rte_trace_point_emit_u16(vchan); + rte_trace_point_emit_int(vchan_status); + rte_trace_point_emit_int(ret); +) +#endif /* _RTE_TRACE_POINT_REGISTER_H_ */ RTE_TRACE_POINT_FP( rte_dma_trace_copy, @@ -96,17 +107,16 @@ RTE_TRACE_POINT_FP( rte_trace_point_emit_int(ret); ) +#ifdef _RTE_TRACE_POINT_REGISTER_H_ RTE_TRACE_POINT_FP( rte_dma_trace_completed, RTE_TRACE_POINT_ARGS(int16_t dev_id, uint16_t vchan, const uint16_t nb_cpls, uint16_t *last_idx, bool *has_error, uint16_t ret), -#ifdef _RTE_TRACE_POINT_REGISTER_H_ uint16_t __last_idx = 0; bool __has_error = false; last_idx = &__last_idx; has_error = &__has_error; -#endif /* _RTE_TRACE_POINT_REGISTER_H_ */ int has_error_val = *has_error; int last_idx_val = *last_idx; rte_trace_point_emit_i16(dev_id); @@ -116,16 +126,31 @@ RTE_TRACE_POINT_FP( rte_trace_point_emit_int(has_error_val); rte_trace_point_emit_u16(ret); ) +#else +RTE_TRACE_POINT_FP( + rte_dma_trace_completed, + RTE_TRACE_POINT_ARGS(int16_t dev_id, uint16_t vchan, + const uint16_t nb_cpls, uint16_t *last_idx, + bool *has_error, uint16_t ret), + int has_error_val = *has_error; + int last_idx_val = *last_idx; + rte_trace_point_emit_i16(dev_id); + rte_trace_point_emit_u16(vchan); + rte_trace_point_emit_u16(nb_cpls); + rte_trace_point_emit_int(last_idx_val); + rte_trace_point_emit_int(has_error_val); + rte_trace_point_emit_u16(ret); +) +#endif /* _RTE_TRACE_POINT_REGISTER_H_ */ +#ifdef _RTE_TRACE_POINT_REGISTER_H_ RTE_TRACE_POINT_FP( rte_dma_trace_completed_status, RTE_TRACE_POINT_ARGS(int16_t dev_id, uint16_t vchan, const uint16_t nb_cpls, uint16_t *last_idx, enum rte_dma_status_code *status, uint16_t ret), -#ifdef _RTE_TRACE_POINT_REGISTER_H_ uint16_t __last_idx = 0; last_idx = &__last_idx; -#endif /* _RTE_TRACE_POINT_REGISTER_H_ */ int last_idx_val = *last_idx; rte_trace_point_emit_i16(dev_id); rte_trace_point_emit_u16(vchan); @@ -134,6 +159,21 @@ RTE_TRACE_POINT_FP( rte_trace_point_emit_ptr(status); rte_trace_point_emit_u16(ret); ) +#else +RTE_TRACE_POINT_FP( + rte_dma_trace_completed_status, + RTE_TRACE_POINT_ARGS(int16_t dev_id, uint16_t vchan, + const uint16_t nb_cpls, uint16_t *last_idx, + enum rte_dma_status_code *status, uint16_t ret), + int last_idx_val = *last_idx; + rte_trace_point_emit_i16(dev_id); + rte_trace_point_emit_u16(vchan); + rte_trace_point_emit_u16(nb_cpls); + rte_trace_point_emit_int(last_idx_val); + rte_trace_point_emit_ptr(status); + rte_trace_point_emit_u16(ret); +) +#endif /* _RTE_TRACE_POINT_REGISTER_H_ */ RTE_TRACE_POINT_FP( rte_dma_trace_burst_capacity, -- 2.47.0.vfs.0.3