Received: by 10.213.65.68 with SMTP id h4csp559711imn; Fri, 16 Mar 2018 11:29:55 -0700 (PDT) X-Google-Smtp-Source: AG47ELtpIgdq6XXFA+jw7RgcBKnRiFa3hhe56mIxEUXqrnuH/oJ+GQYD6O0kJP6IzSty8z6nYohh X-Received: by 2002:a17:902:33c2:: with SMTP id b60-v6mr3213293plc.222.1521224995116; Fri, 16 Mar 2018 11:29:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521224995; cv=none; d=google.com; s=arc-20160816; b=jgzPwfQVVd+YEHIaDp7OipgpIbihN9gqf60zlaiiqFv3xHqAxam5w/xbZiz64UwCdF M6rRStNMonGMUlj37fCHPiTUiLEm/hCU21Sq1NkvmonW6YW+RkVR9+Gzqq26hYjDkTnT wmXIo5D7PHdrCrmxzRIWA8fHL6GWdHq2/xUXYIeJ8IOvtgS6bEeeTp5iLtA8Py8jeuyI RauMC6e4zY+WrugrkcH081WhApd+JFRamIYk1pmLZDzWsB7ya0JB7yGFgy9Px61+COzq ycj8hrxGcJWDbVwhqJ3unboNmQ78zXgSknJHhvkx/lGz4TmjRof/4PCWu3RJ3QeqvP0J t+sA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :spamdiagnosticmetadata:spamdiagnosticoutput:content-language :accept-language:in-reply-to:references:message-id:date:thread-index :thread-topic:subject:to:from:dkim-signature :arc-authentication-results; bh=il7Repi1QkanGD4SufBIrYKtsZutjmBM41kn8O4Og24=; b=iPwwv7btxi7RVrHhe3Ug1jqFACeQ3SGvPVrmWgwmyM9RgmKXp1gEYvQ+3BHg1JpGvL rpf5kUT1KfNQtCIwuv9kjghxl2lcvJfNnhLqBdMiMZPK4L/OOuHFlMVm7nUSy2O0Rtnz joDY8Lg18pW9bTImaRjByp78dcJ5awRYwHuHSTssqFFAgwYL5Py9IRNgP9W4DxVpMenW kOg7DPx4+8TMjc+QhZ8ViN4vttCJ7lCHHZKhziBz2qaUCyeDZo9l0gF9xPNX3N4LuoAk xftgXmdDSo9s4G0EinN+VRH+/Es3IdjsArH/WbAY3hOw7rrVFsonjcEGuDf27rkRXfyX hZ9A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=YiEXxZEj; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x2-v6si6691968plo.479.2018.03.16.11.29.39; Fri, 16 Mar 2018 11:29:55 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=YiEXxZEj; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752866AbeCPS1K (ORCPT + 99 others); Fri, 16 Mar 2018 14:27:10 -0400 Received: from mail-dm3nam03on0124.outbound.protection.outlook.com ([104.47.41.124]:42528 "EHLO NAM03-DM3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752714AbeCPS1G (ORCPT ); Fri, 16 Mar 2018 14:27:06 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=il7Repi1QkanGD4SufBIrYKtsZutjmBM41kn8O4Og24=; b=YiEXxZEjTGmDz0qKQnmd04Ien4Gul+LjzynUjXPOotPgXA2z/QDznvLi/1tR/3+iJ0ZP740AKKMufgXGPXRCaSJzn7ir5uBF5wwOGLP1KFQHK6kSYVc6RfM1Z1IJ6F7UJJoeikPEXuQqQ0YywVC94C5c2VWldInzU6WKjukF7z8= Received: from MWHPR2101MB0729.namprd21.prod.outlook.com (10.167.161.167) by MWHPR2101MB0873.namprd21.prod.outlook.com (10.167.237.19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.609.2; Fri, 16 Mar 2018 18:27:04 +0000 Received: from MWHPR2101MB0729.namprd21.prod.outlook.com ([fe80::2944:e336:d611:1ee9]) by MWHPR2101MB0729.namprd21.prod.outlook.com ([fe80::2944:e336:d611:1ee9%3]) with mapi id 15.20.0609.007; Fri, 16 Mar 2018 18:27:04 +0000 From: Long Li To: "Michael Kelley (EOSG)" , KY Srinivasan , Haiyang Zhang , Stephen Hemminger , "James E . J . Bottomley" , "Martin K . Petersen" , "devel@linuxdriverproject.org" , "linux-scsi@vger.kernel.org" , "linux-kernel@vger.kernel.org" Subject: RE: [PATCH] storvsc: Set up correct queue depth values for IDE devices Thread-Topic: [PATCH] storvsc: Set up correct queue depth values for IDE devices Thread-Index: AQHTvLjTJ3ePeO5x9ESYCa+BVYK1xqPTBI0AgAAVpUA= Date: Fri, 16 Mar 2018 18:27:04 +0000 Message-ID: References: <20180315235223.19844-1-longli@exchange.microsoft.com> In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [2001:4898:80e8:a::2e0] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;MWHPR2101MB0873;7:iEOIz+cZGNCl31oGVWbz5hLH2V8odYlifhszlF4y63nXPdgDL0n/vaTXTjHnIiiFx4Uo5xwpNLypX27M7d7e+w1sX+yUZWkRUaL0xWDxvW1ZIaMMdXQhNUKetEEK116H+Ni818DDuBkq7wu6sKO6xIJOwadHM/7g/usKiH2/yKFIOctENFkwaBoiRknYV1lzQZ8FLc4mxakeYT2cpucmMIH0YFYGVc4wFDSW8BfoJHwSi0Ygr1R+87cL/HQLsoq2;20:b9p+++CzXHm1qBXmRAg8XlY4/JjFSwjfk39l6xgblRaZK/xM9Yun8w49Y/GcadbqR0pVo+5QS8QshoGY6q4rrjJKaFWeFUl3v8h7m+hC9dAk3rsXwu9mEtNV/wucO9NvTiEpQ2HitiMDtZFglCbflj8BuSiAP81M/OqNnLZK5eE= x-ms-exchange-antispam-srfa-diagnostics: SOS; x-ms-office365-filtering-ht: Tenant x-ms-office365-filtering-correlation-id: 29d26457-ea33-48d0-c99e-08d58b6b84bf x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(48565401081)(5600026)(4604075)(3008032)(2017052603328)(7193020);SRVR:MWHPR2101MB0873; x-ms-traffictypediagnostic: MWHPR2101MB0873: x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(28532068793085)(89211679590171); x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(8211001083)(61425038)(6040522)(2401047)(8121501046)(5005006)(3002001)(10201501046)(93006095)(93001095)(3231221)(944501281)(52105095)(6055026)(61426038)(61427038)(6041310)(20161123564045)(20161123558120)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(20161123562045)(6072148)(201708071742011);SRVR:MWHPR2101MB0873;BCL:0;PCL:0;RULEID:;SRVR:MWHPR2101MB0873; x-forefront-prvs: 0613912E23 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(346002)(366004)(376002)(39860400002)(396003)(39380400002)(189003)(199004)(6116002)(10090500001)(55016002)(14454004)(3660700001)(3280700002)(9686003)(2900100001)(2906002)(6346003)(105586002)(53936002)(102836004)(2201001)(86362001)(68736007)(97736004)(46003)(8990500004)(5250100002)(478600001)(10290500003)(6436002)(25786009)(6506007)(2501003)(22452003)(8676002)(99286004)(229853002)(59450400001)(7696005)(2950100002)(8936002)(81166006)(7736002)(81156014)(6246003)(74316002)(106356001)(33656002)(305945005)(86612001)(76176011)(316002)(1511001)(5660300001)(110136005);DIR:OUT;SFP:1102;SCL:1;SRVR:MWHPR2101MB0873;H:MWHPR2101MB0729.namprd21.prod.outlook.com;FPR:;SPF:None;PTR:InfoNoRecords;MX:1;A:1;LANG:en; received-spf: None (protection.outlook.com: microsoft.com does not designate permitted sender hosts) authentication-results: spf=none (sender IP is ) smtp.mailfrom=longli@microsoft.com; x-microsoft-antispam-message-info: Lsd9LXaAkKsbAFad//bGXv8ba5ffp8W3rN0f+0Q8nofWSaRSJdKSJ7ps02svTibWXudzEnbzTRd5f0puxqufP0anqH6WvO0/TNzLc0ri677KNRY14H5QEeIHMqj+KW5NrkEGnz7mf9giAmATVLoduTEvhWsW2KceLrGBVAjvX+poWEmD2L1jsn9Lkt+Tc4uzoaq2rKvMc8rwJZcwy3CJUULCYqLi6HCwf78XoSSB3BACBacypEUpPQLMt+bSbB/VloIGpunTHycvZmpvODStOCJL/R9Ogs5+6WAfjaLqAU1Q7GPlCcLya+P9CP+msGBiS+R6z0V6Ekv3qLmbcG53Ng== spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-Network-Message-Id: 29d26457-ea33-48d0-c99e-08d58b6b84bf X-MS-Exchange-CrossTenant-originalarrivaltime: 16 Mar 2018 18:27:04.6153 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR2101MB0873 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > > Subject: [PATCH] storvsc: Set up correct queue depth values for IDE > > devices > > > > From: Long Li > > > > Unlike SCSI and FC, we don't use multiple channels for IDE. So set > > queue depth correctly for IDE. > > > > Also set the correct cmd_per_lun for all devices. > > > > Signed-off-by: Long Li > > --- > > drivers/scsi/storvsc_drv.c | 8 ++++++-- > > 1 file changed, 6 insertions(+), 2 deletions(-) > > > > diff --git a/drivers/scsi/storvsc_drv.c b/drivers/scsi/storvsc_drv.c > > index 8c51d628b52e..fba170640e9c 100644 > > --- a/drivers/scsi/storvsc_drv.c > > +++ b/drivers/scsi/storvsc_drv.c > > @@ -1722,15 +1722,19 @@ static int storvsc_probe(struct hv_device > *device, > > max_targets =3D STORVSC_MAX_TARGETS; > > max_channels =3D STORVSC_MAX_CHANNELS; > > /* > > - * On Windows8 and above, we support sub-channels for > storage. > > + * On Windows8 and above, we support sub-channels for > storage > > + * on SCSI and FC controllers. > > * The number of sub-channels offerred is based on the > number of > > * VCPUs in the guest. > > */ > > - max_sub_channels =3D (num_cpus / > storvsc_vcpus_per_sub_channel); > > + if (!dev_is_ide) > > + max_sub_channels =3D > > + num_cpus / storvsc_vcpus_per_sub_channel; >=20 > This calculation of the # of sub-channels doesn't get the right answer (a= nd it > didn't before this patch either). storvsc_vcpus_per_sub_channel defaults= to > 4. > If num_cpus is 8, max_sub_channels will be 2, but it should be 1. The su= b- > channel count should not include the main channel since we add 1 to the > sub-channel count below when calculating can_queue. This is a good point. I will fix the code calculating can_queue. >=20 > Furthermore, this is calculation is just a guess, in the sense that we're > replicating the algorithm we think Hyper-V is using to determine the numb= er > of sub-channels to offer. It turns out Hyper-V is changing that algorit= hm for > particular devices in an upcoming new Azure VM size. But the only use of > max_sub_channels is in the calculation of can_queue below, so the impact = is > minimal. >=20 > > } > > > > scsi_driver.can_queue =3D (max_outstanding_req_per_channel * > > (max_sub_channels + 1)); > > + scsi_driver.cmd_per_lun =3D scsi_driver.can_queue; >=20 > can_queue is defined as "int", while cmd_per_lun is defined as "short". > The calculated value of can_queue could easily be over 32,767 with > 15 sub-channels and max_outstanding_req_per_channel being 3036 for the > default 1 Mbyte ring buffer. So the assignment to cmd_per_lun could > produce truncation and even a negative number. This is a good catch. I think I should try calling blk_set_queue_depth() an= d pass the correct value.=20 >=20 > More broadly, since max_outstanding_req_per_channel is based on the ring > buffer size, these calculations imply that Hyper-V storvsp's queuing capa= city > is based on the ring buffer size. I don't think that's the case. From > conversations with the storvsp folks, I think Hyper-V always removes entr= ies > from the guest->host ring buffer and then > lets storvsp queue them separately. So we don't want to be linking > cmd_per_lun (or even can_queue, for that matter) to the ring buffer size. > The current default ring buffer size of 1 Mbyte is probably 10x bigger th= an > needed, and we want to be able to adjust that without ending up with > can_queue and cmd_per_lun values that are too small. cmd_per_lun needs to reflect the device capacity. What value do you propose= ? It's not a good idea to leave them constant. Setting those values are als= o important because we don't' want to return BUSY on writing to ring buffer= on full, that will slow down the SCSI stack. Historically we use ring buffer size to calculate device properties (e.g. c= an_queue for SCSI host). I agree this doesn't need to be based on the exact queuing capacity of ring= buffer, maybe we can do 2X of that value (e.g. look at how block uses nr_r= equest in MQ). Setting those values smaller is more conservative and I don'= t see an ill effect. >=20 > We would probably do better to set can_queue to a constant, and > leave cmd_per_lun at its current value of 2048. The can_queue > value is already capped at 10240 in the blk-mq layer, so maybe that's a > reasonable constant to use. Actually this is not a good idea for smaller ring buffers. You'll see the p= roblem when setting both ring buffer sizes to 10 pages. >=20 > Thoughts? >=20 > > > > host =3D scsi_host_alloc(&scsi_driver, > > sizeof(struct hv_host_device)); > > -- > > 2.14.1