IPsec improvements
Subsystems (3)
cover IPsec improvements
This series moves pskb_put() to the core code -- making the code duplication in caif obsolete (patches 1 and 2).
Additionally does this series optimize the IPsec receive path in patch 3 by allowing skb_cow_data() to leave the buffer fragmented. I noticed the linearization to be a bottleneck when doing some VPN gateway benchmarks. Linearization of the buffer isn't needed in the receive path as the crypto API (and all other users of skb_cow_data) can handle sg.
With patch 3 applied I was able to increase the throughput of an IPsec gateway from 7.12 Gbit/s to 7.28 Gbit/s.
Please apply!
Mathias Krause (3):
net: move pskb_put() to core code
caif: use pskb_put() instead of reimplementing its functionality
net: allow to leave the buffer fragmented in skb_cow_data()
include/linux/skbuff.h | 1 + include/net/esp.h | 2 - net/caif/cfpkt_skbuff.c | 12 +---------- net/core/skbuff.c | 52 +++++++++++++++++++++++++++++++++++++---------- net/xfrm/xfrm_algo.c | 13 ----------- 5 files changed, 43 insertions(+), 37 deletions(-)
Signature · 1 line
1.7.2.5
PATCH 2/3 caif: use pskb_put() instead of reimplementing its functionality
Also remove the warning for fragmented packets -- skb_cow_data() will linearize the buffer, removing all fragments.
--- net/caif/cfpkt_skbuff.c | 12 +----------- 1 files changed, 1 insertions(+), 11 deletions(-)
net/caif/cfpkt_skbuff.c +1 -11
@@ -203,20 +203,10 @@ int cfpkt_add_body(struct cfpkt *pkt, const void *data, u16 len)PKT_ERROR (pkt,"cow failed\n" );return -EPROTO ; } -/* -* Is the SKB non-linear after skb_cow_data()? If so, we are -* going to add data to the last SKB, so we need to adjust -* lengths of the top SKB. -*/ -if (lastskb != skb) { -pr_warn ("Packet is non-linear\n" ); - skb->len += len; - skb->data_len += len; - } }/* All set to put the last SKB and optionally write data there. */ - to =skb_put (lastskb, len); + to =pskb_put (skb, lastskb, len);if (likely (data))memcpy (to, data, len);return 0 ;
Signature · 1 line
1.7.2.5
PATCH 1/3 net: move pskb_put() to core code
In reply to Mathias KrauseThis function has usage beside IPsec so move it to the core skbuff code. While doing so, give it some documentation and change its return type to 'unsigned char *' to be in line with skb_put().
--- include/linux/skbuff.h | 1 + include/net/esp.h | 2 -- net/core/skbuff.c | 23 +++++++++++++++++++++++ net/xfrm/xfrm_algo.c | 13 ------------- 4 files changed, 24 insertions(+), 15 deletions(-)
include/linux/skbuff.h +1 -0
@@ -1418,6 +1418,7 @@ static inline void skb_set_tail_pointer(struct sk_buff *skb, const int offset)/* * Add data to an sk_buff */ +unsigned char *pskb_put (struct sk_buff *skb,struct sk_buff *tail,int len);unsigned char *skb_put (struct sk_buff *skb,unsigned int len);static inline unsigned char *__skb_put (struct sk_buff *skb,unsigned int len) {
include/net/esp.h +0 -2
@@ -13,8 +13,6 @@ struct esp_data {#include <linux/skbuff.h> -void *pskb_put (struct sk_buff *skb,struct sk_buff *tail,int len); -struct ip_esp_hdr ;static inline struct ip_esp_hdr *ip_esp_hdr (const struct sk_buff *skb)
net/core/skbuff.c +23 -0
@@ -1257,6 +1257,29 @@ free_skb:EXPORT_SYMBOL (skb_pad);/** +* pskb_put - add data to the tail of a potentially fragmented buffer +* @skb: start of the buffer to use +* @tail: tail fragment of the buffer to use +* @len: amount of data to add +* +* This function extends the used data area of the potentially +* fragmented buffer. &tail must be the last fragment of &skb -- or +* &skb itself. If this would exceed the total buffer size the kernel +* will panic. A pointer to the first byte of the extra data is +* returned. +*/ + +unsigned char *pskb_put (struct sk_buff *skb,struct sk_buff *tail,int len) +{ +if (tail != skb) { + skb->data_len += len; + skb->len += len; + } +return skb_put (tail, len); +} +EXPORT_SYMBOL_GPL (pskb_put); + +/** * skb_put - add data to a buffer * @skb: buffer to use * @len: amount of data to add
net/xfrm/xfrm_algo.c +0 -13
@@ -802,17 +802,4 @@ int xfrm_count_pfkey_enc_supported(void) }EXPORT_SYMBOL_GPL (xfrm_count_pfkey_enc_supported); -#if defined(CONFIG_INET_ESP ) || defined(CONFIG_INET_ESP_MODULE ) || defined(CONFIG_INET6_ESP ) || defined(CONFIG_INET6_ESP_MODULE ) - -void *pskb_put (struct sk_buff *skb,struct sk_buff *tail,int len) -{ -if (tail != skb) { - skb->data_len += len; - skb->len += len; - } -return skb_put (tail, len); -} -EXPORT_SYMBOL_GPL (pskb_put); -#endif -MODULE_LICENSE ("GPL" );
Signature · 1 line
1.7.2.5
PATCH 3/3 net: allow to leave the buffer fragmented in skb_cow_data()
In reply to Mathias KrauseDo not linearize the buffer per se but only if we're expected to expand the tail. All callers can handle fragmented buffers and even expect them!
Not linearizing the buffer leads to a small performance improvement for the IPsec receive path in case the network driver passed us a fragmented buffer.
With this patch applied I was able to increase the throughput of an IPsec gateway from 7.12 Gbit/s to 7.28 Gbit/s.
--- net/core/skbuff.c | 29 ++++++++++++++++++----------- 1 files changed, 18 insertions(+), 11 deletions(-)
net/core/skbuff.c +18 -11
@@ -3207,7 +3207,7 @@ EXPORT_SYMBOL_GPL(skb_to_sgvec);* * If @tailbits is given, make sure that there is space to write @tailbits * bytes of data beyond current end of socket buffer. @trailer will be -* set to point to the skb in which this space begins. +* linearized and set to point to the skb in which this space begins. * * The number of scatterlist elements required to completely map the * COW'd and extended socket buffer will be returned.
@@ -3218,11 +3218,10 @@ int skb_cow_data(struct sk_buff *skb, int tailbits, struct sk_buff **trailer)int elt;struct sk_buff *skb1, **skb_p; -/* If skb is cloned or its head is paged, reallocate -* head pulling out all the pages (pages are considered not writable -* at the moment even if they are anonymous). +/* If skb is cloned reallocate head pulling out all the pages (pages are +* considered not writable at the moment even if they are anonymous). */ -if ((skb_cloned (skb) ||skb_shinfo (skb)->nr_frags) && +if (skb_cloned (skb) &&__pskb_pull_tail (skb,skb_pagelen (skb)-skb_headlen (skb)) ==NULL )return -ENOMEM ;
@@ -3233,18 +3232,26 @@ int skb_cow_data(struct sk_buff *skb, int tailbits, struct sk_buff **trailer)* good frames. OK, on miss we reallocate and reserve even more * space, 128 bytes is fair. */ -if (skb_tailroom (skb) < tailbits && -pskb_expand_head (skb,0 , tailbits-skb_tailroom (skb)+128 ,GFP_ATOMIC )) -return -ENOMEM ; +if (tailbits) { +if (skb_linearize (skb)) +return -ENOMEM ; + +if (skb_tailroom (skb) < tailbits) { +int ntail = tailbits -skb_tailroom (skb) +128 ; + +if (pskb_expand_head (skb,0 , ntail,GFP_ATOMIC )) +return -ENOMEM ; + } + }/* Voila! */ *trailer = skb; -return 1 ; +return skb_shinfo (skb)->nr_frags +1 ; }/* Misery. We are in troubles, going to mincer fragments... */ - elt =1 ; + elt =skb_shinfo (skb)->nr_frags +1 ; skb_p = &skb_shinfo (skb)->frag_list; copyflag =0 ;
@@ -3296,7 +3303,7 @@ int skb_cow_data(struct sk_buff *skb, int tailbits, struct sk_buff **trailer)kfree_skb (skb1); skb1 = skb2; } - elt++; + elt +=skb_shinfo (skb1)->nr_frags +1 ; *trailer = skb1; skb_p = &skb1->next; }
Signature · 1 line
1.7.2.5
Re: [PATCH net-next 3/3] net: allow to leave the buffer fragmented in skb_cow_data()
Quoted 10 lines · Mathias Krause
Do not linearize the buffer per se but only if we're expected to expand the tail. All callers can handle fragmented buffers and even expect them!
Not linearizing the buffer leads to a small performance improvement for the IPsec receive path in case the network driver passed us a fragmented buffer.
With this patch applied I was able to increase the throughput of an IPsec gateway from 7.12 Gbit/s to 7.28 Gbit/s.
What is the driver you used ?
Re: [PATCH net-next 3/3] net: allow to leave the buffer fragmented in skb_cow_data()
Quoted 5 lines · Eric Dumazet
Quoted 4 lines · Mathias Krause
Do not linearize the buffer per se but only if we're expected to expand the tail. All callers can handle fragmented buffers and even expect them!
Quoted 8 lines
Quoted 6 lines
Not linearizing the buffer leads to a small performance improvement for the IPsec receive path in case the network driver passed us a fragmented buffer.
With this patch applied I was able to increase the throughput of an IPsec gateway from 7.12 Gbit/s to 7.28 Gbit/s.
What is the driver you used ?
The device driver is ixgbe driving an Intel X520-T2. Why you're asking?
Re: [PATCH net-next 1/3] net: move pskb_put() to core code
In reply to Mathias KrauseQuoted 3 lines · Mathias Krause
This function has usage beside IPsec so move it to the core skbuff code. While doing so, give it some documentation and change its return type to 'unsigned char *' to be in line with
skb_put().
[...]
Quoted 4 lines
net/core/skbuff.c +0
-0@@ -1257,6 +1257,29 @@ free_skb:EXPORT_SYMBOL (skb_pad);
net/core/skbuff.c free_skb: · line 1267
Quoted 10 lines
net/core/skbuff.c +8
-0/** +* pskb_put - add data to the tail of a potentially fragmented buffer +* @skb: start of the buffer to use +* @tail: tail fragment of the buffer to use +* @len: amount of data to add +* +* This function extends the used data area of the potentially +* fragmented buffer. &tail must be the last fragment of &skb -- or +* &skb itself. If this would exceed the total buffer size the kernel
Keep using @ to refer to the parameters in this description.
Ben.
Quoted 3 lines
net/core/skbuff.c +3
-0+* will panic. A pointer to the first byte of the extra data is +* returned. +*/
[...]
Signature · 3 lines
Ben Hutchings, Staff Engineer, Solarflare Not speaking for my employer; that's the marketing department's job. They asked us to note that Solarflare product names are trademarked.
David Miller
maintainerFrom: Mathias Krause <[email protected]>
Date: Tue, 5 Nov 2013 14:54:08 +0100
Quoted 11 lines
This series moves
pskb_put()to the core code -- making the code duplication in caif obsolete (patches 1 and 2).Additionally does this series optimize the IPsec receive path in patch 3 by allowing
skb_cow_data()to leave the buffer fragmented. I noticed the linearization to be a bottleneck when doing some VPN gateway benchmarks. Linearization of the buffer isn't needed in the receive path as the crypto API (and all other users ofskb_cow_data) can handle sg.With patch 3 applied I was able to increase the throughput of an IPsec gateway from 7.12 Gbit/s to 7.28 Gbit/s.
Please deal with the feedback given to you by Ben about referring to variables with the '@' prefix consistently in comments, then resend this entire patch series.
Thanks.
Re: [PATCH net-next 1/3] net: move pskb_put() to core code
In reply to Ben HutchingsQuoted 22 lines · Ben Hutchings
Quoted 3 lines · Mathias Krause
This function has usage beside IPsec so move it to the core skbuff code. While doing so, give it some documentation and change its return type to 'unsigned char *' to be in line with
skb_put().[...]
Quoted 4 lines
net/core/skbuff.c +0
-0@@ -1257,6 +1257,29 @@ free_skb:EXPORT_SYMBOL (skb_pad);net/core/skbuff.c free_skb: · line 1267
Quoted 10 lines
net/core/skbuff.c +8
-0/** +* pskb_put - add data to the tail of a potentially fragmented buffer +* @skb: start of the buffer to use +* @tail: tail fragment of the buffer to use +* @len: amount of data to add +* +* This function extends the used data area of the potentially +* fragmented buffer. &tail must be the last fragment of &skb -- or +* &skb itself. If this would exceed the total buffer size the kernel Keep using @ to refer to the parameters in this description.
Quoted 1 line
Ben.
Thanks Ben. Looks like I looked at the wrong examples on how to do it. Will fix those as well.
Quoted 6 lines
Quoted 4 lines
net/core/skbuff.c +3
-0+* will panic. A pointer to the first byte of the extra data is +* returned. +*/ [...]
Quoted 12 lines · David Miller
From: Mathias Krause <[email protected]>
Date: Tue, 5 Nov 2013 14:54:08 +0100Quoted 9 lines
This series moves
pskb_put()to the core code -- making the code duplication in caif obsolete (patches 1 and 2).Additionally does this series optimize the IPsec receive path in patch 3 by allowing
skb_cow_data()to leave the buffer fragmented. I noticed the linearization to be a bottleneck when doing some VPN gateway benchmarks. Linearization of the buffer isn't needed in the receive path as the crypto API (and all other users ofskb_cow_data) can handle sg.
Quoted 6 lines
Quoted 2 lines
With patch 3 applied I was able to increase the throughput of an IPsec gateway from 7.12 Gbit/s to 7.28 Gbit/s.
Please deal with the feedback given to you by Ben about referring to variables with the '@' prefix consistently in comments, then resend this entire patch series.
Will do. Thanks, Dave.
Quoted 2 lines
Thanks.
Herbert Xu
maintainerRe: [PATCH net-next 3/3] net: allow to leave the buffer fragmented in skb_cow_data()
In reply to Mathias Krausenet/core/skbuff.c int skb_cow_data(struct sk_buff *skb, int tailbits, struct sk_buff **trailer) · line 3223
Quoted 7 lines · Mathias Krause
net/core/skbuff.c +2
-3-/* If skb is cloned or its head is paged, reallocate -* head pulling out all the pages (pages are considered not writable -* at the moment even if they are anonymous). +/* If skb is cloned reallocate head pulling out all the pages (pages are +* considered not writable at the moment even if they are anonymous). */
Hang on, you haven't explained why it is OK to write to pages. What if said page is owned by the virt host or some app?
Cheers,
Signature · 3 lines
Email: Herbert Xu <[email protected]> Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
Re: [PATCH net-next 3/3] net: allow to leave the buffer fragmented in skb_cow_data()
Quoted 9 lines · Herbert Xu
net/core/skbuff.c int skb_cow_data(struct sk_buff *skb, int tailbits, struct sk_buff **trailer) · line 3223
Quoted 6 lines · Mathias Krause
net/core/skbuff.c +2
-3-/* If skb is cloned or its head is paged, reallocate -* head pulling out all the pages (pages are considered not writable -* at the moment even if they are anonymous). +/* If skb is cloned reallocate head pulling out all the pages (pages are +* considered not writable at the moment even if they are anonymous). */ Hang on, you haven't explained why it is OK to write to pages.
Why wouldn't it if the skb isn't cloned?
Quoted 1 line
What if said page is owned by the virt host or some app?
How would one detect such a case. I could image not by testing skb_shinfo(skb)->nr_frags as it is right now?
Regards,
Mathias
Herbert Xu
maintainerRe: [PATCH net-next 3/3] net: allow to leave the buffer fragmented in skb_cow_data()
Quoted 5 lines · Mathias Krause
Quoted 1 line · Herbert Xu
Hang on, you haven't explained why it is OK to write to pages.
Why wouldn't it if the skb isn't cloned?
Because if it's owned by an entity outside our stack (e.g., virt host or app) then the skb itself won't be cloned.
Quoted 4 lines
Quoted 1 line
What if said page is owned by the virt host or some app?
How would one detect such a case. I could image not by testing skb_shinfo(skb)->nr_frags as it is right now?
You can't. That's why we always copy. If you want to do this properly then we'll need to add at least a bit to indicate whether the page originated from within the network stack and we have full ownership.
Cheers,
Signature · 3 lines
Email: Herbert Xu <[email protected]> Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
Re: [PATCH net-next 3/3] net: allow to leave the buffer fragmented in skb_cow_data()
Quoted 8 lines · Herbert Xu
Quoted 4 lines · Mathias Krause
Quoted 1 line · Herbert Xu
Hang on, you haven't explained why it is OK to write to pages.
Why wouldn't it if the skb isn't cloned?
Because if it's owned by an entity outside our stack (e.g., virt host or app) then the skb itself won't be cloned.
Ok.
Quoted 5 lines
Quoted 3 lines
Quoted 1 line
What if said page is owned by the virt host or some app?
How would one detect such a case. I could image not by testing skb_shinfo(skb)->nr_frags as it is right now?
You can't. That's why we always copy.
Well, skb_cow_data() will only copy, i.e. call __pskb_pull_tail(), in case the skb is either cloned or fragmented. As you already said it won't be cloned in your case. Does it contain fragments, i.e. is skb_shinfo(skb)->nr_frags != 0? If not, we won't copy with the current code either.
We *will* copy, though, if we're expected to expand the tailroom. That won't change in my patch as we'll linearize the skb in that case -- even if there would enough room in the skb. That's needed to not hit the SKB_LINEAR_ASSERT(skb) in skb_put().
Quoted 4 lines
If you want to do this
properly then we'll need to add at least a bit to indicate whether the page originated from within the network stack and we have full ownership.
Can you please explain why this would be needed? I still don't get the reasoning behind "pages are considered not writable at the moment even if they are anonymous".
skb_cow_data() is only used in those places:
- net/caif/cfpkt_skbuff.c
- net/ipv4/ah4.c
- net/ipv4/esp4.c
- net/ipv6/ah6.c
- net/ipv6/esp6.c
- net/rxrpc/rxkad.c
Can you explain how this change would be a problem for them?
Thanks,
Mathias
Herbert Xu
maintainerRe: [PATCH net-next 3/3] net: allow to leave the buffer fragmented in skb_cow_data()
Quoted 6 lines · Mathias Krause
Well,
skb_cow_data()will only copy, i.e. call__pskb_pull_tail(), in case the skb is either cloned or fragmented. As you already said it won't be cloned in your case. Does it contain fragments, i.e. is skb_shinfo(skb)->nr_frags != 0? If not, we won't copy with the current code either.
Whenever we say page it means nr_frags != 0. So currently as long as we have pages in our skb we will copy. With your patch we will no longer copy in the case where we have pages but the skb isn't cloned. In fact that is the whole point of your patch.
Quoted 3 lines
Can you please explain why this would be needed? I still don't get the reasoning behind "pages are considered not writable at the moment even if they are anonymous".
As I said you don't know where the page in the skb came from. It may point to read-only memory or memory that's shared with another task that isn't expecting things to change underneath it.
It may well turn out to most if not all cases of pages are safe to be written to if skb_cloned == 0. However, we'd need to do a full audit of every source of page frags to be sure. For example, you'd need to look at net drivers and splice.
Cheers,
Signature · 3 lines
Email: Herbert Xu <[email protected]> Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
Re: [PATCH net-next 3/3] net: allow to leave the buffer fragmented in skb_cow_data()
Quoted 13 lines · Herbert Xu
Quoted 6 lines · Mathias Krause
Well,
skb_cow_data()will only copy, i.e. call__pskb_pull_tail(), in case the skb is either cloned or fragmented. As you already said it won't be cloned in your case. Does it contain fragments, i.e. is skb_shinfo(skb)->nr_frags != 0? If not, we won't copy with the current code either.Whenever we say page it means
nr_frags!= 0. So currently as long as we have pages in our skb we will copy. With your patch we will no longer copy in the case where we have pages but the skb isn't cloned. In fact that is the whole point of your patch.
Quoted 7 lines
Quoted 3 lines
Can you please explain why this would be needed? I still don't get the reasoning behind "pages are considered not writable at the moment even if they are anonymous".
As I said you don't know where the page in the skb came from. It may point to read-only memory or memory that's shared with another task that isn't expecting things to change underneath it.
Note that we might have now a per skb flag telling is all page frags are owned.
This is SKBTX_SHARED_FRAG
If SKBTX_SHARED_FRAG is set on shared_info->tx_flags, then at least one frag is not safe and we must copy all frags.
For example, this flag is set in TCP sendfile() path (vmsplice()...), and zero copy paths in general (macvtap, tun)
I am not 100% sure, but this could be a hint.
Re: [PATCH net-next 3/3] net: allow to leave the buffer fragmented in skb_cow_data()
In reply to Herbert XuQuoted 11 lines · Herbert Xu
Quoted 5 lines · Mathias Krause
Well,
skb_cow_data()will only copy, i.e. call__pskb_pull_tail(), in case the skb is either cloned or fragmented. As you already said it won't be cloned in your case. Does it contain fragments, i.e. is skb_shinfo(skb)->nr_frags != 0? If not, we won't copy with the current code either.Whenever we say page it means
nr_frags!= 0. So currently as long as we have pages in our skb we will copy. With your patch we will no longer copy in the case where we have pages but the skb isn't cloned. In fact that is the whole point of your patch.
Indeed. I want to avoid the costly memcpy() on the CPU serving the NIC interrupt, as that is a bottleneck in my setup. The packet processing -- encrypting/decrypting of ESP packets -- gets mostly parallelized via pcrypt, so that's fine. But the initial network processing, i.e. getting to pcrypt, is what's throttling the throughput currently. (RPS only partly solves this problem as for the ESP receive path most traffic ends up on the same flow).
Quoted 4 lines
Quoted 3 lines
Can you please explain why this would be needed? I still don't get the reasoning behind "pages are considered not writable at the moment even if they are anonymous".
Quoted 8 lines
As I said you don't know where the page in the skb came from. It may point to read-only memory or memory that's shared with another task that isn't expecting things to change underneath it.
It may well turn out to most if not all cases of pages are safe to be written to if
skb_cloned== 0. However, we'd need to do a full audit of every source of page frags to be sure. For example, you'd need to look at net drivers and splice.
Ah, okay. Now that makes sense. I'll look into it.
Thanks,
Mathias
Re: [PATCH net-next 3/3] net: allow to leave the buffer fragmented in skb_cow_data()
In reply to Eric DumazetQuoted 24 lines · Eric Dumazet
Quoted 11 lines · Herbert Xu
Quoted 5 lines · Mathias Krause
Well,
skb_cow_data()will only copy, i.e. call__pskb_pull_tail(), in case the skb is either cloned or fragmented. As you already said it won't be cloned in your case. Does it contain fragments, i.e. is skb_shinfo(skb)->nr_frags != 0? If not, we won't copy with the current code either.Whenever we say page it means
nr_frags!= 0. So currently as long as we have pages in our skb we will copy. With your patch we will no longer copy in the case where we have pages but the skb isn't cloned. In fact that is the whole point of your patch.Quoted 6 lines
Quoted 3 lines
Can you please explain why this would be needed? I still don't get the reasoning behind "pages are considered not writable at the moment even if they are anonymous".
As I said you don't know where the page in the skb came from. It may point to read-only memory or memory that's shared with another task that isn't expecting things to change underneath it.
Note that we might have now a per skb flag telling is all page frags are owned.
This is
SKBTX_SHARED_FRAG
Quoted 8 lines
If
SKBTX_SHARED_FRAGis set onshared_info->tx_flags, then at least one frag is not safe and we must copy all frags.For example, this flag is set in TCP
sendfile()path (vmsplice()...), and zero copy paths in general (macvtap, tun)I am not 100% sure, but this could be a hint.
Thanks for the hint, Eric!
Mathias
Herbert Xu
maintainerRe: [PATCH net-next 3/3] net: allow to leave the buffer fragmented in skb_cow_data()
In reply to Mathias KrauseQuoted 8 lines · Mathias Krause
Indeed. I want to avoid the costly
memcpy()on the CPU serving the NIC interrupt, as that is a bottleneck in my setup. The packet processing -- encrypting/decrypting of ESP packets -- gets mostly parallelized via pcrypt, so that's fine. But the initial network processing, i.e. getting to pcrypt, is what's throttling the throughput currently. (RPS only partly solves this problem as for the ESP receive path most traffic ends up on the same flow).
How about this: instead of doing in-place encryption/decryption let's allocate a new destination buffer and encrypt/decrypt into it. Then we essentially get the copy for free.
So instead of modifying skb_cow_data you can change esp4.c, etc.
Cheers,
Signature · 3 lines
Email: Herbert Xu <[email protected]> Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
Re: [PATCH net-next 3/3] net: allow to leave the buffer fragmented in skb_cow_data()
Quoted 9 lines · Herbert Xu
Quoted 7 lines · Mathias Krause
Indeed. I want to avoid the costly
memcpy()on the CPU serving the NIC interrupt, as that is a bottleneck in my setup. The packet processing -- encrypting/decrypting of ESP packets -- gets mostly parallelized via pcrypt, so that's fine. But the initial network processing, i.e. getting to pcrypt, is what's throttling the throughput currently. (RPS only partly solves this problem as for the ESP receive path most traffic ends up on the same flow).
Quoted 5 lines
How about this: instead of doing in-place encryption/decryption let's allocate a new destination buffer and encrypt/decrypt into it. Then we essentially get the copy for free.
So instead of modifying
skb_cow_datayou can changeesp4.c, etc.
That might be another option. But I fear it might affect performance due to caching or NUMA effects. :/
I'll think about it and will try to investigate both approaches.
Thanks,
Mathias