diff options
author | Doron Roberts-Kedes <doronrk@fb.com> | 2018-06-06 12:33:28 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2018-06-06 14:07:53 -0400 |
commit | 7170e6045a6a8b33f4fa5753589dc77b16198e2d (patch) | |
tree | d0b3c5b6035ce9ca8ef2fbfc01964221be142441 | |
parent | fb1967a69f756073362b8f19347f863f227320ad (diff) |
strparser: Add __strp_unpause and use it in ktls.
strp_unpause queues strp_work in order to parse any messages that
arrived while the strparser was paused. However, the process invoking
strp_unpause could eagerly parse a buffered message itself if it held
the sock lock.
__strp_unpause is an alternative to strp_pause that avoids the scheduling
overhead that results when a receiving thread unpauses the strparser
and waits for the next message to be delivered by the workqueue thread.
This patch more than doubled the IOPS achieved in a benchmark of NBD
traffic encrypted using ktls.
Signed-off-by: Doron Roberts-Kedes <doronrk@fb.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | include/net/strparser.h | 2 | ||||
-rw-r--r-- | net/strparser/strparser.c | 13 | ||||
-rw-r--r-- | net/tls/tls_sw.c | 2 |
3 files changed, 16 insertions, 1 deletions
diff --git a/include/net/strparser.h b/include/net/strparser.h index d96b59f45eba..f177c87ce38b 100644 --- a/include/net/strparser.h +++ b/include/net/strparser.h | |||
@@ -90,6 +90,8 @@ static inline void strp_pause(struct strparser *strp) | |||
90 | 90 | ||
91 | /* May be called without holding lock for attached socket */ | 91 | /* May be called without holding lock for attached socket */ |
92 | void strp_unpause(struct strparser *strp); | 92 | void strp_unpause(struct strparser *strp); |
93 | /* Must be called with process lock held (lock_sock) */ | ||
94 | void __strp_unpause(struct strparser *strp); | ||
93 | 95 | ||
94 | static inline void save_strp_stats(struct strparser *strp, | 96 | static inline void save_strp_stats(struct strparser *strp, |
95 | struct strp_aggr_stats *agg_stats) | 97 | struct strp_aggr_stats *agg_stats) |
diff --git a/net/strparser/strparser.c b/net/strparser/strparser.c index 092bebc70048..1a9695183599 100644 --- a/net/strparser/strparser.c +++ b/net/strparser/strparser.c | |||
@@ -512,6 +512,19 @@ int strp_init(struct strparser *strp, struct sock *sk, | |||
512 | } | 512 | } |
513 | EXPORT_SYMBOL_GPL(strp_init); | 513 | EXPORT_SYMBOL_GPL(strp_init); |
514 | 514 | ||
515 | /* Sock process lock held (lock_sock) */ | ||
516 | void __strp_unpause(struct strparser *strp) | ||
517 | { | ||
518 | strp->paused = 0; | ||
519 | |||
520 | if (strp->need_bytes) { | ||
521 | if (strp_peek_len(strp) < strp->need_bytes) | ||
522 | return; | ||
523 | } | ||
524 | strp_read_sock(strp); | ||
525 | } | ||
526 | EXPORT_SYMBOL_GPL(__strp_unpause); | ||
527 | |||
515 | void strp_unpause(struct strparser *strp) | 528 | void strp_unpause(struct strparser *strp) |
516 | { | 529 | { |
517 | strp->paused = 0; | 530 | strp->paused = 0; |
diff --git a/net/tls/tls_sw.c b/net/tls/tls_sw.c index 839e1e165a0c..8ca57d01b18f 100644 --- a/net/tls/tls_sw.c +++ b/net/tls/tls_sw.c | |||
@@ -735,7 +735,7 @@ static bool tls_sw_advance_skb(struct sock *sk, struct sk_buff *skb, | |||
735 | /* Finished with message */ | 735 | /* Finished with message */ |
736 | ctx->recv_pkt = NULL; | 736 | ctx->recv_pkt = NULL; |
737 | kfree_skb(skb); | 737 | kfree_skb(skb); |
738 | strp_unpause(&ctx->strp); | 738 | __strp_unpause(&ctx->strp); |
739 | 739 | ||
740 | return true; | 740 | return true; |
741 | } | 741 | } |