Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

block, bfq: retrieve independent access ranges from request queue

This patch implements the code to gather the content of the
independent_access_ranges structure from the request_queue and copy
it into the queue's bfq_data. This copy is done at queue initialization.

We copy the access ranges into the bfq_data to avoid taking the queue
lock each time we access the ranges.

This implementation, however, puts a limit to the maximum independent
ranges supported by the scheduler. Such a limit is equal to the constant
BFQ_MAX_ACTUATORS. This limit was placed to avoid the allocation of
dynamic memory.

Reviewed-by: Damien Le Moal <damien.lemoal@opensource.wdc.com>
Co-developed-by: Rory Chen <rory.c.chen@seagate.com>
Signed-off-by: Rory Chen <rory.c.chen@seagate.com>
Signed-off-by: Federico Gavioli <f.gavioli97@gmail.com>
Signed-off-by: Paolo Valente <paolo.valente@linaro.org>
Link: https://lore.kernel.org/r/20230103145503.71712-7-paolo.valente@linaro.org
Signed-off-by: Jens Axboe <axboe@kernel.dk>

authored by

Federico Gavioli and committed by
Jens Axboe
4fdb3b9f 8b7fd741

+59 -10
+52 -9
block/bfq-iosched.c
··· 1793 1793 */ 1794 1794 static unsigned int bfq_actuator_index(struct bfq_data *bfqd, struct bio *bio) 1795 1795 { 1796 - /* 1797 - * Multi-actuator support not complete yet, so always return 0 1798 - * for the moment (to keep incomplete mechanisms off). 1799 - */ 1796 + unsigned int i; 1797 + sector_t end; 1798 + 1799 + /* no search needed if one or zero ranges present */ 1800 + if (bfqd->num_actuators == 1) 1801 + return 0; 1802 + 1803 + /* bio_end_sector(bio) gives the sector after the last one */ 1804 + end = bio_end_sector(bio) - 1; 1805 + 1806 + for (i = 0; i < bfqd->num_actuators; i++) { 1807 + if (end >= bfqd->sector[i] && 1808 + end < bfqd->sector[i] + bfqd->nr_sectors[i]) 1809 + return i; 1810 + } 1811 + 1812 + WARN_ONCE(true, 1813 + "bfq_actuator_index: bio sector out of ranges: end=%llu\n", 1814 + end); 1800 1815 return 0; 1801 1816 } 1802 1817 ··· 7120 7105 { 7121 7106 struct bfq_data *bfqd; 7122 7107 struct elevator_queue *eq; 7108 + unsigned int i; 7109 + struct blk_independent_access_ranges *ia_ranges = q->disk->ia_ranges; 7123 7110 7124 7111 eq = elevator_alloc(q, e); 7125 7112 if (!eq) ··· 7164 7147 7165 7148 bfqd->queue = q; 7166 7149 7167 - /* 7168 - * Multi-actuator support not complete yet, unconditionally 7169 - * set to only one actuator for the moment (to keep incomplete 7170 - * mechanisms off). 7171 - */ 7172 7150 bfqd->num_actuators = 1; 7151 + /* 7152 + * If the disk supports multiple actuators, copy independent 7153 + * access ranges from the request queue structure. 7154 + */ 7155 + spin_lock_irq(&q->queue_lock); 7156 + if (ia_ranges) { 7157 + /* 7158 + * Check if the disk ia_ranges size exceeds the current bfq 7159 + * actuator limit. 7160 + */ 7161 + if (ia_ranges->nr_ia_ranges > BFQ_MAX_ACTUATORS) { 7162 + pr_crit("nr_ia_ranges higher than act limit: iars=%d, max=%d.\n", 7163 + ia_ranges->nr_ia_ranges, BFQ_MAX_ACTUATORS); 7164 + pr_crit("Falling back to single actuator mode.\n"); 7165 + } else { 7166 + bfqd->num_actuators = ia_ranges->nr_ia_ranges; 7167 + 7168 + for (i = 0; i < bfqd->num_actuators; i++) { 7169 + bfqd->sector[i] = ia_ranges->ia_range[i].sector; 7170 + bfqd->nr_sectors[i] = 7171 + ia_ranges->ia_range[i].nr_sectors; 7172 + } 7173 + } 7174 + } 7175 + 7176 + /* Otherwise use single-actuator dev info */ 7177 + if (bfqd->num_actuators == 1) { 7178 + bfqd->sector[0] = 0; 7179 + bfqd->nr_sectors[0] = get_capacity(q->disk); 7180 + } 7181 + spin_unlock_irq(&q->queue_lock); 7173 7182 7174 7183 INIT_LIST_HEAD(&bfqd->dispatch); 7175 7184
+7 -1
block/bfq-iosched.h
··· 814 814 * case of single-actuator drives. 815 815 */ 816 816 unsigned int num_actuators; 817 - 817 + /* 818 + * Disk independent access ranges for each actuator 819 + * in this device. 820 + */ 821 + sector_t sector[BFQ_MAX_ACTUATORS]; 822 + sector_t nr_sectors[BFQ_MAX_ACTUATORS]; 823 + struct blk_independent_access_range ia_ranges[BFQ_MAX_ACTUATORS]; 818 824 }; 819 825 820 826 enum bfqq_state_flags {