diff mbox

[net-next,1/1] hv_netvsc: call dump_rndis_message() only in netvsc debug mode

Message ID 1429657085-23379-1-git-send-email-sixiao@microsoft.com
State Changes Requested, archived
Delegated to: David Miller
Headers show

Commit Message

Simon Xiao April 21, 2015, 10:58 p.m. UTC
From: Simon Xiao <sixiao@microsoft.com>

Signed-off-by: Simon Xiao <sixiao@microsoft.com>
Reviewed-by: K. Y. Srinivasan <kys@microsoft.com>
Reviewed-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/net/hyperv/hyperv_net.h   | 3 +++
 drivers/net/hyperv/netvsc_drv.c   | 8 ++++++++
 drivers/net/hyperv/rndis_filter.c | 3 ++-
 3 files changed, 13 insertions(+), 1 deletion(-)

Comments

David Miller April 21, 2015, 9:48 p.m. UTC | #1
From: sixiao@microsoft.com
Date: Tue, 21 Apr 2015 15:58:05 -0700

> From: Simon Xiao <sixiao@microsoft.com>
> 
> Signed-off-by: Simon Xiao <sixiao@microsoft.com>
> Reviewed-by: K. Y. Srinivasan <kys@microsoft.com>
> Reviewed-by: Haiyang Zhang <haiyangz@microsoft.com>

I just gave you feedback on this patch in response to your
original submission, do not ignore it.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Simon Xiao April 21, 2015, 10:14 p.m. UTC | #2
> -----Original Message-----
> From: David Miller [mailto:davem@davemloft.net]
> Sent: Tuesday, April 21, 2015 2:49 PM
> To: Simon Xiao
> Cc: KY Srinivasan; Haiyang Zhang; devel@linuxdriverproject.org;
> netdev@vger.kernel.org; linux-kernel@vger.kernel.org
> Subject: Re: [PATCH net-next,1/1] hv_netvsc: call dump_rndis_message() only in
> netvsc debug mode
> 
> From: sixiao@microsoft.com
> Date: Tue, 21 Apr 2015 15:58:05 -0700
> 
> > From: Simon Xiao <sixiao@microsoft.com>
> >
> > Signed-off-by: Simon Xiao <sixiao@microsoft.com>
> > Reviewed-by: K. Y. Srinivasan <kys@microsoft.com>
> > Reviewed-by: Haiyang Zhang <haiyangz@microsoft.com>
> 
> I just gave you feedback on this patch in response to your original submission,
> do not ignore it.

Thanks for your feedback, David.

In current netvsc driver, for each packet received, it will call dump_rndis_message() 
to try to dump the rndis packet information by netdev_dbg(). 
In non-debug mode, dump_rndis_message() will not dump anything 
but it still initialize some local variables and process the switch logic in the function 
of dump_rndis_message(), which is unnecessary, especially in high network throughput situation.

My change is to have a run-time config flag to control the execution of dump_rndis_message() 
and avoid above unnecessary cost in non-debug mode.
In the default case, it will be non-debug mode,
 and rndis_filter_receive() will not call dump_rndis_message() 
which saves the above extra cost for each packet received.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
David Miller April 22, 2015, 12:30 a.m. UTC | #3
From: Simon Xiao <sixiao@microsoft.com>
Date: Tue, 21 Apr 2015 22:14:14 +0000

> In current netvsc driver, for each packet received, it will call
> dump_rndis_message() to try to dump the rndis packet information by
> netdev_dbg().  In non-debug mode, dump_rndis_message() will not dump
> anything but it still initialize some local variables and process
> the switch logic in the function of dump_rndis_message(), which is
> unnecessary, especially in high network throughput situation.

See NETIF_MSG_* and use it properly in your driver, read other drivers
and learn how to properly use it for things like this.

I'm not going to explain this a third time.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Vitaly Kuznetsov April 22, 2015, 8:52 a.m. UTC | #4
sixiao@microsoft.com writes:

> From: Simon Xiao <sixiao@microsoft.com>
>
> Signed-off-by: Simon Xiao <sixiao@microsoft.com>
> Reviewed-by: K. Y. Srinivasan <kys@microsoft.com>
> Reviewed-by: Haiyang Zhang <haiyangz@microsoft.com>

I don't quite understand what problem is being solved here (and empty
commit message doesn't is not very helpful).

netdev_dbg() is not being printed by default and in case if floods logs
with too many messages you can change it to net_dbg_ratelimited(). We
already have dynamic debug and adding another module parameter shouldn't
be needed...

