Skip to contentSkip to conversation

net: core: use listified Rx for GRO_NORMAL in napi_gro_receive()

PATCH In review Alexander Lobakin 4 participants 15 messages Oct 10, 2019 – Oct 12, 2019

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover net: core: use listified Rx for GRO_NORMAL in napi_gro_receive()

Hi Dave,

This series was written as a continuation to commit 323ebb61e32b ("net: use listified RX for handling GRO_NORMAL skbs"), and also takes an advantage of listified Rx for GRO. This time, however, we're targeting at a way more common and used function, napi_gro_receive().

There are about ~100 call sites of this function, including gro_cells and mac80211, so even wireless systems will benefit from it. The only driver that cares about the return value is ethernet/socionext/netsec, and only for updating statistics. I don't believe that this change can break its functionality, but anyway, we have plenty of time till next merge window to pay this change a proper attention.

Besides having this functionality implemented for napi_gro_frags() users, the main reason is the solid performance boost that has been shown during tests on 1-core MIPS board (with not yet mainlined driver):

* no batching (5.4-rc2): ~450/450 Mbit/s
* with gro_normal_batch == 8: ~480/480 Mbit/s
* with gro_normal_batch == 16: ~500/500 Mbit/s

Applies on top of net-next.
Thanks.

Alexander Lobakin (2):
net: core: use listified Rx for GRO_NORMAL in napi_gro_receive()
net: core: increase the default size of GRO_NORMAL skb lists to flush

 net/core/dev.c | 51 +++++++++++++++++++++++++-------------------------
 1 file changed, 26 insertions(+), 25 deletions(-)
Signature · 1 line
2.23.0
#1 lore raw

PATCH 2/2 net: core: increase the default size of GRO_NORMAL skb lists to flush

Commit 323ebb61e32b ("net: use listified RX for handling GRO_NORMAL skbs") have introduced a sysctl variable gro_normal_batch for defining a limit for listified Rx of GRO_NORMAL skbs. The initial value of 8 is purely arbitrary and has been chosen, I believe, as a minimal safe default.
However, several tests show that it's rather suboptimal and doesn't allow to take a full advantage of listified processing. The best and the most balanced results have been achieved with a batches of 16 skbs per flush.
So double the default value to give a yet another boost for Rx path. It remains configurable via sysctl anyway, so may be fine-tuned for each hardware.

---
 net/core/dev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/core/dev.c +1 -1
index a33f56b439ce..4f60444bb766 100644
@@ -4189,7 +4189,7 @@ int dev_weight_tx_bias __read_mostly = 1;  /* bias for output_queue quota */
 int dev_rx_weight __read_mostly = 64;
 int dev_tx_weight __read_mostly = 64;
 /* Maximum number of GRO_NORMAL skbs to batch up for list-RX */
