<feed xmlns='http://www.w3.org/2005/Atom'>
<title>kernel/linux.git/lib/bitmap.c, branch v7.3-rc1</title>
<subtitle>Linux kernel stable tree (mirror)</subtitle>
<id>https://git.radix-linux.su/kernel/linux.git/atom?h=v7.3-rc1</id>
<link rel='self' href='https://git.radix-linux.su/kernel/linux.git/atom?h=v7.3-rc1'/>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/'/>
<updated>2026-07-22T19:38:38+00:00</updated>
<entry>
<title>bitmap: Return size when no zero area is found</title>
<updated>2026-07-22T19:38:38+00:00</updated>
<author>
<name>Yury Norov</name>
<email>ynorov@nvidia.com</email>
</author>
<published>2026-07-09T02:03:11+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=bf7e3686b708683efe6b7ee79ae4c83a875dbc6f'/>
<id>urn:sha1:bf7e3686b708683efe6b7ee79ae4c83a875dbc6f</id>
<content type='text'>
Return the bitmap size, rather than size + 1, when
bitmap_find_next_zero_area_off() cannot find a suitable area. This
matches the conventional find_bit() failure sentinel and still lets
callers detect failure with an out-of-range check.

Document the public failure contract as a value greater than or equal
to the bitmap size, without requiring callers to depend on the exact
sentinel.

Signed-off-by: Yury Norov &lt;ynorov@nvidia.com&gt;
</content>
</entry>
<entry>
<title>lib: bitmap: optimize bitmap_find_next_zero_area_off()</title>
<updated>2026-07-22T19:38:37+00:00</updated>
<author>
<name>sunyi</name>
<email>279644543@qq.com</email>
</author>
<published>2026-07-06T09:29:34+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=df81d444dc740778f7c7a2d4c3500136851375aa'/>
<id>urn:sha1:df81d444dc740778f7c7a2d4c3500136851375aa</id>
<content type='text'>
Finding a contiguous free region in a highly fragmented
bitmap is not easy and may require many repeated attempts.
Therefore, find_next_bit(map, end, index) is not the optimal choice.
This is because there may be multiple scattered free regions
within the range [index, end) and none of them will meet the length
requirement of @nr.
Instead, it's sufficient to directly find the last bit within
the range [index, end), thus reducing unnecessary repeated calls.

An example of a bitmap:
Bits 0-3:   cleared(4 bits)
Bits 4-5:   set    (2 bits)
Bits 6-8:   cleared(4 bits)
Bits 9-10:  set    (2 bits)
Bits 11-20: cleared(10 bits)

The goal is to find a 10-bit free region.

The old code logic is as follows:
find_next_zero_bit(start = 0, find bit 0) -&gt; find_next_bit(find bit 4) -&gt;
next loop -&gt;
find_next_zero_bit(start = 5, find bit 6) -&gt; find_next_bit(find bit 9) -&gt;
next loop -&gt;
find_next_zero_bit(start = 10, find bit 11) -&gt; success

The new code logic is as follows:
find_next_zero_bit(start = 0, find bit 0) -&gt; find_last_bit(find bit 9) -&gt;
next loop -&gt;
find_next_zero_bit(start = 10, find bit 11) -&gt; success

Performance test results on my hardware(use lib/find_bit_benchmark.c):

		before	after	change	p-value
dense		1211	688	-43.2%	8.3e-11
sparse		13.3	13.4	0.8%	0.27

Yury:

The less micro-benchmark kselftest/dmabuf-heaps/dmabuf-heap gives
even better numbers:

Metric                      Before         After          Change
Trace span                194.0 ms       87.1 ms          -55.1%
Total CMA alloc time      48.46 ms      16.11 ms          -66.8%
Avg alloc latency        184.94 us      61.49 us          -66.8%
Median alloc latency      73.72 us      20.59 us          -72.1%
p90 alloc latency        329.76 us      55.63 us          -83.1%
p99 alloc latency       1866.76 us     859.83 us          -53.9%
Max alloc latency       4821.91 us    2324.41 us          -51.8%

By request size:

