From: Juan Quintela <quintela@redhat.com>
To: "Michael S. Tsirkin" <mst@redhat.com>
Cc: kvm@vger.kernel.org, amit.shah@redhat.com, kraxel@redhat.com
Subject: Re: [PATCH] vhost-net: fix reversed logic in mask notifiers
Date: Tue, 25 May 2010 16:37:36 +0200 [thread overview]
Message-ID: <m3ljb8hwsv.fsf@trasno.mitica> (raw)
In-Reply-To: <20100525140043.GA19688@redhat.com> (Michael S. Tsirkin's message of "Tue, 25 May 2010 17:00:43 +0300")
"Michael S. Tsirkin" <mst@redhat.com> wrote:
> When guest notifier is assigned, we set mask notifier,
> which will assign kvm irqfd.
> When guest notifier is unassigned, mask notifier is unset,
> which should unassign kvm irqfd.
>
> The way to do this is to call mask notifier telling it to mask the vector.
> This, unless vector is already masked which unassigns irqfd already.
>
> The logic in unassign was reversed, which left kvm irqfd assigned.
>
> This patch is qemu-kvm only as irqfd is not upstream.
>
> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
> Reported-by: Amit Shah <amit.shah@redhat.com>
> ---
> hw/msix.c | 4 +++-
> 1 files changed, 3 insertions(+), 1 deletions(-)
>
> diff --git a/hw/msix.c b/hw/msix.c
> index 8f9a621..1398680 100644
> --- a/hw/msix.c
> +++ b/hw/msix.c
> @@ -617,6 +617,7 @@ int msix_set_mask_notifier(PCIDevice *dev, unsigned vector, void *opaque)
> assert(opaque);
> assert(!dev->msix_mask_notifier_opaque[vector]);
>
> + /* Unmask the new notifier unless vector is masked. */
> if (msix_is_masked(dev, vector)) {
> return 0;
> }
> @@ -638,12 +639,13 @@ int msix_unset_mask_notifier(PCIDevice *dev, unsigned vector)
> assert(dev->msix_mask_notifier);
> assert(dev->msix_mask_notifier_opaque[vector]);
>
> + /* Mask the old notifier unless it is already masked. */
> if (msix_is_masked(dev, vector)) {
> return 0;
> }
> r = dev->msix_mask_notifier(dev, vector,
> dev->msix_mask_notifier_opaque[vector],
> - msix_is_masked(dev, vector));
> + !msix_is_masked(dev, vector));
Why don't put just a 1 here?
we have:
if (msix_is_masked())
return 0
r = msix_mask_notifier(....., !msix_is_masked());
i.e. at that point msix_is_masked() is false, or we really, really needs
locking.
Puttting a !foo, when we know that it needs to be an 1 looks strange.
Later, Juan.
PD. Yes, I already asked in a previous version to just have two
methods, mask/unmask. we now at call time which one we need.
next prev parent reply other threads:[~2010-05-25 14:37 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-05-25 14:00 [PATCH] vhost-net: fix reversed logic in mask notifiers Michael S. Tsirkin
2010-05-25 14:25 ` Amit Shah
2010-05-25 14:37 ` Juan Quintela [this message]
2010-05-25 14:42 ` Michael S. Tsirkin
2010-05-25 14:58 ` Juan Quintela
2010-05-25 15:19 ` Michael S. Tsirkin
2010-05-25 15:30 ` Juan Quintela
2010-05-25 14:48 ` Gerd Hoffmann
2010-05-27 13:54 ` Avi Kivity
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=m3ljb8hwsv.fsf@trasno.mitica \
--to=quintela@redhat.com \
--cc=amit.shah@redhat.com \
--cc=kraxel@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=mst@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;
as well as URLs for NNTP newsgroup(s).