Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753998AbbGTTAO (ORCPT ); Mon, 20 Jul 2015 15:00:14 -0400 Received: from mail-bn1bbn0104.outbound.protection.outlook.com ([157.56.111.104]:64144 "EHLO na01-bn1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751461AbbGTTAM convert rfc822-to-8bit (ORCPT ); Mon, 20 Jul 2015 15:00:12 -0400 From: KY Srinivasan To: Dexuan Cui , "davem@davemloft.net" , "netdev@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "devel@linuxdriverproject.org" , "olaf@aepfle.de" , "apw@canonical.com" , "jasowang@redhat.com" , "vkuznets@redhat.com" Subject: RE: [PATCH net-next 1/1] hv_netvsc: Wait for sub-channels to be processed during probe Thread-Topic: [PATCH net-next 1/1] hv_netvsc: Wait for sub-channels to be processed during probe Thread-Index: AQHQv/BE7CKV1hTvu0eTIWyibDz4rJ3fbwKAgABWihCABFpngIAAmnEQ Date: Mon, 20 Jul 2015 19:00:09 +0000 Message-ID: References: <1437074222-13020-1-git-send-email-kys@microsoft.com> <4fd650437f864cf2a58e8334253f5dcd@SIXPR30MB031.064d.mgd.msft.net> In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: microsoft.com; dkim=none (message not signed) header.d=none; x-originating-ip: [2001:4898:80e8:2::6e2] x-microsoft-exchange-diagnostics: 1;BY2PR0301MB1655;5:iRP3UjDuEyJZ4DYkALqI7IfHkTq/UR0fQnGY2PiQhDnBghU9IagPV78RJeB1NY2QYZFBThaniRvy5erZ/3lVdJOnL8P78cCbR3CV0Ifp1QbwEN3E0XE/gYc7ZCGfToE5wNb2zHjtNjSFDvHutKtPxw==;24:3Hn4aHLgceIkzOGM7DsPBHq/L7QJft5uy6ForXsN45rrKAFL5y1rNNz4Bd1KwsglraM+WdSAA6XmkYr+Mhh9w4mkRAgJ1tn7UPSJ5OxiXIA=;20:ftjFEH5wIyAqzsBoOM5twTfFDwSFWm+288hB4mxXtoJ5Gg+CY/N6aUj+YVpH/Uq7X0P4k5JRp+ahL/bqVODHCg== x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BY2PR0301MB1655; by2pr0301mb1655: X-MS-Exchange-Organization-RulesExecuted x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:; x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(601004)(2401001)(5005006)(3002001);SRVR:BY2PR0301MB1655;BCL:0;PCL:0;RULEID:;SRVR:BY2PR0301MB1655; x-forefront-prvs: 0643BDA83C x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(6009001)(377454003)(13464003)(99286002)(2656002)(86362001)(102836002)(40100003)(5001960100002)(2421001)(76176999)(50986999)(5002640100001)(87936001)(5001770100001)(46102003)(2950100001)(10090500001)(2561002)(62966003)(107886002)(2900100001)(54356999)(77096005)(122556002)(33656002)(5001920100001)(5003600100002)(77156002)(19580395003)(2501003)(19580405001)(2201001)(92566002)(76576001)(189998001)(74316001)(106116001)(1511001);DIR:OUT;SFP:1102;SCL:1;SRVR:BY2PR0301MB1655;H:BY2PR0301MB1654.namprd03.prod.outlook.com;FPR:;SPF:None;MLV:sfv;LANG:en; Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-originalarrivaltime: 20 Jul 2015 19:00:09.4684 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY2PR0301MB1655 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3842 Lines: 112 > -----Original Message----- > From: Dexuan Cui > Sent: Monday, July 20, 2015 2:39 AM > To: KY Srinivasan; davem@davemloft.net; netdev@vger.kernel.org; linux- > kernel@vger.kernel.org; devel@linuxdriverproject.org; olaf@aepfle.de; > apw@canonical.com; jasowang@redhat.com; vkuznets@redhat.com > Subject: RE: [PATCH net-next 1/1] hv_netvsc: Wait for sub-channels to be > processed during probe > > > 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 "+=". Thanks Dexuan; I will fix the issue and resend. Regards, K. Y -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/