From: David Vrabel <david.vrabel@citrix.com>
To: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>,
Chen Gang <gang.chen.5i5j@gmail.com>
Cc: <ian.campbell@citrix.com>, <wei.liu2@citrix.com>,
<boris.ostrovsky@oracle.com>, <bhelgaas@google.com>,
<jgross@suse.com>, <yongjun_wei@trendmicro.com.cn>,
<mukesh.rathor@oracle.com>, <xen-devel@lists.xenproject.org>,
"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
<linux-pci@vger.kernel.org>, <linux-scsi@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] xen/xenbus: Use 'void' instead of 'int' for the return of xenbus_switch_state()
Date: Mon, 29 Sep 2014 15:17:10 +0100 [thread overview]
Message-ID: <542969E6.1010104@citrix.com> (raw)
In-Reply-To: <20140929140229.GA28279@laptop.dumpdata.com>
On 29/09/14 15:02, Konrad Rzeszutek Wilk wrote:
> On Sat, Sep 27, 2014 at 12:36:42AM +0800, Chen Gang wrote:
>> When xenbus_switch_state() fails, it will call xenbus_switch_fatal()
>
> Only on the first depth, not on the subsequent ones (as in if
> the first xenbus_switch_fail fails, it won't try to call
> xenbus_switch_state again and again).
>
>> internally, so need not return any status value, then use 'void' instead
>> of 'int' for xenbus_switch_state() and __xenbus_switch_state().
>
> When that switch occurs (to XenbusStateConnected) won't the watches
> fire - meaning we MUST make sure that the watch functions - if they
> use the xenbus_switch_state() they MUST not hold any locks - because
> they could be executed once more?
>
> Oh wait, we don't have to worry about that right now as the callbacks
> that pick up the messages from the XenBus are all gated on one mutex
> anyhow.
>
> Hm, anyhow, I would add this extra piece of information to the patch:
>
>
> diff --git a/drivers/xen/xen-pciback/xenbus.c b/drivers/xen/xen-pciback/xenbus.c
> index c214daa..f7399fd 100644
> --- a/drivers/xen/xen-pciback/xenbus.c
> +++ b/drivers/xen/xen-pciback/xenbus.c
> @@ -661,6 +661,12 @@ static void xen_pcibk_be_watch(struct xenbus_watch *watch,
>
> switch (xenbus_read_driver_state(pdev->xdev->nodename)) {
> case XenbusStateInitWait:
> + /*
> + * xenbus_switch_state can call xenbus_switch_fatal which will
> + * immediately set the state to XenbusStateClosing which
> + * means if we were reading for it here we MUST drop any
> + * locks so that we don't dead-lock.
> + */
Watches are asynchronous and serialised by the xenwatch thread. I can't
see what deadlock you're talking about here. Particularly since the
backend doesn't watch its own state node (it watches the frontend one).
> xen_pcibk_setup_backend(pdev);
> break;
>
>>
>> Also need be sure that all callers which check the return value must let
>> 'err' be 0.
>
> I am bit uncomfortable with that, that is due to:
>
>
> .. snip..
>> diff --git a/drivers/net/xen-netback/xenbus.c b/drivers/net/xen-netback/xenbus.c
>> index 9c47b89..b5c3d47 100644
>> --- a/drivers/net/xen-netback/xenbus.c
>> +++ b/drivers/net/xen-netback/xenbus.c
>> @@ -337,10 +337,7 @@ static int netback_probe(struct xenbus_device *dev,
>> if (err)
>> pr_debug("Error writing multi-queue-max-queues\n");
>>
>> - err = xenbus_switch_state(dev, XenbusStateInitWait);
>> - if (err)
>> - goto fail;
>> -
>> + xenbus_switch_state(dev, XenbusStateInitWait);
>
> Which if it fails it won't call:
>
> 354 fail:
> 355 pr_debug("failed\n");
> 356 netback_remove(dev);
> 357 return err;
>
>
> And since there is no watch on the backend state to go in Closing it won't
> ever call those and we leak memory.
It's not leaking the memory. All resources will be recovered when the
device is removed.
> The same is for xen-blkback mechanism in the probe function.
David
next prev parent reply other threads:[~2014-09-29 14:17 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-09-26 16:36 [PATCH] xen/xenbus: Use 'void' instead of 'int' for the return of xenbus_switch_state() Chen Gang
2014-09-26 18:07 ` [Xen-devel] " David Vrabel
2014-09-27 9:20 ` Chen Gang
2014-09-29 8:41 ` Wei Liu
2014-09-29 14:03 ` Konrad Rzeszutek Wilk
2014-09-29 5:09 ` Juergen Gross
2014-09-29 13:35 ` Bjorn Helgaas
2014-09-29 14:02 ` Konrad Rzeszutek Wilk
2014-09-29 14:17 ` David Vrabel [this message]
2014-09-29 15:40 ` Konrad Rzeszutek Wilk
2014-09-29 17:14 ` David Vrabel
2014-09-30 8:04 ` Chen Gang
2014-09-30 9:55 ` David Vrabel
2014-09-30 10:10 ` Chen Gang
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=542969E6.1010104@citrix.com \
--to=david.vrabel@citrix.com \
--cc=bhelgaas@google.com \
--cc=boris.ostrovsky@oracle.com \
--cc=gang.chen.5i5j@gmail.com \
--cc=ian.campbell@citrix.com \
--cc=jgross@suse.com \
--cc=konrad.wilk@oracle.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=mukesh.rathor@oracle.com \
--cc=netdev@vger.kernel.org \
--cc=wei.liu2@citrix.com \
--cc=xen-devel@lists.xenproject.org \
--cc=yongjun_wei@trendmicro.com.cn \
/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).