1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-03 09:00:21 +00:00
freebsd/sbin/hastd
Alan Somers 8907f744ff Improve performance and functionality of the bitstring(3) api
Two new functions are provided, bit_ffs_at() and bit_ffc_at(), which allow
for efficient searching of set or cleared bits starting from any bit offset
within the bit string.

Performance is improved by operating on longs instead of bytes and using
ffsl() for searches within a long. ffsl() is a compiler builtin in both
clang and gcc for most architectures, converting what was a brute force
while loop search into a couple of instructions.

All of the bitstring(3) API continues to be contained in the header file.
Some of the functions are large enough that perhaps they should be uninlined
and moved to a library, but that is beyond the scope of this commit.

sys/sys/bitstring.h:
        Convert the majority of the existing bit string implementation from
        macros to inline functions.

        Properly protect the implementation from inadvertant macro expansion
        when included in a user's program by prefixing all private
        macros/functions and local variables with '_'.

        Add bit_ffs_at() and bit_ffc_at(). Implement bit_ffs() and
        bit_ffc() in terms of their "at" counterparts.

        Provide a kernel implementation of bit_alloc(), making the full API
        usable in the kernel.

        Improve code documenation.

share/man/man3/bitstring.3:
        Add pre-exisiting API bit_ffc() to the synopsis.

        Document new APIs.

        Document the initialization state of the bit strings
        allocated/declared by bit_alloc() and bit_decl().

        Correct documentation for bitstr_size(). The original code comments
        indicate the size is in bytes, not "elements of bitstr_t". The new
        implementation follows this lead. Only hastd assumed "elements"
        rather than bytes and it has been corrected.

etc/mtree/BSD.tests.dist:
tests/sys/Makefile:
tests/sys/sys/Makefile:
tests/sys/sys/bitstring.c:
        Add tests for all existing and new functionality.

include/bitstring.h
	Include all headers needed by sys/bitstring.h

lib/libbluetooth/bluetooth.h:
usr.sbin/bluetooth/hccontrol/le.c:
        Include bitstring.h instead of sys/bitstring.h.

sbin/hastd/activemap.c:
        Correct usage of bitstr_size().

sys/dev/xen/blkback/blkback.c
        Use new bit_alloc.

sys/kern/subr_unit.c:
        Remove hard-coded assumption that sizeof(bitstr_t) is 1.  Get rid of
        unrb.busy, which caches the number of bits set in unrb.map.  When
        INVARIANTS are disabled, nothing needs to know that information.
        callapse_unr can be adapted to use bit_ffs and bit_ffc instead.
        Eliminating unrb.busy saves memory, simplifies the code, and
        provides a slight speedup when INVARIANTS are disabled.

sys/net/flowtable.c:
        Use the new kernel implementation of bit-alloc, instead of hacking
        the old libc-dependent macro.

sys/sys/param.h
        Update __FreeBSD_version to indicate availability of new API

Submitted by:   gibbs, asomers
Reviewed by:    gibbs, ngie
MFC after:      4 weeks
Sponsored by:   Spectra Logic Corp
Differential Revision:  https://reviews.freebsd.org/D6004
2016-05-04 22:34:11 +00:00
..
activemap.c Improve performance and functionality of the bitstring(3) api 2016-05-04 22:34:11 +00:00
activemap.h
control.c Make hastctl list command output current queue sizes. 2013-10-26 08:38:21 +00:00
control.h Rename HASTCTL_ defines, which are used for conversion between main 2011-04-26 19:38:30 +00:00
crc32.c
crc32.h
ebuf.c For functions that return -1 on failure check exactly for -1 and not for 2012-01-10 22:39:07 +00:00
ebuf.h
event.c For functions that return -1 on failure check exactly for -1 and not for 2012-01-10 22:39:07 +00:00
event.h
hast_checksum.c Simplify code by changing functions types from int to avoid, as the functions 2011-12-15 22:03:17 +00:00
hast_checksum.h
hast_compression.c Spelling fixes for sbin/ 2012-01-07 16:09:33 +00:00
hast_compression.h
hast_proto.c - Add support for 'memsync' mode. This is the fastest replication mode that's 2013-02-17 21:12:34 +00:00
hast_proto.h Remove hast_proto_recv(). It was used only in one place, where 2011-04-17 16:18:45 +00:00
hast.conf.5 mdoc: paragraph improvements. 2015-01-04 12:49:24 +00:00
hast.h Make hastctl list command output current queue sizes. 2013-10-26 08:38:21 +00:00
hastd.8 use .Mt to mark up email addresses consistently (part1) 2014-06-20 09:40:43 +00:00
hastd.c Use MAX() from sys/param.h. 2016-04-21 06:21:33 +00:00
hastd.h
hooks.c Remove useless calls to basename(). 2016-05-01 08:22:11 +00:00
hooks.h
lzf.c
lzf.h Spelling fixes for sbin/ 2012-01-07 16:09:33 +00:00
Makefile Create a package for HAST. 2016-02-08 21:15:07 +00:00
Makefile.depend DIRDEPS_BUILD: Regenerate without local dependencies. 2016-02-24 17:20:11 +00:00
metadata.c For functions that return -1 on failure check exactly for -1 and not for 2012-01-10 22:39:07 +00:00
metadata.h
nv.c Fix compiler warnings. 2013-12-10 20:02:09 +00:00
nv.h
parse.y Improve compatibility with old flex and fix build with GCC. 2013-05-22 17:47:45 +00:00
pjdlog.c Ensure that pjdlog functions don't modify errno. 2011-09-27 06:43:51 +00:00
pjdlog.h Revert r228695. We use __func__ here as a format to distinguish between 2012-11-05 00:38:14 +00:00
primary.c Add lock annotations to the threading API used by hastd. 2014-09-01 18:37:17 +00:00
proto_common.c Check if there is cmsg at all. 2012-07-01 16:26:07 +00:00
proto_impl.h
proto_socketpair.c For functions that return -1 on failure check exactly for -1 and not for 2012-01-10 22:39:07 +00:00
proto_tcp.c For functions that return -1 on failure check exactly for -1 and not for 2012-01-10 22:39:07 +00:00
proto_uds.c For functions that return -1 on failure check exactly for -1 and not for 2012-01-10 22:39:07 +00:00
proto.c Fix compiler warnings. 2013-12-10 20:02:09 +00:00
proto.h
rangelock.c Nice range comparison. 2012-02-11 16:41:52 +00:00
rangelock.h
refcnt.h Drop the 3rd clause from all 3 clause BSD licenses where I am the sole 2014-02-05 18:13:27 +00:00
secondary.c Send wakeup to threads waiting on empty queue before releasing the 2013-12-10 20:06:41 +00:00
subr.c Use nitems() from sys/param.h. 2016-04-20 00:55:35 +00:00
subr.h Constify argument. 2012-01-06 12:27:17 +00:00
synch.h Add lock annotations to the threading API used by hastd. 2014-09-01 18:37:17 +00:00
token.l Improve compatibility with old flex and fix build with GCC. 2013-05-22 17:47:45 +00:00