The branch main has been updated by imp:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=996fa9fb4ec47995e89d2089e6084d37dcb1033c

commit 996fa9fb4ec47995e89d2089e6084d37dcb1033c
Author:     Elliott Mitchell <[email protected]>
AuthorDate: 2024-05-09 04:47:09 +0000
Commit:     Warner Losh <[email protected]>
CommitDate: 2024-05-21 23:52:27 +0000

    kern/rman: update rman_make_alignment_flags()
    
    The flsl() function makes use of hardware functionality to compute the
    value faster than this loop.  The only deviation from flsl() is at 0.
    
    Reviewed by: imp,jhb
    Pull Request: https://github.com/freebsd/freebsd-src/pull/1224
---
 sys/kern/subr_rman.c | 11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)

diff --git a/sys/kern/subr_rman.c b/sys/kern/subr_rman.c
index 2019e19090c0..508152f74002 100644
--- a/sys/kern/subr_rman.c
+++ b/sys/kern/subr_rman.c
@@ -776,19 +776,14 @@ rman_release_resource(struct resource *re)
 uint32_t
 rman_make_alignment_flags(uint32_t size)
 {
-       int i;
 
        /*
         * Find the hightest bit set, and add one if more than one bit
         * set.  We're effectively computing the ceil(log2(size)) here.
         */
-       for (i = 31; i > 0; i--)
-               if ((1 << i) & size)
-                       break;
-       if (~(1 << i) & size)
-               i++;
-
-       return(RF_ALIGNMENT_LOG2(i));
+       if (__predict_false(size == 0))
+               return (0);
+       return (RF_ALIGNMENT_LOG2(flsl(size - 1)));
 }
 
 rman_res_t

Reply via email to