From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM05-DM3-obe.outbound.protection.outlook.com (mail-eopbgr730066.outbound.protection.outlook.com [40.107.73.66]) by dpdk.org (Postfix) with ESMTP id B9D21DED for ; Sat, 3 Nov 2018 12:52:57 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=CAVIUMNETWORKS.onmicrosoft.com; s=selector1-cavium-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=TmLcOiTrJhe35G446mhb0lfp2QyI1GxA8YX7uydRkgk=; b=KOVMq2OhETsCG+BF8Zj9eziWiOZsaJDzcffMxoVMQZ64ZjI324HMeLWbmmIz1P1nC7lpBVeeLHsYo9xuBpE90qY3v1fjBIdImHyqMnK5/SkdNdZ0mH7MUBJRaDQDQmYW0L+I1Px9KOBgeJntNofbNRrv5rkCJr5uypR1491JKgQ= Received: from BYAPR07MB4997.namprd07.prod.outlook.com (52.135.238.214) by BYAPR07MB5445.namprd07.prod.outlook.com (52.135.241.92) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1294.21; Sat, 3 Nov 2018 11:52:54 +0000 Received: from BYAPR07MB4997.namprd07.prod.outlook.com ([fe80::2d56:eab:242f:fdfc]) by BYAPR07MB4997.namprd07.prod.outlook.com ([fe80::2d56:eab:242f:fdfc%2]) with mapi id 15.20.1273.030; Sat, 3 Nov 2018 11:52:54 +0000 From: Jerin Jacob To: Honnappa Nagarahalli CC: "bruce.richardson@intel.com" , "pablo.de.lara.guarch@intel.com" , "dev@dpdk.org" , "yipeng1.wang@intel.com" , "dharmik.thakkar@arm.com" , "gavin.hu@arm.com" , "nd@arm.com" , "thomas@monjalon.net" , "ferruh.yigit@intel.com" , "hemant.agrawal@nxp.com" Thread-Topic: [dpdk-dev] [PATCH v7 4/5] hash: add lock-free read-write concurrency Thread-Index: AQHUbO4hC1hG0V5Pe0K6GLHhoSzYDKU9/ZaA Date: Sat, 3 Nov 2018 11:52:54 +0000 Message-ID: <20181103115240.GA3608@jerin> References: <1540532253-112591-1-git-send-email-honnappa.nagarahalli@arm.com> <1540532253-112591-5-git-send-email-honnappa.nagarahalli@arm.com> In-Reply-To: <1540532253-112591-5-git-send-email-honnappa.nagarahalli@arm.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [115.113.156.3] x-clientproxiedby: BM1PR0101CA0053.INDPRD01.PROD.OUTLOOK.COM (2603:1096:b00:19::15) To BYAPR07MB4997.namprd07.prod.outlook.com (2603:10b6:a03:5b::22) authentication-results: spf=none (sender IP is ) smtp.mailfrom=Jerin.JacobKollanukkaran@cavium.com; x-ms-exchange-messagesentrepresentingtype: 1 x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; BYAPR07MB5445; 6:0wyEJ7Nvyb1NczGyf7ybTWdzT1lPHdpAffujH+8uglRSgElcuRvwWI4IxjoqDQsg4I5AA4WMQSbYwRe1YCfyld4d1Lvp1NXuSi8Dvtw73BCV0IlnW3Q08NDJTkb5I2N7GbksOzd4AdZ/+5RUQx/pOBTgVjQq2iSOFBOtBQIPJyPRmC6nV64gUm9PiP+xJrIL2pQyIyvCUEeY4pfKfAvHMoB+6t4yRIdrwX+1xdKLuKQUGUfz7cUYLasUInHP3hhiZzl5RSQQesl5JcipyH3nyeYHjlQK8ta43C8QqCwfIlxMoBiu645DLXILGkv4x6RyQFMsnuokXWdjdmPsjijPXgjAMVNjpzfJu5Sjr3VDVjV8iC7SrfEHOfQLAKTsmlD89YyaKovLHuzZG/LEp6V9bKNVNUkTW4SOK2c3TQuxpEIY2TewQp4bAAvIjLkwHfxMU5lmqQndaKsM6CAr8FEg+g==; 5:er1/5wTVhj85Ql9UbwfsyUw0Woq29L4foJk2idYZcgYPyJkT5LlB+xlT9p1l37XH+zTyAtv5dJB95pNWUkKG0DV2h3HOK4a5PPiWR9cMT7Z98JXNu/U5SSjXP0F7dD/4/UHYrCkGZhBcvc6+tZiYi3A54fD7opKYmO3ET/4T4es=; 7:Xbdr3ldFodoAIjqXAXc4zi58IWd+RtT1XnCme+C/1Lq8kn2R4GBKPv+xRWI06d7lemRnvmki74t12Qx9gpwl3G3/3gizZWT4OG9Xx5lM5zfeU5PfhdyCbHl+BSOgFKIFts/3KvYkbB27zPHaYZNY7w== x-ms-office365-filtering-correlation-id: 04b9c7ed-6109-4c6e-8275-08d64182e3b9 x-microsoft-antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989299)(4534185)(7168020)(4627221)(201703031133081)(201702281549075)(8990200)(5600074)(711020)(2017052603328)(7153060)(7193020); SRVR:BYAPR07MB5445; x-ms-traffictypediagnostic: BYAPR07MB5445: x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(228905959029699)(180628864354917); x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(93006095)(10201501046)(3002001)(3231382)(944501410)(52105095)(148016)(149066)(150057)(6041310)(20161123558120)(20161123564045)(20161123560045)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(201708071742011)(7699051)(76991095); SRVR:BYAPR07MB5445; BCL:0; PCL:0; RULEID:; SRVR:BYAPR07MB5445; x-forefront-prvs: 08457955C4 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(7916004)(346002)(366004)(376002)(396003)(136003)(39830400003)(189003)(199004)(13464003)(11346002)(446003)(256004)(76176011)(1076002)(55236004)(305945005)(6116002)(7736002)(14454004)(386003)(3846002)(6506007)(33716001)(99286004)(229853002)(186003)(6512007)(33896004)(66066001)(72206003)(9686003)(2906002)(8676002)(54906003)(81156014)(97736004)(81166006)(476003)(316002)(6916009)(7416002)(14444005)(26005)(486006)(8936002)(6436002)(106356001)(4326008)(102836004)(6246003)(5660300001)(52116002)(478600001)(105586002)(42882007)(25786009)(53936002)(33656002)(6486002)(71200400001)(71190400001)(2900100001)(68736007); DIR:OUT; SFP:1101; SCL:1; SRVR:BYAPR07MB5445; H:BYAPR07MB4997.namprd07.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; received-spf: None (protection.outlook.com: cavium.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: GPckrohhc3i5s/+HgGuOaTJh2zz0WacXt58rXQ+Hpy3zPv4pw2RB/tRxk6htgW8K63KG5Cao/VwObjYzBEwljhc/+eKadLpDanjU7hEmszHfXAUeNnNG8nkvnbyrUfXcWve+v4HrzQEsIPMlkKYUTSmuWEGDjOKf93mANDtOfas9ivn2yi4nG5QZYrYdH0kl4KSsQWxX8nEQYyRO+4EsMJ6fsk2JQYYDZOC24wqeGlN/N6VbmEC8rTvsrOpDrvdcVV+OqB9gDu82UKl+aYbJnMc7e3XKqO67wo+wN+gylLMHODsLyKxbiWzi9v1KJ7NQPFB5xVyNhw7YBLbUEF+ujewADn/vtocSJslUDuWQdoU= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="us-ascii" Content-ID: Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-Network-Message-Id: 04b9c7ed-6109-4c6e-8275-08d64182e3b9 X-MS-Exchange-CrossTenant-originalarrivaltime: 03 Nov 2018 11:52:54.8049 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 711e4ccf-2e9b-4bcf-a551-4094005b6194 X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR07MB5445 Subject: Re: [dpdk-dev] [PATCH v7 4/5] hash: add lock-free read-write concurrency 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: , X-List-Received-Date: Sat, 03 Nov 2018 11:52:58 -0000 -----Original Message----- > Date: Fri, 26 Oct 2018 00:37:32 -0500 > From: Honnappa Nagarahalli > To: bruce.richardson@intel.com, pablo.de.lara.guarch@intel.com > CC: dev@dpdk.org, yipeng1.wang@intel.com, honnappa.nagarahalli@arm.com, > dharmik.thakkar@arm.com, gavin.hu@arm.com, nd@arm.com > Subject: [dpdk-dev] [PATCH v7 4/5] hash: add lock-free read-write > concurrency > X-Mailer: git-send-email 2.7.4 >=20 >=20 > Add lock-free read-write concurrency. This is achieved by the > following changes. >=20 > 1) Add memory ordering to avoid race conditions. The only race > condition that can occur is - using the key store element > before the key write is completed. Hence, while inserting the element > the release memory order is used. Any other race condition is caught > by the key comparison. Memory orderings are added only where needed. > For ex: reads in the writer's context do not need memory ordering > as there is a single writer. >=20 > key_idx in the bucket entry and pdata in the key store element are > used for synchronisation. key_idx is used to release an inserted > entry in the bucket to the reader. Use of pdata for synchronisation > is required due to updation of an existing entry where-in only > the pdata is updated without updating key_idx. >=20 > 2) Reader-writer concurrency issue, caused by moving the keys > to their alternative locations during key insert, is solved > by introducing a global counter(tbl_chng_cnt) indicating a > change in table. >=20 > 3) Add the flag to enable reader-writer concurrency during > run time. >=20 > Signed-off-by: Honnappa Nagarahalli Hi Honnappa, This patch is causing _~24%_ performance regression on mpps/core with 64B packet with l3fwd in EM mode with octeontx. Example command to reproduce with 2 core+2 port l3fwd in hash mode(-E) # l3fwd -v -c 0xf00000 -n 4 -- -P -E -p 0x3 --config=3D"(0, 0, 23),(1, 0, 2= 2)" Observations: 1) When hash lookup is _success_ then regression is only 3%. Which is kind = of make sense because additional new atomic instructions What I meant by lookup is _success_ is:=20 Configuring traffic gen like below to match lookup as defined=20 ipv4_l3fwd_em_route_array() in examples/l3fwd/l3fwd_em.c dest.ip port0 201.0.0.0 src.ip port0 200.20.0.1 dest.port port0 102 src.port port0 12 dest.ip port1 101.0.0.0 src.ip port1 100.10.0.1 dest.port port1 101 src.port port1 11 tx.type IPv4+TCP 2) When hash lookup _fails_ the per core mpps regression comes around 24% w= ith 64B packet size. What I meant by lookup is _failure_ is:=20 Configuring traffic gen not to hit the 5 tuples defined in=20 ipv4_l3fwd_em_route_array() in examples/l3fwd/l3fwd_em.c 3) perf top _without_ this patch 37.30% l3fwd [.] em_main_loop 22.40% l3fwd [.] rte_hash_lookup 13.05% l3fwd [.] nicvf_recv_pkts_cksum 9.70% l3fwd [.] nicvf_xmit_pkts 6.18% l3fwd [.] ipv4_hash_crc 4.77% l3fwd [.] nicvf_fill_rbdr 4.50% l3fwd [.] nicvf_single_pool_free_xmited_buffers 1.16% libc-2.28.so [.] memcpy 0.47% l3fwd [.] common_ring_mp_enqueue 0.44% l3fwd [.] common_ring_mc_dequeue 0.03% l3fwd [.] strerror_r@plt 4) perf top with this patch 47.41% l3fwd [.] rte_hash_lookup 23.55% l3fwd [.] em_main_loop 9.53% l3fwd [.] nicvf_recv_pkts_cksum 6.95% l3fwd [.] nicvf_xmit_pkts 4.63% l3fwd [.] ipv4_hash_crc 3.30% l3fwd [.] nicvf_fill_rbdr 3.29% l3fwd [.] nicvf_single_pool_free_xmited_buffers 0.76% libc-2.28.so [.] memcpy 0.30% l3fwd [.] common_ring_mp_enqueue 0.25% l3fwd [.] common_ring_mc_dequeue 0.04% l3fwd [.] strerror_r@plt 5) Based on assembly, most of the cycles spends in rte_hash_lookup around key_idx =3D __atomic_load_n(&bkt->key_idx[i](whose LDAR) and "if (bkt->sig_current[i] =3D=3D sig && key_idx !=3D EMPTY_SLOT) {" 6) Since this patch is big and does 3 things are mentioned above, it is difficult to pin point what is causing the exact issue. But, my primary analysis shows the item (1)(adding the atomic barriers). But I need to spend more cycles to find out the exact causes. The use case like lwfwd in hash mode, where writer does not update stuff in fastpath(aka insert op) will be impact with this patch. 7) Have you checked the l3fwd lookup failure use case in your environment? if so, please share your observation and if not, could you please check it? 8) IMO, Such performance regression is not acceptable for l3fwd use case where hash insert op will be done in slowpath. 9) Does any else facing this problem?