Skip to contentSkip to conversation

staging: vt6656: Declare a few variables as __read_mostly

PATCH In review Oscar Carter 3 participants 9 messages Mar 1, 2020 – Mar 9, 2020 Staging

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 staging: vt6656: Declare a few variables as __read_mostly

These include module parameters.

---
 drivers/staging/vt6656/main_usb.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/staging/vt6656/main_usb.c +2 -2
index 5e48b3ddb94c..701300202b21 100644
@@ -49,12 +49,12 @@ MODULE_LICENSE("GPL");
 MODULE_DESCRIPTION(DEVICE_FULL_DRV_NAM);
 
 #define RX_DESC_DEF0 64
-static int vnt_rx_buffers = RX_DESC_DEF0;
+static int __read_mostly vnt_rx_buffers = RX_DESC_DEF0;
 module_param_named(rx_buffers, vnt_rx_buffers, int, 0644);
 MODULE_PARM_DESC(rx_buffers, "Number of receive usb rx buffers");
 
 #define TX_DESC_DEF0 64
-static int vnt_tx_buffers = TX_DESC_DEF0;
+static int __read_mostly vnt_tx_buffers = TX_DESC_DEF0;
 module_param_named(tx_buffers, vnt_tx_buffers, int, 0644);
 MODULE_PARM_DESC(tx_buffers, "Number of receive usb tx buffers");
 

--
2.20.1

#1 lore raw
Quoted 16 lines · Oscar Carter

These include module parameters.

---
 drivers/staging/vt6656/main_usb.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/staging/vt6656/main_usb.c +0 -1
index 5e48b3ddb94c..701300202b21 100644
@@ -49,12 +49,12 @@ MODULE_LICENSE("GPL");
 MODULE_DESCRIPTION(DEVICE_FULL_DRV_NAM);
 
 #define RX_DESC_DEF0 64
-static int vnt_rx_buffers = RX_DESC_DEF0;

drivers/staging/vt6656/main_usb.c MODULE_LICENSE("GPL"); · line 60

Quoted 10 lines
drivers/staging/vt6656/main_usb.c +2 -1
+static int __read_mostly vnt_rx_buffers = RX_DESC_DEF0;
 module_param_named(rx_buffers, vnt_rx_buffers, int, 0644);
 MODULE_PARM_DESC(rx_buffers, "Number of receive usb rx buffers");
 
 #define TX_DESC_DEF0 64
-static int vnt_tx_buffers = TX_DESC_DEF0;
+static int __read_mostly vnt_tx_buffers = TX_DESC_DEF0;
 module_param_named(tx_buffers, vnt_tx_buffers, int, 0644);
 MODULE_PARM_DESC(tx_buffers, "Number of receive usb tx buffers");
 

Why? What does this help with?

thanks,

greg k-h

#2 lore raw
Quoted 21 lines · Greg Kroah-Hartman
Quoted 20 lines · Oscar Carter

These include module parameters.

---
 drivers/staging/vt6656/main_usb.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/staging/vt6656/main_usb.c +1 -1
index 5e48b3ddb94c..701300202b21 100644
@@ -49,12 +49,12 @@ MODULE_LICENSE("GPL");
 MODULE_DESCRIPTION(DEVICE_FULL_DRV_NAM);
 
 #define RX_DESC_DEF0 64
-static int vnt_rx_buffers = RX_DESC_DEF0;
+static int __read_mostly vnt_rx_buffers = RX_DESC_DEF0;
 module_param_named(rx_buffers, vnt_rx_buffers, int, 0644);
 MODULE_PARM_DESC(rx_buffers, "Number of receive usb rx buffers");
 
Quoted 8 lines

drivers/staging/vt6656/main_usb.c MODULE_LICENSE("GPL"); · line 60

Quoted 6 lines
drivers/staging/vt6656/main_usb.c +1 -1
 #define TX_DESC_DEF0 64
