Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/netinet Run tcp_slowtimo in workqueue if NET_MPSAFE
details: https://anonhg.NetBSD.org/src/rev/8f1415db3457
branches: trunk
changeset: 358837:8f1415db3457
user: ozaki-r <ozaki-r%NetBSD.org@localhost>
date: Fri Jan 19 07:53:01 2018 +0000
description:
Run tcp_slowtimo in workqueue if NET_MPSAFE
If NET_MPSAFE is enabled, we have to avoid taking softnet_lock in softint as
much as possible to prevent any softint handlers including callout handlers
such as tcp_slowtimo from sticking on softnet_lock because it results in
undesired delays of executing subsequent softint handlers.
NFCI for !NET_MPSAFE
diffstat:
sys/netinet/tcp_subr.c | 9 +++------
sys/netinet/tcp_timer.c | 46 ++++++++++++++++++++++++++++++++++++++++++----
sys/netinet/tcp_timer.h | 3 ++-
sys/netinet/tcp_var.h | 4 +---
4 files changed, 48 insertions(+), 14 deletions(-)
diffs (171 lines):
diff -r bfc9b9a41ec8 -r 8f1415db3457 sys/netinet/tcp_subr.c
--- a/sys/netinet/tcp_subr.c Fri Jan 19 07:52:37 2018 +0000
+++ b/sys/netinet/tcp_subr.c Fri Jan 19 07:53:01 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: tcp_subr.c,v 1.271 2017/07/29 05:08:48 maxv Exp $ */
+/* $NetBSD: tcp_subr.c,v 1.272 2018/01/19 07:53:01 ozaki-r Exp $ */
/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -91,7 +91,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: tcp_subr.c,v 1.271 2017/07/29 05:08:48 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tcp_subr.c,v 1.272 2018/01/19 07:53:01 ozaki-r Exp $");
#ifdef _KERNEL_OPT
#include "opt_inet.h"
@@ -382,8 +382,6 @@
struct mowner tcp_sock_tx_mowner = MOWNER_INIT("tcp", "sock tx");
#endif
-callout_t tcp_slowtimo_ch;
-
static int
do_tcpinit(void)
{
@@ -424,8 +422,7 @@
vtw_earlyinit();
- callout_init(&tcp_slowtimo_ch, CALLOUT_MPSAFE);
- callout_reset(&tcp_slowtimo_ch, 1, tcp_slowtimo, NULL);
+ tcp_slowtimo_init();
return 0;
}
diff -r bfc9b9a41ec8 -r 8f1415db3457 sys/netinet/tcp_timer.c
--- a/sys/netinet/tcp_timer.c Fri Jan 19 07:52:37 2018 +0000
+++ b/sys/netinet/tcp_timer.c Fri Jan 19 07:53:01 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: tcp_timer.c,v 1.92 2017/07/28 19:16:41 maxv Exp $ */
+/* $NetBSD: tcp_timer.c,v 1.93 2018/01/19 07:53:01 ozaki-r Exp $ */
/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -93,11 +93,12 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: tcp_timer.c,v 1.92 2017/07/28 19:16:41 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tcp_timer.c,v 1.93 2018/01/19 07:53:01 ozaki-r Exp $");
#ifdef _KERNEL_OPT
#include "opt_inet.h"
#include "opt_tcp_debug.h"
+#include "opt_net_mpsafe.h"
#endif
#include <sys/param.h>
@@ -108,6 +109,8 @@
#include <sys/protosw.h>
#include <sys/errno.h>
#include <sys/kernel.h>
+#include <sys/callout.h>
+#include <sys/workqueue.h>
#include <net/if.h>
@@ -149,6 +152,15 @@
int tcp_maxpersistidle = 0; /* max idle time in persist */
+static callout_t tcp_slowtimo_ch;
+#ifdef NET_MPSAFE
+static struct workqueue *tcp_slowtimo_wq;
+static struct work tcp_slowtimo_wk;
+#endif
+
+static void tcp_slowtimo_work(struct work *, void *);
+static void tcp_slowtimo(void *);
+
/*
* Time to delay the ACK. This is initialized in tcp_init(), unless
* its patched.
@@ -193,6 +205,21 @@
tcp_delack_ticks = TCP_DELACK_TICKS;
}
+void
+tcp_slowtimo_init(void)
+{
+#ifdef NET_MPSAFE
+ int error;
+
+ error = workqueue_create(&tcp_slowtimo_wq, "tcp_slowtimo",
+ tcp_slowtimo_work, NULL, PRI_SOFTNET, IPL_SOFTNET, WQ_MPSAFE);
+ if (error != 0)
+ panic("%s: workqueue_create failed (%d)\n", __func__, error);
+#endif
+ callout_init(&tcp_slowtimo_ch, CALLOUT_MPSAFE);
+ callout_reset(&tcp_slowtimo_ch, 1, tcp_slowtimo, NULL);
+}
+
/*
* Callout to process delayed ACKs for a TCPCB.
*/
@@ -229,8 +256,8 @@
* Updates the timers in all active tcb's and
* causes finite state machine actions if timers expire.
*/
-void
-tcp_slowtimo(void *arg)
+static void
+tcp_slowtimo_work(struct work *wk, void *arg)
{
mutex_enter(softnet_lock);
@@ -241,6 +268,17 @@
callout_schedule(&tcp_slowtimo_ch, hz / PR_SLOWHZ);
}
+static void
+tcp_slowtimo(void *arg)
+{
+
+#ifdef NET_MPSAFE
+ workqueue_enqueue(tcp_slowtimo_wq, &tcp_slowtimo_wk, NULL);
+#else
+ tcp_slowtimo_work(NULL, NULL);
+#endif
+}
+
/*
* Cancel all timers for TCP tp.
*/
diff -r bfc9b9a41ec8 -r 8f1415db3457 sys/netinet/tcp_timer.h
--- a/sys/netinet/tcp_timer.h Fri Jan 19 07:52:37 2018 +0000
+++ b/sys/netinet/tcp_timer.h Fri Jan 19 07:53:01 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: tcp_timer.h,v 1.28 2011/05/24 18:37:52 gdt Exp $ */
+/* $NetBSD: tcp_timer.h,v 1.29 2018/01/19 07:53:01 ozaki-r Exp $ */
/*-
* Copyright (c) 2001, 2005 The NetBSD Foundation, Inc.
@@ -190,6 +190,7 @@
extern const int tcp_backoff[];
void tcp_timer_init(void);
+void tcp_slowtimo_init(void);
#endif
#endif /* !_NETINET_TCP_TIMER_H_ */
diff -r bfc9b9a41ec8 -r 8f1415db3457 sys/netinet/tcp_var.h
--- a/sys/netinet/tcp_var.h Fri Jan 19 07:52:37 2018 +0000
+++ b/sys/netinet/tcp_var.h Fri Jan 19 07:53:01 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: tcp_var.h,v 1.181 2017/11/15 09:55:22 ozaki-r Exp $ */
+/* $NetBSD: tcp_var.h,v 1.182 2018/01/19 07:53:01 ozaki-r Exp $ */
/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -928,8 +928,6 @@
int tcp_signature_compute(struct mbuf *, struct tcphdr *, int, int,
int, u_char *, u_int);
#endif
-void tcp_slowtimo(void *);
-extern callout_t tcp_slowtimo_ch;
void tcp_fasttimo(void);
struct mbuf *
tcp_template(struct tcpcb *);
Home |
Main Index |
Thread Index |
Old Index