Re: [PATCH v6] sbitmap: fix io hung due to race on sbitmap_word::cleared

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

 



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.




[Index of Archives]     [Linux RAID]     [Linux SCSI]     [Linux ATA RAID]     [IDE]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Device Mapper]

  Powered by Linux