From: Steven Smith <sos22@cam.ac.uk>
To: "John D. Ramsdell" <ramsdell@mitre.org>
Cc: xen-devel@lists.xensource.com, Steven Smith <sos22@cam.ac.uk>,
Grzegorz Milos <gm281@cam.ac.uk>,
sos22@srcf.ucam.org
Subject: Re: [PATCH] Mini-OS to use evtchn_port_t for ports and other improvements
Date: Tue, 25 Jul 2006 11:27:15 +0100 [thread overview]
Message-ID: <20060725102715.GA4351@cam.ac.uk> (raw)
In-Reply-To: <ogt3bcszejg.fsf@divan.mitre.org>
[-- Attachment #1.1: Type: text/plain, Size: 3268 bytes --]
Sorry about the delay responding, I've been busy with other things.
This mostly looks like a pretty reasonable bit of cleanup, with just a
few minor niggles.
> @@ -86,8 +86,7 @@
> ev_actions[port].data = NULL;
> }
>
> -int bind_virq( u32 virq, void (*handler)(int, struct pt_regs *, void *data),
> - void *data)
> +int bind_virq(evtchn_port_t virq, evtchn_handler_t handler, void *data)
Did you mean this? A virq isn't the same as an evtchn_port_t, and is
usually uint32_t in the Xen header files.
> {
> evtchn_op_t op;
>
> @@ -105,7 +104,7 @@
> return 0;
> }
>
> -void unbind_virq( u32 port )
> +void unbind_virq(evtchn_port_t port)
> {
> unbind_evtchn(port);
> }
Hmm... not your fault, but unbinding from virqs is broken. You need
to know the port number, but there's no way of getting it from
bind_virq. Given that noone in the tree currently uses either
unbind_virq, I'd be inclined to just kill it.
> +static inline evtchn_port_t
> +maybe_bind_evtchn(evtchn_port_t port, evtchn_handler_t handler, void *data)
> +{
> + if (handler)
> + return bind_evtchn(port, handler, data);
> + else
> + return port;
> +}
> +
> +int evtchn_alloc_unbound(domid_t pal, evtchn_handler_t handler,
> + void *data, evtchn_port_t *port)
> +{
> + evtchn_op_t op;
> + op.cmd = EVTCHNOP_alloc_unbound;
> + op.u.alloc_unbound.dom = DOMID_SELF;
> + op.u.alloc_unbound.remote_dom = pal;
> + int err = HYPERVISOR_event_channel_op(&op);
> + if (err)
> + return err;
> + *port = maybe_bind_evtchn(op.u.alloc_unbound.port, handler, data);
Why maybe_bind? Do you ever expect to need to allocate an unbound
event channel before you know what handler to use for it?
> + return err;
> +}
> +
> +/* Connect to a port so as to allow the exchange of notifications with
> + the pal. Returns the result of the hypervisor call. */
> +
> +int evtchn_bind_interdomain(domid_t pal, evtchn_port_t remote_port,
> + evtchn_handler_t handler, void *data,
> + evtchn_port_t *local_port)
> +{
> + evtchn_op_t op;
> + op.cmd = EVTCHNOP_bind_interdomain;
> + op.u.bind_interdomain.remote_dom = pal;
> + op.u.bind_interdomain.remote_port = remote_port;
> + int err = HYPERVISOR_event_channel_op(&op);
> + if (err)
> + return err;
> + evtchn_port_t port = op.u.bind_interdomain.local_port;
> + clear_evtchn(port); /* Without, handler gets invoked now! */
Invoking the handler as soon as you bind the interdomain channel is a
mostly-deliberate part of the interface. If the other end makes
notifications before you get around to binding they can get lost, and
forcing the channel to fire as soon as you bind to it avoids some
potential lost wakeups.
> + *local_port = maybe_bind_evtchn(port, handler, data);
Again, why maybe_bind?
> @@ -137,6 +137,24 @@
> return gref;
> }
>
> +static char *gnttabop_error_msgs[] = GNTTABOP_error_msgs;
Maybe static const char *const gnttabop_error_msgs[] ?
> +
> +static const size_t gnttabop_error_size =
> + sizeof(gnttabop_error_msgs)/sizeof(gnttabop_error_msgs[0]);
Use ARRAY_SIZE here.
Other than that, this looks pretty good to me.
Steven.
[-- Attachment #1.2: Digital signature --]
[-- Type: application/pgp-signature, Size: 189 bytes --]
[-- Attachment #2: Type: text/plain, Size: 138 bytes --]
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel
next prev parent reply other threads:[~2006-07-25 10:27 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-07-23 12:33 [PATCH] Mini-OS to use evtchn_port_t for ports and other improvements John D. Ramsdell
2006-07-25 10:27 ` Steven Smith [this message]
2006-07-26 0:14 ` John D. Ramsdell
2006-07-27 9:49 ` Steven Smith
2006-07-27 12:56 ` John D. Ramsdell
2006-07-26 10:00 ` John D. Ramsdell
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=20060725102715.GA4351@cam.ac.uk \
--to=sos22@cam.ac.uk \
--cc=gm281@cam.ac.uk \
--cc=ramsdell@mitre.org \
--cc=sos22@srcf.ucam.org \
--cc=xen-devel@lists.xensource.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.