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 1FCEBA0350; Mon, 22 Jun 2020 18:37:39 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 5DCFB1D8D2; Mon, 22 Jun 2020 18:37:38 +0200 (CEST) Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by dpdk.org (Postfix) with ESMTP id 4943F1D73C for ; Mon, 22 Jun 2020 18:37:36 +0200 (CEST) IronPort-SDR: gs6wN3f7+TK+Hq0Nq6sDxqRf9smgw5Ebru4yZi9xk7Jppccir+Z0ppAO/S+qkiAvVjQ2kXssYU sUvIoUenaD6g== X-IronPort-AV: E=McAfee;i="6000,8403,9660"; a="209003539" X-IronPort-AV: E=Sophos;i="5.75,267,1589266800"; d="scan'208";a="209003539" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Jun 2020 09:37:35 -0700 IronPort-SDR: B2uUkbthxPrfoiq8S4Q4x218Kxd1nYb5RalqeXjTtTpSEcz+6k4ldLCQSWzKbSKFdgF+QdEN6E ktbeLA57RRWw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,267,1589266800"; d="scan'208";a="278819301" Received: from orsmsx106.amr.corp.intel.com ([10.22.225.133]) by orsmga006.jf.intel.com with ESMTP; 22 Jun 2020 09:37:35 -0700 Received: from orsmsx161.amr.corp.intel.com (10.22.240.84) by ORSMSX106.amr.corp.intel.com (10.22.225.133) with Microsoft SMTP Server (TLS) id 14.3.439.0; Mon, 22 Jun 2020 09:37:34 -0700 Received: from ORSEDG001.ED.cps.intel.com (10.7.248.4) by ORSMSX161.amr.corp.intel.com (10.22.240.84) with Microsoft SMTP Server (TLS) id 14.3.439.0; Mon, 22 Jun 2020 09:37:34 -0700 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (104.47.57.171) by edgegateway.intel.com (134.134.137.100) with Microsoft SMTP Server (TLS) id 14.3.439.0; Mon, 22 Jun 2020 09:37:34 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Zgpd7mWAOQYW90gcqnwuLstI979UrSgPmnbvizJFz0/q2MWnSq2ZvR+GoHDw7LZaWkui3nFwfjLnVazVfEtNivCHmYPK3PmKPurewpDPDfFLthCLrLNmr4hwq8/wjeNjsQq6gItvozinhueprw3kCBM+yiExrqwf0l1p9cWix23RbhOOpK0TGwM/eaQlxhp7IMlTjVHQYSacgbDuKLzLLGfU8FDNhw/K6KD9xIUwD9mOsZ6hhI93SJmLqC9N1Aw5IUuZ8387Toj48NJo/7Ht3DhlHUlSYs342C+hppQiZ40Qsdvi3XF4CTAYHAM3zPOvkKDkDZFH15ZqCQfTXkGKgg== 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=Zug9zRPp966dGM5AlpVazL8cu04E7/LN+8mOMjE3TQk=; b=WO4KzbkofUCc0qDaM6avBU7m7vTYe3FyRzTrOA0JqjdiRnoA0gWPm9UmloTF4bvMXH6i68sOKV2IJSPrHyvUz6J8cyRgJs30Ayvsh1UnEInL6T85sobon5DbQcKLfX1V/dAO6a2ajnH/mUvEbLkM8xjlIX9FShHnEFjRMkDMen95o8mccSh0LGfaupxEhGy95xwnzKWN/1u/H3XSqqMiiH/r2tS8nWOWZGFf1FlT1B/0E5X6xAej1jOfimITikqaywek1OARy545asAVFz+zAV007sfVeDCyFnHb/P/Uy+OKuKfnP3rvHxW7c80aFrTb5WuJBHPUk4hbKTirEFvsgw== 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=Zug9zRPp966dGM5AlpVazL8cu04E7/LN+8mOMjE3TQk=; b=a1YprG+o3FgDxiL0a1zpwkdJZZaoL21q8P9iCgnxFOUvXsgFLOsshCbyYrMuLBBNx9chLKVb4MC6Ot1haW69LhEp6JKwHpCeKf6NKpM5ZsZke74ZEEMgl4mjB20KUPHM+7lrJJZ0HylSm0xeLVnJKpxu7tOyBn45k0ItWP96e7U= Received: from BYAPR11MB3301.namprd11.prod.outlook.com (2603:10b6:a03:7f::26) by BYAPR11MB3671.namprd11.prod.outlook.com (2603:10b6:a03:b3::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3109.23; Mon, 22 Jun 2020 16:37:32 +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.3109.027; Mon, 22 Jun 2020 16:37:31 +0000 From: "Ananyev, Konstantin" To: "Ananyev, Konstantin" , David Marchand , "dev@dpdk.org" CC: "jerinjacobk@gmail.com" , "Richardson, Bruce" , "mdr@ashroe.eu" , "ktraynor@redhat.com" , "Stokes, Ian" , "i.maximets@ovn.org" , "Thomas Monjalon" , "Mcnamara, John" , "Kovacevic, Marko" , "Burakov, Anatoly" , Olivier Matz , "Andrew Rybchenko" , Neil Horman Thread-Topic: [dpdk-dev] [PATCH v3 6/9] eal: register non-EAL threads as lcores Thread-Index: AQHWSLNsPVSOk0moJ0yrUEnZr46r4g== Date: Mon, 22 Jun 2020 16:37:31 +0000 Message-ID: References: <20200610144506.30505-1-david.marchand@redhat.com> <20200622132531.21857-1-david.marchand@redhat.com> <20200622132531.21857-7-david.marchand@redhat.com> In-Reply-To: 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: intel.com; dkim=none (message not signed) header.d=none;intel.com; dmarc=none action=none header.from=intel.com; x-originating-ip: [192.198.151.184] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: cf84a82b-b4ad-4fc8-e22b-08d816ca8f83 x-ms-traffictypediagnostic: BYAPR11MB3671: 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:4714; x-forefront-prvs: 0442E569BC x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: lj4goFEyagMq3Jx5s8X1y4fpEifDETOjU0diq637R+Ggm4p2UWMzY6qj7Mjt638Vw5biV/XHjNHRIYFudocm40YvgvA4vqD0920KDKGo2yHRxiNOd1MDiazij9AFGph1P+fr5bJ7h1M4cxqCd/uLpZSIjJTQTqICYDDfb3L1Ymxf3AgciXfYAm2ZLzQWh1u+XMG3KikOktrLda3jW7L1kqC4wpMLxbJ13WJ2Xw/5lKjLAx6GJldszNwF7LmtHiz3J8dzGOD/dpdkIfqYdG5FLEd/uJrGlm/Fy8hhr/RIXsDBXqqutZgnKGRjQ3EoIU0RSCt29MPXi74Yy+bwNTr+Jw== 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)(366004)(346002)(376002)(396003)(39860400002)(136003)(33656002)(86362001)(9686003)(186003)(55016002)(5660300002)(4326008)(83380400001)(316002)(76116006)(66476007)(66946007)(478600001)(64756008)(66446008)(66556008)(71200400001)(52536014)(54906003)(7416002)(6506007)(26005)(110136005)(2940100002)(8936002)(7696005)(2906002); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata: syBJjrc6gZRQQwfx802/5tPf3SpVF8Qaj6a2VA+JnBiBe86HCvP/fJKayvBjUKsmn6gT4rm40jrpwt7G5iImPvViUze9ImCfxJYFZvsrZ/dMjp7BVYlAOZip+r2tSiAQPX2pQTClt8DJVUakzZy0g/iWDjsEn/vDKVKQqhAx3Z9vVGOrTL3BDyZeRPHW8OtVH8KJh3q3mU5xD1YAr1CX8NH2q0/fDb+RfPdmBCuvh+hi2giTD2xd9jcr8dTLyjNq38yKNJY0DPjgFEcSR6iKSkIni+rZnWwu3Stcw0359duF4SDZWmZM4zQiRmY4Iy/JMkjB70xoj7eWXL4GRDewS1xKDQ3IK7Wl/fN9hU8JSikgjV4kkzyzXY8LnQTlUm/GbTvoeY1yI0D+Y6SRwZHI8/g3kd+FynA/qtef8qRBSj8QxUx47siyHJZsRGw3Js7cWogonPpYdF2Q6k+Mgm4Z85ElmTKy4EiR1MwXqFKibdDDIKuwveOv0PyxsBbCUGk/ Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Exchange-CrossTenant-Network-Message-Id: cf84a82b-b4ad-4fc8-e22b-08d816ca8f83 X-MS-Exchange-CrossTenant-originalarrivaltime: 22 Jun 2020 16:37:31.7626 (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: Zkbxsfpj2DITbAs3hbCCMBYT3LF4eoLwDss8c2X9G4UufFEYPk5qmoPr6Py5MN83ZfBGnPgRAR31sR6YmJUucLt0FjF67GNMhFflCOxma/o= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR11MB3671 X-OriginatorOrg: intel.com Subject: Re: [dpdk-dev] [PATCH v3 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" >=20 > Hi David, >=20 > > diff --git a/lib/librte_eal/common/eal_common_lcore.c b/lib/librte_eal/= common/eal_common_lcore.c > > index 86d32a3dd7..7db05428e7 100644 > > --- a/lib/librte_eal/common/eal_common_lcore.c > > +++ b/lib/librte_eal/common/eal_common_lcore.c > > @@ -6,12 +6,13 @@ > > #include > > #include > > > > -#include > > -#include > > -#include > > -#include > > #include > > #include > > +#include > > +#include > > +#include > > +#include > > +#include > > > > #include "eal_private.h" > > #include "eal_thread.h" > > @@ -220,3 +221,38 @@ 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; > > + > > + rte_spinlock_lock(&lcore_lock); >=20 > I think it will break current DPDK MP modes. > The problem here - rte_config (and lcore_role[]) is in shared memory, > while the lock is local. > Simplest way probably to move lcore_lock to rte_config. Actually sorry, I was wrong - rte_config is local. So having lcore_lock local seems ok here. Though then, I think another issue arises: For MP case 2 processes might get the same lcore_id via this function.=20 And, as I remember, rte_mempool cache is by default located in shared memor= y. So two threads might end-up racing for the same mempool cache slot. Same story probably about some other shared data that uses lcore_id as an i= ndex >=20 > > + 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); > > +}