From: Greg KH <gregkh@linuxfoundation.org>
To: "K. Y. Srinivasan" <kys@microsoft.com>
Cc: linux-kernel@vger.kernel.org, devel@linuxdriverproject.org,
olaf@aepfle.de, apw@canonical.com, vkuznets@redhat.com,
jasowang@redhat.com
Subject: Re: [PATCH 2/5] hv: add helpers to handle hv_util device state
Date: Sun, 20 Sep 2015 22:25:32 -0700 [thread overview]
Message-ID: <20150921052532.GA24350@kroah.com> (raw)
In-Reply-To: <1442363874-22508-2-git-send-email-kys@microsoft.com>
On Tue, Sep 15, 2015 at 05:37:51PM -0700, K. Y. Srinivasan wrote:
> From: Olaf Hering <olaf@aepfle.de>
>
> The callbacks in kvp, vss and fcopy code are called both from the main thread
> as well as from interrupt context. If a state change is done by the main
> thread it is not immediately seen by the interrupt. As a result the
> state machine gets out of sync.
>
> Force propagation of state changes via get/set helpers with a memory barrier.
>
> Signed-off-by: Olaf Hering <olaf@aepfle.de>
> Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
> ---
> drivers/hv/hyperv_vmbus.h | 14 ++++++++++++++
> 1 files changed, 14 insertions(+), 0 deletions(-)
>
> diff --git a/drivers/hv/hyperv_vmbus.h b/drivers/hv/hyperv_vmbus.h
> index 4b1eb6d..dee5798 100644
> --- a/drivers/hv/hyperv_vmbus.h
> +++ b/drivers/hv/hyperv_vmbus.h
> @@ -780,4 +780,18 @@ enum hvutil_device_state {
> HVUTIL_DEVICE_DYING, /* driver unload is in progress */
> };
>
> +static inline void hvutil_device_set_state(enum hvutil_device_state *p,
> + enum hvutil_device_state s)
> +{
> + *p = s;
> + wmb();
> +}
> +
> +static inline enum hvutil_device_state
> +hvutil_device_get_state(enum hvutil_device_state *p)
> +{
> + rmb();
> + return *p;
> +}
> +
> #endif /* _HYPERV_VMBUS_H */
This is crazy. If you need to know the state of something (pun
intended) then you had better be using a lock, and not relying on a
random pointer to contain a random value and be able to do something
based on that.
This shows the code is broken, don't paper over things by throwing in
random read/write barriers, that is a HUGE flag that something bad is
happening here.
Just use a lock, that's what it is there for.
greg k-h
next prev parent reply other threads:[~2015-09-21 5:25 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-09-16 0:37 [PATCH 0/5] Drivers: hv: Miscellaneous fixes K. Y. Srinivasan
2015-09-16 0:37 ` [PATCH 1/5] Drivers: hv: vmbus: fix init_vp_index() for reloading hv_netvsc K. Y. Srinivasan
2015-09-16 0:37 ` [PATCH 2/5] hv: add helpers to handle hv_util device state K. Y. Srinivasan
2015-09-21 5:25 ` Greg KH [this message]
2015-09-21 10:26 ` Olaf Hering
2015-09-21 11:25 ` Vitaly Kuznetsov
2015-09-21 12:17 ` Olaf Hering
2015-09-21 13:37 ` Vitaly Kuznetsov
2015-09-21 16:45 ` KY Srinivasan
2015-09-21 16:34 ` KY Srinivasan
2015-09-21 16:43 ` Greg KH
2015-09-21 17:00 ` KY Srinivasan
2015-09-16 0:37 ` [PATCH 3/5] hv: fcopy: use wrappers to propagate state K. Y. Srinivasan
2015-09-16 0:37 ` [PATCH 4/5] hv: kvp: use wrappers to propaigate state K. Y. Srinivasan
2015-09-21 5:26 ` Greg KH
2015-09-21 10:18 ` Olaf Hering
2015-09-21 16:31 ` KY Srinivasan
2015-09-21 16:16 ` KY Srinivasan
2015-09-16 0:37 ` [PATCH 5/5] hv: vss: use wrappers to propagate state K. Y. Srinivasan
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=20150921052532.GA24350@kroah.com \
--to=gregkh@linuxfoundation.org \
--cc=apw@canonical.com \
--cc=devel@linuxdriverproject.org \
--cc=jasowang@redhat.com \
--cc=kys@microsoft.com \
--cc=linux-kernel@vger.kernel.org \
--cc=olaf@aepfle.de \
--cc=vkuznets@redhat.com \
/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