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 2D1EBA0C3F; Mon, 28 Jun 2021 14:20:10 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id A3BCE40692; Mon, 28 Jun 2021 14:20:09 +0200 (CEST) Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by mails.dpdk.org (Postfix) with ESMTP id A502A4068A for ; Mon, 28 Jun 2021 14:20:07 +0200 (CEST) X-IronPort-AV: E=McAfee;i="6200,9189,10028"; a="187627585" X-IronPort-AV: E=Sophos;i="5.83,306,1616482800"; d="scan'208";a="187627585" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Jun 2021 05:19:45 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.83,305,1616482800"; d="scan'208";a="625234869" Received: from fmsmsx606.amr.corp.intel.com ([10.18.126.86]) by orsmga005.jf.intel.com with ESMTP; 28 Jun 2021 05:19:45 -0700 Received: from fmsmsx609.amr.corp.intel.com (10.18.126.89) by fmsmsx606.amr.corp.intel.com (10.18.126.86) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2242.4; Mon, 28 Jun 2021 05:19:44 -0700 Received: from fmsedg601.ED.cps.intel.com (10.1.192.135) by fmsmsx609.amr.corp.intel.com (10.18.126.89) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2242.4 via Frontend Transport; Mon, 28 Jun 2021 05:19:44 -0700 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (104.47.59.171) by edgegateway.intel.com (192.55.55.70) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2242.4; Mon, 28 Jun 2021 05:19:44 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=KCOP+/UGPMPJ7k9Fbq8tXLE/thh+7HIvz/pUcYJTyJj439F5riM/uEb9XXQCXQHTWuQoYsYBH6i5HbZO4D4+/HiID9AWHNC42dVDp9UZkmpqMcWKr8cNOK1F7g4N1FBOJ+xQ+Pxrh3ZAcqDoVxdQxbiRuLajL+9trpQjFh1SGMyq7vY1EDMD2ltaUjcJDzLKy28um7w5rg2S8eUH8WLnPazvso50WCebFpgriooWTtPQ/v9qioaR4UTziGx8/xUfTU76GqKDAc+bLsmf/L6wgLa8qd8WBA+QCbOrTYIA7wPdZOu2te3MsLRc7cXvIWntibr6R3xpVd63NJv+vYuhEA== 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=pUcnjNdLBXLUSRkpIfIwAIcyqkSuEC3THal26BMOCnI=; b=C/K739Ytoko0Rf2upapAaQ89ocDIVeCiyGrvrov2EzOnMvVHsYCjsvn2/QIxCuHMTkc2Tl9oqwc4z0gwIs6cizr+vJBUayIu4/akPb/UUVIaS2iWSoeK1CRA2+9hvmWOt2z7Wm1G8Ef1zg7/cRjswWYCTvOjUohLyHGW/uIX9Gnw4ScpXTpXDgfjJyEecFyTO+VVask71Dp0+3aWzLtWqZWeILz/3QusLYMv/gpR1YXtwKGp2UE9xVamLo8b6qF/ElXzpNAo7QoTV+qz73loj2rUm1toaxN0udNpX7hh+/Dm+/is1uL2jlbk3CV7M1TWG7Rtbu2umIplYtVfrPKs4Q== 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=pUcnjNdLBXLUSRkpIfIwAIcyqkSuEC3THal26BMOCnI=; b=bDoNyc8YnpE1j8AhrzAKOCp74tpEjct9qNTIqQs/rMoBTtd4DFe1WZ9yd10/eljB8gKU+BNYrBAh/tR4SIFW+fREwjf+ty9fi0PSd2neBrcItAE1xcTxp47MCs51db/uF6Bc9CVe0XCWjkBWycd+EfVgldBlHMOVvi8CXIRk6PU= Received: from DM6PR11MB4491.namprd11.prod.outlook.com (2603:10b6:5:204::19) by DM5PR11MB1818.namprd11.prod.outlook.com (2603:10b6:3:114::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4264.23; Mon, 28 Jun 2021 12:19:42 +0000 Received: from DM6PR11MB4491.namprd11.prod.outlook.com ([fe80::7dc4:66b0:f76b:6d48]) by DM6PR11MB4491.namprd11.prod.outlook.com ([fe80::7dc4:66b0:f76b:6d48%7]) with mapi id 15.20.4264.026; Mon, 28 Jun 2021 12:19:42 +0000 From: "Ananyev, Konstantin" To: "Burakov, Anatoly" , "dev@dpdk.org" , "McDaniel, Timothy" , "Xing, Beilei" , "Wu, Jingjing" , "Yang, Qiming" , "Zhang, Qi Z" , "Wang, Haiyue" , Matan Azrad , Shahaf Shuler , Viacheslav Ovsiienko , "Richardson, Bruce" CC: "Hunt, David" , "Loftus, Ciara" Thread-Topic: [PATCH v2 1/7] power_intrinsics: use callbacks for comparison Thread-Index: AQHXacqEbNxiI0QnE0eoszSa66E4HKspW0DQ Date: Mon, 28 Jun 2021 12:19:41 +0000 Message-ID: References: <791375007363a5fdb859a00407352e324e5063ed.1624629506.git.anatoly.burakov@intel.com> In-Reply-To: <791375007363a5fdb859a00407352e324e5063ed.1624629506.git.anatoly.burakov@intel.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.5.1.3 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: [109.255.184.192] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 381d2030-bc47-4929-e1f2-08d93a2f01f6 x-ms-traffictypediagnostic: DM5PR11MB1818: 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:9508; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: Q683XX2jnYPh1DbJ4Q9FBwqmnE4/+UZx0s0B5jh+xQsOulAL5QnLO1m0VHh/VuKnbK32pmZBiUTgsSgiXryHzqOKzrLXE9k3F68rbUbOkTwE377iZxUt/FHfZTHwJ+ZpMxS55EIJU8VI9S7H2hhmXQDLq0+hnkI58oERzbngXttnv+1W+cb1ioqp9g7zHVYsfm+jLiAMO4Fn0KHVjRoG2jIlulnQQSWvpPZJvQ6R8X6F1zxxiYIfsvN166122qn0XZ6Ao3Jkx3+brh4OwdE7eEvzFrb/8NQeuoXPcl0vv+/MLZmPp6ryG1OCJJgb6n/PvQeSWrAmopJQY7F6vlbpRDhKwEjIh7W1BX9Jwv4BCGLUkhkNKWzEd9r8UlL+SJFBhfp0FYw4lUy5yIuEYEMPD2hYcbQzWoyYASLoXYhL4/nWLdL7BIdnSLOJqI4LjWTqJCljdUGzeqcOku9xFDmLnlF9fBY/6hJPUql3OfnyWuieaLU7LPatX55f6nM7kpCIbouE5yBo8kjAXCjhePH1Xbv0K8LulZ21mhZe28PxQH7GltPIofqMl90Xg1XNHY7n2uzVXZqHNNVyYl+89hcpPZC0OV5uC7qZN8Gz88AhieN1c9+UkV00rPRcIEl+Npsy45prfPPB1e2/NK/2zXBEBCpw6SznkfSNGM8kAN4RxM1jXh+pOaR7dXVpYivBWt1w x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DM6PR11MB4491.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(396003)(376002)(366004)(136003)(346002)(39860400002)(33656002)(316002)(7696005)(83380400001)(2906002)(52536014)(86362001)(5660300002)(71200400001)(107886003)(110136005)(54906003)(8676002)(4326008)(66946007)(921005)(64756008)(122000001)(66476007)(66556008)(66446008)(9686003)(6506007)(76116006)(38100700002)(26005)(8936002)(186003)(55016002)(6636002)(55236004)(478600001); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?v4ZsozXUtKyOYmDc7TSUXeEryPUFEeQMrB6AHw9Pvd2cfuQVbtlOg9ENEadG?= =?us-ascii?Q?c2+yEjOkzMaIwUHrO7ZS8DOagckTGr/Jztqzh5A+3CNvTryowyAXLJ4msEU/?= =?us-ascii?Q?QaODHPxDUmt1tzB0WYsJQvtexXth52kSH6u0K3RZg73ktq6hdrE7ILrnmYoe?= =?us-ascii?Q?BZDAimSXGTkHmPl+hbEks7sY4x4aMcU6fPXM2tqNuc1gxqOSc5mdkJSdtb8F?= =?us-ascii?Q?PjOn9veWaO8/3eB/ifZ2VD3Bc2xQ81FRes5g53TvETmKBHYGVCexVQU3Ht0g?= =?us-ascii?Q?RE82rnP3Qn6dGsPnWadSGnrMfsDGj97RSA1j2mIX/C9esPqbJmyQOvuUM2ZL?= =?us-ascii?Q?hIO3eSJq7zbHrK4IXKzKZv3WnPPKrlBqvXjJPfrL4xd6Pdnp8rTqzicqaLOK?= =?us-ascii?Q?n3IewfjzTdqiTTGoQ59mTlX+C3b2iIW0XxP8J7rX8gT2UarXvQTYCgpSEP4O?= =?us-ascii?Q?KrpnykfBtQd0tlrTFX3yPFvdpu8CQ4kL0MqddaIGpSqgvIsPw5mEtyG3WJmk?= =?us-ascii?Q?oyPBsVStLfyoQdwAgQUFVIrkdzCgC3bumt+R1BLr0yXRCpL1/nRgdRrj2U4F?= =?us-ascii?Q?LhpmGEBSBOjYFMtegdQrpL8HSzb/uZzdILIocoqc46yaDf0iRL+1J6xjPTyQ?= =?us-ascii?Q?F11zZxRlhaSutVVN/SJ2tvG2I5578R95nBVIwNrsDawpDZl++ibxP959TaJL?= =?us-ascii?Q?7fwUD1IdM/R+tQZkA8n/6XFDpJyYZ+punxVDQAJbJ+yvnV8o8jp0Y+zj2gY/?= =?us-ascii?Q?uCm1NkEFOlsufNthlS7AD5U+TBQiHixWkC8Er1ODmzeSo+8BduLL8eViV/FO?= =?us-ascii?Q?pQ70P+PB38h9KB2IT1jKmteSUtbEXHebOelYVeZyTBYzq2aIecvFD9ahaL98?= =?us-ascii?Q?jDJAeOsSMEmit/ZhVHgd/5SHPBBENYraWtMZKkAoC8+eQR49UHgclpOw6R7Z?= =?us-ascii?Q?7gkrZ1bkHUzCKqoFr8Eg0xZhEfCzRpxufhxz/10/zgzptOm0p86tIfUz7/iR?= =?us-ascii?Q?Lo+6xsSe7WYxqPmrxK55M6GQbJ+KMEuGtCM3jZaNYMtcSH23Rr0plzwbns6M?= =?us-ascii?Q?l7awO49YAPEAFkiTjOFMKgiALabForZ0xJxAyUz7In/Zz2Yn/qC6mpZH1f8m?= =?us-ascii?Q?cg+i7FBd7h99Ra7wMRIwArKIywTseUSINVZO5u9wEurZb8V3ES6C+nYbghXV?= =?us-ascii?Q?W8G8id9Nk1ZXXx+M4/A0tRAiRuT7Gbyn/HptpIssyUNxj3E11PzYa3L3Bqvj?= =?us-ascii?Q?ZXA4WJaljRXD3RY9aZMFFb9r1WJB5vPEj/FKlNsFMClN0nkHgKFd2NZQF/Vc?= =?us-ascii?Q?FbM8oWg7KNquB8v11hOUqg8r?= 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: DM6PR11MB4491.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 381d2030-bc47-4929-e1f2-08d93a2f01f6 X-MS-Exchange-CrossTenant-originalarrivaltime: 28 Jun 2021 12:19:41.8757 (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: ZtQjcecgnekKyUyWiaYPBkYDTND1yuJGHzqCbYX6AkWml8feJsuFNv7J9r45+GmMkIEVwTzIZWNXunMU5VXDuT3aaHx6b3zSXw9JS+NgP5g= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR11MB1818 X-OriginatorOrg: intel.com Subject: Re: [dpdk-dev] [PATCH v2 1/7] power_intrinsics: use callbacks for comparison 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" =20 > Previously, the semantics of power monitor were such that we were > checking current value against the expected value, and if they matched, > then the sleep was aborted. This is somewhat inflexible, because it only > allowed us to check for a specific value. >=20 > This commit replaces the comparison with a user callback mechanism, so > that any PMD (or other code) using `rte_power_monitor()` can define > their own comparison semantics and decision making on how to detect the > need to abort the entering of power optimized state. >=20 > Existing implementations are adjusted to follow the new semantics. >=20 > Suggested-by: Konstantin Ananyev > Signed-off-by: Anatoly Burakov > --- >=20 > Notes: > v2: > - Use callback mechanism for more flexibility > - Address feedback from Konstantin >=20 > doc/guides/rel_notes/release_21_08.rst | 1 + > drivers/event/dlb2/dlb2.c | 16 ++++++++-- > drivers/net/i40e/i40e_rxtx.c | 19 ++++++++---- > drivers/net/iavf/iavf_rxtx.c | 19 ++++++++---- > drivers/net/ice/ice_rxtx.c | 19 ++++++++---- > drivers/net/ixgbe/ixgbe_rxtx.c | 19 ++++++++---- > drivers/net/mlx5/mlx5_rx.c | 16 ++++++++-- > .../include/generic/rte_power_intrinsics.h | 29 ++++++++++++++----- > lib/eal/x86/rte_power_intrinsics.c | 9 ++---- > 9 files changed, 106 insertions(+), 41 deletions(-) >=20 > diff --git a/lib/eal/include/generic/rte_power_intrinsics.h b/lib/eal/inc= lude/generic/rte_power_intrinsics.h > index dddca3d41c..046667ade6 100644 > --- a/lib/eal/include/generic/rte_power_intrinsics.h > +++ b/lib/eal/include/generic/rte_power_intrinsics.h > @@ -18,19 +18,34 @@ > * which are architecture-dependent. > */ >=20 > +/** > + * Callback definition for monitoring conditions. Callbacks with this si= gnature > + * will be used by `rte_power_monitor()` to check if the entering of pow= er > + * optimized state should be aborted. > + * > + * @param val > + * The value read from memory. > + * @param opaque > + * Callback-specific data. > + * > + * @return > + * 0 if entering of power optimized state should proceed > + * -1 if entering of power optimized state should be aborted > + */ > +typedef int (*rte_power_monitor_clb_t)(const uint64_t val, > + const uint64_t opaque[4]); > struct rte_power_monitor_cond { > volatile void *addr; /**< Address to monitor for changes */ > - uint64_t val; /**< If the `mask` is non-zero, location pointed > - * to by `addr` will be read and compared > - * against this value. > - */ > - uint64_t mask; /**< 64-bit mask to extract value read from `addr` */ > - uint8_t size; /**< Data size (in bytes) that will be used to compare > - * expected value (`val`) with data read from the > + uint8_t size; /**< Data size (in bytes) that will be read from the > * monitored memory location (`addr`). Can be 1, 2, > * 4, or 8. Supplying any other value will result in > * an error. > */ > + rte_power_monitor_clb_t fn; /**< Callback to be used to check if > + * entering power optimized state should > + * be aborted. > + */ > + uint64_t opaque[4]; /**< Callback-specific data */ As a nit - would be good to add some new macro for '4'. Apart from that - LGTM. Acked-by: Konstantin Ananyev > }; >=20 > /** > diff --git a/lib/eal/x86/rte_power_intrinsics.c b/lib/eal/x86/rte_power_i= ntrinsics.c > index 39ea9fdecd..3c5c9ce7ad 100644 > --- a/lib/eal/x86/rte_power_intrinsics.c > +++ b/lib/eal/x86/rte_power_intrinsics.c > @@ -110,14 +110,11 @@ rte_power_monitor(const struct rte_power_monitor_co= nd *pmc, > /* now that we've put this address into monitor, we can unlock */ > rte_spinlock_unlock(&s->lock); >=20 > - /* if we have a comparison mask, we might not need to sleep at all */ > - if (pmc->mask) { > + /* if we have a callback, we might not need to sleep at all */ > + if (pmc->fn) { > const uint64_t cur_value =3D __get_umwait_val( > pmc->addr, pmc->size); > - const uint64_t masked =3D cur_value & pmc->mask; > - > - /* if the masked value is already matching, abort */ > - if (masked =3D=3D pmc->val) > + if (pmc->fn(cur_value, pmc->opaque) !=3D 0) > goto end; > } >=20 > -- > 2.25.1