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 29579A0C44; Mon, 12 Apr 2021 09:56:32 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id D693540698; Mon, 12 Apr 2021 09:56:31 +0200 (CEST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mails.dpdk.org (Postfix) with ESMTP id 754BE4068E for ; Mon, 12 Apr 2021 09:56:30 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1618214189; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=r+Kp4FEHZZy54YWim9KDQ1Ezw3T+IPNC6gGk99UJJ/s=; b=ZTl5gPp7FDPkFoO2Q7i/XgUu39Vt0NVh8kLxpow/52yea7QjuqivMSCl7oBMGBbyII1V39 dy5rf45s55dqZ8kx59PQRPTg55nmXZcpObe+/ZwSZxe3tqfMyTBJr6ZAQVa0bZiQat0Mwl NxqgfSRUkAZSPQ3zRnuFQtjdXqmv0sU= Received: from mail-vs1-f70.google.com (mail-vs1-f70.google.com [209.85.217.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-411-XoyEXzJuPEi-kMNArQ169A-1; Mon, 12 Apr 2021 03:56:26 -0400 X-MC-Unique: XoyEXzJuPEi-kMNArQ169A-1 Received: by mail-vs1-f70.google.com with SMTP id z7so582493vsz.6 for ; Mon, 12 Apr 2021 00:56:26 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=r+Kp4FEHZZy54YWim9KDQ1Ezw3T+IPNC6gGk99UJJ/s=; b=T279Bedzyg5sxmwNlsSYsSGYnDZkOngYLT0zZupO0Kql6bj8jwk8kHPvCN2xv3Up/q eiLM15yzbwlGGr+2Z49BX57WPzyA8PYP43kB1EU/WiMtO1DoYAReFm3k0nZiwodId4rK WM+KyT83e7bgx3jMxXCsq9dvm5J3mtdb3JW341woVd25a0dV+6Bdb/83tt81Mc/lXbdo OpPmHPGtB0jMRBy31/PB7z4J0tTdRdIEbgNXBCYoaOeq5FLP1m9I71qs0a2oIJbYqMRy rszA8B13weKd5oamrkKrEnlkuUU5K2FNxC5/VsoQo/AMSTOSguYRKW9mYxJI7IszDFF7 2n0A== X-Gm-Message-State: AOAM5307MxC5EmmNqSN++2/3RBVm6kh/RTzyXB8QBTdg3SBSalnaasLp f5XtBN2z1QEWPzO1cwJjjC9fujuVPNr21bUxTrw1HlNX6zpSEwPSPe6awqVQx3oiR99cn5uLfxy LIekxOV+Ju/rt64ztAeQ= X-Received: by 2002:a67:de08:: with SMTP id q8mr706646vsk.5.1618214185614; Mon, 12 Apr 2021 00:56:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxolrAssw0LNBtrWNRSbietHIx3SFZcviH3HKs7R5YKnDXO0HuELOsd9cpHPW/zmtUv+CAlAzyUj5iGX9OkwAE= X-Received: by 2002:a67:de08:: with SMTP id q8mr706635vsk.5.1618214185414; Mon, 12 Apr 2021 00:56:25 -0700 (PDT) MIME-Version: 1.0 References: <1617057640-24301-2-git-send-email-navasile@linux.microsoft.com> <1617413948-10504-1-git-send-email-navasile@linux.microsoft.com> In-Reply-To: <1617413948-10504-1-git-send-email-navasile@linux.microsoft.com> From: David Marchand Date: Mon, 12 Apr 2021 09:56:14 +0200 Message-ID: To: Narcisa Ana Maria Vasile Cc: dev , Thomas Monjalon , Dmitry Kozlyuk , Khoa To , navasile@microsoft.com, "Dmitry Malloy (MESHCHANINOV)" , roretzla@microsoft.com, Tal Shnaiderman , Omar Cardona , Bruce Richardson , Pallavi Kadam Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=dmarchan@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Subject: Re: [dpdk-dev] [PATCH v6 00/10] eal: Add new API for threading 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 Sat, Apr 3, 2021 at 3:39 AM Narcisa Ana Maria Vasile wrote: > > From: Narcisa Vasile > > EAL thread API > > **Problem Statement** > DPDK currently uses the pthread interface to create and manage threads. > Windows does not support the POSIX thread programming model, so it curren= tly > relies on a header file that hides the Windows calls under > pthread matched interfaces. Given that EAL should isolate the environment > specifics from the applications and libraries and mediate > all the communication with the operating systems, a new EAL interface > is needed for thread management. > > **Goals** > * Introduce a generic EAL API for threading support that will remove > the current Windows pthread.h shim. > * Replace references to pthread_* across the DPDK codebase with the new > RTE_THREAD_* API. > * Allow users to choose between using the RTE_THREAD_* API or a > 3rd party thread library through a configuration option. > > **Design plan** > New API main files: > * rte_thread.h (librte_eal/include) > * rte_thread_types.h (librte_eal/include) > * rte_thread_windows_types.h (librte_eal/windows/include) > * rte_thread.c (librte_eal/windows) > * rte_thread.c (librte_eal/common) > > For flexibility, the user is offered the option of either using the RTE_T= HREAD_* API or > a 3rd party thread library, through a meson flag =E2=80=9Cuse_external_th= read_lib=E2=80=9D. > By default, this flag is set to FALSE, which means Windows libraries and = applications > will use the RTE_THREAD_* API for managing threads. > > If compiling on Windows and the =E2=80=9Cuse_external_thread_lib=E2=80=9D= is *not* set, > the following files will be parsed: > * include/rte_thread.h > * windows/include/rte_thread_windows_types.h > * windows/rte_thread.c > In all other cases, the compilation/parsing includes the following files: > * include/rte_thread.h > * include/rte_thread_types.h > * common/rte_thread.c > > **A schematic example of the design** > -------------------------------------------------- > lib/librte_eal/include/rte_thread.h > int rte_thread_create(); > > lib/librte_eal/common/rte_thread.c > int rte_thread_create() > { > return pthread_create(); > } > > lib/librte_eal/windows/rte_thread.c > int rte_thread_create() > { > return CreateThread(); > } > > lib/librte_eal/windows/meson.build > if get_option('use_external_thread_lib') > sources +=3D 'librte_eal/common/rte_thread.c' > else > sources +=3D 'librte_eal/windows/rte_thread.c' > endif > ----------------------------------------------------- > > **Thread attributes** > > When or after a thread is created, specific characteristics of the thread > can be adjusted. Given that the thread characteristics that are of intere= st > for DPDK applications are affinity and priority, the following structure > that represents thread attributes has been defined: > > typedef struct > { > enum rte_thread_priority priority; > rte_cpuset_t cpuset; > } rte_thread_attr_t; > > The *rte_thread_create()* function can optionally receive an rte_thread_a= ttr_t > object that will cause the thread to be created with the affinity and pri= ority > described by the attributes object. If no rte_thread_attr_t is passed > (parameter is NULL), the default affinity and priority are used. > An rte_thread_attr_t object can also be set to the default values > by calling *rte_thread_attr_init()*. > > *Priority* is represented through an enum that currently advertises > two values for priority: > - RTE_THREAD_PRIORITY_NORMAL > - RTE_THREAD_PRIORITY_REALTIME_CRITICAL > The enum can be extended to allow for multiple priority levels. > rte_thread_set_priority - sets the priority of a thread > rte_thread_attr_set_priority - updates an rte_thread_attr_t object > with a new value for priority > > The user can choose thread priority through an EAL parameter, > when starting an application. If EAL parameter is not used, > the per-platform default value for thread priority is used. > Otherwise administrator has an option to set one of available options: > --thread-prio normal > --thread-prio realtime > > Example: > ./dpdk-l2fwd -l 0-3 -n 4 =E2=80=93thread-prio normal -- -q 8 -p ffff > > *Affinity* is described by the already known =E2=80=9Crte_cpuset_t=E2=80= =9D type. > rte_thread_attr_set/get_affinity - sets/gets the affinity field in a > rte_thread_attr_t object > rte_thread_set/get_affinity =E2=80=93 sets/gets the affinity of a th= read > > **Errors** > A translation function that maps Windows error codes to errno-style > error codes is provided. > > **Future work** > Note that this patchset was focused on introducing new API that will > remove the Windows pthread.h shim. In DPDK, there are still a few referen= ces > to pthread_* that were not implemented in the shim. > The long term plan is for EAL to provide full threading support: > * Adding support for conditional variables > * Additional functionality offered by pthread_* (such as pthread_setname_= np, etc.) > * Static mutex initializers are not used on Windows. If we must continue > using them, they need to be platform dependent and an implementation wi= ll > need to be provided for Windows. Thanks for taking on this huge work. There is no review on this series and I don't have time for it. This is a core part of the EAL API. Seeing how rc1 is at the end of this week, my recommendation is to postpone to 21.08. --=20 David Marchand