Skip to content

Commit fda1dd3

Browse files
committed
find: Switch from inline to __always_inline
'inline' keyword is only a recommendation for compiler. If it decides to not inline find_bit nodemask functions, the whole small_const_nbits() machinery doesn't work. This is how a standard GCC 11.3.0 does for my x86_64 build now. This patch replaces 'inline' directive with unconditional '__always_inline' to make sure that there's always a chance for compile-time optimization. It doesn't change size of kernel image, according to bloat-o-meter. [[ Brian: split out from: Subject: [PATCH 1/3] bitmap: switch from inline to __always_inline https://lore.kernel.org/all/[email protected]/ But rewritten, as there were too many conflicts. ]] Co-developed-by: Brian Norris <[email protected]> Signed-off-by: Brian Norris <[email protected]> Reviewed-by: Kees Cook <[email protected]> Reviewed-by: Nathan Chancellor <[email protected]> Signed-off-by: Yury Norov <[email protected]>
1 parent de9c2c6 commit fda1dd3

File tree

1 file changed

+25
-25
lines changed

1 file changed

+25
-25
lines changed

include/linux/find.h

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ unsigned long _find_next_bit_le(const unsigned long *addr, unsigned
5252
* Returns the bit number for the next set bit
5353
* If no bits are set, returns @size.
5454
*/
55-
static inline
55+
static __always_inline
5656
unsigned long find_next_bit(const unsigned long *addr, unsigned long size,
5757
unsigned long offset)
5858
{
@@ -81,7 +81,7 @@ unsigned long find_next_bit(const unsigned long *addr, unsigned long size,
8181
* Returns the bit number for the next set bit
8282
* If no bits are set, returns @size.
8383
*/
84-
static inline
84+
static __always_inline
8585
unsigned long find_next_and_bit(const unsigned long *addr1,
8686
const unsigned long *addr2, unsigned long size,
8787
unsigned long offset)
@@ -112,7 +112,7 @@ unsigned long find_next_and_bit(const unsigned long *addr1,
112112
* Returns the bit number for the next set bit
113113
* If no bits are set, returns @size.
114114
*/
115-
static inline
115+
static __always_inline
116116
unsigned long find_next_andnot_bit(const unsigned long *addr1,
117117
const unsigned long *addr2, unsigned long size,
118118
unsigned long offset)
@@ -142,7 +142,7 @@ unsigned long find_next_andnot_bit(const unsigned long *addr1,
142142
* Returns the bit number for the next set bit
143143
* If no bits are set, returns @size.
144144
*/
145-
static inline
145+
static __always_inline
146146
unsigned long find_next_or_bit(const unsigned long *addr1,
147147
const unsigned long *addr2, unsigned long size,
148148
unsigned long offset)
@@ -171,7 +171,7 @@ unsigned long find_next_or_bit(const unsigned long *addr1,
171171
* Returns the bit number of the next zero bit
172172
* If no bits are zero, returns @size.
173173
*/
174-
static inline
174+
static __always_inline
175175
unsigned long find_next_zero_bit(const unsigned long *addr, unsigned long size,
176176
unsigned long offset)
177177
{
@@ -198,7 +198,7 @@ unsigned long find_next_zero_bit(const unsigned long *addr, unsigned long size,
198198
* Returns the bit number of the first set bit.
199199
* If no bits are set, returns @size.
200200
*/
201-
static inline
201+
static __always_inline
202202
unsigned long find_first_bit(const unsigned long *addr, unsigned long size)
203203
{
204204
if (small_const_nbits(size)) {
@@ -224,7 +224,7 @@ unsigned long find_first_bit(const unsigned long *addr, unsigned long size)
224224
* Returns the bit number of the N'th set bit.
225225
* If no such, returns >= @size.
226226
*/
227-
static inline
227+
static __always_inline
228228
unsigned long find_nth_bit(const unsigned long *addr, unsigned long size, unsigned long n)
229229
{
230230
if (n >= size)
@@ -249,7 +249,7 @@ unsigned long find_nth_bit(const unsigned long *addr, unsigned long size, unsign
249249
* Returns the bit number of the N'th set bit.
250250
* If no such, returns @size.
251251
*/
252-
static inline
252+
static __always_inline
253253
unsigned long find_nth_and_bit(const unsigned long *addr1, const unsigned long *addr2,
254254
unsigned long size, unsigned long n)
255255
{
@@ -276,7 +276,7 @@ unsigned long find_nth_and_bit(const unsigned long *addr1, const unsigned long *
276276
* Returns the bit number of the N'th set bit.
277277
* If no such, returns @size.
278278
*/
279-
static inline
279+
static __always_inline
280280
unsigned long find_nth_andnot_bit(const unsigned long *addr1, const unsigned long *addr2,
281281
unsigned long size, unsigned long n)
282282
{
@@ -332,7 +332,7 @@ unsigned long find_nth_and_andnot_bit(const unsigned long *addr1,
332332
* Returns the bit number for the next set bit
333333
* If no bits are set, returns @size.
334334
*/
335-
static inline
335+
static __always_inline
336336
unsigned long find_first_and_bit(const unsigned long *addr1,
337337
const unsigned long *addr2,
338338
unsigned long size)
@@ -357,7 +357,7 @@ unsigned long find_first_and_bit(const unsigned long *addr1,
357357
* Returns the bit number for the first set bit
358358
* If no bits are set, returns @size.
359359
*/
360-
static inline
360+
static __always_inline
361361
unsigned long find_first_and_and_bit(const unsigned long *addr1,
362362
const unsigned long *addr2,
363363
const unsigned long *addr3,
@@ -381,7 +381,7 @@ unsigned long find_first_and_and_bit(const unsigned long *addr1,
381381
* Returns the bit number of the first cleared bit.
382382
* If no bits are zero, returns @size.
383383
*/
384-
static inline
384+
static __always_inline
385385
unsigned long find_first_zero_bit(const unsigned long *addr, unsigned long size)
386386
{
387387
if (small_const_nbits(size)) {
@@ -402,7 +402,7 @@ unsigned long find_first_zero_bit(const unsigned long *addr, unsigned long size)
402402
*
403403
* Returns the bit number of the last set bit, or size.
404404
*/
405-
static inline
405+
static __always_inline
406406
unsigned long find_last_bit(const unsigned long *addr, unsigned long size)
407407
{
408408
if (small_const_nbits(size)) {
@@ -425,7 +425,7 @@ unsigned long find_last_bit(const unsigned long *addr, unsigned long size)
425425
* Returns the bit number for the next set bit, or first set bit up to @offset
426426
* If no bits are set, returns @size.
427427
*/
428-
static inline
428+
static __always_inline
429429
unsigned long find_next_and_bit_wrap(const unsigned long *addr1,
430430
const unsigned long *addr2,
431431
unsigned long size, unsigned long offset)
@@ -448,7 +448,7 @@ unsigned long find_next_and_bit_wrap(const unsigned long *addr1,
448448
* Returns the bit number for the next set bit, or first set bit up to @offset
449449
* If no bits are set, returns @size.
450450
*/
451-
static inline
451+
static __always_inline
452452
unsigned long find_next_bit_wrap(const unsigned long *addr,
453453
unsigned long size, unsigned long offset)
454454
{
@@ -465,7 +465,7 @@ unsigned long find_next_bit_wrap(const unsigned long *addr,
465465
* Helper for for_each_set_bit_wrap(). Make sure you're doing right thing
466466
* before using it alone.
467467
*/
468-
static inline
468+
static __always_inline
469469
unsigned long __for_each_wrap(const unsigned long *bitmap, unsigned long size,
470470
unsigned long start, unsigned long n)
471471
{
@@ -506,28 +506,28 @@ extern unsigned long find_next_clump8(unsigned long *clump,
506506

507507
#if defined(__LITTLE_ENDIAN)
508508

509-
static inline unsigned long find_next_zero_bit_le(const void *addr,
510-
unsigned long size, unsigned long offset)
509+
static __always_inline
510+
unsigned long find_next_zero_bit_le(const void *addr, unsigned long size, unsigned long offset)
511511
{
512512
return find_next_zero_bit(addr, size, offset);
513513
}
514514

515-
static inline unsigned long find_next_bit_le(const void *addr,
516-
unsigned long size, unsigned long offset)
515+
static __always_inline
516+
unsigned long find_next_bit_le(const void *addr, unsigned long size, unsigned long offset)
517517
{
518518
return find_next_bit(addr, size, offset);
519519
}
520520

521-
static inline unsigned long find_first_zero_bit_le(const void *addr,
522-
unsigned long size)
521+
static __always_inline
522+
unsigned long find_first_zero_bit_le(const void *addr, unsigned long size)
523523
{
524524
return find_first_zero_bit(addr, size);
525525
}
526526

527527
#elif defined(__BIG_ENDIAN)
528528

529529
#ifndef find_next_zero_bit_le
530-
static inline
530+
static __always_inline
531531
unsigned long find_next_zero_bit_le(const void *addr, unsigned
532532
long size, unsigned long offset)
533533
{
@@ -546,7 +546,7 @@ unsigned long find_next_zero_bit_le(const void *addr, unsigned
546546
#endif
547547

548548
#ifndef find_first_zero_bit_le
549-
static inline
549+
static __always_inline
550550
unsigned long find_first_zero_bit_le(const void *addr, unsigned long size)
551551
{
552552
if (small_const_nbits(size)) {
@@ -560,7 +560,7 @@ unsigned long find_first_zero_bit_le(const void *addr, unsigned long size)
560560
#endif
561561

562562
#ifndef find_next_bit_le
563-
static inline
563+
static __always_inline
564564
unsigned long find_next_bit_le(const void *addr, unsigned
565565
long size, unsigned long offset)
566566
{

0 commit comments

Comments
 (0)