From owner-freebsd-net@freebsd.org Sun Mar 28 11:46:07 2021 Return-Path: Delivered-To: freebsd-net@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 3B0EA5BE0D0 for ; Sun, 28 Mar 2021 11:46:07 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from mailman.nyi.freebsd.org (mailman.nyi.freebsd.org [IPv6:2610:1c1:1:606c::50:13]) by mx1.freebsd.org (Postfix) with ESMTP id 4F7YnW11NGz4WTp for ; Sun, 28 Mar 2021 11:46:07 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: by mailman.nyi.freebsd.org (Postfix) id 20E145BE311; Sun, 28 Mar 2021 11:46:07 +0000 (UTC) Delivered-To: net@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 20A845BE310 for ; Sun, 28 Mar 2021 11:46:07 +0000 (UTC) (envelope-from bugzilla-noreply@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 4F7YnW0LPlz4Wcy for ; Sun, 28 Mar 2021 11:46:07 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org (kenobi.freebsd.org [IPv6:2610:1c1:1:606c::50:1d]) (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 ECC341F982 for ; Sun, 28 Mar 2021 11:46:06 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org ([127.0.1.5]) by kenobi.freebsd.org (8.15.2/8.15.2) with ESMTP id 12SBk64e092729 for ; Sun, 28 Mar 2021 11:46:06 GMT (envelope-from bugzilla-noreply@freebsd.org) Received: (from www@localhost) by kenobi.freebsd.org (8.15.2/8.15.2/Submit) id 12SBk6fm092728 for net@FreeBSD.org; Sun, 28 Mar 2021 11:46:06 GMT (envelope-from bugzilla-noreply@freebsd.org) X-Authentication-Warning: kenobi.freebsd.org: www set sender to bugzilla-noreply@freebsd.org using -f From: bugzilla-noreply@freebsd.org To: net@FreeBSD.org Subject: [Bug 254333] [tcp] sysctl net.inet.tcp.hostcache.list hangs Date: Sun, 28 Mar 2021 11:46:06 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Base System X-Bugzilla-Component: kern X-Bugzilla-Version: 11.4-STABLE X-Bugzilla-Keywords: X-Bugzilla-Severity: Affects Only Me X-Bugzilla-Who: rscheff@freebsd.org X-Bugzilla-Status: New X-Bugzilla-Resolution: X-Bugzilla-Priority: --- X-Bugzilla-Assigned-To: net@FreeBSD.org X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: cc Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: https://bugs.freebsd.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 28 Mar 2021 11:46:07 -0000 https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D254333 Richard Scheffenegger changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |rscheff@freebsd.org --- Comment #4 from Richard Scheffenegger --- I just noticed, that sysctl will actually do a syscall to sysctl twice. First, with no buffer space - expecting to receive the size to allocate for= a buffer, then it tries to allocate twice as much buffer (apparently "for reasons"), before doing the syscall to sysctl a 2nd time. As the system continues to run, I am curious how large the list of hostcache entries is just prior to the "freeze" (of sysctl), and if the system may be space-constrained. Note that during the call, it appears that both kernel and userspace need memory (twice as much in the userspace). userspace seems to use a non-block= ing malloc call, after the first round where the return length is checked. Possibly the system has a hard time allocating a sufficiently large chunk of memory, if the hostcache is fully utilized and extremely busy... In sbuf_new, the kernel is trying a malloc(size, M_SBUF, M_WAITOK|M_ZERO)... Perhaps the sysctl callback procedure could be improved to=20 a) not actually allocate memory when the user has not yet provided a buffer= to fill - only return the require size (reducing the chances to run out-of-spa= ce somewhat) b) not allocate a huge chunk in sbuf_new right away, but use sbuf_extend repeatedly (although sbuf.c will actually grab a larger chunk of memory, co= py the data over,and release the old chunk - thus driving temporary memory requirements higher c) use a different memory model supporting disjoint segments of a c-string scattered in smaller memory chunks, subsequently concatenating them on the SYSCTL_OUT. d) change the M_WAITOK in /kern/subr_sbuf.c#59 to M_NOWAIT and expect an er= ror on very busy systems every once in a while. As a reasonable short term fix, I guess a combination of M_NOWAIT in sbuf.c= and use of sbuf_new(smaller size) / sbuf_extend(smaller_size) may be the prudent approach, if this turns out to be the culprit. --=20 You are receiving this mail because: You are the assignee for the bug.=