On 7/9/24 11:56 PM, Yang Yang wrote:
+ spin_lock_irqsave(&map->swap_lock, flags);
Please use guard(spinlock_irqsave) in new code instead of spin_lock_irqsave() + goto out_unlock + spin_unlock_irqrestore().
That will make this function significantly easier to read and to maintain.
+ + if (!map->cleared) { + if (depth > 0) { + word_mask = (~0UL) >> (BITS_PER_LONG - depth); + /* + * The current behavior is to always retry after moving + * ->cleared to word, and we change it to retry in case + * of any free bits. To avoid dead loop, we need to take
What is a "dead loop"? Did you perhaps want to write "infinite loop"?
+ * wrap & alloc_hint into account. Without this, a soft + * lockup was detected in our test environment.
Source code comments should not refer to "our test environment". Code that is intended for upstream inclusion should work for all setups.
+ */ + if (!wrap && alloc_hint) + word_mask &= ~((1UL << alloc_hint) - 1);
Above I see an open-coded __clear_bit() operation. Has it been considered to use __clear_bit() instead of open-coding it? Thanks, Bart.