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 DBA92A04A2; Wed, 6 Nov 2019 08:45:54 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 64A331C00D; Wed, 6 Nov 2019 08:45:54 +0100 (CET) Received: from EUR01-DB5-obe.outbound.protection.outlook.com (mail-eopbgr150077.outbound.protection.outlook.com [40.107.15.77]) by dpdk.org (Postfix) with ESMTP id E994A1BFFE for ; Wed, 6 Nov 2019 08:45:52 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=W6tMaMQYgxxUfDWVN5CJTqURfXtep0xa9/e8krWfqfZMFuVZ0R+Ji46rcpP6dLKpJFHqkI1NgczeSzgqwC6449gQsK6x6RowNRVbcjWinvkTlo7W0QHE95nIL63d5gKxKE20mjVbzHYXhiDl/IchjGGI07dQNUHRUf00yo0ll50ALgU2FbpYIUDx4dYhlB4iIJyrab/4nJKOXfCheaxk1XYwS+/hpghzHFQ2IVmcO0/4UFSl1ISaCSJSYn+CMTUaFRawf1M/9fKdQmK9zDdIXFZZS4csCQ/7pc+lIUDxIV44L84T3bN5QoxDNigfIAPK3aw5jjeicyt+o+YKwoT2Bw== 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=6S0XJSc+j9LQSvDAUHITi8S87eoU/t235VvwLa2xL9M=; b=juHdYkppilq/y1AJWs4CMCW/624DmUR2QNolGj/RLRMmx3VpWY0bQB6gvijQf+KH/5soiuaNjUzXGX+HiqA9+3V8aXQJhi09dqS4bZMll4HNrIS7bFaT6TudQmlF1BxWAX8gJlPAwEsncnoSNLdMEw5ns4Q2JIEnd7z1yg8Nj+SVlNXWYOmImimQB78fZoYfZdaaW9udsaihNU5u5CegMXIholPSAoaKLLBgs5C9KOrJdDlWw2D7yWWweBgr2sOSEDR/RLN/Nz/hDDAibhuIMLww2sO7trHDVzTSFQ8A4Jgi+udZcbNl3swLVX1ua7mh+PXHrKr1rA/z69QVV93CGg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=mellanox.com; dmarc=pass action=none header.from=mellanox.com; dkim=pass header.d=mellanox.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Mellanox.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=6S0XJSc+j9LQSvDAUHITi8S87eoU/t235VvwLa2xL9M=; b=OyJ0/k+9LYrZwRSEMGGQuZN4WgjWYWfXzdWPFq+LWq5Fj2zjmDxNwVmD13jZ4tWCpcXNyAir+lCfcRTXNFCpI/tUB3VlZFAbOeYXIwvLoTRJUq2a58NDkFO1AfTorEtDksSL+RaK86wXRhwHwzIMjUqO8Co/vCkR95IV2hOMTPE= Received: from VI1PR05MB4192.eurprd05.prod.outlook.com (10.171.183.18) by VI1PR05MB6544.eurprd05.prod.outlook.com (20.179.27.210) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2430.20; Wed, 6 Nov 2019 07:45:50 +0000 Received: from VI1PR05MB4192.eurprd05.prod.outlook.com ([fe80::20a1:86fa:a0ec:472]) by VI1PR05MB4192.eurprd05.prod.outlook.com ([fe80::20a1:86fa:a0ec:472%7]) with mapi id 15.20.2430.020; Wed, 6 Nov 2019 07:45:50 +0000 From: Bing Zhao To: Stephen Hemminger , Slava Ovsiienko CC: Ori Kam , Raslan Darawsheh , "dev@dpdk.org" Thread-Topic: [dpdk-dev] [PATCH] net/mlx5: introduce mlx5 hash list Thread-Index: AQHVk+2gtSjM3M8nYU2cuh5cw1X61Kd81A2AgADmj3A= Date: Wed, 6 Nov 2019 07:45:49 +0000 Message-ID: References: <1572967680-93338-1-git-send-email-bingz@mellanox.com> <20191105092501.04521668@hermes.lan> In-Reply-To: <20191105092501.04521668@hermes.lan> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=bingz@mellanox.com; x-originating-ip: [112.10.107.37] x-ms-publictraffictype: Email x-ms-office365-filtering-ht: Tenant x-ms-office365-filtering-correlation-id: aae4a08f-7fff-4794-e1b0-08d7628d57ec x-ms-traffictypediagnostic: VI1PR05MB6544:|VI1PR05MB6544: x-ld-processed: a652971c-7d2e-4d9b-a6a4-d149256f461b,ExtFwd x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:480; x-forefront-prvs: 02135EB356 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(4636009)(39860400002)(376002)(366004)(396003)(136003)(346002)(199004)(189003)(13464003)(7696005)(74316002)(6636002)(305945005)(66476007)(6436002)(66946007)(64756008)(9686003)(66446008)(76116006)(76176011)(71190400001)(71200400001)(256004)(446003)(14444005)(55016002)(66556008)(6246003)(52536014)(4326008)(229853002)(5660300002)(3846002)(6116002)(8936002)(110136005)(54906003)(81156014)(2906002)(99286004)(81166006)(8676002)(7736002)(316002)(486006)(53546011)(6506007)(66066001)(102836004)(33656002)(86362001)(476003)(11346002)(478600001)(186003)(14454004)(25786009)(26005); DIR:OUT; SFP:1101; SCL:1; SRVR:VI1PR05MB6544; H:VI1PR05MB4192.eurprd05.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; received-spf: None (protection.outlook.com: mellanox.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: 2fESK8lg4uMnYT3/el50bLt7A2THtvwEaH7SkEUQuqRVjOvPavvJzCGal90Mkrp606vpMByPLOEKUYoxhzwIrmHTcFlheeiKOk9FMt+q43PTX5kcFzmE9d7/7015vxBToCVLO7R2CEus2xFc1AogPhy3U3gdseBKH5gqC+ue7nAzwYSXIeBTZnwmek00uA45ZMf8IxUjaB0abwVUPmr64ls91aE9fIk8rmJuZuCiwIFQlWNmh2bOfAbBheF9FiWtMpw4x4HCFF/GK6+Tq+GK20WSnqC77GhA2CmRrIQ3rqyEufLekCmldpSlYQNH1fa/IXDqgZYpePRENUUk0ErCwRkQu8qqwZdTuNgPWofQ/8iUlO1ecxLwLUR9HyoUqBH2jpOTYdlz2VbP/x3hVd8Gfbv1+KNR/pBWQ2aEj6oYg1eMCHrQ7aDi9lHouws+bded Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-Network-Message-Id: aae4a08f-7fff-4794-e1b0-08d7628d57ec X-MS-Exchange-CrossTenant-originalarrivaltime: 06 Nov 2019 07:45:49.9168 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: g1ylP/is9Zs81aPzd7UrvjotGllrxWeWBTW4WTgTw8SzghdEHYiZhPzo7FzAXO6lOhNQgvxpIeMvWu2O35pQkA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR05MB6544 Subject: Re: [dpdk-dev] [PATCH] net/mlx5: introduce mlx5 hash list 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" Hi Stephen, Many thanks for your reviewing and comments. PSB. BR. Bing > -----Original Message----- > From: Stephen Hemminger > Sent: Wednesday, November 6, 2019 1:25 AM > To: Bing Zhao > Cc: Ori Kam ; Slava Ovsiienko > ; Raslan Darawsheh > ; dev@dpdk.org > Subject: Re: [dpdk-dev] [PATCH] net/mlx5: introduce mlx5 hash list >=20 > On Tue, 5 Nov 2019 17:28:00 +0200 > Bing Zhao wrote: >=20 > > +struct mlx5_hlist * > > +mlx5_hlist_create(char *name, uint64_t size, > > +mlx5_hlist_destroy_callback_fn cb) >=20 > Name is unused in rte_malloc, so why bother with it here? [Bing]: The name is also saved in the hash list, though it is never used either in the following stage. But saving such string will give some help w= hen facing some memory corruption issue. And in practice, such const string in rte_*alloc_* functions will help to record more allocation information if there is a wrap for debugging. > > +{ > > + struct mlx5_hlist *h; > > + uint64_t act_size; > > + uint64_t alloc_size; > > + > > + if (!size) > > + return NULL; > > + /* If the low 32B is power of 2, then the 64B integer is too. */ > > + if (!rte_is_power_of_2((uint32_t)size)) { >=20 > If you are doing cast, therefore you are truncating, therefore size can't > really be a uint64_t and should be size_t or uint32_t. [Bing]: Nice catch, thanks. Yes, if is truncated, the validation might be incorrect, 0x11 1000 0000 is not a power of 2 even if 0x1000 0000 is. And indeed, there is no such big array of head is needed in practice. U32 should be enough. I will correct it. >=20 > > + act_size =3D rte_align64pow2(size); > > + DRV_LOG(WARNING, "Size 0x%" PRIX64 " is not power > of 2, will " > > + "be aligned to 0x%" PRIX64 ".\n", size, act_size); > > + } else { > > + act_size =3D size; > > + } >=20 > Power of 2 hash list size wastes significant amount of memory. [Bing]: In Koh's implementation, '%' is used. In general, '&' and a little faster than "%". If '%' is used, then there is no such restriction of the h= ead array size. And to my understanding, if the hash signature is calculated perfectly, then the power of 2 hash list size will make all the entries distributed fairly among the lists. Correct me if anything wrong. >=20 > > + alloc_size =3D sizeof(struct mlx5_hlist) + > > + sizeof(struct mlx5_hlist_head) * act_size; > > + /* Using zmalloc, then no need to initialize the heads. */ > > + h =3D rte_zmalloc(name, alloc_size, RTE_CACHE_LINE_SIZE); > Why not use rte_calloc? >=20 > Why use rte_malloc at all? Does this need to be accessed from > hardware or shared between primary/secondary. Also rte_malloc has > less tooling support (coverity, leak checking, etc) than standard malloc. >=20 [Bing]: Yes, there is no need, and for each rte memory allocation, the overhead is 64B but libc malloc sometimes only occupies 16B. Other stuffs working together with the lists will be allocated by rte APIs. To my understanding, it is better to keep them "near" each other inside the memor= y. @Slava, what's your opinion? >=20 > > + if (!h) { > > + DRV_LOG(ERR, "No memory for hash list %s > creation\n", > > + name ? name : "None"); > > + return NULL; > > + } > > + if (name) > > + snprintf(h->name, MLX5_HLIST_NAMESIZE, "%s", > name); > > + if (!cb) > > + DRV_LOG(WARNING, "No callback function is specified, > will use " > > + "rte_free when destroying hlist %p %s\n", > > + (void *)h, h->name); > > + else > > + h->cb =3D cb; > > + h->table_sz =3D act_size; > > + h->mask =3D act_size - 1; > > + DRV_LOG(DEBUG, "Hash list with %s size 0x%" PRIX64 ", > callback " > > + "0x%" PRIX64 "is created.\n", > > + h->name, act_size, (uint64_t)(uintptr_t)cb); > > + return h; > > +}