From nobody Wed Aug 17 18:52:16 2022 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4M7HFD40fdz4YxkV; Wed, 17 Aug 2022 18:52:16 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4M7HFD2YV2z4CnD; Wed, 17 Aug 2022 18:52:16 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1660762336; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=e2idi3lVk07lK+uyGLQ9Yv5XjBqsYmMmV4n2MOcZZf0=; b=Qcsg0TTTj1yO2E+DtOODZMcTwGfmybUIrR092IjsmhBWNIIYF75f5fsLVCnLbrtTtl9wOz 1L2EiIeQERujOvImqv+clWgxjZwPo8cZrFGPRhsVsNCCi0A74EzVezoIjzLUhb+Sgo5EFP FsJhE6bMOGFoATDqGC4T6oUip2Dhy13ak8r3xkqjBrt/mOxotZWhkREjHIoXGlnOpU2hIx pGdfB+wFzFGg5rBtTVhuMPEhrevSLvhB512yEnpTcclB9Ia+2CsCn6lb3VWe7dIRBP9cLt JaRXMHsSxhb7b7KzksGQ/KXT85G5gbuu8lkBFdHMMvEX8oS+1kS9fn1oPobSkQ== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4M7HFD1RSpz10w9; Wed, 17 Aug 2022 18:52:16 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 27HIqG7j012982; Wed, 17 Aug 2022 18:52:16 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 27HIqGsh012981; Wed, 17 Aug 2022 18:52:16 GMT (envelope-from git) Date: Wed, 17 Aug 2022 18:52:16 GMT Message-Id: <202208171852.27HIqGsh012981@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Gleb Smirnoff Subject: git: 6c452841ef9b - main - tcp: use callout(9) directly instead of pr_slowtimo List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: glebius X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 6c452841ef9b3fff4602694940c25b5c6bd077e1 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1660762336; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=e2idi3lVk07lK+uyGLQ9Yv5XjBqsYmMmV4n2MOcZZf0=; b=KFbwzYviZ4VdQWVfMs8Fuv7NiOXEwZVUTyckgawtn5Y4x7qGtXPakyuuERPDZOkR+vLx/d 02fxOh9HN/q8vl0wP/sk3CZ+IkCK25f4084CIkB3TtIJZDEw0AGWvKzmFmLh4AV+wcHL5r 5gKYg0T1P3n11hrXW1NprXlJkGZnCyfnBuJWFjKmGrsJfnu3FX0sr8m7Lyt6wpVEVl5acl lWvorg//mGR+IYE5rCKPqJ4McU5bFblvoqS64NQ6CELPEGjizNgyJimeCmg0EfvKaNusG6 7tr4zQK4iWEIOIAedOozCFN9bDv+UyyY8D++aD+mbr2tpGe+VXHgNrjzC4qO4A== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1660762336; a=rsa-sha256; cv=none; b=hADFhB0PQFZ0DozR4AbzrYYF8/oX2KzYgBiQLD4aUNP7DdLT3ZZXH3I9aUZxDIsTz1DNSg wG/YLlVkLGQ2FJU9NrjVNbdmqZ/fh+tKmJT4fw/7oU9kChba2Sm6SbOZNSVc8ye/JF8kpZ XYdeUngxcwoOi/vcETqhrY8TwN1OTIwiU7b8DOaq8K0XpwV9z4QL9x9/Rza/WACUBrsR4S qKg6IGHIKCs7Xf29kDb9hbiSh6CdLGvxUEG1HYXoFiPfA+cblmkYyu13N1bMnvmUc3htK8 nky6+tn8BBAGjXjt9Isx9ORYG3nVN9p7VZH6Azpl0V7quBB8Kii2HiW1hmlHOg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by glebius: URL: https://cgit.FreeBSD.org/src/commit/?id=6c452841ef9b3fff4602694940c25b5c6bd077e1 commit 6c452841ef9b3fff4602694940c25b5c6bd077e1 Author: Gleb Smirnoff AuthorDate: 2022-08-17 18:50:31 +0000 Commit: Gleb Smirnoff CommitDate: 2022-08-17 18:50:31 +0000 tcp: use callout(9) directly instead of pr_slowtimo Modern TCP stacks uses multiple callouts per tcpcb, and a global callout is ancient artifact. However it is still used to garbage collect compressed timewait entries. Reviewed by: melifaro, tuexen Differential revision: https://reviews.freebsd.org/D36159 --- sys/netinet/in_proto.c | 1 - sys/netinet/tcp_timer.c | 26 +++++++++++++++++++++----- sys/netinet/tcp_var.h | 1 - sys/netinet6/in6_proto.c | 1 - 4 files changed, 21 insertions(+), 8 deletions(-) diff --git a/sys/netinet/in_proto.c b/sys/netinet/in_proto.c index 615b4f1a4080..b9e9dbdc8f88 100644 --- a/sys/netinet/in_proto.c +++ b/sys/netinet/in_proto.c @@ -131,7 +131,6 @@ struct protosw inetsw[] = { .pr_flags = PR_CONNREQUIRED|PR_IMPLOPCL|PR_WANTRCVD| PR_CAPATTACH, .pr_ctloutput = tcp_ctloutput, - .pr_slowtimo = tcp_slowtimo, .pr_drain = tcp_drain, .pr_usrreqs = &tcp_usrreqs }, diff --git a/sys/netinet/tcp_timer.c b/sys/netinet/tcp_timer.c index 8594ad3a65fa..e5af5cf5afef 100644 --- a/sys/netinet/tcp_timer.c +++ b/sys/netinet/tcp_timer.c @@ -233,15 +233,17 @@ inp_to_cpuid(struct inpcb *inp) } /* - * Tcp protocol timeout routine called every 500 ms. - * Updates timestamps used for TCP - * causes finite state machine actions if timers expire. + * Legacy TCP global callout routine called every 500 ms. + * Used to cleanup timewait states, which lack their own callouts. */ -void -tcp_slowtimo(void) +static struct callout tcpslow_callout; +static void +tcp_slowtimo(void *arg __unused) { + struct epoch_tracker et; VNET_ITERATOR_DECL(vnet_iter); + NET_EPOCH_ENTER(et); VNET_LIST_RLOCK_NOSLEEP(); VNET_FOREACH(vnet_iter) { CURVNET_SET(vnet_iter); @@ -249,7 +251,21 @@ tcp_slowtimo(void) CURVNET_RESTORE(); } VNET_LIST_RUNLOCK_NOSLEEP(); + NET_EPOCH_EXIT(et); + + callout_reset_sbt(&tcpslow_callout, SBT_1MS * 500, SBT_1MS * 10, + tcp_slowtimo, NULL, 0); +} + +static void +tcp_slowtimo_init(void *arg __unused) +{ + + callout_init(&tcpslow_callout, 1); + callout_reset_sbt(&tcpslow_callout, SBT_1MS * 500, SBT_1MS * 10, + tcp_slowtimo, NULL, 0); } +SYSINIT(tcp_timer, SI_SUB_VNET_DONE, SI_ORDER_ANY, tcp_slowtimo_init, NULL); int tcp_backoff[TCP_MAXRXTSHIFT + 1] = { 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 512, 512, 512 }; diff --git a/sys/netinet/tcp_var.h b/sys/netinet/tcp_var.h index 6d6c711f25b7..fa86ab51d68b 100644 --- a/sys/netinet/tcp_var.h +++ b/sys/netinet/tcp_var.h @@ -1187,7 +1187,6 @@ void tcp_tw_zone_change(void); int tcp_twcheck(struct inpcb *, struct tcpopt *, struct tcphdr *, struct mbuf *, int); void tcp_setpersist(struct tcpcb *); -void tcp_slowtimo(void); void tcp_record_dsack(struct tcpcb *tp, tcp_seq start, tcp_seq end, int tlp); struct tcptemp * tcpip_maketemplate(struct inpcb *); diff --git a/sys/netinet6/in6_proto.c b/sys/netinet6/in6_proto.c index 2b70e38fe193..0e413dc5b048 100644 --- a/sys/netinet6/in6_proto.c +++ b/sys/netinet6/in6_proto.c @@ -166,7 +166,6 @@ struct protosw inet6sw[] = { PR_LISTEN|PR_CAPATTACH, .pr_ctloutput = tcp_ctloutput, #ifndef INET /* don't call initialization, timeout, and drain routines twice */ - .pr_slowtimo = tcp_slowtimo, .pr_drain = tcp_drain, #endif .pr_usrreqs = &tcp6_usrreqs,