* [PATCH] vhost-net: fix reversed logic in mask notifiers
@ 2010-05-25 14:00 Michael S. Tsirkin
2010-05-25 14:25 ` Amit Shah
` (3 more replies)
0 siblings, 4 replies; 9+ messages in thread
From: Michael S. Tsirkin @ 2010-05-25 14:00 UTC (permalink / raw)
To: kvm, amit.shah, quintela, kraxel
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));
if (r < 0) {
return r;
}
--
1.7.1.12.g42b7f
^ permalink raw reply related [flat|nested] 9+ messages in thread* Re: [PATCH] vhost-net: fix reversed logic in mask notifiers
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
` (2 subsequent siblings)
3 siblings, 0 replies; 9+ messages in thread
From: Amit Shah @ 2010-05-25 14:25 UTC (permalink / raw)
To: Michael S. Tsirkin; +Cc: kvm, quintela, kraxel
On (Tue) May 25 2010 [17:00:43], Michael S. Tsirkin 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>
Acked-by: Amit Shah <amit.shah@redhat.com>
Amit
^ permalink raw reply [flat|nested] 9+ messages in thread* Re: [PATCH] vhost-net: fix reversed logic in mask notifiers
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
2010-05-25 14:42 ` Michael S. Tsirkin
2010-05-25 14:48 ` Gerd Hoffmann
2010-05-27 13:54 ` Avi Kivity
3 siblings, 1 reply; 9+ messages in thread
From: Juan Quintela @ 2010-05-25 14:37 UTC (permalink / raw)
To: Michael S. Tsirkin; +Cc: kvm, amit.shah, kraxel
"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.
^ permalink raw reply [flat|nested] 9+ messages in thread* Re: [PATCH] vhost-net: fix reversed logic in mask notifiers
2010-05-25 14:37 ` Juan Quintela
@ 2010-05-25 14:42 ` Michael S. Tsirkin
2010-05-25 14:58 ` Juan Quintela
0 siblings, 1 reply; 9+ messages in thread
From: Michael S. Tsirkin @ 2010-05-25 14:42 UTC (permalink / raw)
To: Juan Quintela; +Cc: kvm, amit.shah, kraxel
On Tue, May 25, 2010 at 04:37:36PM +0200, Juan Quintela wrote:
> "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.
I find msix_is_masked clearer here than true since you don't need
to look up definition to understand what this 'true' stands for.
The value is clear from code above. What do you think?
--
MST
^ permalink raw reply [flat|nested] 9+ messages in thread* Re: [PATCH] vhost-net: fix reversed logic in mask notifiers
2010-05-25 14:42 ` Michael S. Tsirkin
@ 2010-05-25 14:58 ` Juan Quintela
2010-05-25 15:19 ` Michael S. Tsirkin
0 siblings, 1 reply; 9+ messages in thread
From: Juan Quintela @ 2010-05-25 14:58 UTC (permalink / raw)
To: Michael S. Tsirkin; +Cc: kvm, amit.shah, kraxel
"Michael S. Tsirkin" <mst@redhat.com> wrote:
> On Tue, May 25, 2010 at 04:37:36PM +0200, Juan Quintela wrote:
>> 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.
>
>
> I find msix_is_masked clearer here than true since you don't need
> to look up definition to understand what this 'true' stands for.
> The value is clear from code above. What do you think?
I preffer the change, but it is up to you.
at that point, we are using !msix_masked() to mean "true"
i.e. we know that msix_masked() is false. What you want to do is "mask".
Later, Juan.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] vhost-net: fix reversed logic in mask notifiers
2010-05-25 14:58 ` Juan Quintela
@ 2010-05-25 15:19 ` Michael S. Tsirkin
2010-05-25 15:30 ` Juan Quintela
0 siblings, 1 reply; 9+ messages in thread
From: Michael S. Tsirkin @ 2010-05-25 15:19 UTC (permalink / raw)
To: Juan Quintela; +Cc: kvm, amit.shah, kraxel
On Tue, May 25, 2010 at 04:58:15PM +0200, Juan Quintela wrote:
> "Michael S. Tsirkin" <mst@redhat.com> wrote:
> > On Tue, May 25, 2010 at 04:37:36PM +0200, Juan Quintela wrote:
>
> >> 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.
> >
> >
> > I find msix_is_masked clearer here than true since you don't need
> > to look up definition to understand what this 'true' stands for.
> > The value is clear from code above. What do you think?
>
> I preffer the change, but it is up to you.
>
> at that point, we are using !msix_masked() to mean "true"
>
> i.e. we know that msix_masked() is false. What you want to do is "mask".
>
> Later, Juan.
Right. I guess I'll keep it as is, when I look at it with a fresh mind
next time, I'll clean it all up.
--
MST
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] vhost-net: fix reversed logic in mask notifiers
2010-05-25 15:19 ` Michael S. Tsirkin
@ 2010-05-25 15:30 ` Juan Quintela
0 siblings, 0 replies; 9+ messages in thread
From: Juan Quintela @ 2010-05-25 15:30 UTC (permalink / raw)
To: Michael S. Tsirkin; +Cc: kvm, amit.shah, kraxel
"Michael S. Tsirkin" <mst@redhat.com> wrote:
> On Tue, May 25, 2010 at 04:58:15PM +0200, Juan Quintela wrote:
>> "Michael S. Tsirkin" <mst@redhat.com> wrote:
>> > On Tue, May 25, 2010 at 04:37:36PM +0200, Juan Quintela wrote:
>>
>> >> 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.
>> >
>> >
>> > I find msix_is_masked clearer here than true since you don't need
>> > to look up definition to understand what this 'true' stands for.
>> > The value is clear from code above. What do you think?
>>
>> I preffer the change, but it is up to you.
>>
>> at that point, we are using !msix_masked() to mean "true"
>>
>> i.e. we know that msix_masked() is false. What you want to do is "mask".
>>
>> Later, Juan.
>
> Right. I guess I'll keep it as is, when I look at it with a fresh mind
> next time, I'll clean it all up.
ok with me.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] vhost-net: fix reversed logic in mask notifiers
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
@ 2010-05-25 14:48 ` Gerd Hoffmann
2010-05-27 13:54 ` Avi Kivity
3 siblings, 0 replies; 9+ messages in thread
From: Gerd Hoffmann @ 2010-05-25 14:48 UTC (permalink / raw)
To: Michael S. Tsirkin; +Cc: kvm, amit.shah, quintela
On 05/25/10 16:00, Michael S. Tsirkin 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>
Acked-by: Gerd Hoffmann <kraxel@redhat.com>
cheers,
Gerd
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] vhost-net: fix reversed logic in mask notifiers
2010-05-25 14:00 [PATCH] vhost-net: fix reversed logic in mask notifiers Michael S. Tsirkin
` (2 preceding siblings ...)
2010-05-25 14:48 ` Gerd Hoffmann
@ 2010-05-27 13:54 ` Avi Kivity
3 siblings, 0 replies; 9+ messages in thread
From: Avi Kivity @ 2010-05-27 13:54 UTC (permalink / raw)
To: Michael S. Tsirkin; +Cc: kvm, amit.shah, quintela, kraxel
On 05/25/2010 05:00 PM, Michael S. Tsirkin 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.
>
Applied, thanks.
--
error compiling committee.c: too many arguments to function
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2010-05-27 13:54 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
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
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).