Re: [PATCH v5 0/5] DMA mapping changes for SCSI core

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

 



On 11/07/2022 11:40, Damien Le Moal wrote:
On 7/11/22 16:36, John Garry wrote:
On 11/07/2022 00:08, Damien Le Moal wrote:
Ah, I think that I misunderstood Damien's question. I thought he was
asking why not keep shost max_sectors at dma_max_mapping_size() and then
init each sdev request queue max hw sectors at dma_opt_mapping_size().
I was suggesting the reverse:)  Keep the device hard limit
(max_hw_sectors) to the max dma mapping and set the soft limit
(max_sectors) to the optimal dma mapping size.

Sure, but as I mentioned below, I only see a small % of requests whose
mapping size exceeds max_sectors but that still causes a big performance
hit. So that is why I want to set the hard limit as the optimal dma
mapping size.

How can you possibly end-up with requests larger than max_sectors ? BIO
split is done using this limit, right ? Or is it that request merging is
allowed up to max_hw_sectors even if the resulting request size exceeds
max_sectors ?


Ah, I see how I thought that I was seeing requests whose size exceeded max_sectors. Somebody must have changed a single disk in my system and this odd disk has a higher default max_sectors_kb -- 512 vs 128 for the rest.

So ignoring my nonesence that I was seeing oversize requests, as for the idea to set default max_sectors at dma_opt_mapping_size(), I see some issues: - for SAS disks I have no common point to impose this limit. Maybe in the slave configure callback, but each SAS driver has its own implementation generally - Even if we do config in slave_configure callback the max_sectors value is overwritten later in sd_revalidate_disk().

This following change could sort the issue though:

---8<----
diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index 895b56c8f25e..bb49bea3d161 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -3214,6 +3214,8 @@ static int sd_revalidate_disk(struct gendisk *disk)
        sector_t old_capacity = sdkp->capacity;
        unsigned char *buffer;
        unsigned int dev_max, rw_max;
+       struct Scsi_Host *host = sdp->host;
+       struct device *dev = host->dma_dev;

        SCSI_LOG_HLQUEUE(3, sd_printk(KERN_INFO, sdkp,
                                      "sd_revalidate_disk\n"));
@@ -3296,8 +3298,13 @@ static int sd_revalidate_disk(struct gendisk *disk)
                                      (sector_t)BLK_DEF_MAX_SECTORS);
        }

-       /* Do not exceed controller limit */
-       rw_max = min(rw_max, queue_max_hw_sectors(q));
+       if (dev->dma_mask) {
+               /* Do not exceed dma optimal limit */
+               rw_max = min_t(unsigned int, rw_max,
+                               dma_opt_mapping_size(dev) >> SECTOR_SHIFT);
+       } else {
+               rw_max = min(rw_max, queue_max_hw_sectors(q));
+       }

        /*
* Only update max_sectors if previously unset or if the current value

--->8---

Or I could go with the method in this series, which is not preferred. Let me know what you think.

Thanks,
John




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [SCSI Target Devel]     [Linux SCSI Target Infrastructure]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Linux IIO]     [Samba]     [Device Mapper]

  Powered by Linux