-static int vnt_tx_buffers = TX_DESC_DEF0;
+static int __read_mostly vnt_tx_buffers = TX_DESC_DEF0;
 module_param_named(tx_buffers, vnt_tx_buffers, int, 0644);
 MODULE_PARM_DESC(tx_buffers, "Number of receive usb tx buffers");
 

Why? What does this help with?

If we declare these variables __read_mostly we can improve the performance. If these variables are read many more times than written, each core of a multicore system can maintain a copy in a local cache and the time to access is less than if they use the shared-cache.

Quoted 4 lines

thanks,

greg k-h

thanks,

oscar carter

#3 lore raw
Quoted 31 lines · Oscar Carter
Quoted 21 lines · Greg Kroah-Hartman
Quoted 20 lines · Oscar Carter

These include module parameters.

---
 drivers/staging/vt6656/main_usb.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/staging/vt6656/main_usb.c +1 -1
index 5e48b3ddb94c..701300202b21 100644
@@ -49,12 +49,12 @@ MODULE_LICENSE("GPL");
 MODULE_DESCRIPTION(DEVICE_FULL_DRV_NAM);
 
 #define RX_DESC_DEF0 64
-static int vnt_rx_buffers = RX_DESC_DEF0;
+static int __read_mostly vnt_rx_buffers = RX_DESC_DEF0;
 module_param_named(rx_buffers, vnt_rx_buffers, int, 0644);
 MODULE_PARM_DESC(rx_buffers, "Number of receive usb rx buffers");
 
Quoted 8 lines

drivers/staging/vt6656/main_usb.c MODULE_LICENSE("GPL"); · line 60

Quoted 6 lines
drivers/staging/vt6656/main_usb.c +1 -1
 #define TX_DESC_DEF0 64
-static int vnt_tx_buffers = TX_DESC_DEF0;
+static int __read_mostly vnt_tx_buffers = TX_DESC_DEF0;
 module_param_named(tx_buffers, vnt_tx_buffers, int, 0644);
 MODULE_PARM_DESC(tx_buffers, "Number of receive usb tx buffers");
 

Why? What does this help with?

Quoted 4 lines

If we declare these variables __read_mostly we can improve the performance. If these variables are read many more times than written, each core of a multicore system can maintain a copy in a local cache and the time to access is less than if they use the shared-cache.

This is a USB driver, performance is always limited to the hardware, not the CPU location of variables.

Please always benchmark things to see if it actually makes sense to make changes like this, before proposing them.

thanks,

greg k-h

#4 lore raw
Quoted 32 lines · Greg Kroah-Hartman
Quoted 31 lines · Oscar Carter
Quoted 29 lines · Greg Kroah-Hartman
Quoted 16 lines · Oscar Carter

These include module parameters.

---
 drivers/staging/vt6656/main_usb.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/staging/vt6656/main_usb.c +0 -1
index 5e48b3ddb94c..701300202b21 100644
@@ -49,12 +49,12 @@ MODULE_LICENSE("GPL");
 MODULE_DESCRIPTION(DEVICE_FULL_DRV_NAM);
 
 #define RX_DESC_DEF0 64
-static int vnt_rx_buffers = RX_DESC_DEF0;

drivers/staging/vt6656/main_usb.c MODULE_LICENSE("GPL"); · line 60

Quoted 10 lines
drivers/staging/vt6656/main_usb.c +2 -1
+static int __read_mostly vnt_rx_buffers = RX_DESC_DEF0;
 module_param_named(rx_buffers, vnt_rx_buffers, int, 0644);
 MODULE_PARM_DESC(rx_buffers, "Number of receive usb rx buffers");
 
 #define TX_DESC_DEF0 64
-static int vnt_tx_buffers = TX_DESC_DEF0;
+static int __read_mostly vnt_tx_buffers = TX_DESC_DEF0;
 module_param_named(tx_buffers, vnt_tx_buffers, int, 0644);
 MODULE_PARM_DESC(tx_buffers, "Number of receive usb tx buffers");
 

Why? What does this help with?

Quoted 7 lines
Quoted 4 lines

If we declare these variables __read_mostly we can improve the performance. If these variables are read many more times than written, each core of a multicore system can maintain a copy in a local cache and the time to access is less than if they use the shared-cache.

