vhost: use dynamic log type
diff mbox series

Message ID 20191112214709.30953-1-stephen@networkplumber.org
State Rejected, archived
Delegated to: Maxime Coquelin
Headers show
Series
  • vhost: use dynamic log type
Related show

Checks

Context Check Description
ci/Intel-compilation success Compilation OK
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-compilation success Compile Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/checkpatch success coding style OK

Commit Message

Stephen Hemminger Nov. 12, 2019, 9:47 p.m. UTC
Rather than overloading USER1 and USER2 logtypes,
use a DPDK dynamic log type.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/librte_vhost/vhost.c | 12 ++++++++++++
 lib/librte_vhost/vhost.h |  5 +++--
 2 files changed, 15 insertions(+), 2 deletions(-)

Comments

Maxime Coquelin Jan. 9, 2020, 2:44 p.m. UTC | #1
Hi Stephen,

On 11/12/19 10:47 PM, Stephen Hemminger wrote:
> Rather than overloading USER1 and USER2 logtypes,
> use a DPDK dynamic log type.
> 
> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
> ---
>  lib/librte_vhost/vhost.c | 12 ++++++++++++
>  lib/librte_vhost/vhost.h |  5 +++--
>  2 files changed, 15 insertions(+), 2 deletions(-)
> 
> diff --git a/lib/librte_vhost/vhost.c b/lib/librte_vhost/vhost.c
> index 1cbe948f7470..9149770a16f5 100644
> --- a/lib/librte_vhost/vhost.c
> +++ b/lib/librte_vhost/vhost.c
> @@ -27,6 +27,8 @@
>  
>  struct virtio_net *vhost_devices[MAX_VHOST_DEVICE];
>  
> +int vhost_logtype_config, vhost_logtype_data;
> +
>  /* Called with iotlb_lock read-locked */
>  uint64_t
>  __vhost_iova_to_vva(struct virtio_net *dev, struct vhost_virtqueue *vq,
> @@ -1457,3 +1459,13 @@ int rte_vhost_extern_callback_register(int vid,
>  	dev->extern_data = ctx;
>  	return 0;
>  }
> +
> +RTE_INIT(rte_vhost_init_log)
> +{
> +	vhost_logtype_config = rte_log_register("lib.vhost.config");
> +	if (vhost_logtype_config >= 0)
> +		rte_log_set_level(vhost_logtype_config, RTE_LOG_NOTICE);
> +	vhost_logtype_data = rte_log_register("lib.vhost.data");
> +	if (vhost_logtype_data >= 0)
> +		rte_log_set_level(vhost_logtype_data, RTE_LOG_NOTICE);
> +}
> diff --git a/lib/librte_vhost/vhost.h b/lib/librte_vhost/vhost.h
> index 9f11b28a31bf..87ce24991c26 100644
> --- a/lib/librte_vhost/vhost.h
> +++ b/lib/librte_vhost/vhost.h
> @@ -499,8 +499,9 @@ vhost_log_write_iova(struct virtio_net *dev, struct vhost_virtqueue *vq,
>  }
>  
>  /* Macros for printing using RTE_LOG */
> -#define RTE_LOGTYPE_VHOST_CONFIG RTE_LOGTYPE_USER1
> -#define RTE_LOGTYPE_VHOST_DATA   RTE_LOGTYPE_USER1
> +extern int vhost_logtype_config, vhost_logtype_data;
> +#define RTE_LOGTYPE_VHOST_CONFIG vhost_logtype_config
> +#define RTE_LOGTYPE_VHOST_DATA   vhost_logtype_data
>  
>  #ifdef RTE_LIBRTE_VHOST_DEBUG
>  #define VHOST_MAX_PRINT_BUFF 6072
> 

Adrian posted an alternative patch before you to support dynamic
logging. Moreover, Adrian patch makes the data path logs to be compiled
out by default, which is better from performance point of view.

This is last version of Adrian's patch:
http://patches.dpdk.org/patch/63565/

I propose to drop your patch and pick Adrian's instead.

Thanks,
Maxime

Patch
diff mbox series

diff --git a/lib/librte_vhost/vhost.c b/lib/librte_vhost/vhost.c
index 1cbe948f7470..9149770a16f5 100644
--- a/lib/librte_vhost/vhost.c
+++ b/lib/librte_vhost/vhost.c
@@ -27,6 +27,8 @@ 
 
 struct virtio_net *vhost_devices[MAX_VHOST_DEVICE];
 
+int vhost_logtype_config, vhost_logtype_data;
+
 /* Called with iotlb_lock read-locked */
 uint64_t
 __vhost_iova_to_vva(struct virtio_net *dev, struct vhost_virtqueue *vq,
@@ -1457,3 +1459,13 @@  int rte_vhost_extern_callback_register(int vid,
 	dev->extern_data = ctx;
 	return 0;
 }
+
+RTE_INIT(rte_vhost_init_log)
+{
+	vhost_logtype_config = rte_log_register("lib.vhost.config");
+	if (vhost_logtype_config >= 0)
+		rte_log_set_level(vhost_logtype_config, RTE_LOG_NOTICE);
+	vhost_logtype_data = rte_log_register("lib.vhost.data");
+	if (vhost_logtype_data >= 0)
+		rte_log_set_level(vhost_logtype_data, RTE_LOG_NOTICE);
+}
diff --git a/lib/librte_vhost/vhost.h b/lib/librte_vhost/vhost.h
index 9f11b28a31bf..87ce24991c26 100644
--- a/lib/librte_vhost/vhost.h
+++ b/lib/librte_vhost/vhost.h
@@ -499,8 +499,9 @@  vhost_log_write_iova(struct virtio_net *dev, struct vhost_virtqueue *vq,
 }
 
 /* Macros for printing using RTE_LOG */
-#define RTE_LOGTYPE_VHOST_CONFIG RTE_LOGTYPE_USER1
-#define RTE_LOGTYPE_VHOST_DATA   RTE_LOGTYPE_USER1
+extern int vhost_logtype_config, vhost_logtype_data;
+#define RTE_LOGTYPE_VHOST_CONFIG vhost_logtype_config
+#define RTE_LOGTYPE_VHOST_DATA   vhost_logtype_data
 
 #ifdef RTE_LIBRTE_VHOST_DEBUG
 #define VHOST_MAX_PRINT_BUFF 6072