[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <F792CF86EFE20D4AB8064279AFBA51C61EA9B9A2@SIXPRD3002MB028.064d.mgd.msft.net>
Date: Fri, 30 Jan 2015 05:03:23 +0000
From: Dexuan Cui <decui@...rosoft.com>
To: Vitaly Kuznetsov <vkuznets@...hat.com>
CC: "gregkh@...uxfoundation.org" <gregkh@...uxfoundation.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
"driverdev-devel@...uxdriverproject.org"
<driverdev-devel@...uxdriverproject.org>,
"olaf@...fle.de" <olaf@...fle.de>,
"apw@...onical.com" <apw@...onical.com>,
"jasowang@...hat.com" <jasowang@...hat.com>,
KY Srinivasan <kys@...rosoft.com>,
Haiyang Zhang <haiyangz@...rosoft.com>
Subject: RE: [PATCH 3/3] hv: vmbus_open(): reset the channel state on ENOMEM
> -----Original Message-----
> From: Vitaly Kuznetsov [mailto:vkuznets@...hat.com]
> Sent: Thursday, January 29, 2015 21:22 PM
> To: Dexuan Cui
> Cc: gregkh@...uxfoundation.org; linux-kernel@...r.kernel.org; driverdev-
> devel@...uxdriverproject.org; olaf@...fle.de; apw@...onical.com;
> jasowang@...hat.com; KY Srinivasan; Haiyang Zhang
> Subject: Re: [PATCH 3/3] hv: vmbus_open(): reset the channel state on ENOMEM
>
> Dexuan Cui <decui@...rosoft.com> 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.
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!
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.
KY, Haiyang,
Can you please confirm this issue?
Thanks,
-- Dexuan
>
> >
> > CC: "K. Y. Srinivasan" <kys@...rosoft.com>
> > Signed-off-by: Dexuan Cui <decui@...rosoft.com>
> > ---
> > drivers/hv/channel.c | 8 +++++---
> > 1 file changed, 5 insertions(+), 3 deletions(-)
> >
> > diff --git a/drivers/hv/channel.c b/drivers/hv/channel.c
> > index 2978f5e..26dcf26 100644
> > --- a/drivers/hv/channel.c
> > +++ b/drivers/hv/channel.c
> > @@ -89,9 +89,10 @@ int vmbus_open(struct vmbus_channel *newchannel,
> u32 send_ringbuffer_size,
> > out = (void *)__get_free_pages(GFP_KERNEL|__GFP_ZERO,
> > get_order(send_ringbuffer_size + recv_ringbuffer_size));
> >
> > - if (!out)
> > - return -ENOMEM;
> > -
> > + if (!out) {
> > + err = -ENOMEM;
> > + goto error0;
> > + }
> >
> > in = (void *)((unsigned long)out + send_ringbuffer_size);
> >
> > @@ -199,6 +200,7 @@ error0:
> > free_pages((unsigned long)out,
> > get_order(send_ringbuffer_size + recv_ringbuffer_size));
> > kfree(open_info);
> > + newchannel->state = CHANNEL_OPEN_STATE;
> > return err;
> > }
> > EXPORT_SYMBOL_GPL(vmbus_open);
>
> --
> Vitaly
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists