mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Dexuan Cui <decui@microsoft.com>
To: KY Srinivasan <kys@microsoft.com>,
	"davem@davemloft.net" <davem@davemloft.net>,
	"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"devel@linuxdriverproject.org" <devel@linuxdriverproject.org>,
	"olaf@aepfle.de" <olaf@aepfle.de>,
	"apw@canonical.com" <apw@canonical.com>,
	"jasowang@redhat.com" <jasowang@redhat.com>,
	"vkuznets@redhat.com" <vkuznets@redhat.com>
Subject: RE: [PATCH net-next 1/1] hv_netvsc: Wait for sub-channels to be processed during probe
Date: Mon, 20 Jul 2015 09:39:03 +0000	[thread overview]
Message-ID: <da594b2ca2ed48f8b5119b7fb0269f2d@SIXPR30MB031.064d.mgd.msft.net> (raw)
In-Reply-To: <BY2PR0301MB1654D90488532EDD2318B7B3A0980@BY2PR0301MB1654.namprd03.prod.outlook.com>

> From: KY Srinivasan
> Sent: Friday, July 17, 2015 23:33
> > From: Dexuan Cui
> > Sent: Friday, July 17, 2015 3:01 AM
> > > From: K. Y. Srinivasan
> > > Sent: Friday, July 17, 2015 3:17
> > > Subject: [PATCH net-next 1/1] hv_netvsc: Wait for sub-channels to be
> > processed
> > > during probe
> > > diff --git a/drivers/net/hyperv/hyperv_net.h
> > b/drivers/net/hyperv/hyperv_net.h
> > > ...
> > > @@ -1116,6 +1127,9 @@ int rndis_filter_device_add(struct hv_device
> > *dev,
> > >  num_possible_rss_qs = cpumask_weight(node_cpu_mask);
> > >  net_device->num_chn = min(num_possible_rss_qs, num_rss_qs);
> > >
> > > +num_rss_qs = net_device->num_chn - 1;
> > > +net_device->num_sc_offered = num_rss_qs;
> > > +
> > >  if (net_device->num_chn == 1)
> > >  goto out;
> > >
> > > @@ -1157,11 +1171,22 @@ int rndis_filter_device_add(struct hv_device
> > *dev,
> > >
> > >  ret = rndis_filter_set_rss_param(rndis_device, net_device-
> > >num_chn);
> > >
> > > +/*
> > > + * Wait for the host to send us the sub-channel offers.
> > > + */
> > > +spin_lock_irqsave(&net_device->sc_lock, flags);
> > > +sc_delta = net_device->num_chn - 1 - num_rss_qs;
> > > +net_device->num_sc_offered -= sc_delta;
> >
> > Hi KY,
> > IMO here the "-= " should be "+="?
> >
> > I think sc_delta is usually <= 0, meaning the host may allocate less
> > subchannels than
> > we expect.
> > With "-=", net_device->num_sc_offered can become bigger -- this doesn't
> > seem correct.
> We control how many sub-channels we want the host to offer (say
> sc_requested). Based on this
> number we begin to track how many have actually been processed - we
> decrement sc_requested
> each time a sub-channel offer is processed. If the host were to actually offer all
> that we have requested,
> then checking for sc_requested to be zero is sufficient to ensure that we have
> processed all the
> potentially in-flight sub-channels. However, the host  may choose to offer less
> than what we had asked for
> and the variable "delta" is tracking this difference. Since we are counting down
> from what we had asked for
> we have to subtract "delta" for proper accounting.

Yes, I understand the rationale.
Let me show the issue by example:

Let's assume sc_requested is 7 and the host actually only offers 3 sub-channels:
1. Just before sending the NVSP_MSG5_TYPE_SUBCHANNEL message, we have
net_device->num_chn == 8,
num_rss_qs ==  7
net_device->num_sc_offered == 7

2. Just after we get the reply of the message,
net_device->num_chn == 4
sc_delta = net_device->num_chn - 1 - num_rss_qs, so sc_delta == 4 - 1 - 7 = -4
net_device->num_sc_offered -= sc_delta, so
net_device->num_sc_offered == 7 - (-4) = 11. It's not zero, so we sleep on the
wait_for_completion().

3. Now we process the 3 sub-channel and net_device->num_sc_offered will
become 11 -1 -1 -1 == 8 and no complete() will be invoked!

That's why I think the "-=" in the line
net_device->num_sc_offered -= sc_delta
should be "+=".

> > Why not use
> > "net_device->num_sc_offered = net_device->num_chn - 1;" directly?
> > At this point, net_device->num_chn has been the number of the actual
> > channels.
>
> I am not sure what the question here is. num_sc_offered is initialized to the
> number we
> are going to ask and this is the number that will be decremented each time a
> sub-channel
> is processed. Since the host may decide to offer us less than what we had asked
> and some
> sub-channels may have already been processed (num_sc_offerred decremented
> accordingly)
> by the time we discover that the host has offered us less than what we asked for,
> we adjust
> num_sc_offered accordingly.

Sorry, I had a misunderstanding here.
Please just ignore this question.

Thanks,
-- Dexuan

  reply	other threads:[~2015-07-20  9:39 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-16 19:17 K. Y. Srinivasan
2015-07-17 10:00 ` Dexuan Cui
2015-07-17 15:33   ` KY Srinivasan
2015-07-20  9:39     ` Dexuan Cui [this message]
2015-07-20 19:00       ` KY Srinivasan
2015-07-17 10:07 ` Dexuan Cui
2015-07-17 15:34   ` KY Srinivasan
2015-07-17 14:12 ` Vitaly Kuznetsov
2015-07-17 15:53   ` KY Srinivasan
2015-07-17 16:09     ` Vitaly Kuznetsov
2015-07-17 16:13       ` KY Srinivasan

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=da594b2ca2ed48f8b5119b7fb0269f2d@SIXPR30MB031.064d.mgd.msft.net \
    --to=decui@microsoft.com \
    --cc=apw@canonical.com \
    --cc=davem@davemloft.net \
    --cc=devel@linuxdriverproject.org \
    --cc=jasowang@redhat.com \
    --cc=kys@microsoft.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=olaf@aepfle.de \
    --cc=vkuznets@redhat.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

all inboxes | Powered by JetHome®