Date: Wed, 19 Sep 2018 12:08:19 -0400 From: Shawn Webb <shawn.webb@hardenedbsd.org> To: Mateusz Guzik <mjg@FreeBSD.org> Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r338802 - head/sys/vm Message-ID: <20180919160819.lfzrey3upzri4tll@mutt-hbsd> In-Reply-To: <201809191602.w8JG2Y0X046254@repo.freebsd.org> References: <201809191602.w8JG2Y0X046254@repo.freebsd.org>
next in thread | previous in thread | raw e-mail | index | archive | help
--3huvumm73ebqbljo Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, Sep 19, 2018 at 04:02:34PM +0000, Mateusz Guzik wrote: > Author: mjg > Date: Wed Sep 19 16:02:33 2018 > New Revision: 338802 > URL: https://svnweb.freebsd.org/changeset/base/338802 >=20 > Log: > vm: check for empty kstack cache before locking > =20 > The current cache logic checks the total number of stacks in the kernel, > which even on small boxes significantly exceeds the 128 limit (e.g. an > 8-way box with zfs has almost 800 stacks allocated). > =20 > Stacks are cached earlier for each main thread. > =20 > As a result the code is rarely executed, but when it is then (on boxes = like > the above) it always fails. Since there are no provisions made for NUMA= and > release time is approaching, just do a quick check to avoid acquiring t= he > lock. > =20 > Approved by: re (kib) >=20 > Modified: > head/sys/vm/vm_glue.c >=20 > Modified: head/sys/vm/vm_glue.c > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D > --- head/sys/vm/vm_glue.c Wed Sep 19 15:39:16 2018 (r338801) > +++ head/sys/vm/vm_glue.c Wed Sep 19 16:02:33 2018 (r338802) > @@ -327,7 +327,7 @@ vm_thread_new(struct thread *td, int pages) > else if (pages > KSTACK_MAX_PAGES) > pages =3D KSTACK_MAX_PAGES; > =20 > - if (pages =3D=3D kstack_pages) { > + if (pages =3D=3D kstack_pages && kstack_cache !=3D NULL) { > mtx_lock(&kstack_cache_mtx); > if (kstack_cache !=3D NULL) { > ks_ce =3D kstack_cache; Since kstack_cache is guaranteed not to be NULL, can the second conditional that checks for kstack_cache not being NULL be removed? Thanks, --=20 Shawn Webb Cofounder and Security Engineer HardenedBSD Tor-ified Signal: +1 443-546-8752 Tor+XMPP+OTR: lattera@is.a.hacker.sx GPG Key ID: 0x6A84658F52456EEE GPG Key Fingerprint: 2ABA B6BD EF6A F486 BE89 3D9E 6A84 658F 5245 6EEE --3huvumm73ebqbljo Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEKrq2ve9q9Ia+iT2eaoRlj1JFbu4FAluidG4ACgkQaoRlj1JF bu4f8xAAlfGz+6Wb3F6Hyip/fhypaiv/G2hAsEwV2pPvMDk0qIkqFxDrLE/shsgp UpjfCnkNFm9g/bVTxouPcDtuj5Tj1jLxBTlZcATw1lGvUTL30lUscT+bnIcw2ylz xwPhHpYdYjokhq91ju/faZ4IVTODhr3vDx9GyZVr7MDcRmSDQSWy4mW2+zoNCBg+ gF+I5lqpA4cN16tkLW+1nh+czdKsg8gn4k7JIp06DKwn5Zr1JeH5ZTnnAVYl27vR Pu8xtEcLHsMTDLw3VzGHiUdps5D9gfpy0GddqZvuFhYMcRiv87oX+78DCEFBoOQ5 IS0LfVb7ajacHzlGSq4ZbMb6rJOVAcfSSqHTdrxDL7TMIw1JG444HtGJPNeSd/nf tX1XRiHxvD86BgnF9sbXKX+wbrHC7ajvxXnEpHdZNXyKUhc5uPZYCcXgtsgMNkbm RAqJfP52d1WKbjnukWT3RdolwtzGViB60LD48xor9W0ImjQHHV22fa9l8CSh2mze 1SoCsnFw62g1Ulpgx3opzmvbHwHJ6OimvxFGBRmIFV7lfzGcdeeWRcbdEBa9xSSI 10FDVd9POeZ5ueKab8RGilQKcrnujzNsw0iSZfvwRCWqYNCjc90/zfZZ2nAkSyJ3 1Va8s8SC/UCJ/RpSw3leFkXeCf0ZioHs+7HB2HTrGcvyIdTFjRM= =G9fa -----END PGP SIGNATURE----- --3huvumm73ebqbljo--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20180919160819.lfzrey3upzri4tll>