Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp4080109rwb; Tue, 16 Aug 2022 14:10:05 -0700 (PDT) X-Google-Smtp-Source: AA6agR7SHX6FgoyMqVDetHjMb9opGrP6BudLY0M3TmpvO43X9Zm+4wfasS4A/0nvul3gkSJVhwSR X-Received: by 2002:a05:6402:424d:b0:43e:95d8:eb46 with SMTP id g13-20020a056402424d00b0043e95d8eb46mr20764021edb.306.1660684205417; Tue, 16 Aug 2022 14:10:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660684205; cv=none; d=google.com; s=arc-20160816; b=e2FSj34m9i8VVjIl6NToqaTESrtZT8ScuuVTp37RKfQF6JoUZhUxasBZ8Mu3gmNhqK XgPdLtVOL9pO+BHAlt/Pb6/K84LXTphg10Vyh3BD/ch1/7zD43MAOv7FC/LoMsvckY8J In2v0aeHXu6jgTsFPsGBDknttF6hk/gwWAlVeOvUQUL/NSW764wnwU0v8d50Gychg8qT P5s2oueBhfD5Sdz2rrGHZRd4r1O3HQ/pWloXkTvew8GAIAV6W0zuYu1md58DwEQay8Df OF0TIQEiMf3td58/UD9h+RDZdO7wu9DkRrR9+jrgLy+afwejOdrcwpbnyJVUDP9ILMrj FogA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:subject:user-agent:mime-version:date:message-id; bh=Vrc6124aALFU0NfTBaaR+oYVUjowfqgFRHgiQbwKGbQ=; b=vbt9gVgmeg36laaOeG+Dyn9IWcHdj1IX3WN4Oe9Yn23PUfabMCIKMT8Oaw+v+2Xiha OZjyiN1zxz9CL/RdL62FzV++yDhg1IdLiuyCK6C3T/m528VFMs3vYWrKtR8d7Z5SZRoV YEMbnu5TjgVpk9ImSpCp/KZ2psxBB+3DTqebEKIJnCnNJjqkExpsxMMvTtCOkVruCwXa BnsFilEq4fX/eIvE0Q5R6tX2d/CszfmKVha7rm20/2eDmFxRpf8tjKkDAbfclXoz5lHJ +BEsciOl5VOE7KqEvqSqU00MLvMvVbPsIBPri5ZEox4yvTXcF8PyhZRA7iME4AGjC3cv Xg5A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p25-20020a17090628d900b00712210a96a4si194387ejd.226.2022.08.16.14.09.39; Tue, 16 Aug 2022 14:10:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237171AbiHPUo7 (ORCPT + 99 others); Tue, 16 Aug 2022 16:44:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55216 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237207AbiHPUol (ORCPT ); Tue, 16 Aug 2022 16:44:41 -0400 Received: from frasgout.his.huawei.com (frasgout.his.huawei.com [185.176.79.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7C093696EC; Tue, 16 Aug 2022 13:44:36 -0700 (PDT) Received: from fraeml710-chm.china.huawei.com (unknown [172.18.147.201]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4M6jgf5VMJz67N4d; Wed, 17 Aug 2022 04:39:42 +0800 (CST) Received: from lhrpeml500003.china.huawei.com (7.191.162.67) by fraeml710-chm.china.huawei.com (10.206.15.59) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Tue, 16 Aug 2022 22:44:34 +0200 Received: from [10.195.244.204] (10.195.244.204) by lhrpeml500003.china.huawei.com (7.191.162.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Tue, 16 Aug 2022 21:44:33 +0100 Message-ID: Date: Tue, 16 Aug 2022 21:44:33 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.6.1 Subject: Re: [ata] 0568e61225: stress-ng.copy-file.ops_per_sec -15.0% regression To: Damien Le Moal , Oliver Sang CC: Christoph Hellwig , "Martin K. Petersen" , LKML , "Linux Memory Management List" , , , , , , , References: <1f498d4a-f93f-ceb4-b713-753196e5e08d@opensource.wdc.com> <3451fa5a-6229-073f-ae18-0c232cd48ed5@huawei.com> <2e9cf5a6-c043-5ccf-e363-097c6c941891@huawei.com> <43eaa104-5b09-072c-56aa-6289569b0015@opensource.wdc.com> <28d6e48b-f52f-9467-8260-262504a1a1ff@huawei.com> <05a48c68-33ae-10e2-e565-6c124bad93c5@opensource.wdc.com> From: John Garry In-Reply-To: <05a48c68-33ae-10e2-e565-6c124bad93c5@opensource.wdc.com> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [10.195.244.204] X-ClientProxiedBy: lhrpeml100003.china.huawei.com (7.191.160.210) To lhrpeml500003.china.huawei.com (7.191.162.67) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,NICE_REPLY_A, RCVD_IN_DNSWL_MED,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 16/08/2022 21:02, Damien Le Moal wrote: >> ou confirm this? Thanks! >> >> On this basis, it appears that max_hw_sectors_kb is getting capped from >> scsi default @ 1024 sectors by commit 0568e61225. If it were getting >> capped by swiotlb mapping limit then that would give us 512 sectors - >> this value is fixed. >> >> So for my SHT change proposal I am just trying to revert to previous >> behaviour in 5.19 - make max_hw_sectors_kb crazy big again. > I reread the entire thing and I think I got things reverted here. The perf > regression happens with the 512/512 settings, while the original 1280/32767 > before your patches was OK. Right, that's as I read it. It would be useful for Oliver to confirm the results. > So is your patch defining the optimal mapping size > cause the reduction to 512/512. The optimal mapping size only affects specifically sas controllers, so I think that we can ignore that one for now. The reduction to 512/512 comes from the change in ata_scsi_dev_config(). > It would mean that for ATA, we need a sane > default mapping instead of SCSI default 1024 sectors. Right > Now I understand your > proposed change using ATA_MAX_SECTORS_LBA48. > > However, that would be correct only for LBA48 capable drives. > ata_dev_configure() already sets dev->max_sectors correctly according to the > drive type, capabilities and eventual quirks. So the problem comes from the > libata-scsi change: > > dev->max_sectors = min(dev->max_sectors, sdev->host->max_sectors); > > when sdev->host->max_sectors is 0 (not initialized). That cannot happen. If sht->max_sectors is 0, then we set shost->max_sectors at SCSI default 1024 sectors in scsi_host_alloc() For my proposed change, dev->max_sectors would still be initialized in ata_dev_configure() according to drive type, etc. And it should be <= LBA48 max sectors (=65535). So then in ata_scsi_dev_config(): dev->max_sectors = min(dev->max_sectors, sdev->host->max_sectors) this only has an impact for ahci controllers if sdev->host->max_sectors was capped according to host dma dev max mapping size. I will admit that this is not ideal. An alt approach is to change ata_scsi_dev_config() to cap the dev max_sectors only according to shost dma dev mapping limit (similar to scsi_add_host_with_dma()), but that would not work for a controller like ipr, which does have a geniune max_sectors limit (which we should respect). Thanks, John > So maybe simply changing > this line to: > > dev->max_sectors = min_not_zero(dev->max_sectors, sdev->host->max_sectors); > > would do the trick ? Any particular adapter driver that needs a mapping cap on > the adpter max mapping size can still set sdev->host->max_sectors as needed, and > we keep the same defaults as before when it is not set. Thoughts ? Or am I > missing something else ? > > >>> The regression may come not from commands becoming tiny, but from the fact that >>> after the patch, max_sectors_kb is too large, >> I don't think it is, but need confirmation. >> >>> causing a lot of overhead with >>> qemu swiotlb mapping and slowing down IO processing. >>> Above, it can be seen that we ed up with max_sectors_kb being 1280, which is the >>> default for most scsi disks (including ATA drives). That is normal. But before >>> that, it was 512, which likely better fits qemu swiotlb and does not generate >> Again, I don't think this this is the case. Need confirmation. >> >>> overhead. So the above fix will not change anything I think...