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: "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: Wed, 7 Dec 2016 13:23:48 +0000	[thread overview]
Message-ID: <AM4PR0701MB2146020B030F882D09A24A4E94850@AM4PR0701MB2146.eurprd07.prod.outlook.com> (raw)
In-Reply-To: <20161207101257.GK31182@yliu-dev.sh.intel.com>



> -----Original Message-----
> From: Yuanhan Liu [mailto:yuanhan.liu@linux.intel.com]
> Sent: den 7 december 2016 11:13
> To: Jan Wickbom <jan.wickbom@ericsson.com>
> Cc: 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:
> >  static int
> > -fdset_fill(fd_set *rfset, fd_set *wfset, struct fdset *pfdset)
> > +fdset_fill(struct pollfd *rwfds, struct fdset *pfdset)
> >  {
> >  	struct fdentry *pfdentry;
> > -	int i, maxfds = -1;
> > -	int num = MAX_FDS;
> > -
> > -	if (pfdset == NULL)
> > -		return -1;
> > +	int i;
> > +	int num;
> >
> > -	for (i = 0; i < num; i++) {
> > +	for (i = 0, num = pfdset->num; i < num; i++) {
> >  		pfdentry = &pfdset->fd[i];
> > -		if (pfdentry->fd != -1) {
> > -			int added = 0;
> > -			if (pfdentry->rcb && rfset) {
> > -				FD_SET(pfdentry-
> >fd, rfset);
> > -				added = 1;
> > -			}
> > -			if (pfdentry->wcb && wfset) {
> > -				FD_SET(pfdentry-
> >fd, wfset);
> > -				added = 1;
> > -			}
> > -			if (added)
> > -				maxfds = pfdentry-
> >fd < maxfds ?
> > -
> 	maxfds : pfdentry->fd;
> > +
> > +		if (pfdentry->fd < 0) {
> > +			/* Hole in the list. Move the last
> one here */
> > +
> > +			*pfdentry = pfdset->fd[num - 1];
> > +			pfdset->fd[num - 1].fd = -1;
> > +			num =
> fdset_adjust_num(pfdset);
> >  		}
> > +		rwfds[i].fd = pfdentry->fd;
> > +		rwfds[i].events = pfdentry->rcb ? POLLIN : 0;
> > +		rwfds[i].events |= pfdentry->wcb ? POLLOUT :
> 0;
> 
> Another thing is we don't have to re-init this rwfds array again
> and again. Instead, we could
> 
> - set it up correctly when fdset_add is invoked: set the fd and
>   events.
> 
> - reset revents when it's been handled at fdset_event_dispatch().
> 
> - swap with the last one and shrink the array on fd delete
> 
> Could you make a follow up patch for that?

I don't see how that could easily be done. The loop index, i, is a direct reference between
an entry in the rwfds array and an entry in the pfdset array. It should stay like that while we are
hanging in the poll(). If  an entry in the pfdset array is removed while we are hanging in the poll()
and we then immediately replaces it with the last entry in the array we will end up in trouble if the
revent gets set for the "replaced" index. The direct reference is gone.
Or am I missing something?
/jaw
> 
> Thanks.
> 
> 	--yliu

  reply	other threads:[~2016-12-07 13:24 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
2016-12-07  7:43     ` Yuanhan Liu
2016-12-07 10:12 ` Yuanhan Liu
2016-12-07 13:23   ` Jan Wickbom [this message]
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=AM4PR0701MB2146020B030F882D09A24A4E94850@AM4PR0701MB2146.eurprd07.prod.outlook.com \
    --to=jan.wickbom@ericsson.com \
    --cc=dev@dpdk.org \
    --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).