From: Vitaly Kuznetsov <vkuznets@redhat.com>
To: Michael Kelley <mikelley@microsoft.com>
Cc: KY Srinivasan <kys@microsoft.com>,
"martin.petersen\@oracle.com" <martin.petersen@oracle.com>,
Long Li <longli@microsoft.com>,
"James.Bottomley\@hansenpartnership.com"
<James.Bottomley@hansenpartnership.com>,
"emilne\@redhat.com" <emilne@redhat.com>,
"linux-hyperv\@vger.kernel.org" <linux-hyperv@vger.kernel.org>,
"linux-kernel\@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"linux-scsi\@vger.kernel.org" <linux-scsi@vger.kernel.org>
Subject: Re: [PATCH 1/1] scsi: storvsc: Fix calculation of sub-channel count
Date: Mon, 01 Apr 2019 15:45:13 +0200 [thread overview]
Message-ID: <87imvx261i.fsf@vitty.brq.redhat.com> (raw)
In-Reply-To: <1554076559-14873-1-git-send-email-mikelley@microsoft.com>
Michael Kelley <mikelley@microsoft.com> writes:
> When the number of sub-channels offered by Hyper-V is >= the number
> of CPUs in the VM, calculate the correct number of sub-channels.
> The current code produces one too many.
>
> This scenario arises only when the number of CPUs is artificially
> restricted (for example, with maxcpus=<n> on the kernel boot line),
> because Hyper-V normally offers a sub-channel count < number of CPUs.
> While the current code doesn't break, the extra sub-channel is
> unbalanced across the CPUs (for example, a total of 5 channels on
> a VM with 4 CPUs).
>
> Signed-off-by: Michael Kelley <mikelley@microsoft.com>
> ---
> drivers/scsi/storvsc_drv.c | 12 +++++++++++-
> 1 file changed, 11 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/scsi/storvsc_drv.c b/drivers/scsi/storvsc_drv.c
> index 84380ba..fbaa11a 100644
> --- a/drivers/scsi/storvsc_drv.c
> +++ b/drivers/scsi/storvsc_drv.c
> @@ -674,7 +674,17 @@ static void handle_multichannel_storage(struct hv_device *device, int max_chns)
> struct vstor_packet *vstor_packet;
> int ret, t;
>
> - num_sc = ((max_chns > num_cpus) ? num_cpus : max_chns);
> + /*
> + * If the number of CPUs is artificially restricted, such as
> + * with maxcpus=1 on the kernel boot line, Hyper-V could offer
> + * sub-channels >= the number of CPUs. These sub-channels
> + * should not be created. The primary channel is already created
> + * and assigned to one CPU, so check against # CPUs - 1.
> + */
Indeed.
> + num_sc = min((num_cpus - 1), max_chns);
Reviewed-by: Vitaly Kuznetsov <vkuznets@redhat.com>
(nit: you could've written
num_sc = min((num_online_cpus() - 1), max_chns);
and got rid of the now-unneeded num_cpus variable).
> + if (!num_sc)
> + return;
> +
> stor_device = get_out_stor_device(device);
> if (!stor_device)
> return;
--
Vitaly
prev parent reply other threads:[~2019-04-01 13:45 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-03-31 23:57 [PATCH 1/1] scsi: storvsc: Fix calculation of sub-channel count Michael Kelley
2019-04-01 13:45 ` Vitaly Kuznetsov [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87imvx261i.fsf@vitty.brq.redhat.com \
--to=vkuznets@redhat.com \
--cc=James.Bottomley@hansenpartnership.com \
--cc=emilne@redhat.com \
--cc=kys@microsoft.com \
--cc=linux-hyperv@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=longli@microsoft.com \
--cc=martin.petersen@oracle.com \
--cc=mikelley@microsoft.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).