Received: by 10.223.176.5 with SMTP id f5csp395750wra; Thu, 1 Feb 2018 23:02:45 -0800 (PST) X-Google-Smtp-Source: AH8x225vmJnaZ41dCBjhi3OpT023xQD+AhjFZt3fn9nVTFiAHkQnRDlEv9n7K/zLDjFgfwlxbxNk X-Received: by 10.98.68.91 with SMTP id r88mr39518626pfa.52.1517554965322; Thu, 01 Feb 2018 23:02:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517554965; cv=none; d=google.com; s=arc-20160816; b=RXnxJNINwRMcJLWoEPvRH/3HE5bK+CMl8s/7LO4LM3PI3QqstaUlZ+Jwt9dW5PryKq rmpPAVWTzLfR5VlRE/yADYdg2PdX3V16By4f8L+Mr/PlmPcm71uqKcw4DefEl7O6+5ii 6Z18x4iBIrzNAsr1pRVWiRWzd/frgWyiHjrqe+Ud7nH54nF3dmRFyiUVl+K5D7QcwM9N Gob8BkmtkPayVKg//VaiZBkMr0vP2nbLD60T4gVgKwPWAtlyotJ5WGtHJLaIp3O9HfQs 9GOFWi82VqYI+aItgFJGr0MUoDzcAotMDnPaktKOHSoA7F2QQq+kzmtKMNO43mSLRkAi PZAg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature :arc-authentication-results; bh=dVId1OVUdaKLJUX6lw8d+kL3PPbqyvMMOkN7VdfAmf8=; b=EDC1KLUCAO8whwRFvqEZmCOtR/6ef4AXwD9HEKBUqvcTIo2ibTxcSi5XBS77X+jwLZ bmR2N4OrabSK3COhaMldoz/qMnJMTqueh6PR95YGrkdImpV5BEOTF8N9Hb7YXEVB2ZBd Coc/ReqJYwNUDBr7AdJ2xGmOJ28sC8u7oJ9n6a5CzIc2BcHi7KLXLjQiq0AkhetSIdZc YZ4zl9P30pIeEMnZn7SSR/7kG6RXiVLOA9mxV046MSwn4orqjG0XFVEI+EHHPKrjvNAA +QUHXomhnpDUDP0g7YPQe6oTR9ovybQ/g4tUB7iRpfqjVSbSSrvqvJ7PT4BlapmntdPK jvyQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=XbC9bSg7; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h3-v6si1231752pld.110.2018.02.01.23.02.30; Thu, 01 Feb 2018 23:02:45 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=XbC9bSg7; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751821AbeBBHBh (ORCPT + 99 others); Fri, 2 Feb 2018 02:01:37 -0500 Received: from mail-lf0-f67.google.com ([209.85.215.67]:44629 "EHLO mail-lf0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751043AbeBBHB3 (ORCPT ); Fri, 2 Feb 2018 02:01:29 -0500 Received: by mail-lf0-f67.google.com with SMTP id v188so29907795lfa.11 for ; Thu, 01 Feb 2018 23:01:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding:content-language; bh=dVId1OVUdaKLJUX6lw8d+kL3PPbqyvMMOkN7VdfAmf8=; b=XbC9bSg70oJp2vjOxh5C4Ego8g0yVPcWe7z30vJZaYFcqGPF/uk1DpBNF12mZbLbKL 146PsC7pgpcQ6uUTzJOXYPJzuIYXBzm1M8cNr1i3VPq/9dw6pTRAgwiYbjvf3VZiaePT hWf1CcXo/P/n8spJ9MzIwrbwxEHG5ssEMBTvYqwCB3PsuerONj499I7zv8MjtfxOk0EM mOtvU0uls38IMBJQsmFAgt9ot+CMSfKxhmUelRv21LGdbar9yuS0LuzbvqxnaKAniQMt rWpb8iYx00Gttf/MpsBV7IDTEFDJMO894T+lZtg3cKI7BmBO+/cbNZ7z9+u1mllOoSIR d9+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding :content-language; bh=dVId1OVUdaKLJUX6lw8d+kL3PPbqyvMMOkN7VdfAmf8=; b=Ko5QnrxndzGoKFRmmeaEW4/gHmXZdGa9i/pMjMJnBKx8Ru6V34+Dy5ut/3J8evgb2K QR3rbtZBr5HRVcqUVKCu3YkhKlD7FTL+LVCxDeCVFcsfotSo546ugf4+un0j003oiUy2 JOwvHoBs7VGoUKDO6vcnKgm8YZ12sfau7rRrl/3NLi3XmU9t9430KfAB1HvWdP1c8g67 TMFOE13k/01zrFRc3t+6+JKn4cy04QPuGLkL1LzBj9YgunRqorqnoNPcdmk3anann9/l emvdkCwSV/rJ1SainsI41zxy3qpkL1FlFtVzpzeaSTK6IuQXoZMxS50Lb3Ioj+8IELRH AN8w== X-Gm-Message-State: AKwxyteJPWX+qGTF/lmkcJsJw5fz9ogipEhHSpfkaDDPWlyDl5ugH8x1 fcJbQbdyktscnmMhcTisYSA= X-Received: by 10.46.33.169 with SMTP id h41mr10638798lji.20.1517554886802; Thu, 01 Feb 2018 23:01:26 -0800 (PST) Received: from [10.17.182.9] (ll-52.209.223.85.sovam.net.ua. [85.223.209.52]) by smtp.gmail.com with ESMTPSA id s87sm252172lfk.68.2018.02.01.23.01.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 01 Feb 2018 23:01:26 -0800 (PST) Subject: Re: [PATCH] xen: fix frontend driver disconnected from xenbus on removal To: Boris Ostrovsky , xen-devel@lists.xenproject.org, linux-kernel@vger.kernel.org Cc: jgross@suse.com, otubo@redhat.com, Oleksandr Andrushchenko References: <1517475439-10541-1-git-send-email-andr2000@gmail.com> <1517475439-10541-2-git-send-email-andr2000@gmail.com> <3943477e-7768-ceb3-38a3-3a20cb0e3082@oracle.com> <05dc798a-852a-aca4-8098-862ee566e1d8@gmail.com> From: Oleksandr Andrushchenko Message-ID: <5d702f19-24c8-97e5-3c5f-31ee51f8c943@gmail.com> Date: Fri, 2 Feb 2018 09:01:25 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 02/01/2018 11:09 PM, Boris Ostrovsky wrote: > On 02/01/2018 03:24 PM, Oleksandr Andrushchenko wrote: >> >> On 02/01/2018 10:08 PM, Boris Ostrovsky wrote: >>> On 02/01/2018 03:57 AM, Oleksandr Andrushchenko wrote: >>>> From: Oleksandr Andrushchenko >>>> >>>> Current xenbus frontend driver removal flow first disconnects >>>> the driver from xenbus and then calls driver's remove callback. >>>> This makes it impossible for the driver to listen to backend's >>>> state changes and synchronize the removal procedure. >>>> >>>> Fix this by removing other end XenBus watches after the >>>> driver's remove callback is called. >>>> >>>> Signed-off-by: Oleksandr Andrushchenko >>>> >>>> --- >>>> drivers/xen/xenbus/xenbus_probe.c | 4 ++-- >>>> 1 file changed, 2 insertions(+), 2 deletions(-) >>>> >>>> diff --git a/drivers/xen/xenbus/xenbus_probe.c >>>> b/drivers/xen/xenbus/xenbus_probe.c >>>> index 74888cacd0b0..9c63cd3f416b 100644 >>>> --- a/drivers/xen/xenbus/xenbus_probe.c >>>> +++ b/drivers/xen/xenbus/xenbus_probe.c >>>> @@ -258,11 +258,11 @@ int xenbus_dev_remove(struct device *_dev) >>>> DPRINTK("%s", dev->nodename); >>>> - free_otherend_watch(dev); >>>> - >>>> if (drv->remove) >>>> drv->remove(dev); >>> Is it possible for the watch to fire here? >> Indeed. Yes, It is possible, so we have to somehow protect the removed >> driver from being called, e.g. the driver cleans up in its .remove, >> but watch may still trigger .otherend_changed callback. >> Is this what you mean? > (-David who is not at Citrix anymore) > > Exactly. > > That's why otherend cleanup is split into free_otherend_watch() and > free_otherend_details(). Understood, thank you Confusion came because of the patch [1]: in .remove we wait for the backend to change its states in .otherend_changed callback and wake us, but I am not sure how those state changes may occur if during .remove the driver has already watches freed. So, this is why I tried to play around with free_otherend_watch()... > >> If so, do you have something neat on your mind how to solve this? > Not necessarily "neat" but perhaps you can use > xenbus_read_otherend_details() in both front and back ends. After all, > IIUIC you are doing something synchronously so you don't really need a > watch. Yes, I will implement a dedicated flow in the .remove instead of relying on .otherend_changed > -boris > >>> -boris >>> >>>> + free_otherend_watch(dev); >>>> + >>>> free_otherend_details(dev); >>>> xenbus_switch_state(dev, XenbusStateClosed); >> Thank you, >> Oleksandr Thank you, Oleksandr [1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/drivers/net/xen-netfront.c?id=5b5971df3bc2775107ddad164018a8a8db633b81