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 48CC0A00C5; Wed, 29 Apr 2020 18:51:47 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 8EF1D1DAD8; Wed, 29 Apr 2020 18:51:46 +0200 (CEST) Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by dpdk.org (Postfix) with ESMTP id 3931A1DACB; Wed, 29 Apr 2020 18:51:44 +0200 (CEST) IronPort-SDR: KiNfyfmxQfpqIxMDNs6Wi3UwAZ1npphnVizPB/Mw7QwBM+Dtil2ryjoOKIaVFKCxi4QCbc+bQF nv9L5jvjQhAQ== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Apr 2020 09:51:43 -0700 IronPort-SDR: sSmHyvUchnyd7zViEIxkzjhm3YTo6Hc2zfTkpvGrGa/Ns+7Cnz3RRdez5FIAwkCeky7jV7YP2U U0gFxkl+jECQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,332,1583222400"; d="scan'208";a="293262489" Received: from fmsmsx106.amr.corp.intel.com ([10.18.124.204]) by fmsmga002.fm.intel.com with ESMTP; 29 Apr 2020 09:51:43 -0700 Received: from fmsmsx601.amr.corp.intel.com (10.18.126.81) by FMSMSX106.amr.corp.intel.com (10.18.124.204) with Microsoft SMTP Server (TLS) id 14.3.439.0; Wed, 29 Apr 2020 09:51:42 -0700 Received: from fmsmsx601.amr.corp.intel.com (10.18.126.81) by fmsmsx601.amr.corp.intel.com (10.18.126.81) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Wed, 29 Apr 2020 09:51:42 -0700 Received: from FMSEDG001.ED.cps.intel.com (10.1.192.133) by fmsmsx601.amr.corp.intel.com (10.18.126.81) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.1713.5 via Frontend Transport; Wed, 29 Apr 2020 09:51:42 -0700 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (104.47.55.176) by edgegateway.intel.com (192.55.55.68) with Microsoft SMTP Server (TLS) id 14.3.439.0; Wed, 29 Apr 2020 09:51:42 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=NPpJ3/zPXTzKGMHM/SUZH0yc5Hb0XVakLmOtdcux5/HpMgCtxBO7LIlOx7AWZtk/Jm5gzsZy0j9MT3n230wjG9/gSeBzKdHJymrIAr/Op+VEUfZnXPhrX0eqR/hXcBfuoNvRrC+zJTvuse0DUGnvEOfwvp1KPK+TKPb+6BCa8tPlDajnfkKdc4Kwz6jX5MnrXu7JO0Io3rm0MiEz1KKJv4D8spVgqiTSg9UTtv+XrYwt78ybub08lRsSevbMoR8fh7xS1QaKiSX36c10QRt2Cbb3chmqnZrx9iLxVBwNWILenocnYYUEVviH6j9CMtvoupqYW9VZ1WPBOww6rVPHlw== 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=mp7Swtuf/cdnjdaiuJKERvUh1Eg2DJvc+FavKj7pC4g=; b=ErHA/2/HrQSbqH20++N00mmNt4LYvPjFalgfQ7NKPa1HgCqK4kJLMSeoLexp4sPVNIGd5IqvM6cEbCGo3CR9spR27PnDHiRAA8fO60Gzf5QvC36KJh4zMu1a5l9kDsbRVz+H6j7V2LIySXiv9JFFTk/AurFE6Bcf1M0+E01oUvddlutjDsZ3Bykkf36KG18Kj2dJpVp+FH8NB7zhSe8/GghbqA84lGTeRCiPvR7ABuVv+QGkp4VpbXWDjeepEFrI0qM3lqMgF/wfRf+0awMaU6LhXlft2Xk0uaKIs+8Qc0pVrOAWZNQG/vpdSQZcC31STTKk+EIcQtP2nvZZ9YVWRQ== 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=mp7Swtuf/cdnjdaiuJKERvUh1Eg2DJvc+FavKj7pC4g=; b=wAEjhpO9BU6dA6fMQB9mElZLR4gbKJuhKjMbdlH6B3jb6ue4nSAd686pSv+ZvJvnUbDZi9s6CY0yzS/KRyCpZkP6vPjX74ZRUnCmkY+ETi1PmDSoUtezT5ItESjkJIAGdceC4ujsM+QgFsuKz0Iz50qTIeahaR8GpdmyqRPWNHo= Received: from BYAPR11MB3143.namprd11.prod.outlook.com (2603:10b6:a03:92::32) by BYAPR11MB2775.namprd11.prod.outlook.com (2603:10b6:a02:bd::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2937.22; Wed, 29 Apr 2020 16:51:39 +0000 Received: from BYAPR11MB3143.namprd11.prod.outlook.com ([fe80::5917:9757:49b0:3c49]) by BYAPR11MB3143.namprd11.prod.outlook.com ([fe80::5917:9757:49b0:3c49%5]) with mapi id 15.20.2937.023; Wed, 29 Apr 2020 16:51:39 +0000 From: "Van Haaren, Harry" To: Phil Yang , "dev@dpdk.org" CC: "thomas@monjalon.net" , "david.marchand@redhat.com" , "Ananyev, Konstantin" , "jerinj@marvell.com" , "hemant.agrawal@nxp.com" , "Honnappa.Nagarahalli@arm.com" , "gavin.hu@arm.com" , "nd@arm.com" , "Honnappa Nagarahalli" , "stable@dpdk.org" , "Eads, Gage" , "Richardson, Bruce" Thread-Topic: [PATCH v2 1/6] service: fix race condition for MT unsafe service Thread-Index: AQHWGYzR0pQ9nE/SWEGnc1eZ3IqbiqiQVgOQ Date: Wed, 29 Apr 2020 16:51:39 +0000 Message-ID: References: <1584407863-774-8-git-send-email-phil.yang@arm.com> <1587659482-27133-1-git-send-email-phil.yang@arm.com> <1587659482-27133-2-git-send-email-phil.yang@arm.com> In-Reply-To: <1587659482-27133-2-git-send-email-phil.yang@arm.com> Accept-Language: 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: arm.com; dkim=none (message not signed) header.d=none;arm.com; dmarc=none action=none header.from=intel.com; x-originating-ip: [192.198.151.172] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: d32e4e79-7aaa-4c66-98bb-08d7ec5d968b x-ms-traffictypediagnostic: BYAPR11MB2775: 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:3383; x-forefront-prvs: 03883BD916 x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BYAPR11MB3143.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFTY:; SFS:(346002)(376002)(136003)(366004)(396003)(39860400002)(5660300002)(71200400001)(8936002)(33656002)(4326008)(7696005)(107886003)(86362001)(478600001)(53546011)(55016002)(7416002)(76116006)(186003)(316002)(52536014)(2906002)(66946007)(110136005)(9686003)(8676002)(26005)(66446008)(6506007)(54906003)(64756008)(66556008)(66476007); DIR:OUT; SFP:1102; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: Ii3Nc7ECsV9wJHkpe/Ba1SZBxWSZmZpsHJcqbYBlFATzEsVpXYWTXZT/wKYkL97OuBTdLHlhWj1wzbI9D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nsDmHgCOq9+r7y6z8Ps1f2xN1DMkY4vUaw+e7cWh+O7xs2LFfXNkT6AjYDJ+20EIx8hbCTukVzG/Ogpg3e6y+5iCg1PSLnQ/mgEpn6Dqqc6QzaLQ1fhlnX4b6rrKH10KdPufKkl6QVdLZbK Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Exchange-CrossTenant-Network-Message-Id: d32e4e79-7aaa-4c66-98bb-08d7ec5d968b X-MS-Exchange-CrossTenant-originalarrivaltime: 29 Apr 2020 16:51:39.6640 (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: BnLgUtnjLooyIjPy+sQRb9ykyFG7o65WWeFy6J6Ka+/Uhse/yKcVpdtQRXP775AhipIf+zwFv7FtghPlQVbyxFkf2YSMWb2oAvVsvI+Y1y0= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR11MB2775 X-OriginatorOrg: intel.com Subject: Re: [dpdk-dev] [PATCH v2 1/6] service: fix race condition for MT unsafe service 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" > -----Original Message----- > From: Phil Yang > Sent: Thursday, April 23, 2020 5:31 PM > To: Van Haaren, Harry ; dev@dpdk.org > Cc: thomas@monjalon.net; david.marchand@redhat.com; Ananyev, Konstantin > ; jerinj@marvell.com; > hemant.agrawal@nxp.com; Honnappa.Nagarahalli@arm.com; > gavin.hu@arm.com; nd@arm.com; Honnappa Nagarahalli > ; stable@dpdk.org > Subject: [PATCH v2 1/6] service: fix race condition for MT unsafe service >=20 > From: Honnappa Nagarahalli >=20 > The MT unsafe service might get configured to run on another core > while the service is running currently. This might result in the > MT unsafe service running on multiple cores simultaneously. Use > 'execute_lock' always when the service is MT unsafe. >=20 > Fixes: e9139a32f6e8 ("service: add function to run on app lcore") > Cc: stable@dpdk.org >=20 > Signed-off-by: Honnappa Nagarahalli > Reviewed-by: Phil Yang > --- Thanks for spinning a new revision - based on ML discussion previously, it seems like the "use service-run-count" to avoid this race would be a complex solution. Suggesting the following; 1) Take the approach as per this patch, to always take the atomic, fixing t= he race condition. 2) Add an API to service-cores, which allows "committing" of mappings. Comm= itting the mapping would imply that the mappings will not be changed in fut= ure. With runtime-remapping being removed from the equation, the existing b= ranch-over-atomic optimization is valid again. So this would offer applications two situations A) No application change: possible performance regression due to atomic alw= ays taken. B) Call "commit" API, and regain the performance as per previous DPDK versi= ons. Thoughts/opinions on the above? I've flagged the rest of the patchset for = review ASAP. Regards, -Harry > lib/librte_eal/common/rte_service.c | 11 +++++------ > 1 file changed, 5 insertions(+), 6 deletions(-) >=20 > diff --git a/lib/librte_eal/common/rte_service.c > b/lib/librte_eal/common/rte_service.c > index 70d17a5..b8c465e 100644 > --- a/lib/librte_eal/common/rte_service.c > +++ b/lib/librte_eal/common/rte_service.c > @@ -50,6 +50,10 @@ struct rte_service_spec_impl { > uint8_t internal_flags; >=20 > /* per service statistics */ > + /* Indicates how many cores the service is mapped to run on. > + * It does not indicate the number of cores the service is running > + * on currently. > + */ > rte_atomic32_t num_mapped_cores; > uint64_t calls; > uint64_t cycles_spent; > @@ -370,12 +374,7 @@ service_run(uint32_t i, struct core_state *cs, uint6= 4_t > service_mask, >=20 > cs->service_active_on_lcore[i] =3D 1; >=20 > - /* check do we need cmpset, if MT safe or <=3D 1 core > - * mapped, atomic ops are not required. > - */ > - const int use_atomics =3D (service_mt_safe(s) =3D=3D 0) && > - (rte_atomic32_read(&s->num_mapped_cores) > 1); > - if (use_atomics) { > + if (service_mt_safe(s) =3D=3D 0) { > if (!rte_atomic32_cmpset((uint32_t *)&s->execute_lock, 0, 1)) > return -EBUSY; >=20 > -- > 2.7.4