Request      Before Avg    After Avg          Change
1 page         79.68 us     34.47 us          -56.7%
256 pages     285.50 us     87.30 us          -69.4%

Co-developed-by: Yury Norov &lt;yury.norov@gmail.com&gt;
Signed-off-by: Yury Norov &lt;yury.norov@gmail.com&gt;
Signed-off-by: sunyi &lt;279644543@qq.com&gt;
Signed-off-by: Yury Norov &lt;ynorov@nvidia.com&gt;
</content>
</entry>
<entry>
<title>bitmap: introduce bitmap_weighted_xor()</title>
<updated>2026-04-02T00:03:07+00:00</updated>
<author>
<name>Yury Norov</name>
<email>ynorov@nvidia.com</email>
</author>
<published>2026-03-02T01:11:55+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=d57e74f10461b80c77d1678f646720f616fb8553'/>
<id>urn:sha1:d57e74f10461b80c77d1678f646720f616fb8553</id>
<content type='text'>
The function helps to XOR bitmaps and calculate Hamming weight of
the result in one pass.

Reviewed-by: Aleksandr Loktionov &lt;aleksandr.loktionov@intel.com&gt;
Reviewed-by: Jacob Keller &lt;jacob.e.keller@intel.com&gt;
Signed-off-by: Yury Norov &lt;ynorov@nvidia.com&gt;
</content>
</entry>
<entry>
<title>bitmap: add test_zero_nbits()</title>
<updated>2026-03-24T17:39:53+00:00</updated>
<author>
<name>Yury Norov</name>
<email>ynorov@nvidia.com</email>
</author>
<published>2026-03-19T00:43:48+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=95d324fb1b48434f4c659e4c245c3bdeecdff22c'/>
<id>urn:sha1:95d324fb1b48434f4c659e4c245c3bdeecdff22c</id>
<content type='text'>
In most real-life cases, 0-length bitmap provided by user is a sign of
an error. The API doesn't provide any guarantees on returned value, and
the bitmap pointers are not dereferenced.

Signed-off-by: Yury Norov &lt;ynorov@nvidia.com&gt;
</content>
</entry>
<entry>
<title>cpumask: Introduce cpumask_weighted_or()</title>
<updated>2025-11-20T11:14:54+00:00</updated>
<author>
<name>Thomas Gleixner</name>
<email>tglx@linutronix.de</email>
</author>
<published>2025-11-19T17:26:57+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=437cb3ded25038d5280d21de489ce78c745118d5'/>
<id>urn:sha1:437cb3ded25038d5280d21de489ce78c745118d5</id>
<content type='text'>
CID management OR's two cpumasks and then calculates the weight on the
result. That's inefficient as that has to walk the same stuff twice. As
this is done with runqueue lock held, there is a real benefit of speeding
this up. Depending on the system this results in 10-20% less cycles spent
with runqueue lock held for a 4K cpumask.

Provide cpumask_weighted_or() and the corresponding bitmap functions which
return the weight of the OR result right away.

Signed-off-by: Thomas Gleixner &lt;tglx@linutronix.de&gt;
Signed-off-by: Peter Zijlstra (Intel) &lt;peterz@infradead.org&gt;
Reviewed-by: Yury Norov (NVIDIA) &lt;yury.norov@gmail.com&gt;
Reviewed-by: Mathieu Desnoyers &lt;mathieu.desnoyers@efficios.com&gt;
Link: https://patch.msgid.link/20251119172549.448263340@linutronix.de
</content>
</entry>
<entry>
<title>cpumask: add cpumask_weight_andnot()</title>
<updated>2024-02-01T12:06:40+00:00</updated>
<author>
<name>Yury Norov</name>
<email>yury.norov@gmail.com</email>
</author>
<published>2024-01-29T06:21:04+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=c1f5204efcbcced83f67f12fa8f1a7f5f244fb87'/>
<id>urn:sha1:c1f5204efcbcced83f67f12fa8f1a7f5f244fb87</id>
<content type='text'>
Similarly to cpumask_weight_and(), cpumask_weight_andnot() is a handy
helper that may help to avoid creating an intermediate mask just to
calculate number of bits that set in a 1st given mask, and clear in 2nd
one.