This is a USB driver, performance is always limited to the hardware, not the CPU location of variables.

Thank you for the explanation.

Quoted 3 lines

Please always benchmark things to see if it actually makes sense to make changes like this, before proposing them.

I'm sorry.

Quoted 4 lines

thanks,

greg k-h

thanks,

Oscar

#5 lore raw
Quoted 5 lines · Oscar Carter
Quoted 3 lines · Greg Kroah-Hartman

On Sun, Mar 01, 2020 at 02:17:01PM +0100, Oscar Carter wrote:
This is a USB driver, performance is always limited to the hardware, not the CPU location of variables.

Quoted 8 lines

Thank you for the explanation.

Quoted 3 lines

Please always benchmark things to see if it actually makes sense to make changes like this, before proposing them.

I'm sorry.

I've been removed from CC list on Greg's answer, so I haven't seen the explanation earlier and reviewed the patch the next day. I should have know better, won't happen again.

Thank you,
Quentin

#6 lore raw
Quoted 12 lines · Quentin Deslandes
Quoted 11 lines · Oscar Carter
Quoted 3 lines · Greg Kroah-Hartman

On Sun, Mar 01, 2020 at 02:17:01PM +0100, Oscar Carter wrote:
This is a USB driver, performance is always limited to the hardware, not the CPU location of variables.

Thank you for the explanation.

Quoted 3 lines

Please always benchmark things to see if it actually makes sense to make changes like this, before proposing them.

Quoted 6 lines
Quoted 2 lines

I'm sorry.

I've been removed from CC list on Greg's answer, so I haven't seen the explanation earlier and reviewed the patch the next day. I should have know better, won't happen again.

You weren't on the original list of people on the patch, so I didn't remove anything here that I can tell.

thanks,

greg k-h

#7 lore raw
Quoted 16 lines · Greg Kroah-Hartman
Quoted 15 lines · Quentin Deslandes
Quoted 13 lines · Oscar Carter
Quoted 3 lines · Greg Kroah-Hartman

On Sun, Mar 01, 2020 at 02:17:01PM +0100, Oscar Carter wrote:
This is a USB driver, performance is always limited to the hardware, not the CPU location of variables.

Thank you for the explanation.

Quoted 3 lines

Please always benchmark things to see if it actually makes sense to make changes like this, before proposing them.

I'm sorry.

Quoted 6 lines
Quoted 3 lines

I've been removed from CC list on Greg's answer, so I haven't seen the explanation earlier and reviewed the patch the next day. I should have know better, won't happen again.

You weren't on the original list of people on the patch, so I didn't remove anything here that I can tell.

Turns out you were, on the lkml one, but not the one that went through the driver-devel list. odd...

Reviewed-by on v1 1/1
#8 lore raw
In reply to Oscar Carter
Quoted 27 lines · Oscar Carter

These include module parameters.

---
 drivers/staging/vt6656/main_usb.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/staging/vt6656/main_usb.c +2 -3
index 5e48b3ddb94c..701300202b21 100644
@@ -49,12 +49,12 @@ MODULE_LICENSE("GPL");
 MODULE_DESCRIPTION(DEVICE_FULL_DRV_NAM);
 
 #define RX_DESC_DEF0 64
-static int vnt_rx_buffers = RX_DESC_DEF0;
+static int __read_mostly vnt_rx_buffers = RX_DESC_DEF0;
 module_param_named(rx_buffers, vnt_rx_buffers, int, 0644);
 MODULE_PARM_DESC(rx_buffers, "Number of receive usb rx buffers");
 
 #define TX_DESC_DEF0 64
-static int vnt_tx_buffers = TX_DESC_DEF0;
+static int __read_mostly vnt_tx_buffers = TX_DESC_DEF0;
 module_param_named(tx_buffers, vnt_tx_buffers, int, 0644);
 MODULE_PARM_DESC(tx_buffers, "Number of receive usb tx buffers");
 
--
Quoted 2 lines

2.20.1

Looks good to me.