possible power-of-2 cleanup

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



  is anyone still working on the power-of-2 stuff?  surely, there's a
cleaner way to code this from fs/namespace.c:


        /*
         * Find the power-of-two list-heads that can fit into the allocation..
         * We don't guarantee that "sizeof(struct list_head)" is necessarily
         * a power-of-two.
         */
        nr_hash = PAGE_SIZE / sizeof(struct list_head);
        hash_bits = 0;
        do {
                hash_bits++;
        } while ((nr_hash >> hash_bits) != 0);
        hash_bits--;

        /*
         * Re-calculate the actual number of entries and the mask
         * from the number of bits we can fit.
         */
        nr_hash = 1UL << hash_bits;
        hash_mask = nr_hash - 1;


rday

-- 
========================================================================
Robert P. J. Day
Linux Consulting, Training and Annoying Kernel Pedantry
Waterloo, Ontario, CANADA

http://crashcourse.ca
========================================================================
-
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Kernel Development]     [Kernel Announce]     [Kernel Newbies]     [Linux Networking Development]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Device Mapper]

  Powered by Linux