From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 8E2DFA0561; Thu, 18 Mar 2021 21:04:34 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 5B359140F37; Thu, 18 Mar 2021 21:04:34 +0100 (CET) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id 619A740698 for ; Thu, 18 Mar 2021 21:04:33 +0100 (CET) Received: by linux.microsoft.com (Postfix, from userid 1086) id 9BC5D20B39C5; Thu, 18 Mar 2021 13:04:32 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 9BC5D20B39C5 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1616097872; bh=xNXgbty82hDoMs/kbP3snLOC5o7GVUQaWR3dIPmtIdg=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=f9zx3kCmYySoCy51G/1Rkl6QK4dZYxnHsCgQK3V+C+3Xu4iDQSDM1Bl3s9cTIImYG 0GEmCW3ZdyktBzO1cdEQGASbnIjVxVuqOvsImp60qZYIRdS6s4AMwoyE5FwmeQfhfC USpqdQ6EhJ1i9sUoLWN9ae6es5mDWPOEu8i2UEps= Date: Thu, 18 Mar 2021 13:04:32 -0700 From: Tyler Retzlaff To: Tal Shnaiderman Cc: Narcisa Ana Maria Vasile , "dev@dpdk.org" , NBU-Contact-Thomas Monjalon , "dmitry.kozliuk@gmail.com" , "khot@microsoft.com" , "navasile@microsoft.com" , "dmitrym@microsoft.com" , "roretzla@microsoft.com" , "ocardona@microsoft.com" , "bruce.richardson@intel.com" , "david.marchand@redhat.com" , "pallavi.kadam@intel.com" Message-ID: <20210318200432.GA9226@linuxonhyperv3.guj3yctzbm1etfxqx2vob5hsef.xx.internal.cloudapp.net> References: <1616029240-26588-1-git-send-email-navasile@linux.microsoft.com> <1616029240-26588-2-git-send-email-navasile@linux.microsoft.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) Subject: Re: [dpdk-dev] [PATCH 1/3] Add EAL threads API X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list 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 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; > > +} >