Signed-off-by: Yury Norov &lt;yury.norov@gmail.com&gt;
Reviewed-by: Jacob Keller &lt;jacob.e.keller@intel.com&gt;
Signed-off-by: Paolo Abeni &lt;pabeni@redhat.com&gt;
</content>
</entry>
<entry>
<title>bitmap: move bitmap_*_region() functions to bitmap.h</title>
<updated>2023-10-16T23:14:45+00:00</updated>
<author>
<name>Yury Norov</name>
<email>yury.norov@gmail.com</email>
</author>
<published>2023-09-25T02:38:17+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=6cb42f91aa6dfd10fd847c469caebe63b35141ff'/>
<id>urn:sha1:6cb42f91aa6dfd10fd847c469caebe63b35141ff</id>
<content type='text'>
Now that bitmap_*_region() functions are implemented as thin wrappers
around others, it's worth to move them to the header, as it opens room
for compile-time optimizations.

CC: Andy Shevchenko &lt;andriy.shevchenko@linux.intel.com&gt;
CC: Rasmus Villemoes &lt;linux@rasmusvillemoes.dk&gt;
CC: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
Signed-off-by: Yury Norov &lt;yury.norov@gmail.com&gt;
</content>
</entry>
<entry>
<title>bitmap: drop _reg_op() function</title>
<updated>2023-10-15T03:25:23+00:00</updated>
<author>
<name>Yury Norov</name>
<email>yury.norov@gmail.com</email>
</author>
<published>2023-09-25T02:38:16+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=1d4836527d4168d648010909637fb6cfe45d3fac'/>
<id>urn:sha1:1d4836527d4168d648010909637fb6cfe45d3fac</id>
<content type='text'>
Now that all _reg_op() users are switched to alternative functions,
_reg_op() machinery is not needed anymore.

CC: Andy Shevchenko &lt;andriy.shevchenko@linux.intel.com&gt;
CC: Rasmus Villemoes &lt;linux@rasmusvillemoes.dk&gt;
Signed-off-by: Yury Norov &lt;yury.norov@gmail.com&gt;
</content>
</entry>
<entry>
<title>bitmap: replace _reg_op(REG_OP_ISFREE) with find_next_bit()</title>
<updated>2023-10-15T03:25:22+00:00</updated>
<author>
<name>Yury Norov</name>
<email>yury.norov@gmail.com</email>
</author>
<published>2023-09-25T02:38:15+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=9276819a68b52cf2577f77985041faf527cf477c'/>
<id>urn:sha1:9276819a68b52cf2577f77985041faf527cf477c</id>
<content type='text'>
_reg_op(REG_OP_ISFREE) can be trivially replaced with find_next_bit().
Doing that opens room for potential small_const_nbits() optimization.

CC: Andy Shevchenko &lt;andriy.shevchenko@linux.intel.com&gt;
CC: Rasmus Villemoes &lt;linux@rasmusvillemoes.dk&gt;
Signed-off-by: Yury Norov &lt;yury.norov@gmail.com&gt;
</content>
</entry>
<entry>
<title>bitmap: replace _reg_op(REG_OP_RELEASE) with bitmap_clear()</title>
<updated>2023-10-15T03:25:22+00:00</updated>
<author>
<name>Yury Norov</name>
<email>yury.norov@gmail.com</email>
</author>
<published>2023-09-25T02:38:14+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=add00c76ee4dafbc35b170bea144358fd62daebb'/>
<id>urn:sha1:add00c76ee4dafbc35b170bea144358fd62daebb</id>
<content type='text'>
_reg_op(REG_OP_RELEASE) duplicates bitmap_clear().

CC: Andy Shevchenko &lt;andriy.shevchenko@linux.intel.com&gt;
CC: Rasmus Villemoes &lt;linux@rasmusvillemoes.dk&gt;
Signed-off-by: Yury Norov &lt;yury.norov@gmail.com&gt;
</content>
</entry>
</feed>
