Date: Fri, 3 May 2019 02:55:54 +0000 (UTC) From: Douglas William Moore <dougm@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r347043 - head/sys/vm Message-ID: <201905030255.x432tsKK001162@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: dougm Date: Fri May 3 02:55:54 2019 New Revision: 347043 URL: https://svnweb.freebsd.org/changeset/base/347043 Log: fls() should find the most significant bit of an int faster than a linear search can, so use it to avoid a linear search in isqrt. Approved by: kib (mentor), markj (mentor) Differential Revision: https://reviews.freebsd.org/D20102 Modified: head/sys/vm/vm_pageout.c Modified: head/sys/vm/vm_pageout.c ============================================================================== --- head/sys/vm/vm_pageout.c Fri May 3 02:51:33 2019 (r347042) +++ head/sys/vm/vm_pageout.c Fri May 3 02:55:54 2019 (r347043) @@ -928,9 +928,7 @@ isqrt(u_int num) { u_int bit, root, tmp; - bit = 1u << ((NBBY * sizeof(u_int)) - 2); - while (bit > num) - bit >>= 2; + bit = num != 0 ? (1u << ((fls(num) - 1) & ~1)) : 0; root = 0; while (bit != 0) { tmp = root + bit;
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201905030255.x432tsKK001162>