DPDK patches and discussions
 help / color / mirror / Atom feed
From: Jan Wickbom <jan.wickbom@ericsson.com>
To: Yuanhan Liu <yuanhan.liu@linux.intel.com>
Cc: "huawei.xie@intel.com" <huawei.xie@intel.com>,
	"dev@dpdk.org" <dev@dpdk.org>,
	Patrik Andersson R <patrik.r.andersson@ericsson.com>
Subject: Re: [dpdk-dev] [PATCH] vhost: allow for many vhost user ports
Date: Tue, 6 Dec 2016 11:42:36 +0000	[thread overview]
Message-ID: <AM4PR0701MB214617221B10D1390754E5F194820@AM4PR0701MB2146.eurprd07.prod.outlook.com> (raw)
In-Reply-To: <20161206065633.GQ24403@yliu-dev.sh.intel.com>

> -----Original Message-----
> From: Yuanhan Liu [mailto:yuanhan.liu@linux.intel.com]
> Sent: den 6 december 2016 07:57
> To: Jan Wickbom <jan.wickbom@ericsson.com>
> Cc: huawei.xie@intel.com; dev@dpdk.org; Patrik Andersson R
> <patrik.r.andersson@ericsson.com>
> Subject: Re: [PATCH] vhost: allow for many vhost user ports
> 
> On Thu, Dec 01, 2016 at 04:26:50PM +0100, Jan Wickbom wrote:
> > Currently select() is used to monitor file descriptors for vhostuser
> > ports. This limits the number of ports possible to create since the
> > fd number is used as index in the fd_set and we have seen fds > 1023.
> 
> Yeah, it's a known issue for a while. Thanks for making a patch to fix
> that!

Thanks for your comments! Please see below for some questions/opinions.

> 
> > This patch changes select() to poll(). This way we can keep an
> > packed (pollfd) array for the fds, e.g. as many fds as the size of
> > the array.
> >
> > Also see:
> > http://dpdk.org/ml/archives/dev/2016-April/037024.html
> >
> ...
> > +/**
> > + * Adjusts the highest index populated in the array of fds
> 
> This function only shrinks (but not extends) the fdset array, so why
> not naming it to something like "fdset_shrink".
> 
> > + * @return
> > + *   Index of highest position populated + 1.
> 
> I think it's clearer to say "The new size of fdset".
> 
> 
> > @@ -189,7 +206,7 @@
> >  			pfdset->fd[i].fd = -1;
> >  			pfdset->fd[i].rcb = pfdset-
> >fd[i].wcb = NULL;
> >  			pfdset->fd[i].dat = NULL;
> > -			pfdset->num--;
> > +			(void) fdset_adjust_num(pfdset);
> 
> Unncessary cast.

I'd like to keep the cast. The function returns int and it's nice to show we deliberately
don't care. No strong opinion though, but we should do the same everywhere. Please
see below.

> 
> >  			i = -1;
> >  		}
> >  		pthread_mutex_unlock(&pfdset->fd_mutex);
> > @@ -211,12 +228,12 @@
> >
> >  	pfdset->fd[index].fd = -1;
> >  	pfdset->fd[index].rcb = pfdset->fd[index].wcb = NULL;
> > -	pfdset->fd[index].dat = NULL;
> > -	pfdset->num--;
> > +	(void) fdset_adjust_num(pfdset);

If we remove the cast above, we should remove this one as well.

> >
> >  	pthread_mutex_unlock(&pfdset->fd_mutex);
> >  }
> >
> > +
> >  /**
> >   * This functions runs in infinite blocking loop until there is no fd in
> >   * pfdset. It calls corresponding r/w handler if there is event on the fd.
> > @@ -229,44 +246,48 @@
> >  void
> >  fdset_event_dispatch(struct fdset *pfdset)
> >  {
> > -	fd_set rfds, wfds;
> > -	int i, maxfds;
> > +	int i;
> >  	struct fdentry *pfdentry;
> > -	int num = MAX_FDS;
> > +	int numfds;
> >  	fd_cb rcb, wcb;
> >  	void *dat;
> >  	int fd;
> >  	int remove1, remove2;
> >  	int ret;
> > +	int handled;
> >
> >  	if (pfdset == NULL)
> >  		return;
> >
> > +	struct pollfd * const rwfds =
> > +		rte_malloc("struct pollfd", MAX_FDS *
> sizeof(*rwfds), 0);
> 
> There is neither a NULL check, nor a free after the usage. Since it's
> a fixed size at compile time (MAX_FDS), you might want to define a
> static array for that.
> 
> 	--yliu

  reply	other threads:[~2016-12-06 11:43 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-12-01 15:26 Jan Wickbom
2016-12-06  6:56 ` Yuanhan Liu
2016-12-06 11:42   ` Jan Wickbom [this message]
2016-12-07  7:43     ` Yuanhan Liu
2016-12-07 10:12 ` Yuanhan Liu
2016-12-07 13:23   ` Jan Wickbom
2016-12-08  5:50     ` Yuanhan Liu
2016-12-12 16:55       ` Jan Wickbom
2016-12-07 12:46 ` [dpdk-dev] [PATCH v2] " Jan Wickbom
2016-12-12 16:50 ` [dpdk-dev] [PATCH v3] " Jan Wickbom
2016-12-13  9:14   ` Yuanhan Liu
2016-12-13 13:15     ` Jan Wickbom
2016-12-13 13:19 ` [dpdk-dev] [PATCH v4] " Jan Wickbom
2016-12-14  3:25   ` Yuanhan Liu
2016-12-14 15:30 ` [dpdk-dev] [PATCH v5] " Jan Wickbom
2016-12-21  9:45   ` [dpdk-dev] [PATCH v6] " Yuanhan Liu
2016-12-21 18:06     ` Stephen Hemminger
2016-12-22  3:16       ` Yuanhan Liu
2017-01-12  4:05     ` Yuanhan 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=AM4PR0701MB214617221B10D1390754E5F194820@AM4PR0701MB2146.eurprd07.prod.outlook.com \
    --to=jan.wickbom@ericsson.com \
    --cc=dev@dpdk.org \
    --cc=huawei.xie@intel.com \
    --cc=patrik.r.andersson@ericsson.com \
    --cc=yuanhan.liu@linux.intel.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 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).