From mboxrd@z Thu Jan 1 00:00:00 1970 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) Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga104.fm.intel.com with ESMTP; 07 Dec 2016 21:49:58 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.33,317,1477983600"; d="scan'208";a="795590582" Received: from yliu-dev.sh.intel.com (HELO yliu-dev) ([10.239.67.162]) by FMSMGA003.fm.intel.com with ESMTP; 07 Dec 2016 21:49:58 -0800 Date: Thu, 8 Dec 2016 13:50:41 +0800 From: Yuanhan Liu To: Jan Wickbom Cc: "dev@dpdk.org" , Patrik Andersson R 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 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.23 (2014-03-12) Subject: Re: [dpdk-dev] [PATCH] vhost: allow for many vhost user ports X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 08 Dec 2016 05:50:00 -0000 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