Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 22 Jul 2022 17:27:45 -0600
From:      Kristof Provost <kp@FreeBSD.org>
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
Message-ID:  <41E75387-FE50-474E-BDC4-909A114FFD78@FreeBSD.org>
In-Reply-To: <202207222319.26MNJEVY032683@gitrepo.freebsd.org>
References:  <202207222319.26MNJEVY032683@gitrepo.freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help
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 <kp@FreeBSD.org>
> AuthorDate: 2022-07-22 17:17:04 +0000
> Commit:     Kristof Provost <kp@FreeBSD.org>
> 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 <dsips@netapp.com>

I thought I=E2=80=99d set the author, but clearly not.

Kristof



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?41E75387-FE50-474E-BDC4-909A114FFD78>