> ---
>  drivers/net/hyperv/hyperv_net.h   | 3 +++
>  drivers/net/hyperv/netvsc_drv.c   | 8 ++++++++
>  drivers/net/hyperv/rndis_filter.c | 3 ++-
>  3 files changed, 13 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/net/hyperv/hyperv_net.h b/drivers/net/hyperv/hyperv_net.h
> index a10b316..c9be35e 100644
> --- a/drivers/net/hyperv/hyperv_net.h
> +++ b/drivers/net/hyperv/hyperv_net.h
> @@ -28,6 +28,9 @@
>  #include <linux/hyperv.h>
>  #include <linux/rndis.h>
>
> +/* flag for netvsc debug mode */
> +extern int debug_mode;
> +
>  /* RSS related */
>  #define OID_GEN_RECEIVE_SCALE_CAPABILITIES 0x00010203  /* query only */
>  #define OID_GEN_RECEIVE_SCALE_PARAMETERS 0x00010204  /* query and set */
> diff --git a/drivers/net/hyperv/netvsc_drv.c b/drivers/net/hyperv/netvsc_drv.c
> index a3a9d38..7c41864 100644
> --- a/drivers/net/hyperv/netvsc_drv.c
> +++ b/drivers/net/hyperv/netvsc_drv.c
> @@ -52,6 +52,10 @@ static int ring_size = 128;
>  module_param(ring_size, int, S_IRUGO);
>  MODULE_PARM_DESC(ring_size, "Ring buffer size (# of pages)");
>
> +int debug_mode = 0;
> +module_param(debug_mode, int, S_IRUGO);
> +MODULE_PARM_DESC(debug_mode, "debug mode: zero(0) for non-debug mode; non-zero for debug mode");
> +
>  static void do_set_multicast(struct work_struct *w)
>  {
>  	struct net_device_context *ndevctx =
> @@ -999,6 +1003,10 @@ static int __init netvsc_drv_init(void)
>  		pr_info("Increased ring_size to %d (min allowed)\n",
>  			ring_size);
>  	}
> +
> +	if (debug_mode != 0)
> +		pr_info("Run netvsc in debug mode");
> +
>  	return vmbus_driver_register(&netvsc_drv);
>  }
>
> diff --git a/drivers/net/hyperv/rndis_filter.c b/drivers/net/hyperv/rndis_filter.c
> index 0d92efe..a3f43f6 100644
> --- a/drivers/net/hyperv/rndis_filter.c
> +++ b/drivers/net/hyperv/rndis_filter.c
> @@ -429,7 +429,8 @@ int rndis_filter_receive(struct hv_device *dev,
>
>  	rndis_msg = pkt->data;
>
> -	dump_rndis_message(dev, rndis_msg);
> +	if (debug_mode != 0)
> +		dump_rndis_message(dev, rndis_msg);
>
>  	switch (rndis_msg->ndis_msg_type) {
>  	case RNDIS_MSG_PACKET:
diff mbox

Patch

diff --git a/drivers/net/hyperv/hyperv_net.h b/drivers/net/hyperv/hyperv_net.h
index a10b316..c9be35e 100644
--- a/drivers/net/hyperv/hyperv_net.h
+++ b/drivers/net/hyperv/hyperv_net.h
@@ -28,6 +28,9 @@ 
 #include <linux/hyperv.h>
 #include <linux/rndis.h>
 
+/* flag for netvsc debug mode */
+extern int debug_mode;
+
 /* RSS related */
 #define OID_GEN_RECEIVE_SCALE_CAPABILITIES 0x00010203  /* query only */
 #define OID_GEN_RECEIVE_SCALE_PARAMETERS 0x00010204  /* query and set */
diff --git a/drivers/net/hyperv/netvsc_drv.c b/drivers/net/hyperv/netvsc_drv.c
index a3a9d38..7c41864 100644
--- a/drivers/net/hyperv/netvsc_drv.c
+++ b/drivers/net/hyperv/netvsc_drv.c
@@ -52,6 +52,10 @@  static int ring_size = 128;
 module_param(ring_size, int, S_IRUGO);
 MODULE_PARM_DESC(ring_size, "Ring buffer size (# of pages)");
 
+int debug_mode = 0;
+module_param(debug_mode, int, S_IRUGO);
+MODULE_PARM_DESC(debug_mode, "debug mode: zero(0) for non-debug mode; non-zero for debug mode");
+
 static void do_set_multicast(struct work_struct *w)
 {
 	struct net_device_context *ndevctx =
@@ -999,6 +1003,10 @@  static int __init netvsc_drv_init(void)
 		pr_info("Increased ring_size to %d (min allowed)\n",
 			ring_size);
 	}
+
+	if (debug_mode != 0)
+		pr_info("Run netvsc in debug mode");
+
 	return vmbus_driver_register(&netvsc_drv);
 }
 
diff --git a/drivers/net/hyperv/rndis_filter.c b/drivers/net/hyperv/rndis_filter.c
index 0d92efe..a3f43f6 100644
--- a/drivers/net/hyperv/rndis_filter.c
+++ b/drivers/net/hyperv/rndis_filter.c
@@ -429,7 +429,8 @@  int rndis_filter_receive(struct hv_device *dev,
 
 	rndis_msg = pkt->data;
 
-	dump_rndis_message(dev, rndis_msg);
+	if (debug_mode != 0)
+		dump_rndis_message(dev, rndis_msg);
 
 	switch (rndis_msg->ndis_msg_type) {
 	case RNDIS_MSG_PACKET: