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 04607A034F; Tue, 9 Nov 2021 23:59:35 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 8FA9C40E03; Tue, 9 Nov 2021 23:59:35 +0100 (CET) Received: from EUR02-VE1-obe.outbound.protection.outlook.com (mail-eopbgr20080.outbound.protection.outlook.com [40.107.2.80]) by mails.dpdk.org (Postfix) with ESMTP id 4D2B74068B for ; Tue, 9 Nov 2021 23:59:34 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=82J5/ZJ/sTmHftgxrlvJcNNiZsNu9w2WvlxSfevGzpc=; b=EZIhnqOcpN8svogfAcjvssgDFebcPcSeH+XZ8kSiC66QYEQWKUdlt/0I9DNT2gFnnD5D1ICUbfMriY2W2JbZdOMZjfXtTHp8iPDYVks7qo/t6/Kgs8hY21zHUkrPJwbSjjcn9bEcWHDfndp4RqYOLq6ta7fvDaRYam1TqeFw7SA= Received: from AS9PR06CA0289.eurprd06.prod.outlook.com (2603:10a6:20b:45a::29) by VI1PR08MB4336.eurprd08.prod.outlook.com (2603:10a6:803:fe::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4690.15; Tue, 9 Nov 2021 22:59:29 +0000 Received: from VE1EUR03FT009.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:45a:cafe::f6) by AS9PR06CA0289.outlook.office365.com (2603:10a6:20b:45a::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4669.16 via Frontend Transport; Tue, 9 Nov 2021 22:59:29 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 63.35.35.123 as permitted sender) receiver=protection.outlook.com; client-ip=63.35.35.123; helo=64aa7808-outbound-1.mta.getcheckrecipient.com; Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by VE1EUR03FT009.mail.protection.outlook.com (10.152.18.92) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4649.14 via Frontend Transport; Tue, 9 Nov 2021 22:59:28 +0000 Received: ("Tessian outbound 6ebd41198c5d:v108"); Tue, 09 Nov 2021 22:59:28 +0000 X-CR-MTA-TID: 64aa7808 Received: from 05f7755cfdc6.3 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 43B38DBD-ADC2-4C2D-9D80-BD88955441C4.1; Tue, 09 Nov 2021 22:59:20 +0000 Received: from EUR04-HE1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 05f7755cfdc6.3 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Tue, 09 Nov 2021 22:59:20 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FmIjkzSOHV46p2pCdHvI3I/eHEjEngLM4CxpLGg5FPlAOh7NQEPwHmKbEk0tYYHAc+VVaeDyYugHNkpNyfDYzKpbGYJn6uQXfKi8Umuf348/QOp0sBfzDB5ylYGiI2/8bTESBd4BWbyR3qQiJ11Pjk7WGN9582FdzPG1GiPu2NAOUfsuUoVR36wvhjiT2xl1I39w3u93wxHZx9n4FJrXXsMzuXZtLI5vrt71d1MeqZS/a21gN49IUVoPGkZ2ymE5qP0PBYnMn925bpNNpYvrf8RD1RfDr/GbNBGblBWVnWCUZmo34IY+P7Pz14RLk+n+FkF02mNP1y8n/gWxZreR9Q== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=82J5/ZJ/sTmHftgxrlvJcNNiZsNu9w2WvlxSfevGzpc=; b=g4YqwfBjf4dWE8vOHtmZw4duwMbK0yMzuF4cui8OU62WU2FyUONZutV4s5rde8o95B8dL4uRmIDBM+kKX5ezGe4VxKmKMSOL7NzEZ1yBH0caoNVuC5bgmaEo9QRYq8c3D7bz8gB9LWp2E3IVG2Pazh2dEMTUSwH3cJgAkhV0T0p+uIYRpSu3LJxwwlAwfH45lKSVmRsL/RSTjt6cE+ro0kWrB9bO1Q4T1naTlewPwbiU9/QxvZHcS5TlilhnBU9HJAg3EZpmIEe27PLyNwJhf0XK7n6xcaYu0nZw/sMqZg2smLQvY3+xzV3YPYpvgsoWmplxUZOmqcFsktR/uEN9+w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=82J5/ZJ/sTmHftgxrlvJcNNiZsNu9w2WvlxSfevGzpc=; b=EZIhnqOcpN8svogfAcjvssgDFebcPcSeH+XZ8kSiC66QYEQWKUdlt/0I9DNT2gFnnD5D1ICUbfMriY2W2JbZdOMZjfXtTHp8iPDYVks7qo/t6/Kgs8hY21zHUkrPJwbSjjcn9bEcWHDfndp4RqYOLq6ta7fvDaRYam1TqeFw7SA= Received: from DBAPR08MB5814.eurprd08.prod.outlook.com (2603:10a6:10:1b1::6) by DB9PR08MB6345.eurprd08.prod.outlook.com (2603:10a6:10:252::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4669.16; Tue, 9 Nov 2021 22:59:14 +0000 Received: from DBAPR08MB5814.eurprd08.prod.outlook.com ([fe80::8501:86ca:a393:17b7]) by DBAPR08MB5814.eurprd08.prod.outlook.com ([fe80::8501:86ca:a393:17b7%9]) with mapi id 15.20.4690.015; Tue, 9 Nov 2021 22:59:14 +0000 From: Honnappa Nagarahalli To: Joyce Kong , "thomas@monjalon.net" , "david.marchand@redhat.com" , Ruifeng Wang , "konstantin.ananyev@intel.com" , "rsanford@akamai.com" , "erik.g.carrillo@intel.com" , "olivier.matz@6wind.com" , "yipeng1.wang@intel.com" , "sameh.gobriel@intel.com" , "bruce.richardson@intel.com" , "vladimir.medvedkin@intel.com" , "anatoly.burakov@intel.com" , "andrew.rybchenko@oktetlabs.ru" , "jerinj@marvell.com" , "declan.doherty@intel.com" , "ciara.power@intel.com" , "xiaoyun.li@intel.com" , "nicolas.chautru@intel.com" , "maryam.tahhan@intel.com" , "reshma.pattan@intel.com" , "cristian.dumitrescu@intel.com" CC: "dev@dpdk.org" , nd , nd Thread-Topic: [PATCH v1 09/12] app/compress: use compiler atomic builtins for display sync Thread-Index: AQHXh4ga5SdFnZuZtEOGSLckVXcKFKv8abbA Date: Tue, 9 Nov 2021 22:59:14 +0000 Message-ID: References: <20210802101847.3462-1-joyce.kong@arm.com> <20210802101847.3462-10-joyce.kong@arm.com> In-Reply-To: <20210802101847.3462-10-joyce.kong@arm.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ts-tracking-id: CC6AC6601FC2A64E9A7C82E2A8F7F2BA.0 x-checkrecipientchecked: true Authentication-Results-Original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; x-ms-publictraffictype: Email X-MS-Office365-Filtering-Correlation-Id: 73d14cfb-70dc-4633-5edb-08d9a3d495bb x-ms-traffictypediagnostic: DB9PR08MB6345:|VI1PR08MB4336: x-ld-processed: f34e5979-57d9-4aaa-ad4d-b122a662184d,ExtAddr X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true nodisclaimer: true x-ms-oob-tlc-oobclassifiers: OLM:303;OLM:303; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: G5V5p5gRYKSg4MgTVmLHdLaD/TJ2/zAfMdGq+suGfis5GCvRNh5D8aonLMfboMRHE+ZRGJQYVIOHtPEe5yNZ9f7zbq9NxhMHEAkthw76AUdxm77UFhhsAEiZeFQ4wXUS2gXUmvdkVffyi25n/wIBwbijL0t1aiEIVBm67qBZhtZzJPQ9uDg70kRHSBDUQSe4UO1I5FwIUJ3WcrNU8Jz4yIOGwHomUIrwVaCDIHnYrISk0D2OwzhyEFLvBqRDMynai+1QBdQoaIKwM5IU71EBJf9rGZzRlTpmvuF/SjjuSh69Y/W2GbSSVBbJfgGK/BKVZrH8V4GjCE7Es1zUXIMOmL/aPS1vJySZ6pfYB3G3JHA9YW74iv6EDa93oa6Z/dtFlskiPf6popKHxJ9CDHeuvy6JpnOzK6ddnoxxOBmcJahglwYG1t6B2Qam7/x7z3brfIHtaS5KDZDiY68nxhGSSdJyEao7ijz2/qNNTf6gLtvXIcxW/aDnwr6BafaH1PBuwxG+tVoqKL/3bwDjUxaDknuPEvIEZUcWxn+6szgD+MWFQ6ZXpRff3HWFdWUaTPqnzo8SjcP6OHFPKDuvAvmzJ0R/o8L36Ie5bcKx2MYDVNYmSU2Zt5c4J0PCQu4Xw8AP7wIGbwS2EonA5NM9hhxkYG4hB/PP2017vL25av3VcmLckWqa8CwJXt6LyqMiUHwYU7SXbUvP5/xFMWsJvCJvxRHnSQIVQbP6LZTdQl7ugtY= X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DBAPR08MB5814.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(55016002)(110136005)(6506007)(8676002)(7416002)(86362001)(54906003)(38100700002)(76116006)(122000001)(38070700005)(4326008)(316002)(921005)(2906002)(5660300002)(66946007)(64756008)(66556008)(66476007)(52536014)(71200400001)(7696005)(8936002)(9686003)(83380400001)(186003)(508600001)(33656002)(66446008)(26005); DIR:OUT; SFP:1101; Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR08MB6345 Original-Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: VE1EUR03FT009.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: fc216fff-189d-475f-e5d9-08d9a3d48cf2 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 77gg7BF+cR54CXVih+z7NjVunb2Y6PlxWMT4neW8RjA3WA8kmgBXzBh+1E7K505+54OSVvQWp/D/5szjNmyrObm64brhOH9nH6pOWtF7JgS4owxEBzwkEOaMfJuDjENAHru8PjHiw5AVGyC+ZLabMM745uyDEGEXr1CGh0RYMJRlXyH2SjQvpT2PSekK5YhIgShDQr8yjsG/P6Hy9ujpJiU9ojtgX4R9u2ICANaF/CPQt5E3x+yCmqWu5g39OsroTzDNv/xdcl+77SLZNEwWRMU37g7+3GWieOMnlCsrxncmKFx2so0xjMARgZ170+HJZo4SCmOQX/izrIekoZ+fwPzaM/r5HF3Hs6ly+Q5Dpi707b3P2BCw0iI/pzEZYZNz+K1VyQPVq5CpwDdfIJuasmt4janMhozp4HOEGxwE5Wng0LzeiFGAkE3CjWiGN9xN5bBk/0JrkL2wC9JIoTfa5U9BUFfybbkBlNee7e7gKlUyjQ8GiYzWX11mqL63yBjEiSkzCb0N8bkJ91Bs5YRlys8iU3l9NU4teI8LuiVWrnhIbm+CAOsSSeHyzZ8QxNhUi3wZAbCMSqVutyNvR2W9HZDOKn6YnH3wzsbLntIXMzLKVtr2Opn5avxO+Mp+vbUr/mYwuBnPVNTQ1JNd24EMkLBS+fwPzF0mTnOTACOTTgKigWU156qKOPqmhjRqeqyw5gA87G39uzS1siLk6ekeYgC3jGYUFM8gM3YfZV5PV5U= X-Forefront-Antispam-Report: CIP:63.35.35.123; CTRY:IE; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:64aa7808-outbound-1.mta.getcheckrecipient.com; PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com; CAT:NONE; SFS:(4636009)(36840700001)(46966006)(356005)(186003)(110136005)(921005)(54906003)(8676002)(70586007)(70206006)(83380400001)(81166007)(5660300002)(47076005)(2906002)(52536014)(316002)(8936002)(26005)(86362001)(82310400003)(36860700001)(336012)(508600001)(9686003)(33656002)(55016002)(7696005)(6506007)(4326008); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Nov 2021 22:59:28.8755 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 73d14cfb-70dc-4633-5edb-08d9a3d495bb X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d; Ip=[63.35.35.123]; Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-AuthSource: VE1EUR03FT009.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR08MB4336 Subject: Re: [dpdk-dev] [PATCH v1 09/12] app/compress: use compiler atomic builtins for display sync 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 > Convert rte_atomic_test_and_set usage to compiler atomic CAS operation fo= r > display sync. >=20 > Signed-off-by: Joyce Kong > Reviewed-by: Ruifeng Wang > --- > app/test-compress-perf/comp_perf_test_common.h | 2 +- > app/test-compress-perf/comp_perf_test_cyclecount.c | 10 +++++++--- > app/test-compress-perf/comp_perf_test_throughput.c | 11 ++++++++--- > app/test-compress-perf/comp_perf_test_verify.c | 6 ++++-- > 4 files changed, 20 insertions(+), 9 deletions(-) >=20 > diff --git a/app/test-compress-perf/comp_perf_test_common.h b/app/test- > compress-perf/comp_perf_test_common.h > index 72705c6a2b..d039e5a29a 100644 > --- a/app/test-compress-perf/comp_perf_test_common.h > +++ b/app/test-compress-perf/comp_perf_test_common.h > @@ -14,7 +14,7 @@ struct cperf_mem_resources { > uint16_t qp_id; > uint8_t lcore_id; >=20 > - rte_atomic16_t print_info_once; > + uint16_t print_info_once; >=20 > uint32_t total_bufs; > uint8_t *compressed_data; > diff --git a/app/test-compress-perf/comp_perf_test_cyclecount.c b/app/tes= t- > compress-perf/comp_perf_test_cyclecount.c > index 55559a7d5a..e002e53bdf 100644 > --- a/app/test-compress-perf/comp_perf_test_cyclecount.c > +++ b/app/test-compress-perf/comp_perf_test_cyclecount.c > @@ -468,7 +468,7 @@ cperf_cyclecount_test_runner(void *test_ctx) > struct cperf_cyclecount_ctx *ctx =3D test_ctx; > struct comp_test_data *test_data =3D ctx->ver.options; > uint32_t lcore =3D rte_lcore_id(); > - static rte_atomic16_t display_once =3D RTE_ATOMIC16_INIT(0); > + static uint16_t display_once; > static rte_spinlock_t print_spinlock; > int i; >=20 > @@ -488,10 +488,12 @@ cperf_cyclecount_test_runner(void *test_ctx) >=20 > ctx->ver.mem.lcore_id =3D lcore; >=20 > + uint16_t exp =3D 0; > /* > * printing information about current compression thread > */ > - if (rte_atomic16_test_and_set(&ctx->ver.mem.print_info_once)) > + if (__atomic_compare_exchange_n(&ctx->ver.mem.print_info_once, > &exp, > + 1, 0, __ATOMIC_RELAXED, > __ATOMIC_RELAXED)) > printf(" lcore: %u," > " driver name: %s," > " device name: %s," > @@ -547,8 +549,10 @@ cperf_cyclecount_test_runner(void *test_ctx) > duration_setup_per_op =3D ctx->duration_op / > (ctx->ver.mem.total_bufs * test_data->num_iter); >=20 > + exp =3D 0; > /* R E P O R T processing */ > - if (rte_atomic16_test_and_set(&display_once)) { > + if (__atomic_compare_exchange_n(&display_once, &exp, 1, 0, > + __ATOMIC_RELAXED, __ATOMIC_RELAXED)) { I think we can re-organize the current code which will avoid using atomic o= perations on 'display_once'. How about the following code? rte_spinlock_lock(&print_spinlock); if (display_once !=3D 1) { display_once =3D 1; printf("\nLegend for the table\n"..... } printf.... printf.... printf.... rte_spinlock_unlock(&print_spinlock); Rest of the changes look fine. >=20 > rte_spinlock_lock(&print_spinlock); >=20 > diff --git a/app/test-compress-perf/comp_perf_test_throughput.c b/app/tes= t- > compress-perf/comp_perf_test_throughput.c > index 13922b658c..f587ad2ec3 100644 > --- a/app/test-compress-perf/comp_perf_test_throughput.c > +++ b/app/test-compress-perf/comp_perf_test_throughput.c > @@ -329,15 +329,18 @@ cperf_throughput_test_runner(void *test_ctx) > struct cperf_benchmark_ctx *ctx =3D test_ctx; > struct comp_test_data *test_data =3D ctx->ver.options; > uint32_t lcore =3D rte_lcore_id(); > - static rte_atomic16_t display_once =3D RTE_ATOMIC16_INIT(0); > + static uint16_t display_once; > int i, ret =3D EXIT_SUCCESS; >=20 > ctx->ver.mem.lcore_id =3D lcore; >=20 > + uint16_t exp =3D 0; > /* > * printing information about current compression thread > */ > - if (rte_atomic16_test_and_set(&ctx->ver.mem.print_info_once)) > + if (__atomic_compare_exchange_n(&ctx->ver.mem.print_info_once, > &exp, > + 1, 0, __ATOMIC_RELAXED, > __ATOMIC_RELAXED)) > + > printf(" lcore: %u," > " driver name: %s," > " device name: %s," > @@ -391,7 +394,9 @@ cperf_throughput_test_runner(void *test_ctx) > ctx->decomp_gbps =3D rte_get_tsc_hz() / ctx->decomp_tsc_byte * 8 / > 1000000000; >=20 > - if (rte_atomic16_test_and_set(&display_once)) { > + exp =3D 0; > + if (__atomic_compare_exchange_n(&display_once, &exp, 1, 0, > + __ATOMIC_RELAXED, __ATOMIC_RELAXED)) { > printf("\n%12s%6s%12s%17s%15s%16s\n", > "lcore id", "Level", "Comp size", "Comp ratio [%]", > "Comp [Gbps]", "Decomp [Gbps]"); > diff --git a/app/test-compress-perf/comp_perf_test_verify.c b/app/test- > compress-perf/comp_perf_test_verify.c > index 5e13257b79..6a2497985b 100644 > --- a/app/test-compress-perf/comp_perf_test_verify.c > +++ b/app/test-compress-perf/comp_perf_test_verify.c > @@ -388,7 +388,7 @@ cperf_verify_test_runner(void *test_ctx) > struct cperf_verify_ctx *ctx =3D test_ctx; > struct comp_test_data *test_data =3D ctx->options; > int ret =3D EXIT_SUCCESS; > - static rte_atomic16_t display_once =3D RTE_ATOMIC16_INIT(0); > + static uint16_t display_once; > uint32_t lcore =3D rte_lcore_id(); >=20 > ctx->mem.lcore_id =3D lcore; > @@ -428,7 +428,9 @@ cperf_verify_test_runner(void *test_ctx) > test_data->input_data_sz * 100; >=20 > if (!ctx->silent) { > - if (rte_atomic16_test_and_set(&display_once)) { > + uint16_t exp =3D 0; > + if (__atomic_compare_exchange_n(&display_once, &exp, 1, > 0, > + __ATOMIC_RELAXED, __ATOMIC_RELAXED)) { > printf("%12s%6s%12s%17s\n", > "lcore id", "Level", "Comp size", "Comp ratio [%]"); > } > -- > 2.17.1