[dpdk-dev] [PATCH 1/3] Add EAL threads API

Tyler Retzlaff roretzla at linux.microsoft.com
Thu Mar 18 21:04:32 CET 2021


On Thu, Mar 18, 2021 at 02:48:01PM +0000, Tal Shnaiderman wrote:
> 
> I don't know if this table is needed, the approach should be to have the return value/rte_errno identical between the OSs.
> And having the specific OS errno printed.

the underlying problem here is that dpdk is adopting linux errno spaces
as the de-facto standard.  even between bsd and linux some apis will
return different errno for the same input parameters.

between linux/bsd/unix this ends up being more subtle since usually the
alternate errno returned is still handled by the consumer of the api
in a similar manner but arguably could result in different behavior on
different platforms for the same application i.e. compatibility delta.

with windows the problem is more pronounced. calls to the underlying
native apis may fail with errors that semantically can't be represented
by the linux errno space or may not return an error at all. in such
circumstances a more generic errno is returned or the call succeeds
where it may have failed on another platform.  i.e. compatibility delta.

the patch as presented aims to be as semantically compatible as possible
with the current adopted linux errno space. we try to remap the underlying
platform error to something that makes sense within the set of linux errno
that we are allowed to return and when we can't map it we return a more
generic errno. if we've made mistakes here, please let us know.

i think there is probably a more general discussion to be had that is
off-topic for this patch about how to report errors portably in dpdk and
at the same time preserve and provide access to the underlying platform
details of the errors when needed.

> e.g. pthread_setschedparam On UNIX returns ESRCH when no thread id is found, the table below doesn't translate to it so Windows
> will never return such error code, maybe use only the errnos below for all OSs? what do you think?
> 
> > +/* Translates the most common error codes related to threads */ static
> > +int rte_thread_translate_win32_error(DWORD error) {
> > +	switch (error) {
> > +	case ERROR_SUCCESS:
> > +		return 0;
> > +
> > +	case ERROR_INVALID_PARAMETER:
> > +		return -EINVAL;
> > +
> > +	case ERROR_INVALID_HANDLE:
> > +		return -EFAULT;
> > +
> > +	case ERROR_NOT_ENOUGH_MEMORY:
> > +	/* FALLTHROUGH */
> > +	case ERROR_NO_SYSTEM_RESOURCES:
> > +		return -ENOMEM;
> > +
> > +	case ERROR_PRIVILEGE_NOT_HELD:
> > +	/* FALLTHROUGH */
> > +	case ERROR_ACCESS_DENIED:
> > +		return -EACCES;
> > +
> > +	case ERROR_ALREADY_EXISTS:
> > +		return -EEXIST;
> > +
> > +	case ERROR_POSSIBLE_DEADLOCK:
> > +		return -EDEADLK;
> > +
> > +	case ERROR_INVALID_FUNCTION:
> > +	/* FALLTHROUGH */
> > +	case ERROR_CALL_NOT_IMPLEMENTED:
> > +		return -ENOSYS;
> > +
> > +	default:
> > +		return -EINVAL;
> > +	}
> > +
> > +	return -EINVAL;
> > +}
> </snip>


More information about the dev mailing list