Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp3190194imw; Mon, 18 Jul 2022 03:52:15 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tPZTLcDVAb/ZZRkOUmDgEzsGsP3GCBClZW9B8emsqqnbM50Znzg2wcWvYdJPZUNUhtP3Rz X-Received: by 2002:a05:6870:b381:b0:fe:2004:b3b5 with SMTP id w1-20020a056870b38100b000fe2004b3b5mr14885292oap.63.1658141535727; Mon, 18 Jul 2022 03:52:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658141535; cv=none; d=google.com; s=arc-20160816; b=j90jwz/SqPJe+7954zW8Frb7CvHHpSeHEcXoNQ+c/IZxQo8SuwL5aJbT3hROZMuKNa Vk2CQQjfRu1tRidoFS5WDjAfwPLc7G/BiYQWy9wsSiSGGXUXoewBoNAen7sESIer/ic7 sP85ZAt5qusBI+X0mzHEE5MPUEvBm2eqTrpbfGQVfc+D1AVGwAMJqbPnE0sCaayW6e9T vzb++UpdClOdCWPY4WQ3Dl6jSMrUpmXnVvz8ic3P9mwO5s/SQrhUwL7a0kfuCMWJVIXE 4vVQb0Lt8GoDnEvcRz4w5iB8HGJclcoQDCgi3Rkn0P7qipTAdiA38CaEFwarThOnVDK7 4BYg== 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 :organization:from:references:cc:to:content-language:subject :user-agent:mime-version:date:message-id:dkim-signature :wdcironportexception:ironport-sdr:ironport-sdr:dkim-signature; bh=rZsImc8B+vwPDZ8pGrV6xvGubBcECvWyFzvXCy0q9YQ=; b=etOLHgtwlKrCuG8Bt1I2sIkG7VqXIAhfBJUMphb8tDB7JvbNDjdYdaMdeU0kFHQ3Or YqnqRDZPCiWkERr0nJg6A90JAUN9cHNhfGOcyht3FdtgJjIWYpcMzpPvODB1I4+6FJid 5Rc6mymP+npv71RLx7l31TX3LSfbGdXB0RQX9F4lBI5iB14tU0cD5CfZV60IgZFkYHKI puWFbu1NVy4i9m7APV+TD3LdUiJIdxTKoK4PZ0WarsVWLDdz8pp6nnzTKTCN4oe1iebj 8NuxBI4RdHgwgo1EXYkj3Zto0ZicSVTOZLZJNlvUTE2hIstkCgwQ1/lsVYJ2od6bLLwh /7MQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@wdc.com header.s=dkim.wdc.com header.b=L9CAw7Xp; dkim=pass header.i=@opensource.wdc.com header.s=dkim header.b=ffy3r4Qz; 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=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=opensource.wdc.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q20-20020a056870809400b000e213d20e50si9658556oab.276.2022.07.18.03.52.00; Mon, 18 Jul 2022 03:52:15 -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; dkim=fail header.i=@wdc.com header.s=dkim.wdc.com header.b=L9CAw7Xp; dkim=pass header.i=@opensource.wdc.com header.s=dkim header.b=ffy3r4Qz; 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=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=opensource.wdc.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233597AbiGRKrh (ORCPT + 99 others); Mon, 18 Jul 2022 06:47:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53338 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233435AbiGRKrg (ORCPT ); Mon, 18 Jul 2022 06:47:36 -0400 Received: from esa3.hgst.iphmx.com (esa3.hgst.iphmx.com [216.71.153.141]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C5EEA12AB1 for ; Mon, 18 Jul 2022 03:47:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1658141254; x=1689677254; h=message-id:date:mime-version:subject:to:cc:references: from:in-reply-to:content-transfer-encoding; bh=ICBy3sF/NsNEHPOB6+kzZdomREf/FmWtWHtPkhQaSng=; b=L9CAw7XpPcCa9ZiHW69MQ5BFYK/boM1KRmaeCxRLhTeqknF8QfIpzMUj 5wgKEpuy10KyZHwub5KNqcBpRp1OoI5H8hyU5vBSMMZ8jgccV+ZS9ViEa 5hY11cjLqTS3rZhsLj/xOv2r1kVPpOQXiO5feG46tmrqWjm9BQqkzq0qo puE70x5xUI3iuSs/CzI8PZD9uG06HvR7WDfuCvdJlsyd3GfxGgxNZH2Je hD7oX0ja0S82BnlXib0hM4bU0II5IV722Cjw6WLCNGayFkDzmGcBoggSB Dg3uI7MdKc1FCaxfqeF7BzXPJj+59SCPwLBmACdkraHo0F4z3cne+xFci Q==; X-IronPort-AV: E=Sophos;i="5.92,280,1650902400"; d="scan'208";a="210984677" Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 18 Jul 2022 18:47:33 +0800 IronPort-SDR: /jrUnmIlPSIjnzGWoE6RIOS4sEawG2+QkpVWc1rjJHTWolbYU2i8kWbGtiW22AGfZnLH55yRDC WsXb5ELeGQZ9aobB32EPtrDBR0dpcHsxDT5uHXDa0lXKUGZB9pueuIa7us2kKEF7eyldEmCqXm kHeBLcsXqxqaG2RjLUCQTtc1a1jKsUnaBstYje/rugzau5Li+QiafCA27AiJrphy/eVnQob/VX uHCxeH6Y1xxJAu9m2mJ5V0VwiajugYTcE0hTmHF+g0lEENeKHgUILmYkLolwW89R+Q/NYUbiOq VWepYpf6esjQvobJlLQa8fUD Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 18 Jul 2022 03:09:00 -0700 IronPort-SDR: fCpXBSRFuijiQQjnYA7UI7xSy51lDcG4LdirOeoapRJijH+pzatGeNZV7PTfQeqMvQtbBZC/rf u9VL5AD5zvardltzgrvLdLFxvrZi609nIhogtEn2Vlht0wKJiwes/cBbFO+c9QOEPEGW6Mb8XC WBwuPjn4OUHPyuSDEhVrWPrJynWSwiqGZLzE5shQPktjeeXFhh3SDgcl71kM4efJZVwGMOmq6J 0FZPobd9ToeWQtJUNXF+2GeujelN/NGsAZdg2puibLYxZ7eCfhnGtHqCoAYH6cQk2rih94s75T IkE= WDCIronportException: Internal Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 18 Jul 2022 03:47:34 -0700 Received: from usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTP id 4Lmdvn4XFQz1Rws0 for ; Mon, 18 Jul 2022 03:47:33 -0700 (PDT) Authentication-Results: usg-ed-osssrv.wdc.com (amavisd-new); dkim=pass reason="pass (just generated, assumed good)" header.d=opensource.wdc.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d= opensource.wdc.com; h=content-transfer-encoding:content-type :in-reply-to:organization:from:references:to:content-language :subject:user-agent:mime-version:date:message-id; s=dkim; t= 1658141252; x=1660733253; bh=ICBy3sF/NsNEHPOB6+kzZdomREf/FmWtWHt PkhQaSng=; b=ffy3r4QzJl2eMxIGeYvZDxhndyaiLEBA6fObdRuA9MXXWuuAuiB zxy2PZue182NyNIs04OSk2RsuUJHRg1ElHOVGtXKOX0xUbQAqa615RJPLSPZbOk6 tgjaNfOx5LbKyKliH7H1EJXWmR6bKjTbD2Lsjb0S+1zqNlcakLIYxDDMDF7pgJpm OyOGmOMuDR4RZuFjFX+RVZsMPb0VhGzJ2aDMcdHEUamVC3CuoZt8+m2Mcyb9bHLT malHx8Lm/DEhM60u7f8h6dsj57P5IU0HEjZ83ME2zYrTjqB6SFgHwzkujjGyAuUe WnQPWsMgLhRBfdAGPCNZOXKZ0yxHnoXANag== X-Virus-Scanned: amavisd-new at usg-ed-osssrv.wdc.com Received: from usg-ed-osssrv.wdc.com ([127.0.0.1]) by usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id WEW_Q5IcLjk9 for ; Mon, 18 Jul 2022 03:47:32 -0700 (PDT) Received: from [10.225.163.120] (unknown [10.225.163.120]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTPSA id 4Lmdvk2p0qz1RtVk; Mon, 18 Jul 2022 03:47:30 -0700 (PDT) Message-ID: <6725df4f-4e27-3320-8b7b-22ba15a07866@opensource.wdc.com> Date: Mon, 18 Jul 2022 19:47:29 +0900 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.11.0 Subject: Re: [PATCH v6 4/6] scsi: sd: Allow max_sectors be capped at DMA optimal size limit Content-Language: en-US To: John Garry , joro@8bytes.org, will@kernel.org, jejb@linux.ibm.com, martin.petersen@oracle.com, hch@lst.de, m.szyprowski@samsung.com, robin.murphy@arm.com Cc: linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-ide@vger.kernel.org, iommu@lists.linux.dev, linux-scsi@vger.kernel.org, linuxarm@huawei.com References: <1657797329-98541-1-git-send-email-john.garry@huawei.com> <1657797329-98541-5-git-send-email-john.garry@huawei.com> From: Damien Le Moal Organization: Western Digital Research In-Reply-To: <1657797329-98541-5-git-send-email-john.garry@huawei.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_DNSWL_MED, SPF_HELO_PASS,SPF_PASS autolearn=unavailable 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 7/14/22 20:15, John Garry wrote: > Streaming DMA mappings may be considerably slower when mappings go through > an IOMMU and the total mapping length is somewhat long. This is because the > IOMMU IOVA code allocates and free an IOVA for each mapping, which may > affect performance. > > New member Scsi_Host.opt_sectors is added, which is the optimal host > max_sectors, and use this value to cap the request queue max_sectors when > set. > > It could be considered to have request queues io_opt value initially > set at Scsi_Host.opt_sectors in __scsi_init_queue(), but that is not > really the purpose of io_opt. > > Finally, even though Scsi_Host.opt_sectors value should never be greater > than the request queue max_hw_sectors value, continue to limit to this > value for safety. > > Signed-off-by: John Garry > --- > drivers/scsi/sd.c | 2 ++ > include/scsi/scsi_host.h | 1 + > 2 files changed, 3 insertions(+) > > diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c > index a1a2ac09066f..3eaee1f7aaca 100644 > --- a/drivers/scsi/sd.c > +++ b/drivers/scsi/sd.c > @@ -3296,6 +3296,8 @@ static int sd_revalidate_disk(struct gendisk *disk) > (sector_t)BLK_DEF_MAX_SECTORS); > } > > + rw_max = min_not_zero(rw_max, sdp->host->opt_sectors); > + Adding a comment explaining what the cap is would be nice. > /* Do not exceed controller limit */ > rw_max = min(rw_max, queue_max_hw_sectors(q)); > > diff --git a/include/scsi/scsi_host.h b/include/scsi/scsi_host.h > index 667d889b92b5..d32a84b2bb40 100644 > --- a/include/scsi/scsi_host.h > +++ b/include/scsi/scsi_host.h > @@ -607,6 +607,7 @@ struct Scsi_Host { > short unsigned int sg_tablesize; > short unsigned int sg_prot_tablesize; > unsigned int max_sectors; > + unsigned int opt_sectors; > unsigned int max_segment_size; > unsigned long dma_boundary; > unsigned long virt_boundary_mask; Otherwise, looks good. Reviewed-by: Damien Le Moal -- Damien Le Moal Western Digital Research