From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 96DBDA0350; Mon, 29 Jun 2020 16:27:30 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 7B3CA1BF81; Mon, 29 Jun 2020 16:27:30 +0200 (CEST) Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by dpdk.org (Postfix) with ESMTP id C3A041BEDD for ; Mon, 29 Jun 2020 16:27:28 +0200 (CEST) IronPort-SDR: EafvX/xQxOK5Gpbzej8rFNFZwOSrWbijsXwwy6OyRupcwuN5eaaHLrxuubG7y1jhRGJ3UV+KxW 9aXGKLrCo5vw== X-IronPort-AV: E=McAfee;i="6000,8403,9666"; a="145035357" X-IronPort-AV: E=Sophos;i="5.75,294,1589266800"; d="scan'208";a="145035357" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Jun 2020 07:27:27 -0700 IronPort-SDR: 8jTjE0d0a5s6LJ/Z7D1d/eRytrvgJ7uWlWR0E7W5D6aRd22mBXEy/BGJ1z6McxHPmreLzZi15q MjkFZN6gQElA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,294,1589266800"; d="scan'208";a="480807052" Received: from orsmsx105.amr.corp.intel.com ([10.22.225.132]) by fmsmga005.fm.intel.com with ESMTP; 29 Jun 2020 07:27:27 -0700 Received: from orsmsx601.amr.corp.intel.com (10.22.229.14) by ORSMSX105.amr.corp.intel.com (10.22.225.132) with Microsoft SMTP Server (TLS) id 14.3.439.0; Mon, 29 Jun 2020 07:27:26 -0700 Received: from orsmsx601.amr.corp.intel.com (10.22.229.14) by ORSMSX601.amr.corp.intel.com (10.22.229.14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Mon, 29 Jun 2020 07:27:26 -0700 Received: from ORSEDG001.ED.cps.intel.com (10.7.248.4) by orsmsx601.amr.corp.intel.com (10.22.229.14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.1713.5 via Frontend Transport; Mon, 29 Jun 2020 07:27:26 -0700 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (104.47.55.177) by edgegateway.intel.com (134.134.137.100) with Microsoft SMTP Server (TLS) id 14.3.439.0; Mon, 29 Jun 2020 07:27:26 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LIvG5DanTjvaWgE1D61UwU1WjgQTRF20inxGdiRP4uiyIv8cs8GRAPdlaZZ6x2qX/c+shqWcUBCpeVhLc5Svguh7MkGtgGegUtU30qxOuCCc6A+oL/cEPXfYd6etLFT6x8BhmIVXMxHEuXLcuoS2DRZ/YeTV4iN8CulcuaSc4nUY7RBJDJrnmXYV+u8nx2ZeNP3wSBCe3JZWSj8BaKF0+htx9nUwSjb8uxD5eKpnlSyTLpUx4RURicKkQfd1kIYigLP99g7u1Qy7lMgDE/OEBmLtCPzTkNpIuYArxh6Ee+NWGKpSMJktLbUT/5xnVKYDLh7SvdUAt0s6bosripmUdA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=8VEzNZEqTRsAGJkjwsNbb30t2oonfHnGWDBO49mty9M=; b=b4h/vuZr+6SipQyrpfYCvoXHA6YgGQp1tBFYzR+ju92ZUJ4oUmkchOhwJikofL2rimEnfRdADzgrRHtLkjS3aJ/k0/hAb0pbE39y94g9qKs0UXWJ5AnRL7LlbZuW2U8n7V7Aox1v938Wc1dkBBVrh9tuF2/Ejzp2ifK1IVytMplOl8ocoEgc9Z9kS+a9sbZjV83IpUBmgHLMWy1qwVmLIToqfDPJCY0sbaq518egEJMbSJF5caglrXOvKeygdtnCZWg/e0rMBDNqcuRR7X/tCULgY1i2KJH2Tnt4RMfTriSE0UUHnsxuXXCPUnswh8AIpO4QiXQTDzSYmz8gjySxcg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.onmicrosoft.com; s=selector2-intel-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=8VEzNZEqTRsAGJkjwsNbb30t2oonfHnGWDBO49mty9M=; b=v/E0ciLmu4f5x2h4MADBgU7uYw6Cr+rpFh2EUWsl/8kBINmRjOfbdbGfzt6UOEIDjk/R6GTgzugMuUXYwntwPV83lffTzPXJFWG4loOHDd0edWEFZ8GZsm0Bjo/WUQmr/fsqS2/JAWtR1IoxMrKE26M/FG2DEvTqc1ykErbZdcA= Received: from BYAPR11MB3301.namprd11.prod.outlook.com (2603:10b6:a03:7f::26) by BY5PR11MB4226.namprd11.prod.outlook.com (2603:10b6:a03:1bf::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3131.20; Mon, 29 Jun 2020 14:27:19 +0000 Received: from BYAPR11MB3301.namprd11.prod.outlook.com ([fe80::f160:29ab:b8f9:4189]) by BYAPR11MB3301.namprd11.prod.outlook.com ([fe80::f160:29ab:b8f9:4189%6]) with mapi id 15.20.3131.027; Mon, 29 Jun 2020 14:27:19 +0000 From: "Ananyev, Konstantin" To: David Marchand , "dev@dpdk.org" CC: "jerinjacobk@gmail.com" , "Richardson, Bruce" , "mdr@ashroe.eu" , "thomas@monjalon.net" , "arybchenko@solarflare.com" , "ktraynor@redhat.com" , "Stokes, Ian" , "i.maximets@ovn.org" , "Mcnamara, John" , "Kovacevic, Marko" , "Burakov, Anatoly" , Olivier Matz , "Neil Horman" Thread-Topic: [dpdk-dev] [PATCH v4 6/9] eal: register non-EAL threads as lcores Thread-Index: AQHWS8kYbTDR6Ho0yk6Ct324V4QbJ6jvkIww Date: Mon, 29 Jun 2020 14:27:18 +0000 Message-ID: References: <20200610144506.30505-1-david.marchand@redhat.com> <20200626144736.11011-1-david.marchand@redhat.com> <20200626144736.11011-7-david.marchand@redhat.com> In-Reply-To: <20200626144736.11011-7-david.marchand@redhat.com> Accept-Language: en-GB, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-product: dlpe-windows dlp-reaction: no-action dlp-version: 11.2.0.6 authentication-results: redhat.com; dkim=none (message not signed) header.d=none;redhat.com; dmarc=none action=none header.from=intel.com; x-originating-ip: [192.198.151.175] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: bd9b12b5-9d43-4ea4-23d8-08d81c38879a x-ms-traffictypediagnostic: BY5PR11MB4226: x-ld-processed: 46c98d88-e344-4ed4-8496-4ed7712e255d,ExtAddr x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:8273; x-forefront-prvs: 044968D9E1 x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: a5Ir8GKVSkR8beF+/H/MXHLxl/9FpgL70Qx7iHkpFj84QBjgO3lN5ahktafXgEvKNW05k3+V/9J/4wm3GTm36a/+bQcAuzxmjJ46qN2jRKvrc1sx5vjZEJ/xsCCooyl32pErO1J0HGlh7YwYdKPR74Xpf5HdFhfHK/uNRdZZ5nMVENY4eBxy5VMCROywk6QeTdHftX4u6dlu/xjFNJkTW2GTtkoSgIQ2F3yQHczfF596fCEMmJ/ADwbkU/O7x9aq1MYVuVASq/b0RkB3y1i8NUJQS5Y6lzZ8rK/lpLwTOQ+lfh84OD5qz3EmeZltDlorf302FkUqeT/8GSQYVUsMLA== x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BYAPR11MB3301.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFTY:; SFS:(4636009)(396003)(136003)(376002)(366004)(39860400002)(346002)(83380400001)(33656002)(9686003)(8676002)(7416002)(52536014)(8936002)(5660300002)(55016002)(110136005)(4326008)(316002)(2906002)(30864003)(54906003)(66946007)(6506007)(66476007)(66556008)(64756008)(66446008)(76116006)(186003)(26005)(478600001)(86362001)(71200400001)(7696005); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata: 924MmC0lfHn+tm+MJPSf6lW3r5m5MA8R8XJc0L+wTcy05Ca4m0qBxkVATZ+XiQLUzXKDqKF1RNxdbl2NrzuzZSme5Fve7gmL6B0o+Mv3w6twTBzuqw3n8FltOPub6iUKs5Ms2RYJLzfeNm2w1BK3Iymq9wQfKqXec+9rzMJEq/affcGjOqOo0a2XeOKWK0TDZYQcF0953TdhH7XZN7VChQgESDgWgX8rZSHlJsMEukCNUsdnsWK3rW9L6Ut9m4mTyfqBhYfbv3SN7VlAGkpydXsASTy9FnOHn/Deea8Xjrbmh/vWzflgA2dUMjso3sXul5dMelAqrxC1dBCxNXX7tk+GWXffbYOpcWQa/lDsjOZDEqAw1eQn2Jj1qG8X7Rj0AGxtoyfs6Z0Z4NWcGGd+ImFe8w+ksrHVaMtOl26AN9k/5ME6jXM82U20yiwUhFdHU6Ma3eWItvhPuNfVsFJ9fZUzk0x11NVQXh0PFmcI1HwKdojeKFXMn4w2eZvGNbRD Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: BYAPR11MB3301.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: bd9b12b5-9d43-4ea4-23d8-08d81c38879a X-MS-Exchange-CrossTenant-originalarrivaltime: 29 Jun 2020 14:27:18.9348 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: R2VrcR5ccyshtoCYs/s66Jml/WKNmO1UxqztGOmE5vfN1fSVHdRx/KJEhszT7c1CS1PINCQR1LPOAud9wFZa9pHIWI6GevKOZ3jxK3BT3fM= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR11MB4226 X-OriginatorOrg: intel.com Subject: Re: [dpdk-dev] [PATCH v4 6/9] eal: register non-EAL threads as lcores 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" > diff --git a/lib/librte_eal/common/eal_common_lcore.c b/lib/librte_eal/co= mmon/eal_common_lcore.c > index 86d32a3dd7..a61824a779 100644 > --- a/lib/librte_eal/common/eal_common_lcore.c > +++ b/lib/librte_eal/common/eal_common_lcore.c > @@ -6,13 +6,15 @@ > #include > #include >=20 > -#include > -#include > -#include > -#include > #include > #include > +#include > +#include > +#include > +#include > +#include >=20 > +#include "eal_memcfg.h" > #include "eal_private.h" > #include "eal_thread.h" >=20 > @@ -220,3 +222,43 @@ rte_socket_id_by_idx(unsigned int idx) > } > return config->numa_nodes[idx]; > } > + > +static rte_spinlock_t lcore_lock =3D RTE_SPINLOCK_INITIALIZER; > + > +unsigned int > +eal_lcore_non_eal_allocate(void) > +{ > + struct rte_config *cfg =3D rte_eal_get_configuration(); > + unsigned int lcore_id; > + > + if (cfg->process_type =3D=3D RTE_PROC_SECONDARY || > + !eal_mcfg_forbid_multiprocess()) { > + RTE_LOG(ERR, EAL, "Multiprocess in use, cannot allocate new lcore.\n")= ; > + return RTE_MAX_LCORE; > + } > + rte_spinlock_lock(&lcore_lock); > + for (lcore_id =3D 0; lcore_id < RTE_MAX_LCORE; lcore_id++) { > + if (cfg->lcore_role[lcore_id] !=3D ROLE_OFF) > + continue; > + cfg->lcore_role[lcore_id] =3D ROLE_NON_EAL; > + cfg->lcore_count++; > + break; > + } > + if (lcore_id =3D=3D RTE_MAX_LCORE) > + RTE_LOG(DEBUG, EAL, "No lcore available.\n"); > + rte_spinlock_unlock(&lcore_lock); > + return lcore_id; > +} > + > +void > +eal_lcore_non_eal_release(unsigned int lcore_id) > +{ > + struct rte_config *cfg =3D rte_eal_get_configuration(); > + > + rte_spinlock_lock(&lcore_lock); > + if (cfg->lcore_role[lcore_id] =3D=3D ROLE_NON_EAL) { > + cfg->lcore_role[lcore_id] =3D ROLE_OFF; > + cfg->lcore_count--; > + } > + rte_spinlock_unlock(&lcore_lock); > +} > diff --git a/lib/librte_eal/common/eal_common_mcfg.c b/lib/librte_eal/com= mon/eal_common_mcfg.c > index 49d3ed0ce5..5b42d454e2 100644 > --- a/lib/librte_eal/common/eal_common_mcfg.c > +++ b/lib/librte_eal/common/eal_common_mcfg.c > @@ -44,6 +44,42 @@ eal_mcfg_check_version(void) > return 0; > } >=20 > +enum mp_status { > + MP_UNKNOWN, > + MP_FORBIDDEN, > + MP_ENABLED, > +}; > + > +static bool > +eal_mcfg_set_mp_status(enum mp_status status) > +{ > + struct rte_mem_config *mcfg =3D rte_eal_get_configuration()->mem_config= ; > + uint8_t expected; > + uint8_t desired; > + > + expected =3D MP_UNKNOWN; > + desired =3D status; > + if (__atomic_compare_exchange_n(&mcfg->mp_status, &expected, desired, > + false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST)) > + return true; > + > + return __atomic_load_n(&mcfg->mp_status, __ATOMIC_RELAXED) =3D=3D desir= ed; > +} > + > +bool > +eal_mcfg_forbid_multiprocess(void) > +{ > + assert(rte_eal_get_configuration()->process_type =3D=3D RTE_PROC_PRIMAR= Y); > + return eal_mcfg_set_mp_status(MP_FORBIDDEN); > +} > + > +bool > +eal_mcfg_enable_multiprocess(void) > +{ > + assert(rte_eal_get_configuration()->process_type =3D=3D RTE_PROC_SECOND= ARY); > + return eal_mcfg_set_mp_status(MP_ENABLED); > +} I still don't think it is a good idea to allow to change primary proc behav= iour (allow/forbid secondary procs to attach) on the fly. Imagine the situation - there is a primary proc (supposed to run forever) that does rte_thread_register/rte_thread_unregister during its lifetime. Plus from time to time user runs some secondary process to collect stats/de= bug the primary one (proc-info or so). Now behaviour of such system will be completely non-deterministic: In some runs primary proc will do rte_thread_register() first, and then sec= ondary proc will be never able to attach. In other cases - secondary will win the race, and then for primary=20 eal_lcore_non_eal_allocate() will always fail. Which means different behaviour, significantly varying performance, etc. I am not big fun to introduce such workaround at all, but at least startup = flag, will guarantee consistent behaviour: secondary proc will always fail to att= ach and eal_lcore_non_eal_allocate() will always succeed (as long as there are free lcore_ids off-course). >From your previous mail: > A EAL flag is a stable API from the start, as there is nothing > describing how we can remove one. > So a new EAL flag for an experimental API/feature seems contradictory. Hm, yes there is a gap, but why eal flag can't also be an experimental one? What will be the difference between flag and API call here? We can still reserve the right to remove/change it at any time. As another thought about startup parameters - would it make sense to have new one: --lcore-allow-list=3D...? That would limit lcore_ids available for the process. Without this new parameter specified - lcore_allowed_list would be equal to startup lcore list (static ones), and no dynamic lcore allocations will be allowed. As an example: dpdk_app --lcores=3D6,7 --lcore-allow=3D0-100 will reserve lcore_ids 6,7 at startup (same as we do now), and leave [0-5] and [8-100] available for dynamic usage. =20 > void > eal_mcfg_update_internal(void) > { > diff --git a/lib/librte_eal/common/eal_common_thread.c b/lib/librte_eal/c= ommon/eal_common_thread.c > index a7ae0691bf..1cbddc4b5b 100644 > --- a/lib/librte_eal/common/eal_common_thread.c > +++ b/lib/librte_eal/common/eal_common_thread.c > @@ -236,3 +236,36 @@ rte_ctrl_thread_create(pthread_t *thread, const char= *name, > pthread_join(*thread, NULL); > return -ret; > } > + > +void > +rte_thread_register(void) > +{ > + unsigned int lcore_id; > + rte_cpuset_t cpuset; > + > + /* EAL init flushes all lcores, we can't register before. */ > + assert(internal_config.init_complete =3D=3D 1); > + if (pthread_getaffinity_np(pthread_self(), sizeof(cpuset), > + &cpuset) !=3D 0) > + CPU_ZERO(&cpuset); > + lcore_id =3D eal_lcore_non_eal_allocate(); > + if (lcore_id >=3D RTE_MAX_LCORE) > + lcore_id =3D LCORE_ID_ANY; > + rte_thread_init(lcore_id, &cpuset); > + if (lcore_id !=3D LCORE_ID_ANY) > + RTE_LOG(DEBUG, EAL, "Registered non-EAL thread as lcore %u.\n", > + lcore_id); > +} > + > +void > +rte_thread_unregister(void) > +{ > + unsigned int lcore_id =3D rte_lcore_id(); > + > + if (lcore_id !=3D LCORE_ID_ANY) > + eal_lcore_non_eal_release(lcore_id); > + rte_thread_uninit(); > + if (lcore_id !=3D LCORE_ID_ANY) > + RTE_LOG(DEBUG, EAL, "Unregistered non-EAL thread (was lcore %u).\n", > + lcore_id); > +} > diff --git a/lib/librte_eal/common/eal_memcfg.h b/lib/librte_eal/common/e= al_memcfg.h > index 583fcb5953..340e523c6a 100644 > --- a/lib/librte_eal/common/eal_memcfg.h > +++ b/lib/librte_eal/common/eal_memcfg.h > @@ -41,6 +41,8 @@ struct rte_mem_config { > rte_rwlock_t memory_hotplug_lock; > /**< Indicates whether memory hotplug request is in progress. */ >=20 > + uint8_t mp_status; /**< Indicates whether multiprocess can be used. */ > + > /* memory segments and zones */ > struct rte_fbarray memzones; /**< Memzone descriptors. */ >=20 > @@ -91,6 +93,14 @@ eal_mcfg_wait_complete(void); > int > eal_mcfg_check_version(void); >=20 > +/* mark primary process as not supporting multi-process. */ > +bool > +eal_mcfg_forbid_multiprocess(void); > + > +/* instruct primary process that a secondary process attached once. */ > +bool > +eal_mcfg_enable_multiprocess(void); > + > /* set mem config as complete */ > void > eal_mcfg_complete(void); > diff --git a/lib/librte_eal/common/eal_private.h b/lib/librte_eal/common/= eal_private.h > index 0592fcd694..73238ff157 100644 > --- a/lib/librte_eal/common/eal_private.h > +++ b/lib/librte_eal/common/eal_private.h > @@ -396,6 +396,24 @@ uint64_t get_tsc_freq(void); > */ > uint64_t get_tsc_freq_arch(void); >=20 > +/** > + * Allocate a free lcore to associate to a non-EAL thread. > + * > + * @return > + * - the id of a lcore with role ROLE_NON_EAL on success. > + * - RTE_MAX_LCORE if none was available. > + */ > +unsigned int eal_lcore_non_eal_allocate(void); > + > +/** > + * Release the lcore used by a non-EAL thread. > + * Counterpart of eal_lcore_non_eal_allocate(). > + * > + * @param lcore_id > + * The lcore with role ROLE_NON_EAL to release. > + */ > +void eal_lcore_non_eal_release(unsigned int lcore_id); > + > /** > * Prepare physical memory mapping > * i.e. hugepages on Linux and > diff --git a/lib/librte_eal/freebsd/eal.c b/lib/librte_eal/freebsd/eal.c > index 13e5de006f..32a3d999b8 100644 > --- a/lib/librte_eal/freebsd/eal.c > +++ b/lib/librte_eal/freebsd/eal.c > @@ -424,6 +424,10 @@ rte_config_init(void) > } > if (rte_eal_config_reattach() < 0) > return -1; > + if (!eal_mcfg_enable_multiprocess()) { > + RTE_LOG(ERR, EAL, "Primary process refused secondary attachment\n"); > + return -1; > + } > eal_mcfg_update_internal(); > break; > case RTE_PROC_AUTO: > diff --git a/lib/librte_eal/include/rte_lcore.h b/lib/librte_eal/include/= rte_lcore.h > index 3968c40693..43747e88df 100644 > --- a/lib/librte_eal/include/rte_lcore.h > +++ b/lib/librte_eal/include/rte_lcore.h > @@ -31,6 +31,7 @@ enum rte_lcore_role_t { > ROLE_RTE, > ROLE_OFF, > ROLE_SERVICE, > + ROLE_NON_EAL, > }; >=20 > /** > @@ -67,7 +68,8 @@ rte_lcore_has_role(unsigned int lcore_id, enum rte_lcor= e_role_t role); > * to run threads with lcore IDs 0, 1, 2 and 3 on physical core 10.. > * > * @return > - * Logical core ID (in EAL thread) or LCORE_ID_ANY (in non-EAL thread) > + * Logical core ID (in EAL thread or registered non-EAL thread) or > + * LCORE_ID_ANY (in unregistered non-EAL thread) > */ > static inline unsigned > rte_lcore_id(void) > @@ -279,6 +281,27 @@ int rte_thread_setname(pthread_t id, const char *nam= e); > __rte_experimental > int rte_thread_getname(pthread_t id, char *name, size_t len); >=20 > +/** > + * Register current non-EAL thread as a lcore. > + * > + * @note This API is not compatible with the multi-process feature: > + * - if a primary process registers a non-EAL thread, then no secondary = process > + * will initialise. > + * - if a secondary process initialises successfully, trying to register= a > + * non-EAL thread from either primary or secondary processes will alwa= ys end > + * up with the thread getting LCORE_ID_ANY as lcore. > + */ > +__rte_experimental > +void > +rte_thread_register(void); > + > +/** > + * Unregister current thread and release lcore if one was associated. > + */ > +__rte_experimental > +void > +rte_thread_unregister(void); > + > /** > * Create a control thread. > * > diff --git a/lib/librte_eal/linux/eal.c b/lib/librte_eal/linux/eal.c > index 8894cea50a..1d90d1c0e3 100644 > --- a/lib/librte_eal/linux/eal.c > +++ b/lib/librte_eal/linux/eal.c > @@ -514,6 +514,10 @@ rte_config_init(void) > } > if (rte_eal_config_reattach() < 0) > return -1; > + if (!eal_mcfg_enable_multiprocess()) { > + RTE_LOG(ERR, EAL, "Primary process refused secondary attachment\n"); > + return -1; > + } > eal_mcfg_update_internal(); > break; > case RTE_PROC_AUTO: > diff --git a/lib/librte_eal/rte_eal_version.map b/lib/librte_eal/rte_eal_= version.map > index 5831eea4b0..39c41d445d 100644 > --- a/lib/librte_eal/rte_eal_version.map > +++ b/lib/librte_eal/rte_eal_version.map > @@ -396,6 +396,8 @@ EXPERIMENTAL { >=20 > # added in 20.08 > __rte_trace_mem_per_thread_free; > + rte_thread_register; > + rte_thread_unregister; > }; >=20 > INTERNAL { > diff --git a/lib/librte_mempool/rte_mempool.h b/lib/librte_mempool/rte_me= mpool.h > index 652d19f9f1..9e0ee052b3 100644 > --- a/lib/librte_mempool/rte_mempool.h > +++ b/lib/librte_mempool/rte_mempool.h > @@ -28,9 +28,9 @@ > * rte_mempool_get() or rte_mempool_put() are designed to be called from= an EAL > * thread due to the internal per-lcore cache. Due to the lack of cachin= g, > * rte_mempool_get() or rte_mempool_put() performance will suffer when c= alled > - * by non-EAL threads. Instead, non-EAL threads should call > - * rte_mempool_generic_get() or rte_mempool_generic_put() with a user ca= che > - * created with rte_mempool_cache_create(). > + * by unregistered non-EAL threads. Instead, unregistered non-EAL thread= s > + * should call rte_mempool_generic_get() or rte_mempool_generic_put() wi= th a > + * user cache created with rte_mempool_cache_create(). > */ >=20 > #include > @@ -1233,7 +1233,7 @@ void rte_mempool_dump(FILE *f, struct rte_mempool *= mp); > /** > * Create a user-owned mempool cache. > * > - * This can be used by non-EAL threads to enable caching when they > + * This can be used by unregistered non-EAL threads to enable caching wh= en they > * interact with a mempool. > * > * @param size > @@ -1264,7 +1264,8 @@ rte_mempool_cache_free(struct rte_mempool_cache *ca= che); > * @param lcore_id > * The logical core id. > * @return > - * A pointer to the mempool cache or NULL if disabled or non-EAL threa= d. > + * A pointer to the mempool cache or NULL if disabled or unregistered = non-EAL > + * thread. > */ > static __rte_always_inline struct rte_mempool_cache * > rte_mempool_default_cache(struct rte_mempool *mp, unsigned lcore_id) > -- > 2.23.0