-int gro_normal_batch __read_mostly = 8;
+int gro_normal_batch __read_mostly = 16;
 
 /* Called with irq disabled */
 static inline void ____napi_schedule(struct softnet_data *sd,
Signature · 1 line
2.23.0
#2 lore raw

Re: [PATCH net-next 2/2] net: core: increase the default size of GRO_NORMAL skb lists to flush

Quoted 5 lines · Alexander Lobakin

Commit 323ebb61e32b ("net: use listified RX for handling GRO_NORMAL skbs") have introduced a sysctl variable gro_normal_batch for defining a limit for listified Rx of GRO_NORMAL skbs. The initial value of 8 is purely arbitrary and has been chosen, I believe, as a minimal safe default.

8 was chosen by performance tests on my setup with v1 of that patch; see https://www.spinics.net/lists/netdev/msg585001.html . Sorry for not including that info in the final version of the patch. While I didn't re-do tests on varying gro_normal_batch on the final version, I think changing it needs more evidence than just "we tested it; it's better".  In particular, increasing the batch size should be accompanied by demonstration that latency isn't increased in e.g. a multi-stream ping-pong test.

Quoted 8 lines

However, several tests show that it's rather suboptimal and doesn't allow to take a full advantage of listified processing. The best and the most balanced results have been achieved with a batches of 16 skbs per flush.
So double the default value to give a yet another boost for Rx path.

It remains configurable via sysctl anyway, so may be fine-tuned for each hardware.

I see this as a reason to leave the default as it is; the combination of your tests and mine have established that the optimal size does vary (I found 16 to be 2% slower than 8 with my setup), so any tweaking of the default is likely only worthwhile if we have data over lots of different hardware combinations.

Quoted 18 lines
---
 net/core/dev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/core/dev.c +1 -1
index a33f56b439ce..4f60444bb766 100644
@@ -4189,7 +4189,7 @@ int dev_weight_tx_bias __read_mostly = 1;  /* bias for output_queue quota */
 int dev_rx_weight __read_mostly = 64;
 int dev_tx_weight __read_mostly = 64;
 /* Maximum number of GRO_NORMAL skbs to batch up for list-RX */
-int gro_normal_batch __read_mostly = 8;
+int gro_normal_batch __read_mostly = 16;
 
 /* Called with irq disabled */
 static inline void ____napi_schedule(struct softnet_data *sd,
#3 lore raw

Re: [PATCH net-next 2/2] net: core: increase the default size of GRO_NORMAL skb lists to flush

Hi Edward,

Edward Cree wrote 10.10.2019 21:16:

Quoted 21 lines · Alexander Lobakin
Quoted 5 lines

Commit 323ebb61e32b ("net: use listified RX for handling GRO_NORMAL skbs") have introduced a sysctl variable gro_normal_batch for defining a limit for listified Rx of GRO_NORMAL skbs. The initial value of 8 is purely arbitrary and has been chosen, I believe, as a minimal safe default.

8 was chosen by performance tests on my setup with v1 of that patch; see https://www.spinics.net/lists/netdev/msg585001.html . Sorry for not including that info in the final version of the patch. While I didn't re-do tests on varying gro_normal_batch on the final version, I think changing it needs more evidence than just "we tested it; it's better".  In particular, increasing the batch size should be accompanied by demonstration that latency isn't increased in e.g. a multi-stream ping-pong test.

Quoted 5 lines

However, several tests show that it's rather suboptimal and doesn't allow to take a full advantage of listified processing. The best and the most balanced results have been achieved with a batches of 16 skbs per flush.
So double the default value to give a yet another boost for Rx path.

Quoted 7 lines
Quoted 2 lines

It remains configurable via sysctl anyway, so may be fine-tuned for each hardware.

I see this as a reason to leave the default as it is; the combination of your tests and mine have established that the optimal size does vary (I found 16 to be 2% slower than 8 with my setup), so any tweaking of the default is likely only worthwhile if we have data over lots of different hardware combinations.

Agree, if you've got slower results on 16, we must leave the default value, as it seems to be VERY hardware- and driver- dependent. So, patch 2/2 is not actual any more (I supposed that it would likely go away before sending this series).

Quoted 17 lines
Quoted 17 lines
---
 net/core/dev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/core/dev.c +0 -0
index a33f56b439ce..4f60444bb766 100644
@@ -4189,7 +4189,7 @@ int dev_weight_tx_bias __read_mostly = 1;  /* 

bias for output_queue quota */
int dev_rx_weight __read_mostly = 64;
int dev_tx_weight __read_mostly = 64;
/* Maximum number of GRO_NORMAL skbs to batch up for list-RX */

net/core/dev.c +1 -1
-int gro_normal_batch __read_mostly = 8;
+int gro_normal_batch __read_mostly = 16;
Quoted 2 lines
Quoted 2 lines

/* Called with irq disabled */
static inline void ____napi_schedule(struct softnet_data *sd,

Regards,
ᚷ ᛖ ᚢ ᚦ ᚠ ᚱ

#4 lore raw

Re: [PATCH net-next 2/2] net: core: increase the default size of GRO_NORMAL skb lists to flush

Alexander Lobakin wrote 11.10.2019 10:23:

Quoted 32 lines

Hi Edward,

Edward Cree wrote 10.10.2019 21:16:

Quoted 21 lines · Alexander Lobakin
Quoted 5 lines

Commit 323ebb61e32b ("net: use listified RX for handling GRO_NORMAL skbs") have introduced a sysctl variable gro_normal_batch for defining a limit for listified Rx of GRO_NORMAL skbs. The initial value of 8 is purely arbitrary and has been chosen, I believe, as a minimal safe default.

8 was chosen by performance tests on my setup with v1 of that patch; see https://www.spinics.net/lists/netdev/msg585001.html . Sorry for not including that info in the final version of the patch. While I didn't re-do tests on varying gro_normal_batch on the final version, I think changing it needs more evidence than just "we tested it; it's better".  In particular, increasing the batch size should be accompanied by demonstration that latency isn't increased in e.g. a multi-stream ping-pong test.

Quoted 5 lines

However, several tests show that it's rather suboptimal and doesn't allow to take a full advantage of listified processing. The best and the most balanced results have been achieved with a batches of 16 skbs per flush.
So double the default value to give a yet another boost for Rx path.

Quoted 7 lines
Quoted 2 lines

It remains configurable via sysctl anyway, so may be fine-tuned for each hardware.

I see this as a reason to leave the default as it is; the combination of your tests and mine have established that the optimal size does vary (I found 16 to be 2% slower than 8 with my setup), so any tweaking of the default is likely only worthwhile if we have data over lots of different hardware combinations.

Quoted 4 lines

Agree, if you've got slower results on 16, we must leave the default value, as it seems to be VERY hardware- and driver- dependent. So, patch 2/2 is not actual any more (I supposed that it would likely go away before sending this series).

I've generated an another solution. Considering that gro_normal_batch is very individual for every single case, maybe it would be better to make it per-NAPI (or per-netdevice) variable rather than a global across the kernel?
I think most of all network-capable configurations and systems has more than one network device nowadays, and they might need different values for achieving their bests.

One possible variant is:

#define THIS_DRIVER_GRO_NORMAL_BATCH 16

/* ... */

netif_napi_add(dev, napi, this_driver_rx_poll, NAPI_POLL_WEIGHT); /* napi->gro_normal_batch will be set to the systcl value during NAPI context initialization */
napi_set_gro_normal_batch(napi, THIS_DRIVER_GRO_NORMAL_BATCH); /* new static inline helper, napi->gro_normal_batch will be set to the driver-speficic value of 16 */

The second possible variant is to make gro_normal_batch sysctl per-netdevice to tune it from userspace.
Or we can combine them into one to make it available for tweaking from both driver and userspace, just like it's now with XPS CPUs setting.

If you'll find any of this reasonable and worth implementing, I'll come with it in v2 after a proper testing.

Quoted 18 lines
Quoted 18 lines
Quoted 18 lines
---
 net/core/dev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/core/dev.c +0 -0
index a33f56b439ce..4f60444bb766 100644
@@ -4189,7 +4189,7 @@ int dev_weight_tx_bias __read_mostly = 1;  /* 

bias for output_queue quota */
int dev_rx_weight __read_mostly = 64;
int dev_tx_weight __read_mostly = 64;
/* Maximum number of GRO_NORMAL skbs to batch up for list-RX */

net/core/dev.c +1 -1
-int gro_normal_batch __read_mostly = 8;
+int gro_normal_batch __read_mostly = 16;
Quoted 5 lines
Quoted 2 lines
Quoted 2 lines

/* Called with irq disabled */
static inline void ____napi_schedule(struct softnet_data *sd,

Regards,
ᚷ ᛖ ᚢ ᚦ ᚠ ᚱ

Regards,
ᚷ ᛖ ᚢ ᚦ ᚠ ᚱ

#5 lore raw

Re: [PATCH net-next 2/2] net: core: increase the default size of GRO_NORMAL skb lists to flush

Quoted 22 lines · Alexander Lobakin

I've generated an another solution. Considering that gro_normal_batch is very individual for every single case, maybe it would be better to make it per-NAPI (or per-netdevice) variable rather than a global across the kernel?
I think most of all network-capable configurations and systems has more than one network device nowadays, and they might need different values for achieving their bests.

One possible variant is:

#define THIS_DRIVER_GRO_NORMAL_BATCH 16

/* ... */

netif_napi_add(dev, napi, this_driver_rx_poll, NAPI_POLL_WEIGHT); /* napi->gro_normal_batch will be set to the systcl value during NAPI context initialization */
napi_set_gro_normal_batch(napi, THIS_DRIVER_GRO_NORMAL_BATCH); /* new static inline helper, napi->gro_normal_batch will be set to the driver-speficic value of 16 */

Quoted 7 lines

The second possible variant is to make gro_normal_batch sysctl per-netdevice to tune it from userspace.
Or we can combine them into one to make it available for tweaking from both driver and userspace, just like it's now with XPS CPUs setting.

If you'll find any of this reasonable and worth implementing, I'll come with it in v2 after a proper testing.

Most likely the optimal tuning is also a function of the host cpu caches.

Building a too big list can also lead to premature cache evictions.

Tuning the value on your test machines does not mean the value will be good for other systems.

Adding yet another per device value should only be done if you demonstrate a significant performance increase compared to the conservative value Edward chose.

Also the behavior can be quite different depending on the protocols, make sure you test handling of TCP pure ACK packets.

Accumulating 64 (in case the device uses standard NAPI_POLL_WEIGHT) of them before entering upper stacks seems not a good choice, since 64 skbs will need to be kept in the GRO system, compared to only 8 with Edward value.

#6 lore raw

Re: [PATCH net-next 2/2] net: core: increase the default size of GRO_NORMAL skb lists to flush

Hi Eric,

Eric Dumazet wrote 12.10.2019 14:18:

Quoted 32 lines · Alexander Lobakin
Quoted 23 lines

I've generated an another solution. Considering that gro_normal_batch is very individual for every single case, maybe it would be better to make it per-NAPI (or per-netdevice) variable rather than a global across the kernel?
I think most of all network-capable configurations and systems has more than one network device nowadays, and they might need different values for achieving their bests.

One possible variant is:

#define THIS_DRIVER_GRO_NORMAL_BATCH 16

/* ... */

netif_napi_add(dev, napi, this_driver_rx_poll, NAPI_POLL_WEIGHT); /* napi->gro_normal_batch will be set to the systcl value during NAPI context initialization */
napi_set_gro_normal_batch(napi, THIS_DRIVER_GRO_NORMAL_BATCH); /* new static inline helper, napi->gro_normal_batch will be set to the driver-speficic value of 16 */

Quoted 7 lines

The second possible variant is to make gro_normal_batch sysctl per-netdevice to tune it from userspace.
Or we can combine them into one to make it available for tweaking from both driver and userspace, just like it's now with XPS CPUs setting.

If you'll find any of this reasonable and worth implementing, I'll come with it in v2 after a proper testing.

Quoted 6 lines

Most likely the optimal tuning is also a function of the host cpu caches.

Building a too big list can also lead to premature cache evictions.

Tuning the value on your test machines does not mean the value will be good for other systems.

Oh, I missed that it might be a lot more machine-dependent than netdevice-dependent. Thank you for explanation. The best I can do in that case is to leave batch control in its current.
I'll publish v2 containing only the acked first part of the series on Monday if nothing serious will happen. Addition of listified Rx to napi_gro_receive() was the main goal anyway.

Quoted 11 lines

Adding yet another per device value should only be done if you demonstrate a significant performance increase compared to the conservative value Edward chose.

Also the behavior can be quite different depending on the protocols, make sure you test handling of TCP pure ACK packets.

Accumulating 64 (in case the device uses standard NAPI_POLL_WEIGHT) of them before entering upper stacks seems not a good choice, since 64 skbs will need to be kept in the GRO system, compared to only 8 with Edward value.

Regards,
ᚷ ᛖ ᚢ ᚦ ᚠ ᚱ

#7 lore raw

PATCH 1/1 net: core: use listified Rx for GRO_NORMAL in napi_gro_receive()

In reply to Alexander Lobakin

Commit 323ebb61e32b4 ("net: use listified RX for handling GRO_NORMAL skbs") made use of listified skb processing for the users of napi_gro_frags().
The same technique can be used in a way more common napi_gro_receive() to speed up non-merged (GRO_NORMAL) skbs for a wide range of drivers, including gro_cells and mac80211 users.

---
 net/core/dev.c | 49 +++++++++++++++++++++++++------------------------
 1 file changed, 25 insertions(+), 24 deletions(-)
net/core/dev.c +25 -24
index 8bc3dce71fc0..a33f56b439ce 100644
@@ -5884,6 +5884,26 @@ struct packet_offload *gro_find_complete_by_type(__be16 type)
 }
 EXPORT_SYMBOL(gro_find_complete_by_type);
 
+/* Pass the currently batched GRO_NORMAL SKBs up to the stack. */
+static void gro_normal_list(struct napi_struct *napi)
+{
+	if (!napi->rx_count)
+		return;
+	netif_receive_skb_list_internal(&napi->rx_list);
+	INIT_LIST_HEAD(&napi->rx_list);
+	napi->rx_count = 0;
+}
+
+/* Queue one GRO_NORMAL SKB up for list processing.  If batch size exceeded,
+ * pass the whole batch up to the stack.
+ */
+static void gro_normal_one(struct napi_struct *napi, struct sk_buff *skb)
+{
+	list_add_tail(&skb->list, &napi->rx_list);
+	if (++napi->rx_count >= gro_normal_batch)
+		gro_normal_list(napi);
+}
+
 static void napi_skb_free_stolen_head(struct sk_buff *skb)
 {
 	skb_dst_drop(skb);
@@ -5891,12 +5911,13 @@ static void napi_skb_free_stolen_head(struct sk_buff *skb)
 	kmem_cache_free(skbuff_head_cache, skb);
 }
 
-static gro_result_t napi_skb_finish(gro_result_t ret, struct sk_buff *skb)
+static gro_result_t napi_skb_finish(struct napi_struct *napi,
+				    struct sk_buff *skb,
+				    gro_result_t ret)
 {
 	switch (ret) {
 	case GRO_NORMAL:
-		if (netif_receive_skb_internal(skb))
-			ret = GRO_DROP;
+		gro_normal_one(napi, skb);
 		break;
 
 	case GRO_DROP:
@@ -5928,7 +5949,7 @@ gro_result_t napi_gro_receive(struct napi_struct *napi, struct sk_buff *skb)
 
 	skb_gro_reset_offset(skb);
 
-	ret = napi_skb_finish(dev_gro_receive(napi, skb), skb);
+	ret = napi_skb_finish(napi, skb, dev_gro_receive(napi, skb));
 	trace_napi_gro_receive_exit(ret);
 
 	return ret;
@@ -5974,26 +5995,6 @@ struct sk_buff *napi_get_frags(struct napi_struct *napi)
 }
 EXPORT_SYMBOL(napi_get_frags);
 
-/* Pass the currently batched GRO_NORMAL SKBs up to the stack. */
-static void gro_normal_list(struct napi_struct *napi)
-{
-	if (!napi->rx_count)
-		return;
-	netif_receive_skb_list_internal(&napi->rx_list);
-	INIT_LIST_HEAD(&napi->rx_list);
-	napi->rx_count = 0;
-}
-
-/* Queue one GRO_NORMAL SKB up for list processing.  If batch size exceeded,
- * pass the whole batch up to the stack.
- */
-static void gro_normal_one(struct napi_struct *napi, struct sk_buff *skb)
-{
-	list_add_tail(&skb->list, &napi->rx_list);
-	if (++napi->rx_count >= gro_normal_batch)
-		gro_normal_list(napi);
-}
-
 static gro_result_t napi_frags_finish(struct napi_struct *napi,
 				      struct sk_buff *skb,
 				      gro_result_t ret)
Signature · 1 line
2.23.0
#8 lore raw
Quoted 44 lines · Alexander Lobakin

Commit 323ebb61e32b4 ("net: use listified RX for handling GRO_NORMAL skbs") made use of listified skb processing for the users of napi_gro_frags().
The same technique can be used in a way more common napi_gro_receive() to speed up non-merged (GRO_NORMAL) skbs for a wide range of drivers, including gro_cells and mac80211 users.

---
 net/core/dev.c | 49 +++++++++++++++++++++++++------------------------
 1 file changed, 25 insertions(+), 24 deletions(-)
net/core/dev.c +20 -0
index 8bc3dce71fc0..a33f56b439ce 100644
@@ -5884,6 +5884,26 @@ struct packet_offload *gro_find_complete_by_type(__be16 type)
 }
 EXPORT_SYMBOL(gro_find_complete_by_type);
 
+/* Pass the currently batched GRO_NORMAL SKBs up to the stack. */
+static void gro_normal_list(struct napi_struct *napi)
+{
+	if (!napi->rx_count)
+		return;
+	netif_receive_skb_list_internal(&napi->rx_list);
+	INIT_LIST_HEAD(&napi->rx_list);
+	napi->rx_count = 0;
+}
+
+/* Queue one GRO_NORMAL SKB up for list processing.  If batch size exceeded,
+ * pass the whole batch up to the stack.
+ */
+static void gro_normal_one(struct napi_struct *napi, struct sk_buff *skb)
+{
+	list_add_tail(&skb->list, &napi->rx_list);
+	if (++napi->rx_count >= gro_normal_batch)
+		gro_normal_list(napi);
+}
+
 static void napi_skb_free_stolen_head(struct sk_buff *skb)
 {
 	skb_dst_drop(skb);

net/core/dev.c static void napi_skb_free_stolen_head(struct sk_buff *skb) · line 5916

Quoted 7 lines
net/core/dev.c +3 -1
@@ -5891,12 +5911,13 @@ static void napi_skb_free_stolen_head(struct sk_buff *skb)
 	kmem_cache_free(skbuff_head_cache, skb);
 }
 
-static gro_result_t napi_skb_finish(gro_result_t ret, struct sk_buff *skb)
+static gro_result_t napi_skb_finish(struct napi_struct *napi,
+				    struct sk_buff *skb,
+				    gro_result_t ret)

Any reason why the argument order here is changed around?

-Ed

Quoted 45 lines
net/core/dev.c +2 -23
 {
 	switch (ret) {
 	case GRO_NORMAL:
-		if (netif_receive_skb_internal(skb))
-			ret = GRO_DROP;
+		gro_normal_one(napi, skb);
 		break;
 
 	case GRO_DROP:
@@ -5928,7 +5949,7 @@ gro_result_t napi_gro_receive(struct napi_struct *napi, struct sk_buff *skb)
 
 	skb_gro_reset_offset(skb);
 
-	ret = napi_skb_finish(dev_gro_receive(napi, skb), skb);
+	ret = napi_skb_finish(napi, skb, dev_gro_receive(napi, skb));
 	trace_napi_gro_receive_exit(ret);
 
 	return ret;
@@ -5974,26 +5995,6 @@ struct sk_buff *napi_get_frags(struct napi_struct *napi)
 }
 EXPORT_SYMBOL(napi_get_frags);
 
-/* Pass the currently batched GRO_NORMAL SKBs up to the stack. */
-static void gro_normal_list(struct napi_struct *napi)
-{
-	if (!napi->rx_count)
-		return;
-	netif_receive_skb_list_internal(&napi->rx_list);
-	INIT_LIST_HEAD(&napi->rx_list);
-	napi->rx_count = 0;
-}
-
-/* Queue one GRO_NORMAL SKB up for list processing.  If batch size exceeded,
- * pass the whole batch up to the stack.
- */
-static void gro_normal_one(struct napi_struct *napi, struct sk_buff *skb)
-{
-	list_add_tail(&skb->list, &napi->rx_list);
-	if (++napi->rx_count >= gro_normal_batch)
-		gro_normal_list(napi);
-}
-
 static gro_result_t napi_frags_finish(struct napi_struct *napi,
 				      struct sk_buff *skb,
 				      gro_result_t ret)
#9 lore raw

Edward Cree wrote 10.10.2019 21:23:

Quoted 52 lines · Alexander Lobakin
Quoted 51 lines

Commit 323ebb61e32b4 ("net: use listified RX for handling GRO_NORMAL skbs") made use of listified skb processing for the users of napi_gro_frags().
The same technique can be used in a way more common napi_gro_receive() to speed up non-merged (GRO_NORMAL) skbs for a wide range of drivers, including gro_cells and mac80211 users.

---
 net/core/dev.c | 49 +++++++++++++++++++++++++------------------------
 1 file changed, 25 insertions(+), 24 deletions(-)
net/core/dev.c +20 -0
index 8bc3dce71fc0..a33f56b439ce 100644
@@ -5884,6 +5884,26 @@ struct packet_offload 
 *gro_find_complete_by_type(__be16 type)
 }
 EXPORT_SYMBOL(gro_find_complete_by_type);
 
+/* Pass the currently batched GRO_NORMAL SKBs up to the stack. */
+static void gro_normal_list(struct napi_struct *napi)
+{
+	if (!napi->rx_count)
+		return;
+	netif_receive_skb_list_internal(&napi->rx_list);
+	INIT_LIST_HEAD(&napi->rx_list);
+	napi->rx_count = 0;
+}
+
+/* Queue one GRO_NORMAL SKB up for list processing.  If batch size 
 exceeded,
+ * pass the whole batch up to the stack.
+ */
+static void gro_normal_one(struct napi_struct *napi, struct sk_buff 
 *skb)
+{
+	list_add_tail(&skb->list, &napi->rx_list);
+	if (++napi->rx_count >= gro_normal_batch)
+		gro_normal_list(napi);
+}
+

static void napi_skb_free_stolen_head(struct sk_buff *skb) {

net/core/dev.c +0 -0
 	skb_dst_drop(skb);
@@ -5891,12 +5911,13 @@ static void napi_skb_free_stolen_head(struct 
 sk_buff *skb)
 	kmem_cache_free(skbuff_head_cache, skb);
 }
 
Quoted 6 lines

net/core/dev.c static void napi_skb_free_stolen_head(struct sk_buff *skb) · line 5916

Quoted 5 lines
net/core/dev.c +3 -1
-static gro_result_t napi_skb_finish(gro_result_t ret, struct sk_buff 
 *skb)
+static gro_result_t napi_skb_finish(struct napi_struct *napi,
+				    struct sk_buff *skb,
+				    gro_result_t ret)

Any reason why the argument order here is changed around?

Actually yes: to match napi_skb_finish() and napi_frags_finish() prototypes, as gro_normal one() required an addition of napi argument anyway.

Quoted 43 lines

-Ed

Quoted 41 lines
net/core/dev.c +1 -2
 {
 	switch (ret) {
 	case GRO_NORMAL:
-		if (netif_receive_skb_internal(skb))
-			ret = GRO_DROP;
+		gro_normal_one(napi, skb);
 		break;
net/core/dev.c +1 -1
 	case GRO_DROP:
@@ -5928,7 +5949,7 @@ gro_result_t napi_gro_receive(struct napi_struct 
 *napi, struct sk_buff *skb)
 
 	skb_gro_reset_offset(skb);
 
-	ret = napi_skb_finish(dev_gro_receive(napi, skb), skb);
+	ret = napi_skb_finish(napi, skb, dev_gro_receive(napi, skb));
 	trace_napi_gro_receive_exit(ret);
 
net/core/dev.c +0 -15
 	return ret;
@@ -5974,26 +5995,6 @@ struct sk_buff *napi_get_frags(struct 
 napi_struct *napi)
 }
 EXPORT_SYMBOL(napi_get_frags);
 
-/* Pass the currently batched GRO_NORMAL SKBs up to the stack. */
-static void gro_normal_list(struct napi_struct *napi)
-{
-	if (!napi->rx_count)
-		return;
-	netif_receive_skb_list_internal(&napi->rx_list);
-	INIT_LIST_HEAD(&napi->rx_list);
-	napi->rx_count = 0;
-}
-
-/* Queue one GRO_NORMAL SKB up for list processing.  If batch size 
 exceeded,
- * pass the whole batch up to the stack.
- */
-static void gro_normal_one(struct napi_struct *napi, struct sk_buff 
 *skb)
-{
Quoted 8 lines

net/core/dev.c struct sk_buff *napi_get_frags(struct napi_struct *napi) · line 6000

Quoted 8 lines
net/core/dev.c +0 -5
-	list_add_tail(&skb->list, &napi->rx_list);
-	if (++napi->rx_count >= gro_normal_batch)
-		gro_normal_list(napi);
-}
-

static gro_result_t napi_frags_finish(struct napi_struct *napi,

net/core/dev.c +0 -0
 				      struct sk_buff *skb,
 				      gro_result_t ret)

Regards,
ᚷ ᛖ ᚢ ᚦ ᚠ ᚱ

Acked-by
#10 lore raw
Quoted 9 lines
Quoted 9 lines · Alexander Lobakin
Quoted 8 lines

Commit 323ebb61e32b4 ("net: use listified RX for handling GRO_NORMAL skbs") made use of listified skb processing for the users of napi_gro_frags().
The same technique can be used in a way more common napi_gro_receive() to speed up non-merged (GRO_NORMAL) skbs for a wide range of drivers, including gro_cells and mac80211 users.

but I think this needs review from the socionext folks as well.

#11 lore raw

Edward Cree wrote 11.10.2019 12:20:

Quoted 11 lines
Quoted 9 lines
Quoted 9 lines · Alexander Lobakin
Quoted 8 lines

Commit 323ebb61e32b4 ("net: use listified RX for handling GRO_NORMAL skbs") made use of listified skb processing for the users of napi_gro_frags().
The same technique can be used in a way more common napi_gro_receive() to speed up non-merged (GRO_NORMAL) skbs for a wide range of drivers, including gro_cells and mac80211 users.

but I think this needs review from the socionext folks as well.

Thanks!
Sure, I'm waiting for any other possible comments.

Regards,
ᚷ ᛖ ᚢ ᚦ ᚠ ᚱ

#12 lore raw
In reply to Alexander Lobakin

Hi Alexander,

Quoted 7 lines · Alexander Lobakin

Hi Dave,

This series was written as a continuation to commit 323ebb61e32b ("net: use listified RX for handling GRO_NORMAL skbs"), and also takes an advantage of listified Rx for GRO. This time, however, we're targeting at a way more common and used function, napi_gro_receive().

Quoted 7 lines

There are about ~100 call sites of this function, including gro_cells and mac80211, so even wireless systems will benefit from it. The only driver that cares about the return value is ethernet/socionext/netsec, and only for updating statistics. I don't believe that this change can break its functionality, but anyway, we have plenty of time till next merge window to pay this change a proper attention.

I don't think this will break anything on the netsec driver. Dropped packets will still be properly accounted for

Quoted 13 lines

Besides having this functionality implemented for napi_gro_frags() users, the main reason is the solid performance boost that has been shown during tests on 1-core MIPS board (with not yet mainlined driver):

* no batching (5.4-rc2): ~450/450 Mbit/s
* with gro_normal_batch == 8: ~480/480 Mbit/s
* with gro_normal_batch == 16: ~500/500 Mbit/s

Applies on top of net-next.
Thanks.

Quoted 10 lines

Alexander Lobakin (2):
net: core: use listified Rx for GRO_NORMAL in napi_gro_receive()
net: core: increase the default size of GRO_NORMAL skb lists to flush

 net/core/dev.c | 51 +++++++++++++++++++++++++-------------------------
 1 file changed, 26 insertions(+), 25 deletions(-)
Signature · 1 line
2.23.0

Thanks
/Ilias

#13 lore raw

Hi Ilias,

Ilias Apalodimas wrote 11.10.2019 15:23:

Quoted 18 lines

Hi Alexander,

Quoted 7 lines · Alexander Lobakin

Hi Dave,

This series was written as a continuation to commit 323ebb61e32b ("net: use listified RX for handling GRO_NORMAL skbs"), and also takes an advantage of listified Rx for GRO. This time, however, we're targeting at a way more common and used function, napi_gro_receive().

Quoted 7 lines

There are about ~100 call sites of this function, including gro_cells and mac80211, so even wireless systems will benefit from it. The only driver that cares about the return value is ethernet/socionext/netsec, and only for updating statistics. I don't believe that this change can break its functionality, but anyway, we have plenty of time till next merge window to pay this change a proper attention.

Quoted 3 lines

I don't think this will break anything on the netsec driver. Dropped packets will still be properly accounted for

Thank you for clarification. Do I need to mention you under separate Acked-by in v2?

Quoted 22 lines
Quoted 22 lines

Besides having this functionality implemented for napi_gro_frags() users, the main reason is the solid performance boost that has been shown during tests on 1-core MIPS board (with not yet mainlined driver):

* no batching (5.4-rc2): ~450/450 Mbit/s
* with gro_normal_batch == 8: ~480/480 Mbit/s
* with gro_normal_batch == 16: ~500/500 Mbit/s

Applies on top of net-next.
Thanks.

Alexander Lobakin (2):
net: core: use listified Rx for GRO_NORMAL in napi_gro_receive()
net: core: increase the default size of GRO_NORMAL skb lists to
flush

 net/core/dev.c | 51 
+++++++++++++++++++++++++-------------------------
 1 file changed, 26 insertions(+), 25 deletions(-)
Quoted 6 lines
Quoted 3 lines

--
2.23.0

Thanks
/Ilias

Regards,
ᚷ ᛖ ᚢ ᚦ ᚠ ᚱ

#14 lore raw

Hi Alexander,

Quoted 21 lines · Alexander Lobakin

Hi Ilias,

Ilias Apalodimas wrote 11.10.2019 15:23:

Quoted 18 lines

Hi Alexander,

Quoted 14 lines · Alexander Lobakin

Hi Dave,

This series was written as a continuation to commit 323ebb61e32b ("net: use listified RX for handling GRO_NORMAL skbs"), and also takes an advantage of listified Rx for GRO. This time, however, we're targeting at a way more common and used function, napi_gro_receive().

There are about ~100 call sites of this function, including gro_cells and mac80211, so even wireless systems will benefit from it. The only driver that cares about the return value is ethernet/socionext/netsec, and only for updating statistics. I don't believe that this change can break its functionality, but anyway, we have plenty of time till next merge window to pay this change a proper attention.

Quoted 8 lines
Quoted 4 lines

I don't think this will break anything on the netsec driver. Dropped packets
will still be properly accounted for

Thank you for clarification. Do I need to mention you under separate Acked-by in v2?

Well i only checked for the netsec part. I'll try having a look on the whole patch and send a proper Acked-by if i get some free time!

Quoted 26 lines
Quoted 26 lines
Quoted 25 lines

Besides having this functionality implemented for napi_gro_frags() users, the main reason is the solid performance boost that has been shown during tests on 1-core MIPS board (with not yet mainlined driver):

* no batching (5.4-rc2): ~450/450 Mbit/s
* with gro_normal_batch == 8: ~480/480 Mbit/s
* with gro_normal_batch == 16: ~500/500 Mbit/s

Applies on top of net-next.
Thanks.

Alexander Lobakin (2):
net: core: use listified Rx for GRO_NORMAL in napi_gro_receive()
net: core: increase the default size of GRO_NORMAL skb lists to
flush

 net/core/dev.c | 51
+++++++++++++++++++++++++-------------------------
 1 file changed, 26 insertions(+), 25 deletions(-)

--
2.23.0

Quoted 5 lines
Quoted 2 lines

Thanks
/Ilias

Regards,
ᚷ ᛖ ᚢ ᚦ ᚠ ᚱ

Regards
/Ilias