Skip to content

Commit 7170e60

Browse files
Doron Roberts-Kedesdavem330
authored andcommitted
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 <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent fb1967a commit 7170e60

File tree

3 files changed

+16
-1
lines changed

3 files changed

+16
-1
lines changed

include/net/strparser.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,8 @@ static inline void strp_pause(struct strparser *strp)
9090

9191
/* May be called without holding lock for attached socket */
9292
void strp_unpause(struct strparser *strp);
93+
/* Must be called with process lock held (lock_sock) */
94+
void __strp_unpause(struct strparser *strp);
9395

9496
static inline void save_strp_stats(struct strparser *strp,
9597
struct strp_aggr_stats *agg_stats)

net/strparser/strparser.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -512,6 +512,19 @@ int strp_init(struct strparser *strp, struct sock *sk,
512512
}
513513
EXPORT_SYMBOL_GPL(strp_init);
514514

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+
515528
void strp_unpause(struct strparser *strp)
516529
{
517530
strp->paused = 0;

net/tls/tls_sw.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -735,7 +735,7 @@ static bool tls_sw_advance_skb(struct sock *sk, struct sk_buff *skb,
735735
/* Finished with message */
736736
ctx->recv_pkt = NULL;
737737
kfree_skb(skb);
738-
strp_unpause(&ctx->strp);
738+
__strp_unpause(&ctx->strp);
739739

740740
return true;
741741
}

0 commit comments

Comments
 (0)