From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from sessmg22.ericsson.net (sessmg22.ericsson.net [193.180.251.58]) by dpdk.org (Postfix) with ESMTP id 7E86A475E for ; Wed, 7 Dec 2016 14:24:57 +0100 (CET) X-AuditID: c1b4fb3a-854f998000005d1c-3b-58480da8c204 Received: from ESESSHC014.ericsson.se (Unknown_Domain [153.88.183.60]) by (Symantec Mail Security) with SMTP id 43.EB.23836.8AD08485; Wed, 7 Dec 2016 14:24:56 +0100 (CET) Received: from EUR01-HE1-obe.outbound.protection.outlook.com (153.88.183.145) by oa.msg.ericsson.com (153.88.183.60) with Microsoft SMTP Server (TLS) id 14.3.319.2; Wed, 7 Dec 2016 14:23:49 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ericsson.onmicrosoft.com; s=selector1-ericsson-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=/fC/faQDAzZLS3HgHeklCq4EBwzG0D+GXChEV5OrLtQ=; b=ctOlAkggvr/rXm+jo2t5THhXIgGVwgMleq1rc5Gm7hDooDc5QejSXTWNYfmL9qkl/vN1ixC7+uat75lwcrkBWoUQXLrLjuRlkblDBvqhoMnL21b58dSdzLlrPkyko68QO6g7b3Djk/hwIc+ZCn3rVJyzyFJqKydQLhcH7Xp8t6M= Received: from AM4PR0701MB2146.eurprd07.prod.outlook.com (10.167.132.143) by HE1PR07MB1003.eurprd07.prod.outlook.com (10.162.27.19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.771.4; Wed, 7 Dec 2016 13:23:49 +0000 Received: from AM4PR0701MB2146.eurprd07.prod.outlook.com ([10.167.132.143]) by AM4PR0701MB2146.eurprd07.prod.outlook.com ([10.167.132.143]) with mapi id 15.01.0771.008; Wed, 7 Dec 2016 13:23:48 +0000 From: Jan Wickbom To: Yuanhan Liu CC: "dev@dpdk.org" , Patrik Andersson R Thread-Topic: [PATCH] vhost: allow for many vhost user ports Thread-Index: AQHSS+dsrC7gZAg5S0ivPPolwDmqTqD8TSeAgAAuW+A= Date: Wed, 7 Dec 2016 13:23:48 +0000 Message-ID: References: <1480606010-6132-1-git-send-email-jan.wickbom@ericsson.com> <20161207101257.GK31182@yliu-dev.sh.intel.com> In-Reply-To: <20161207101257.GK31182@yliu-dev.sh.intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=jan.wickbom@ericsson.com; x-originating-ip: [192.176.1.95] x-microsoft-exchange-diagnostics: 1; HE1PR07MB1003; 7:MVfypSa5xqQF8C9+gT3vB3x1l8xTyQr9XDcGp6fjxpoSkLjWr6d2lOthqTdJHBOk5MO3Mop+mCjo62A+MOqNdwa9bX8WUBura6w4K6rnm2/+q97L0nmv66MS/VeCUj+3PxdvHCynIUMMD78s1VVaBZ+bLgHPUC2ZtzUE1yqIticiaydnR0DQ8PkDLtxiwdCRQm3tPp1Q8soIuVrxo6ayIJ3Jq+i+FKmcwJDUqe+SrxnmLRhYn689u+wK1AatmtzbGJrmkmaZPr9jEO148DX8kEk2CVPCo2UujhmI4fyRTsoWzWkP2QtHmgf86oTiDfhWlF/kh/RrAR46iOhuMjHLDJpA/xoTccXXKxq3xe1+A6cDLrtuu8T50XDjpLgQP7gOn2rwcyk1KdqNL3/tZwoxlqysodrqf97P/9ciM13q2QOP1Xp5dzTWhfLOSJtSl+YHXruu2K445PvoK+m87Rpe5Q== x-forefront-antispam-report: SFV:SKI; SCL:-1SFV:NSPM; SFS:(10009020)(6009001)(7916002)(24454002)(13464003)(189002)(199003)(106356001)(2900100001)(229853002)(4001430100002)(5660300001)(54356999)(33656002)(4326007)(3660700001)(74316002)(68736007)(76176999)(97736004)(50986999)(76576001)(6916009)(66066001)(101416001)(38730400001)(39850400001)(2906002)(39410400001)(2950100002)(7846002)(7696004)(106116001)(39860400001)(7736002)(305945005)(105586002)(39450400002)(77096006)(6506006)(8936002)(110136003)(86362001)(3280700002)(189998001)(6116002)(107886002)(8676002)(9686002)(122556002)(81156014)(102836003)(81166006)(3846002)(39840400001)(92566002); DIR:OUT; SFP:1101; SCL:1; SRVR:HE1PR07MB1003; H:AM4PR0701MB2146.eurprd07.prod.outlook.com; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:en; x-ms-office365-filtering-correlation-id: e2cecfbc-f790-43ed-fd25-08d41ea44724 x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001);SRVR:HE1PR07MB1003; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(37575265505322)(228905959029699); x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(6040375)(601004)(2401047)(8121501046)(5005006)(10201501046)(3002001)(6041248)(20161123555025)(20161123560025)(20161123564025)(20161123562025)(6072148); SRVR:HE1PR07MB1003; BCL:0; PCL:0; RULEID:; SRVR:HE1PR07MB1003; x-forefront-prvs: 01494FA7F7 received-spf: None (protection.outlook.com: ericsson.com does not designate permitted sender hosts) spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Exchange-CrossTenant-originalarrivaltime: 07 Dec 2016 13:23:48.2067 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 92e84ceb-fbfd-47ab-be52-080c6b87953f X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1PR07MB1003 X-OriginatorOrg: ericsson.com X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFmphleLIzCtJLcpLzFFi42KZGbHdRncFr0eEwe9HFhbvPm1nsrg+4QKr A5PHrwVLWT3mnQwMYIrisklJzcksSy3St0vgyti55jpjwQyRiu7tK5gaGCfxdzFyckgImEh8 vjCfpYuRi0NIYB2jxJapt9ghnOOMEicuNoA5LAK9zBKLF/9jAWkREpjGJNFxNxOi6jSjxK2D W1lBEmwCOhKr33aA2SICuhJP56wDs5kFIiV2HDjOBmILC1hL7LvzhQWixkaireUDE4RtJbHt 7Ht2EJtFQEViwbTlYDW8AgkSj+98Z4ZYXCFx9d5DMJsTaM72a5vBehkFxCS+n1rDBLFLXOLW k/lMEL8JSCzZc54ZwhaVePn4HytEfbTEyn1PWCDiChKdB95A1fewSKz97gDymIRAF5vE5IPT 2SASvhLXL69khbF3t65jh7CzJWY1bIda4C0xtW8uI1Qzk8SBW1uhimQk1hxYzgTxQarE8rWt jJCQkJK4e6WTcQKj1iwkh0PYOhILdn9ig7C1JZYtfM08CxwYghInZz5hWcDIsopRtDi1uDg3 3chIL7UoM7m4OD9PLy+1ZBMjMG0c3PLbagfjweeOhxgFOBiVeHgLLrlFCLEmlhVX5h5ilOBg VhLhbeb0iBDiTUmsrEotyo8vKs1JLT7EKM3BoiTOa7byfriQQHpiSWp2ampBahFMlomDU6qB 0dk+uNnk7/YP5yYq2Zg22e9b/K519XeG8L6tLUd2FCiIbulpyf3UttJVP99A+L0jb7D5+xi9 uDfC/wJWKQhaLstfEbvjTNbLTW8c5vb8buv6nSleMunItIhTpsfMr2Y4/Z43VfCM36J5xlGT t6eKbw60F/t9YVkVR7u1zGPG4lM+mbu5r7+/qsRSnJFoqMVcVJwIAKDPWMkXAwAA 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: Wed, 07 Dec 2016 13:24:57 -0000 > -----Original Message----- > From: Yuanhan Liu [mailto:yuanhan.liu@linux.intel.com] > Sent: den 7 december 2016 11:13 > To: Jan Wickbom > Cc: dev@dpdk.org; Patrik Andersson R > Subject: Re: [PATCH] vhost: allow for many vhost user ports >=20 > 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 =3D -1; > > - int num =3D MAX_FDS; > > - > > - if (pfdset =3D=3D NULL) > > - return -1; > > + int i; > > + int num; > > > > - for (i =3D 0; i < num; i++) { > > + for (i =3D 0, num =3D pfdset->num; i < num; i++) { > > pfdentry =3D &pfdset->fd[i]; > > - if (pfdentry->fd !=3D -1) { > > - int added =3D 0; > > - if (pfdentry->rcb && rfset) { > > - FD_SET(pfdentry- > >fd, rfset); > > - added =3D 1; > > - } > > - if (pfdentry->wcb && wfset) { > > - FD_SET(pfdentry- > >fd, wfset); > > - added =3D 1; > > - } > > - if (added) > > - maxfds =3D pfdentry- > >fd < maxfds ? > > - > maxfds : pfdentry->fd; > > + > > + if (pfdentry->fd < 0) { > > + /* Hole in the list. Move the last > one here */ > > + > > + *pfdentry =3D pfdset->fd[num - 1]; > > + pfdset->fd[num - 1].fd =3D -1; > > + num =3D > fdset_adjust_num(pfdset); > > } > > + rwfds[i].fd =3D pfdentry->fd; > > + rwfds[i].events =3D pfdentry->rcb ? POLLIN : 0; > > + rwfds[i].events |=3D pfdentry->wcb ? POLLOUT : > 0; >=20 > Another thing is we don't have to re-init this rwfds array again > and again. Instead, we could >=20 > - set it up correctly when fdset_add is invoked: set the fd and > events. >=20 > - reset revents when it's been handled at fdset_event_dispatch(). >=20 > - swap with the last one and shrink the array on fd delete >=20 > 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 r= eference between an entry in the rwfds array and an entry in the pfdset array. It should sta= y 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 wil= l end up in trouble if the revent gets set for the "replaced" index. The direct reference is gone. Or am I missing something? /jaw >=20 > Thanks. >=20 > --yliu