Skip to contentSkip to conversation

libxc/evtchn: Missed events when using several handles.

DISCUSSION Vincent Bernardoff 2 participants 4 messages Aug 6, 2013

lore
Share & tools
lore
#0 lore raw

Using the attached test programs, the select fails when using h2, and works with using h1 (line 41).

It seems that using several evtchn handles does not work correctly. What is the expected behaviour when using multiple event channel handles ?

Cheers,

Vincent

#include <stdio.h>
#include <stdlib.h>
#include <sys/select.h>
#include <xenctrl.h>

int main(int argc, char** argv)
{
// This test is to check that you can use several handles to evtchn.

xc_evtchn *h1, *h2;
evtchn_port_or_error_t dest, src;
int fd, ret;

fd_set fdset;

  FD_ZERO(&fdset);

  h1 = xc_evtchn_open(NULL, 0);
  h2 = xc_evtchn_open(NULL, 0);

  if (h1 == NULL || h2 == NULL)
    {
      perror("xc_evtchn_open");
      exit(EXIT_FAILURE);
    }

  dest = xc_evtchn_bind_unbound_port(h1, 0);
  if (dest == -1)
    {
      perror("xc_evtchn_bind_unbound_port");
      exit(EXIT_FAILURE);
    }

  src = xc_evtchn_bind_interdomain(h1, 0, dest);
  if (src == -1)
    {
      perror("xc_evtchn_bind_interdomain");
      exit(EXIT_FAILURE);
    }

  fd = xc_evtchn_fd(h2);
  if (fd < 0)
    {
      perror("xc_evtchn_fd");
      exit(EXIT_FAILURE);
    }

  FD_SET(fd, &fdset);

  ret = xc_evtchn_notify(h1, src);
  if (ret == -1)
    {
      perror("xc_evtchn_notify");
      exit(EXIT_FAILURE);
    }

  ret = select(fd+1, &fdset, NULL, NULL, NULL);
  if (ret == -1)
    {
      perror("select");
      exit(EXIT_FAILURE);
    }

printf("select says there is %d bit set in the bitmask.\n", ret); exit(EXIT_SUCCESS);
}

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#1 lore raw
Quoted 2 lines · Vincent Bernardoff

Using the attached test programs, the select fails when using h2, and works with using h1 (line 41).

What do yo mean by "fails", does it return an error or does it just block waiting for an event which never happens?

Quoted 2 lines

It seems that using several evtchn handles does not work correctly. What is the expected behaviour when using multiple event channel handles ?

You only appear to bind an evtchn to h1, so I would expect that you would only see evtchns on h1 and selecting on h2 will just block waiting for something to happen, or maybe h2 will return an error because there are no evtchns to wait on. If you bind a different evtchn to h2 then you should be able to wait on both h1 and h2.

Ian.

#2 lore raw
Quoted 5 lines · Ian Campbell
Quoted 2 lines · Vincent Bernardoff
Quoted 2 lines

Using the attached test programs, the select fails when using h2, and works with using h1 (line 41).

What do yo mean by "fails", does it return an error or does it just block waiting for an event which never happens?

It does block waiting for an event which never happens.

Quoted 5 lines
Quoted 2 lines
Quoted 2 lines

It seems that using several evtchn handles does not work correctly. What is the expected behaviour when using multiple event channel handles ?

You only appear to bind an evtchn to h1, so I would expect that you would only see evtchns on h1 and selecting on h2 will just block waiting for something to happen,

It seems to be the case.

or maybe h2 will return an error because there

Quoted 1 line

are no evtchns to wait on.

No, this doesn't happen.

If you bind a different evtchn to h2 then you

Quoted 1 line

should be able to wait on both h1 and h2.

I thought that an handle was an interface to the eventchn, and that binding events was completely independant of handles, that is, all handles receive all events. I was obviously wrong, but it was not clear to guess.

Thanks,

Vincent.

#3 lore raw
Quoted 4 lines · Vincent Bernardoff

I thought that an handle was an interface to the eventchn, and that binding events was completely independant of handles, that is, all handles receive all events. I was obviously wrong, but it was not clear to guess.

Each handle is an independent entity with its own set of bound event channels.

Ian.