[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] Re: [PATCH 1/2] xen/event: Add reference counting to event channel



On Tue, 2011-10-25 at 20:09 +0100, Konrad Rzeszutek Wilk wrote:
> On Tue, Oct 25, 2011 at 09:17:15AM +0100, Ian Campbell wrote:
> > On Mon, 2011-10-24 at 21:22 +0100, Konrad Rzeszutek Wilk wrote:
> > > 
> > > > +void evtchn_put(unsigned int evtchn)
> > > 
> > > The decleration for 'evtchn' is 'unsigned short' so that can be
> > > used instead of 'unsigned int'.
> > 
> > I think I nearly made the same comment but then I looked at
> > drivers/xen/events.c and found that it uses "unsigned", "unsigned
> > short", "unsigned int" and "int" fairly interchangeably. The externally
> > visible API (i.e. include/xen/events.h) tends to stick to just "unsigned
> > int" or "int".
> > 
> > The problem with the short types is that they don't leave room for an
> > error indication, which is why on the Xen tools (libxc) side we have his
> > piece of minor ugliness:
> >         typedef int evtchn_port_or_error_t;
> > 
> > The actual hypercall interface uses "typedef uint32_t evtchn_port_t" but
> > AIUI real evtchn values are guaranteed to fit in 31 bits.
> 
> 
> Oh fun! So we actually have a bug with 'unsigned short' cutting it down
> from 2^31 to 2^16!

The actual maximums are 1024 (on x86_32) and 4096 (on x86_64) so
"guaranteed to fit 31 bits" (which I took from the xenctrl.h comment) is
more a case of definitely big enough. The use of 31 is more of an
allusion to errors being negative, I think.

Ian


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.