]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commitdiff
strparser: Add __strp_unpause and use it in ktls.
authorDoron Roberts-Kedes <doronrk@fb.com>
Wed, 6 Jun 2018 16:33:28 +0000 (09:33 -0700)
committerDavid S. Miller <davem@davemloft.net>
Wed, 6 Jun 2018 18:07:53 +0000 (14:07 -0400)
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>
include/net/strparser.h
net/strparser/strparser.c
net/tls/tls_sw.c

index d96b59f45ebaac1280f1ca53bb923a0147ade6a9..f177c87ce38bd1919eab1f07f14b8c07006883eb 100644 (file)
@@ -90,6 +90,8 @@ static inline void strp_pause(struct strparser *strp)
 
 /* May be called without holding lock for attached socket */
 void strp_unpause(struct strparser *strp);
+/* Must be called with process lock held (lock_sock) */
+void __strp_unpause(struct strparser *strp);
 
 static inline void save_strp_stats(struct strparser *strp,
                                   struct strp_aggr_stats *agg_stats)
index 092bebc7004835fc4ad56a5474e16c6876c910ac..1a96951835999091c81ba451700f0a74565d9c59 100644 (file)
@@ -512,6 +512,19 @@ int strp_init(struct strparser *strp, struct sock *sk,
 }
 EXPORT_SYMBOL_GPL(strp_init);
 
+/* Sock process lock held (lock_sock) */
+void __strp_unpause(struct strparser *strp)
+{
+       strp->paused = 0;
+
+       if (strp->need_bytes) {
+               if (strp_peek_len(strp) < strp->need_bytes)
+                       return;
+       }
+       strp_read_sock(strp);
+}
+EXPORT_SYMBOL_GPL(__strp_unpause);
+
 void strp_unpause(struct strparser *strp)
 {
        strp->paused = 0;
index 839e1e165a0c619fecafe2afacc62728774d271b..8ca57d01b18f6bfc55a06bcc0c21d6220c7a01d5 100644 (file)
@@ -735,7 +735,7 @@ static bool tls_sw_advance_skb(struct sock *sk, struct sk_buff *skb,
        /* Finished with message */
        ctx->recv_pkt = NULL;
        kfree_skb(skb);
-       strp_unpause(&ctx->strp);
+       __strp_unpause(&ctx->strp);
 
        return true;
 }