Re: [PATCH v2 4/9] null_blk: improve zone locking

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

 



> +	spin_lock_init(&dev->zone_res_lock);
> +	if (dev->memory_backed)
>  		dev->zone_locks = bitmap_zalloc(dev->nr_zones, GFP_KERNEL);
> +	else
> +		dev->zone_locks = kmalloc_array(dev->nr_zones,
> +						sizeof(spinlock_t), GFP_KERNEL);
> +	if (!dev->zone_locks) {

Using the same pointer for different types is pretty horrible.  At very
least we should use a union.

But I think we'd end up with less contention if we add a new

struct nullb_zone

that contains the fields of blk_zone that we actuall care about plus:

	union {
		spinlock_t	spinlock;
		mutex_t		mutex;
	}

and then use the proper lock primitive also for the memory backed case.



[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