xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Wei Liu <Wei.Liu2@citrix.com>
To: Mats Petersson <mats.petersson@citrix.com>
Cc: wei.liu2@citrix.com, "xen-devel@lists.xen.org" <xen-devel@lists.xen.org>
Subject: Re: [PATCH] Switch to poll in xenconsoled's io loop.
Date: Fri, 4 Jan 2013 12:30:14 +0000	[thread overview]
Message-ID: <1357302614.18503.20.camel@iceland> (raw)
In-Reply-To: <50E5CC57.5050806@citrix.com>

On Thu, 2013-01-03 at 18:22 +0000, Mats Petersson wrote:
> On 03/01/13 17:14, Wei Liu wrote:
> > The original implementation utilies select(). In Linux select() typically
> > supports up to 1024 file descriptors. This can be a problem when user tries to
> > boot up many guests. Switching to poll() has minimum impact on existing code
> > and has better scalibility.
> >
> > Up to 8192 file descriptors are supported in the current implementation.
> >
> > Signed-off-by: Wei Liu <wei.liu2@citrix.com>
> > ---
> >   tools/console/daemon/io.c |   90 +++++++++++++++++++++++++--------------------
> >   1 file changed, 50 insertions(+), 40 deletions(-)
> >
> > diff --git a/tools/console/daemon/io.c b/tools/console/daemon/io.c
> > index 48fe151..4e3c55c 100644
> > --- a/tools/console/daemon/io.c
> > +++ b/tools/console/daemon/io.c
> > @@ -28,7 +28,7 @@
> >   #include <stdlib.h>
> >   #include <errno.h>
> >   #include <string.h>
> > -#include <sys/select.h>
> > +#include <poll.h>
> >   #include <fcntl.h>
> >   #include <unistd.h>
> >   #include <termios.h>
> > @@ -930,7 +930,6 @@ static void handle_log_reload(void)
> >   
> >   void handle_io(void)
> >   {
> > -	fd_set readfds, writefds;
> >   	int ret;
> >   
> >   	if (log_hv) {
> > @@ -959,21 +958,33 @@ void handle_io(void)
> >   
> >   	for (;;) {
> >   		struct domain *d, *n;
> > -		int max_fd = -1;
> > -		struct timeval timeout;
> > +		int poll_timeout; /* timeout in milliseconds */
> >   		struct timespec ts;
> >   		long long now, next_timeout = 0;
> >   
> > -		FD_ZERO(&readfds);
> > -		FD_ZERO(&writefds);
> > -
> > -		FD_SET(xs_fileno(xs), &readfds);
> > -		max_fd = MAX(xs_fileno(xs), max_fd);
> > -
> > -		if (log_hv) {
> > -			FD_SET(xc_evtchn_fd(xce_handle), &readfds);
> > -			max_fd = MAX(xc_evtchn_fd(xce_handle), max_fd);
> > -		}
> > +#define MAX_POLL_FDS 8192
> > +		static struct pollfd fds[MAX_POLL_FDS];
> > +		static struct pollfd *fd_to_pollfd[MAX_POLL_FDS];
> > +		int nr_fds;
> > +#define SET_FDS(_fd, _events) do {				\
> > +			if (_fd >= MAX_POLL_FDS)		\
> > +				break;				\
> > +			fds[nr_fds].fd = (_fd);			\
> > +			fds[nr_fds].events = (_events);		\
> > +			fd_to_pollfd[(_fd)] = &fds[nr_fds];	\
> > +			nr_fds++;				\
> > +		} while (0)
> > +#define FD_REVENTS(_fd) (((_fd) < MAX_POLL_FDS && fd_to_pollfd[(_fd)]) ? \
> > +			 fd_to_pollfd[(_fd)]->revents : 0)
> > +
> > +		nr_fds = 0;
> > +		memset(fds, 0, sizeof(fds));
> > +		memset(fd_to_pollfd, 0, sizeof(fd_to_pollfd));
> > +
> > +		SET_FDS(xs_fileno(xs), POLLIN);
> > +
> > +		if (log_hv)
> > +			SET_FDS(xc_evtchn_fd(xce_handle), POLLIN);
> >   
> Would it not make sense to use dynamically allocated memory instead - 
> that way, when we run out of 8192, there is nothing to change.

Writing a new version to use dynamically allocated memory.


Wei.

  reply	other threads:[~2013-01-04 12:30 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-03 17:14 [PATCH] Switch to poll in xenconsoled's io loop Wei Liu
2013-01-03 18:22 ` Mats Petersson
2013-01-04 12:30   ` Wei Liu [this message]
2013-01-04 15:58 ` [PATCH V2] Switch from select() to poll() in xenconsoled's IO loop Wei Liu
2013-01-04 16:08   ` Ian Campbell
2013-01-04 16:38     ` Wei Liu
2013-01-04 16:51       ` Mats Petersson
2013-01-04 17:17 ` [PATCH V3] " Wei Liu
2013-01-07 10:20   ` Ian Campbell
2013-01-07 12:12     ` Wei Liu
2013-01-07 12:16       ` Ian Campbell
2013-01-07 14:28 ` [PATCH V4] " Wei Liu
2013-01-07 14:39   ` Ian Campbell
2013-01-07 14:44     ` Wei Liu
2013-01-07 14:52     ` Ian Jackson
2013-01-07 14:41   ` Mats Petersson
2013-01-07 15:01     ` Wei Liu
2013-01-07 15:06       ` Mats Petersson
2013-01-07 15:17         ` Ian Campbell
2013-01-07 15:16       ` Ian Campbell
2013-01-07 15:24         ` Wei Liu

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=1357302614.18503.20.camel@iceland \
    --to=wei.liu2@citrix.com \
    --cc=mats.petersson@citrix.com \
    --cc=xen-devel@lists.xen.org \
    /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 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).