• Damien Le Moal's avatar
    null_blk: improve zone locking · 2b8b7ed7
    Damien Le Moal authored
    With memory backing disabled, using a single spinlock for protecting
    zone information and zone resource management prevents the parallel
    execution on multiple queue of IO requests to different zones.
    Furthermore, regardless of the use of memory backing, if a null_blk
    device is created without limits on the number of open and active zones,
    accounting for zone resource management is not necessary.
    
    >From these observations, zone locking is changed as follows to improve
    performance:
    1) the zone_lock spinlock is renamed zone_res_lock and used only if
       zone resource management is necessary, that is, if either
       zone_max_open or zone_max_active are not 0. This is indicated using
       the new boolean need_zone_res_mgmt in the nullb_device structure.
       null_zone_write() is modified to reduce the amount of code executed
       with the zone_res_lock spinlock held.
    2) With memory backing disabled, per zone locking is changed to a
       spinlock per zone.
    3) Introduce the structure nullb_zone to replace the use of
       struct blk_zone for zone information. This new structure includes a
       union of a spinlock and a mutex for zone locking. The spinlock is
       used when memory backing is disabled and the mutex is used with
       memory backing.
    
    With these changes, fio performance with zonemode=zbd for 4K random
    read and random write on a dual socket (24 cores per socket) machine
    using the none schedulder is as follows:
    
    before patch:
    	write (psync x 96 jobs) = 465 KIOPS
    	read (libaio@qd=8 x 96 jobs) = 1361 KIOPS
    after patch:
    	write (psync x 96 jobs) = 456 KIOPS
    	read (libaio@qd=8 x 96 jobs) = 4096 KIOPS
    
    Write performance remains mostly unchanged but read performance is three
    times higher. Performance when using the mq-deadline scheduler is not
    changed by this patch as mq-deadline becomes the bottleneck for a
    multi-queue device.
    Signed-off-by: default avatarDamien Le Moal <damien.lemoal@wdc.com>
    Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
    Reviewed-by: default avatarJohannes Thumshirn <johannes.thumshirn@wdc.com>
    Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
    2b8b7ed7
null_blk.h 4.7 KB