From: Alex Williamson <alex.williamson@redhat.com>
To: Sergio Lopez <slp@redhat.com>
Cc: qemu-devel@nongnu.org, vgoyal@redhat.com,
"Fam Zheng" <fam@euphon.net>,
kvm@vger.kernel.org, "Jagannathan Raman" <jag.raman@oracle.com>,
"Cornelia Huck" <cohuck@redhat.com>,
"Halil Pasic" <pasic@linux.ibm.com>,
qemu-block@nongnu.org,
"Christian Borntraeger" <borntraeger@linux.ibm.com>,
"Michael S. Tsirkin" <mst@redhat.com>,
"David Hildenbrand" <david@redhat.com>,
"Paolo Bonzini" <pbonzini@redhat.com>,
"Eric Farman" <farman@linux.ibm.com>,
"Hanna Reitz" <hreitz@redhat.com>,
"Stefan Hajnoczi" <stefanha@redhat.com>,
"Elena Ufimtseva" <elena.ufimtseva@oracle.com>,
"Kevin Wolf" <kwolf@redhat.com>,
"Philippe Mathieu-Daudé" <f4bug@amsat.org>,
"Richard Henderson" <richard.henderson@linaro.org>,
qemu-s390x@nongnu.org, "Matthew Rosato" <mjrosato@linux.ibm.com>,
"John G Johnson" <john.g.johnson@oracle.com>,
"Thomas Huth" <thuth@redhat.com>
Subject: Re: [PATCH 1/2] Allow returning EventNotifier's wfd
Date: Wed, 2 Mar 2022 08:38:45 -0700 [thread overview]
Message-ID: <20220302083845.02433972.alex.williamson@redhat.com> (raw)
In-Reply-To: <20220302152342.3hlzw3ih2agqqu6c@mhamilton>
On Wed, 2 Mar 2022 16:23:42 +0100
Sergio Lopez <slp@redhat.com> wrote:
> On Wed, Mar 02, 2022 at 08:12:34AM -0700, Alex Williamson wrote:
> > On Wed, 2 Mar 2022 12:36:43 +0100
> > Sergio Lopez <slp@redhat.com> wrote:
> >
> > > event_notifier_get_fd(const EventNotifier *e) always returns
> > > EventNotifier's read file descriptor (rfd). This is not a problem when
> > > the EventNotifier is backed by a an eventfd, as a single file
> > > descriptor is used both for reading and triggering events (rfd ==
> > > wfd).
> > >
> > > But, when EventNotifier is backed by a pipefd, we have two file
> > > descriptors, one that can only be used for reads (rfd), and the other
> > > only for writes (wfd).
> > >
> > > There's, at least, one known situation in which we need to obtain wfd
> > > instead of rfd, which is when setting up the file that's going to be
> > > sent to the peer in vhost's SET_VRING_CALL.
> > >
> > > Extend event_notifier_get_fd() to receive an argument which indicates
> > > whether the caller wants to obtain rfd (false) or wfd (true).
> >
> > There are about 50 places where we add the false arg here and 1 where
> > we use true. Seems it would save a lot of churn to hide this
> > internally, event_notifier_get_fd() returns an rfd, a new
> > event_notifier_get_wfd() returns the wfd. Thanks,
>
> I agree. In fact, that's what I implemented in the first place. I
> changed to this version in which event_notifier_get_fd() is extended
> because it feels more "correct". But yes, the pragmatic option would
> be adding a new event_notifier_get_wfd().
>
> I'll wait for more reviews, and unless someone voices against it, I'll
> respin the patches with that strategy (I already have it around here).
I'd argue that adding a bool as an arg to a function to change the
return value is sufficiently non-intuitive to program for that the
wrapper method is actually more correct. event_notifier_get_fd()
essentially becomes a shorthand for event_notifier_get_rfd(). Thanks,
Alex
WARNING: multiple messages have this Message-ID (diff)
From: Alex Williamson <alex.williamson@redhat.com>
To: Sergio Lopez <slp@redhat.com>
Cc: "Fam Zheng" <fam@euphon.net>,
"Elena Ufimtseva" <elena.ufimtseva@oracle.com>,
kvm@vger.kernel.org, "John G Johnson" <john.g.johnson@oracle.com>,
"David Hildenbrand" <david@redhat.com>,
qemu-devel@nongnu.org, "Jagannathan Raman" <jag.raman@oracle.com>,
"Matthew Rosato" <mjrosato@linux.ibm.com>,
qemu-block@nongnu.org, "Michael S. Tsirkin" <mst@redhat.com>,
"Halil Pasic" <pasic@linux.ibm.com>,
"Thomas Huth" <thuth@redhat.com>,
"Christian Borntraeger" <borntraeger@linux.ibm.com>,
vgoyal@redhat.com, "Eric Farman" <farman@linux.ibm.com>,
"Richard Henderson" <richard.henderson@linaro.org>,
qemu-s390x@nongnu.org, "Stefan Hajnoczi" <stefanha@redhat.com>,
"Kevin Wolf" <kwolf@redhat.com>,
"Cornelia Huck" <cohuck@redhat.com>,
"Philippe Mathieu-Daudé" <f4bug@amsat.org>,
"Hanna Reitz" <hreitz@redhat.com>,
"Paolo Bonzini" <pbonzini@redhat.com>
Subject: Re: [PATCH 1/2] Allow returning EventNotifier's wfd
Date: Wed, 2 Mar 2022 08:38:45 -0700 [thread overview]
Message-ID: <20220302083845.02433972.alex.williamson@redhat.com> (raw)
In-Reply-To: <20220302152342.3hlzw3ih2agqqu6c@mhamilton>
On Wed, 2 Mar 2022 16:23:42 +0100
Sergio Lopez <slp@redhat.com> wrote:
> On Wed, Mar 02, 2022 at 08:12:34AM -0700, Alex Williamson wrote:
> > On Wed, 2 Mar 2022 12:36:43 +0100
> > Sergio Lopez <slp@redhat.com> wrote:
> >
> > > event_notifier_get_fd(const EventNotifier *e) always returns
> > > EventNotifier's read file descriptor (rfd). This is not a problem when
> > > the EventNotifier is backed by a an eventfd, as a single file
> > > descriptor is used both for reading and triggering events (rfd ==
> > > wfd).
> > >
> > > But, when EventNotifier is backed by a pipefd, we have two file
> > > descriptors, one that can only be used for reads (rfd), and the other
> > > only for writes (wfd).
> > >
> > > There's, at least, one known situation in which we need to obtain wfd
> > > instead of rfd, which is when setting up the file that's going to be
> > > sent to the peer in vhost's SET_VRING_CALL.
> > >
> > > Extend event_notifier_get_fd() to receive an argument which indicates
> > > whether the caller wants to obtain rfd (false) or wfd (true).
> >
> > There are about 50 places where we add the false arg here and 1 where
> > we use true. Seems it would save a lot of churn to hide this
> > internally, event_notifier_get_fd() returns an rfd, a new
> > event_notifier_get_wfd() returns the wfd. Thanks,
>
> I agree. In fact, that's what I implemented in the first place. I
> changed to this version in which event_notifier_get_fd() is extended
> because it feels more "correct". But yes, the pragmatic option would
> be adding a new event_notifier_get_wfd().
>
> I'll wait for more reviews, and unless someone voices against it, I'll
> respin the patches with that strategy (I already have it around here).
I'd argue that adding a bool as an arg to a function to change the
return value is sufficiently non-intuitive to program for that the
wrapper method is actually more correct. event_notifier_get_fd()
essentially becomes a shorthand for event_notifier_get_rfd(). Thanks,
Alex
next prev parent reply other threads:[~2022-03-02 15:38 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-02 11:36 [PATCH 0/2] Enable vhost-user to be used on BSD systems Sergio Lopez
2022-03-02 11:36 ` Sergio Lopez
2022-03-02 11:36 ` [PATCH 1/2] Allow returning EventNotifier's wfd Sergio Lopez
2022-03-02 11:36 ` Sergio Lopez
2022-03-02 15:12 ` Alex Williamson
2022-03-02 15:12 ` Alex Williamson
2022-03-02 15:23 ` Sergio Lopez
2022-03-02 15:23 ` Sergio Lopez
2022-03-02 15:38 ` Alex Williamson [this message]
2022-03-02 15:38 ` Alex Williamson
2022-03-02 16:06 ` Stefan Hajnoczi
2022-03-02 16:06 ` Stefan Hajnoczi
2022-03-02 17:09 ` Paolo Bonzini
2022-03-02 17:09 ` Paolo Bonzini
2022-03-02 11:36 ` [PATCH 2/2] Allow building vhost-user in BSD Sergio Lopez
2022-03-02 11:36 ` Sergio Lopez
2022-03-02 17:10 ` Paolo Bonzini
2022-03-02 17:10 ` Paolo Bonzini
2022-03-02 17:18 ` Philippe Mathieu-Daudé
2022-03-02 17:18 ` Philippe Mathieu-Daudé
2022-03-02 17:31 ` Sergio Lopez
2022-03-02 17:31 ` Sergio Lopez
2022-03-02 17:38 ` Philippe Mathieu-Daudé
2022-03-02 17:38 ` Philippe Mathieu-Daudé
2022-03-02 17:49 ` Sergio Lopez
2022-03-02 17:49 ` Sergio Lopez
2022-03-02 17:55 ` Daniel P. Berrangé
2022-03-02 17:55 ` Daniel P. Berrangé
2022-03-02 19:22 ` Philippe Mathieu-Daudé
2022-03-02 19:22 ` Philippe Mathieu-Daudé
2022-03-02 18:05 ` Paolo Bonzini
2022-03-02 18:05 ` Paolo Bonzini
2022-03-02 18:26 ` Daniel P. Berrangé
2022-03-02 18:26 ` Daniel P. Berrangé
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=20220302083845.02433972.alex.williamson@redhat.com \
--to=alex.williamson@redhat.com \
--cc=borntraeger@linux.ibm.com \
--cc=cohuck@redhat.com \
--cc=david@redhat.com \
--cc=elena.ufimtseva@oracle.com \
--cc=f4bug@amsat.org \
--cc=fam@euphon.net \
--cc=farman@linux.ibm.com \
--cc=hreitz@redhat.com \
--cc=jag.raman@oracle.com \
--cc=john.g.johnson@oracle.com \
--cc=kvm@vger.kernel.org \
--cc=kwolf@redhat.com \
--cc=mjrosato@linux.ibm.com \
--cc=mst@redhat.com \
--cc=pasic@linux.ibm.com \
--cc=pbonzini@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=qemu-s390x@nongnu.org \
--cc=richard.henderson@linaro.org \
--cc=slp@redhat.com \
--cc=stefanha@redhat.com \
--cc=thuth@redhat.com \
--cc=vgoyal@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.