public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Vitaly Kuznetsov <vkuznets@redhat.com>
To: "K. Y. Srinivasan" <kys@microsoft.com>
Cc: gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org,
	devel@linuxdriverproject.org, olaf@aepfle.de, apw@canonical.com,
	jasowang@redhat.com, <stable@vger.kernel.org>,
	#@linuxonhyperv.com, v4.2+@linuxonhyperv.com
Subject: Re: [PATCH 1/2] Drivers: hv: vmbus: Fix a Host signaling bug
Date: Thu, 19 Nov 2015 10:11:20 +0100	[thread overview]
Message-ID: <87egfmicav.fsf@vitty.brq.redhat.com> (raw)
In-Reply-To: <1447880710-9751-1-git-send-email-kys@microsoft.com> (K. Y. Srinivasan's message of "Wed, 18 Nov 2015 13:05:09 -0800")

"K. Y. Srinivasan" <kys@microsoft.com> writes:

> Currently we have two policies for deciding when to signal the host:
> One based on the ring buffer state and the other based on what the
> VMBUS client driver wants to do. Consider the case when the client
> wants to explicitly control when to signal the host. In this case,
> if the client were to defer signaling, we will not be able to signal
> the host subsequently when the client does want to signal since the
> ring buffer state will prevent the signaling. Implement logic to
> have only one signaling policy in force for a given channel.
>
> Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
> Reviewed-by: Haiyang Zhang <haiyangz@microsoft.com>
> Tested-by: Haiyang Zhang <haiyangz@microsoft.com>
> Cc: <stable@vger.kernel.org> # v4.2+
> ---
>  drivers/hv/channel.c   |   18 ++++++++++++++++++
>  include/linux/hyperv.h |   12 ++++++++++++
>  2 files changed, 30 insertions(+), 0 deletions(-)
>
> diff --git a/drivers/hv/channel.c b/drivers/hv/channel.c
> index 77d2579..c6278c7 100644
> --- a/drivers/hv/channel.c
> +++ b/drivers/hv/channel.c
> @@ -653,10 +653,19 @@ int vmbus_sendpacket_ctl(struct vmbus_channel *channel, void *buffer,
>  	 *    on the ring. We will not signal if more data is
>  	 *    to be placed.
>  	 *
> +	 * Based on the channel signal state, we will decide
> +	 * which signaling policy will be applied.
> +	 *
>  	 * If we cannot write to the ring-buffer; signal the host
>  	 * even if we may not have written anything. This is a rare
>  	 * enough condition that it should not matter.
>  	 */
> +
> +	if (channel->signal_state)
> +		signal = true;
> +	else
> +		kick_q = true;
> +
>  	if (((ret == 0) && kick_q && signal) || (ret))
>  		vmbus_setevent(channel);
>
> @@ -756,10 +765,19 @@ int vmbus_sendpacket_pagebuffer_ctl(struct vmbus_channel *channel,
>  	 *    on the ring. We will not signal if more data is
>  	 *    to be placed.
>  	 *
> +	 * Based on the channel signal state, we will decide
> +	 * which signaling policy will be applied.
> +	 *
>  	 * If we cannot write to the ring-buffer; signal the host
>  	 * even if we may not have written anything. This is a rare
>  	 * enough condition that it should not matter.
>  	 */
> +
> +	if (channel->signal_state)
> +		signal = true;
> +	else
> +		kick_q = true;
> +
>  	if (((ret == 0) && kick_q && signal) || (ret))
>  		vmbus_setevent(channel);
>
> diff --git a/include/linux/hyperv.h b/include/linux/hyperv.h
> index 437c9c8..7b1af52 100644
> --- a/include/linux/hyperv.h
> +++ b/include/linux/hyperv.h
> @@ -756,8 +756,20 @@ struct vmbus_channel {
>  	 * link up channels based on their CPU affinity.
>  	 */
>  	struct list_head percpu_list;
> +	/*
> +	 * Host signaling policy: The default policy will be
> +	 * based on the ring buffer state. We will also support
> +	 * a policy where the client driver can have explicit
> +	 * signaling control.
> +	 */
> +	bool signal_state;

Making policy selector 'bool' is counter-intuitive: I suggest we rename
this to somethink like 'signal_explicit' if we're sure there won't be
new policies or (even better in my opinion) introduce a new enum with
these policies, e.g:

       enum hv_channel_policy signal_policy;

where

enum hv_channel_policy {
      HV_CHANNELPOLICY_DEFAULT,
      HV_CHANNELPOLICY_EXPLICIT,
};

>  };
>
> +static inline void set_channel_signal_state(struct vmbus_channel *c, bool state)
> +{
> +	c->signal_state = state;
> +}
> +
>  static inline void set_channel_read_state(struct vmbus_channel *c, bool state)
>  {
>  	c->batched_reading = state;

-- 
  Vitaly

      parent reply	other threads:[~2015-11-19  9:11 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-18 21:04 [PATCH 0/2] Drivers: hv: vmbus: Fix a couple of bugs K. Y. Srinivasan
2015-11-18 21:05 ` [PATCH 1/2] Drivers: hv: vmbus: Fix a Host signaling bug K. Y. Srinivasan
2015-11-18 21:05   ` [PATCH 2/2] drivers/hv: correct tsc page sequence invalid value K. Y. Srinivasan
2015-11-19  9:11   ` Vitaly Kuznetsov [this message]

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=87egfmicav.fsf@vitty.brq.redhat.com \
    --to=vkuznets@redhat.com \
    --cc=#@linuxonhyperv.com \
    --cc=apw@canonical.com \
    --cc=devel@linuxdriverproject.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=jasowang@redhat.com \
    --cc=kys@microsoft.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=olaf@aepfle.de \
    --cc=stable@vger.kernel.org \
    --cc=v4.2+@linuxonhyperv.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