From mboxrd@z Thu Jan 1 00:00:00 1970 From: Yuanhan Liu Subject: Re: [PATCH] vhost: allow for many vhost user ports Date: Thu, 8 Dec 2016 13:50:41 +0800 Message-ID: <20161208055041.GO31182@yliu-dev.sh.intel.com> References: <1480606010-6132-1-git-send-email-jan.wickbom@ericsson.com> <20161207101257.GK31182@yliu-dev.sh.intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: "dev@dpdk.org" , Patrik Andersson R To: Jan Wickbom Return-path: Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by dpdk.org (Postfix) with ESMTP id 5CCCC106A for ; Thu, 8 Dec 2016 06:50:00 +0100 (CET) Content-Disposition: inline In-Reply-To: List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" On Wed, Dec 07, 2016 at 01:23:48PM +0000, Jan Wickbom wrote: > > 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) ... > > > + 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? Yes, we should not shrink the rwfds during the poll, but we could later, at the end of the while() loop. Talking about that, you should not invoke fdset_shrink() inside fdset_del(), since it could be in the poll stage. --yliu