Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754700AbbBBCiN (ORCPT ); Sun, 1 Feb 2015 21:38:13 -0500 Received: from mail-bn1on0146.outbound.protection.outlook.com ([157.56.110.146]:22048 "EHLO na01-bn1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752277AbbBBCiL convert rfc822-to-8bit (ORCPT ); Sun, 1 Feb 2015 21:38:11 -0500 From: Dexuan Cui To: KY Srinivasan , Vitaly Kuznetsov CC: "gregkh@linuxfoundation.org" , "linux-kernel@vger.kernel.org" , "driverdev-devel@linuxdriverproject.org" , "olaf@aepfle.de" , "apw@canonical.com" , "jasowang@redhat.com" , Haiyang Zhang Subject: RE: [PATCH 3/3] hv: vmbus_open(): reset the channel state on ENOMEM Thread-Topic: [PATCH 3/3] hv: vmbus_open(): reset the channel state on ENOMEM Thread-Index: AQHQO8amul8y1x/ehE+ONgiQmCHxXZzYEp8ggAQkKQCAAHJckA== Date: Mon, 2 Feb 2015 02:37:48 +0000 Message-ID: References: <1422529370-28261-1-git-send-email-decui@microsoft.com> <87fvat7mcz.fsf@vitty.brq.redhat.com> In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [141.251.55.68] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 X-EOPAttributedMessage: 0 Authentication-Results: spf=pass (sender IP is 206.191.229.84) smtp.mailfrom=decui@microsoft.com; redhat.com; dkim=none (message not signed) header.d=none; X-Forefront-Antispam-Report: CIP:206.191.229.84;CTRY:US;IPV:NLI;EFV:NLI;SFV:NSPM;SFS:(10019020)(6009001)(438002)(51704005)(377454003)(164054003)(92566002)(86146001)(97756001)(50986999)(2561002)(46406003)(22746005)(2900100001)(2950100001)(93886004)(77156002)(62966003)(22756005)(2920100001)(102836002)(54356999)(76176999)(55846006)(19580395003)(104016003)(6806004)(50466002)(33656002)(46102003)(1511001)(66066001)(87936001)(106116001)(2656002)(23726002)(106466001)(86362001)(86612001)(79686002);DIR:OUT;SFP:1102;SCL:1;SRVR:DM2PR0301MB0845;H:064-smtp-out.microsoft.com;FPR:;SPF:Pass;MLV:sfv;LANG:en; X-Microsoft-Antispam: UriScan:; X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:;SRVR:DM2PR0301MB0845; X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(601004);SRVR:DM2PR0301MB0845; X-Forefront-PRVS: 0475418F50 X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:;SRVR:DM2PR0301MB0845; X-OriginatorOrg: microsoft.onmicrosoft.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Feb 2015 02:38:06.4445 (UTC) X-MS-Exchange-CrossTenant-Id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=72f988bf-86f1-41af-91ab-2d7cd011db47;Ip=[206.191.229.84] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM2PR0301MB0845 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3618 Lines: 94 > -----Original Message----- > From: KY Srinivasan > Sent: Monday, February 2, 2015 3:42 AM > To: Dexuan Cui; Vitaly Kuznetsov > Cc: gregkh@linuxfoundation.org; linux-kernel@vger.kernel.org; driverdev- > devel@linuxdriverproject.org; olaf@aepfle.de; apw@canonical.com; > jasowang@redhat.com; Haiyang Zhang > Subject: RE: [PATCH 3/3] hv: vmbus_open(): reset the channel state on ENOMEM > > -----Original Message----- > > From: Dexuan Cui > > Sent: Thursday, January 29, 2015 9:03 PM > > To: Vitaly Kuznetsov > > Cc: gregkh@linuxfoundation.org; linux-kernel@vger.kernel.org; driverdev- > > devel@linuxdriverproject.org; olaf@aepfle.de; apw@canonical.com; > > jasowang@redhat.com; KY Srinivasan; Haiyang Zhang > > Subject: RE: [PATCH 3/3] hv: vmbus_open(): reset the channel state on > > ENOMEM > > > > > -----Original Message----- > > > From: Vitaly Kuznetsov [mailto:vkuznets@redhat.com] > > > Sent: Thursday, January 29, 2015 21:22 PM > > > To: Dexuan Cui > > > Cc: gregkh@linuxfoundation.org; linux-kernel@vger.kernel.org; > > > driverdev- devel@linuxdriverproject.org; olaf@aepfle.de; > > > apw@canonical.com; jasowang@redhat.com; KY Srinivasan; Haiyang Zhang > > > Subject: Re: [PATCH 3/3] hv: vmbus_open(): reset the channel state on > > > ENOMEM > > > > > > Dexuan Cui writes: > > > > > > > Without this patch, the state is put to CHANNEL_OPENING_STATE, and > > > > when the driver is loaded next time, vmbus_open() will fail > > > > immediately due to > > > > newchannel->state != CHANNEL_OPEN_STATE. > > > > > > The patch makes sense, but I have one small doubt. We call vmbus_open > > > from probe functions of various devices. E.g. in hyperv-keyboard we > > > have: > > > error = vmbus_open(...) > > > if (error) > > > goto err_free_mem; > > > > > > and we don't call vmbus_close(...) on this path so no > > > CHANNELMSG_CLOSECHANNEL will be send. > > If vmbus_open() fails, depending on where the failure occurred, the necessary > rollback is expected to have > been done in the vmbus_open() function itself. In vmbus_open function the last > thing we do is to send the request > to the host to open the channel. If this fails, then there is no need to close the > channel. Got it. > > Exactly. > > > > > Who's gonna retry probe? > > The user can try 'rmmod' and 'modprobe' the module to re-probe. > > > > > Wouldn't it be better to close the channel? > > Good question! > We close the channel only if the open() of the channel succeeded. Got it. > > > > In your example, due to " goto err_free_mem", we don't run vmbus_close(), > > so the memory allocated for the ringbuffer is actually leaked! > > > > Next time when we reload the module, vmbus_open() will allocate new > > memory for the ringbuffer. > > I must be missing something here. When vmbus_open() fails, we will rollback the > state and free up the memory > allocated for the ring buffer. KY, Sorry, I didn't check the code carefully... You're correct. There is no issue here. > > As I look at the vmbus_open() code I do see an issue with regards cleaning up > the gpadl state and I am sending a patch for this > shortly. I will base this on top of the this series from Dexuan. Thanks, KY! I'm not sure you meant the below line at the end of vmbus_open(): if (err == 0) newchannel->state = CHANNEL_OPENED_STATE; ELSE ??? -- Dexuan -- 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/