From nobody Fri Jul 22 23:27:45 2022 X-Original-To: dev-commits-src-all@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 4LqQbB5gd9z4XD89; Fri, 22 Jul 2022 23:27:50 +0000 (UTC) (envelope-from kp@FreeBSD.org) Received: from smtp.freebsd.org (smtp.freebsd.org [96.47.72.83]) (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 "smtp.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4LqQbB5B6nz3y03; Fri, 22 Jul 2022 23:27:50 +0000 (UTC) (envelope-from kp@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1658532470; 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: in-reply-to:in-reply-to:references:references; bh=VUH88RMG9LEMMSvAAxWm/KDUlcX//YYNl7Z4PW8kLP0=; b=jUo8R6ZCjSRsqGz5FKNCqHYWgLizMuqI1ntNThF2/NueD7/cwMFt8wPgrUJ8UV241RS5i+ Ix8bQVqM64bgzxmwqBUJA0Iq31a+mfn35o4zkdA5avY+3MTeXnxl/Xk1cMZgWEyWwog2kI OmSvwxPrmIdkZLjHoAyRwyHzNU7vZOu7SB7oeGffQgDjV/sKlzh4oQ9YpRGVujxn2Bh5kC G7GoizKovjukZtDhgdayusaT4+CYGyqIF2F7EKAd917lcDjgUNKhRwhIYYN7Mx+k/0kQ7Z +Ft8ZgsGuI4oFQBz2AzDypUiKQEL/3nGtGuWYtOhcSUDpDdx5IVkTDFwApbLpA== Received: from venus.codepro.be (venus.codepro.be [5.9.86.228]) (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 (2048 bits) client-digest SHA256) (Client CN "mx1.codepro.be", Issuer "R3" (verified OK)) (Authenticated sender: kp) by smtp.freebsd.org (Postfix) with ESMTPSA id 4LqQbB3VB4z142Q; Fri, 22 Jul 2022 23:27:50 +0000 (UTC) (envelope-from kp@FreeBSD.org) Received: by venus.codepro.be (Postfix, authenticated sender kp) id 254C930B1E; Sat, 23 Jul 2022 01:27:48 +0200 (CEST) From: Kristof Provost To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org Subject: Re: git: 151abc80cde7 - main - if_vlan: avoid hash table thrashing when adding and removing entries Date: Fri, 22 Jul 2022 17:27:45 -0600 X-Mailer: MailMate (1.14r5852) Message-ID: <41E75387-FE50-474E-BDC4-909A114FFD78@FreeBSD.org> In-Reply-To: <202207222319.26MNJEVY032683@gitrepo.freebsd.org> References: <202207222319.26MNJEVY032683@gitrepo.freebsd.org> List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1658532470; 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: in-reply-to:in-reply-to:references:references; bh=VUH88RMG9LEMMSvAAxWm/KDUlcX//YYNl7Z4PW8kLP0=; b=W//GO902RlfmGaZR+/y7xxJAUzdbqfhxhk0jaooXQ0z3kBDlyzymCSYGLcBUDvSDVSBwfy mWCXNjEzlK5tmjbW/PNfKepTAmCcMttiDTNuy5Jgza7FzcZzudN5RHflSdMO0Ehm5tVj0Y /V17VaOurSl40hTRvZNtlo02JznjKBohs4jF0CJXXDN5heaXvyFpZ21kWGM3oW3oHjeTDP kt8qMq9VWthWGYGhCAMb+8c2qcZjEgd1RAXDW2h8J1gegsykQTKnAp8A1TLGj82YuHlD4+ m6rmnIo4cVfpV/9qVizEOFSKq5woU99PEom05zSfBpf1s06PtydN6yLvBIbP6g== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1658532470; a=rsa-sha256; cv=none; b=tzxM+UO6GoqHGGqlsRrB6fRj2N0mPC6/egCCmU73CcDNzm59ivEhNxJS+31uJuzehXDS7U vgRlsu5oSUIn8pPSJUxEtZTJ9yzXuyr5/201yXRmntqNc5PnhO45jlUgwV667vUnb/Yv58 wUF7fTY6+88yFSUpCUadsRjtzQGDowOlceK8q03ULeA0NmL9iMAZYL+zbGywaqq4wrJZbp 3aHb0JaFLeCUNX1e2AEekwoC88BVWfRvFWe8o+3NpwVy5mSU5hwO9yddmFJLNHJCKEoYoV qvT7wDIozppezzfgw7kF+wVG+DUHosCG+WAPdBJ/jn+ExFalgVag7xH4U94lrw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N On 22 Jul 2022, at 17:19, Kristof Provost wrote: > The branch main has been updated by kp: > > URL: https://cgit.FreeBSD.org/src/commit/?id=3D151abc80cde778bc18b91c33= 4d07fbd52bbb38fb > > commit 151abc80cde778bc18b91c334d07fbd52bbb38fb > Author: Kristof Provost > AuthorDate: 2022-07-22 17:17:04 +0000 > Commit: Kristof Provost > CommitDate: 2022-07-22 17:18:41 +0000 > > if_vlan: avoid hash table thrashing when adding and removing entrie= s > > vlan_remhash() uses incorrect value for b. > > When using the default value for VLAN_DEF_HWIDTH (4), the VLAN hash= -list table > expands from 16 chains to 32 chains as the 129th entry is added. tr= unk->hwidth > becomes 5. Say a few more entries are added and there are now 135 e= ntries. > trunk-hwidth will still be 5. If an entry is removed, vlan_remhash(= ) will > calculate a value of 32 for b. refcnt will be decremented to 134. T= he if > comparison at line 473 will return true and vlan_growhash() will be= called. The > VLAN hash-list table will be compressed from 32 chains wide to 16 c= hains wide. > hwidth will become 4. This is an error, and it can be seen when a n= ew VLAN is > added. The table will again be expanded. If an entry is then remove= d, again > the table is contracted. > > If the number of VLANS stays in the range of 128-512, each time an = insert > follows a remove, the table will expand. Each time a remove follows= an > insert, the table will be contracted. > > The fix is simple. The line 473 should test that the number of entr= ies has > decreased such that the table should be contracted using what would= be the new > value of hwidth. line 467 should be: > > b =3D 1 << (trunk->hwidth - 1); > > PR: 265382 > Reviewed by: kp > MFC after: 2 weeks > Sponsored by: NetApp, Inc. Submitted by: David Sips I thought I=E2=80=99d set the author, but clearly not. Kristof