[dpdk-dev] [PATCH v13 02/14] eal/linux: add rte_epoll_wait/ctl support

Liang, Cunming cunming.liang at intel.com
Fri Jul 17 07:47:11 CEST 2015



> -----Original Message-----
> From: Thomas Monjalon [mailto:thomas.monjalon at 6wind.com]
> Sent: Tuesday, July 14, 2015 12:56 AM
> To: Liang, Cunming
> Cc: dev at dpdk.org; shemming at brocade.com; david.marchand at 6wind.com;
> Zhou, Danny; Wang, Liang-min; Richardson, Bruce; Liu, Yong;
> nhorman at tuxdriver.com
> Subject: Re: [PATCH v13 02/14] eal/linux: add rte_epoll_wait/ctl support
> 
> 2015-06-19 12:00, Cunming Liang:
> > +int
> > +rte_epoll_wait(int epfd, struct rte_epoll_event *events,
> > +	       int maxevents, int timeout)
> > +{
> > +	struct epoll_event evs[maxevents];
> > +	int rc;
> > +
> > +	if (!events) {
> > +		RTE_LOG(ERR, EAL, "rte_epoll_event can't be NULL\n");
> > +		return -1;
> > +	}
> > +
> > +	/* using per thread epoll fd */
> > +	if (epfd == RTE_EPOLL_PER_THREAD)
> > +		epfd = rte_intr_tls_epfd();
> > +
> > +	while (1) {
> > +		rc = epoll_wait(epfd, evs, maxevents, timeout);
> > +		if (likely(rc > 0)) {
> > +			/* epoll_wait has at least one fd ready to read */
> > +			rc = eal_epoll_process_event(evs, rc, events);
> > +			break;
> > +		} else if (rc < 0) {
> > +			if (errno == EINTR)
> > +				continue;
> > +			/* epoll_wait fail */
> > +			RTE_LOG(ERR, EAL, "epoll_wait returns with fail %s\n",
> > +				strerror(errno));
> > +			rc = -1;
> > +			break;
> > +		}
> > +	}
> > +
> > +	return rc;
> > +}
> 
> In general, such loop is application-level.
> What is the added value of rte_epoll_wait()?
> Do we need some wrappers to libc in DPDK?
Some motivations to do it,
1) 'epoll_event' takes either fd or a data point. However we require more to cover both rx interrupt and other user's events.
2) Some errno processing can be addressed commonly, it's helpful to focus on the real event we're interested in.
3) Usually there's one epoll instance per lcore to serve the events. Here gives a default one if it isn't assigned.


More information about the dev mailing list