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 C91E9A046B for ; Fri, 28 Jun 2019 17:21:48 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 9FCFF378E; Fri, 28 Jun 2019 17:21:47 +0200 (CEST) Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-eopbgr60067.outbound.protection.outlook.com [40.107.6.67]) by dpdk.org (Postfix) with ESMTP id 308FB34F0 for ; Fri, 28 Jun 2019 17:21:47 +0200 (CEST) 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=pCI/R/lVXsZX10GO3cEQfu3a0aIUZBtbTsBAakKwWKE=; b=U4/V34xD2nYIBcTwY8JDUFsWMWtRDMyRfCRD5zycmeqg+EEjRpWIvkiGOB9mD48FK5AEI89G2L1psXZ+PWLFKj+3foNb0uBHmoRwmwRU46HimLFF70uScp0L9fV8SkV7z+2Fst4uiBgoGqc1VY0fKwmwSl70OS7wPzJYohcOOAc= Received: from DB3PR0502MB3980.eurprd05.prod.outlook.com (52.134.72.27) by DB3PR0502MB3996.eurprd05.prod.outlook.com (52.134.65.142) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2032.17; Fri, 28 Jun 2019 15:21:45 +0000 Received: from DB3PR0502MB3980.eurprd05.prod.outlook.com ([fe80::69c1:c0d7:1fa1:f89f]) by DB3PR0502MB3980.eurprd05.prod.outlook.com ([fe80::69c1:c0d7:1fa1:f89f%6]) with mapi id 15.20.2032.016; Fri, 28 Jun 2019 15:21:45 +0000 From: Yongseok Koh To: Anatoly Burakov CC: dev , Hemant Agrawal , Shreyansh Jain , Matan Azrad , Shahaf Shuler , Maxime Coquelin , Tiwei Bie , Zhihong Wang , "david.marchand@redhat.com" , Thomas Monjalon , "stephen@networkplumber.org" Thread-Topic: [PATCH v2 02/14] drivers: use new memory locking API Thread-Index: AQHVK2/YDRhfPTe2zkydin+JOcY7p6axM4MA Date: Fri, 28 Jun 2019 15:21:45 +0000 Message-ID: References: <77d637da0fc8ccace999fb8934ff1fe4ae38e55e.1561478388.git.anatoly.burakov@intel.com> In-Reply-To: <77d637da0fc8ccace999fb8934ff1fe4ae38e55e.1561478388.git.anatoly.burakov@intel.com> 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=yskoh@mellanox.com; x-originating-ip: [209.116.155.178] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 2132a6f5-d0cd-4abf-ce9f-08d6fbdc54f3 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600148)(711020)(4605104)(1401327)(4618075)(2017052603328)(7193020); SRVR:DB3PR0502MB3996; x-ms-traffictypediagnostic: DB3PR0502MB3996: x-ld-processed: a652971c-7d2e-4d9b-a6a4-d149256f461b,ExtAddr x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:597; x-forefront-prvs: 00826B6158 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(4636009)(136003)(376002)(346002)(39860400002)(396003)(366004)(189003)(199004)(6512007)(81166006)(102836004)(305945005)(73956011)(66476007)(446003)(6116002)(3846002)(26005)(64756008)(66446008)(6246003)(66946007)(36756003)(6436002)(25786009)(316002)(6486002)(66556008)(66066001)(86362001)(14454004)(71200400001)(71190400001)(54906003)(486006)(11346002)(186003)(14444005)(8676002)(256004)(229853002)(33656002)(476003)(91956017)(6506007)(8936002)(53546011)(53936002)(76176011)(2616005)(2906002)(81156014)(68736007)(76116006)(478600001)(5660300002)(7736002)(99286004)(6916009)(4326008)(7416002); DIR:OUT; SFP:1101; SCL:1; SRVR:DB3PR0502MB3996; H:DB3PR0502MB3980.eurprd05.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; received-spf: None (protection.outlook.com: mellanox.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: yrfgnIJBNO2eo1mxN7HHBcyVERBAaZtfm7YFodC+bpAriG1wcntvlRYEBTn2FARYX9Ldo/REO9lU6hhCBiDQVg6k11/gCPcOqomQo8xjSAwLtBbcjseSpvpjtju2AmpChNWOKmn5ph0UIMA9ZYGp3oO64UdgRcACc9wc0hn8mgwFfOSVG/OGnwvfp5MxWkGL0whO+P6LltMQPQwIgCAqyaQ8E6+a/DBTUBPiBk7DzRdINT83ymY5yzNY6Bwwr7hjTdran6smgIaD4ehunJu5xtWe7/zpVrX4bRcGKO8abKfXnmXKoWDsUg5jQucv4fcUmzNlj6gzJ7kTPH8R9UUJdzuuIbTz9vTWtZX9oXViW7qkIwYEhWTMINRfD6/KDay5vOlu3dS3OheUCb0NJMezy5QVFIcRcPYzmQ3jFeJoZMU= Content-Type: text/plain; charset="us-ascii" Content-ID: <7B16BE7915B26646AF935D5A78DCE701@eurprd05.prod.outlook.com> Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2132a6f5-d0cd-4abf-ce9f-08d6fbdc54f3 X-MS-Exchange-CrossTenant-originalarrivaltime: 28 Jun 2019 15:21:45.4865 (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: yskoh@mellanox.com X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB3PR0502MB3996 Subject: Re: [dpdk-dev] [PATCH v2 02/14] drivers: use new memory locking API 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" > On Jun 25, 2019, at 9:05 AM, Anatoly Burakov = wrote: >=20 > Replace usages of direct access to shared memory config with > calls to the new API. >=20 > Signed-off-by: Anatoly Burakov > --- > drivers/bus/fslmc/fslmc_vfio.c | 8 +++----- > drivers/net/mlx4/mlx4_mr.c | 11 +++++------ > drivers/net/mlx5/mlx5_mr.c | 11 +++++------ For mlx4/5 PMDs, Acked-by: Yongseok Koh > drivers/net/virtio/virtio_user/virtio_user_dev.c | 7 +++---- > 4 files changed, 16 insertions(+), 21 deletions(-) >=20 > diff --git a/drivers/bus/fslmc/fslmc_vfio.c b/drivers/bus/fslmc/fslmc_vfi= o.c > index 1aae56fa9..44e4fa6e2 100644 > --- a/drivers/bus/fslmc/fslmc_vfio.c > +++ b/drivers/bus/fslmc/fslmc_vfio.c > @@ -347,14 +347,12 @@ fslmc_dmamap_seg(const struct rte_memseg_list *msl = __rte_unused, > int rte_fslmc_vfio_dmamap(void) > { > int i =3D 0, ret; > - struct rte_mem_config *mcfg =3D rte_eal_get_configuration()->mem_config= ; > - rte_rwlock_t *mem_lock =3D &mcfg->memory_hotplug_lock; >=20 > /* Lock before parsing and registering callback to memory subsystem */ > - rte_rwlock_read_lock(mem_lock); > + rte_mcfg_mem_read_lock(); >=20 > if (rte_memseg_walk(fslmc_dmamap_seg, &i) < 0) { > - rte_rwlock_read_unlock(mem_lock); > + rte_mcfg_mem_read_unlock(); > return -1; > } >=20 > @@ -378,7 +376,7 @@ int rte_fslmc_vfio_dmamap(void) > /* Existing segments have been mapped and memory callback for hotplug > * has been installed. > */ > - rte_rwlock_read_unlock(mem_lock); > + rte_mcfg_mem_read_unlock(); >=20 > return 0; > } > diff --git a/drivers/net/mlx4/mlx4_mr.c b/drivers/net/mlx4/mlx4_mr.c > index 48d458ad4..80827ce75 100644 > --- a/drivers/net/mlx4/mlx4_mr.c > +++ b/drivers/net/mlx4/mlx4_mr.c > @@ -593,7 +593,6 @@ mlx4_mr_create_primary(struct rte_eth_dev *dev, struc= t mlx4_mr_cache *entry, > uintptr_t addr) > { > struct mlx4_priv *priv =3D dev->data->dev_private; > - struct rte_mem_config *mcfg =3D rte_eal_get_configuration()->mem_config= ; > const struct rte_memseg_list *msl; > const struct rte_memseg *ms; > struct mlx4_mr *mr =3D NULL; > @@ -696,7 +695,7 @@ mlx4_mr_create_primary(struct rte_eth_dev *dev, struc= t mlx4_mr_cache *entry, > * just single page. If not, go on with the big chunk atomically from > * here. > */ > - rte_rwlock_read_lock(&mcfg->memory_hotplug_lock); > + rte_mcfg_mem_read_lock(); > data_re =3D data; > if (len > msl->page_sz && > !rte_memseg_contig_walk(mr_find_contig_memsegs_cb, &data_re)) { > @@ -714,7 +713,7 @@ mlx4_mr_create_primary(struct rte_eth_dev *dev, struc= t mlx4_mr_cache *entry, > */ > data.start =3D RTE_ALIGN_FLOOR(addr, msl->page_sz); > data.end =3D data.start + msl->page_sz; > - rte_rwlock_read_unlock(&mcfg->memory_hotplug_lock); > + rte_mcfg_mem_read_unlock(); > mr_free(mr); > goto alloc_resources; > } > @@ -734,7 +733,7 @@ mlx4_mr_create_primary(struct rte_eth_dev *dev, struc= t mlx4_mr_cache *entry, > DEBUG("port %u found MR for %p on final lookup, abort", > dev->data->port_id, (void *)addr); > rte_rwlock_write_unlock(&priv->mr.rwlock); > - rte_rwlock_read_unlock(&mcfg->memory_hotplug_lock); > + rte_mcfg_mem_read_unlock(); > /* > * Must be unlocked before calling rte_free() because > * mlx4_mr_mem_event_free_cb() can be called inside. > @@ -802,12 +801,12 @@ mlx4_mr_create_primary(struct rte_eth_dev *dev, str= uct mlx4_mr_cache *entry, > /* Lookup can't fail. */ > assert(entry->lkey !=3D UINT32_MAX); > rte_rwlock_write_unlock(&priv->mr.rwlock); > - rte_rwlock_read_unlock(&mcfg->memory_hotplug_lock); > + rte_mcfg_mem_read_unlock(); > return entry->lkey; > err_mrlock: > rte_rwlock_write_unlock(&priv->mr.rwlock); > err_memlock: > - rte_rwlock_read_unlock(&mcfg->memory_hotplug_lock); > + rte_mcfg_mem_read_unlock(); > err_nolock: > /* > * In case of error, as this can be called in a datapath, a warning > diff --git a/drivers/net/mlx5/mlx5_mr.c b/drivers/net/mlx5/mlx5_mr.c > index 66e8e874e..872d0591e 100644 > --- a/drivers/net/mlx5/mlx5_mr.c > +++ b/drivers/net/mlx5/mlx5_mr.c > @@ -580,7 +580,6 @@ mlx5_mr_create_primary(struct rte_eth_dev *dev, struc= t mlx5_mr_cache *entry, > struct mlx5_priv *priv =3D dev->data->dev_private; > struct mlx5_ibv_shared *sh =3D priv->sh; > struct mlx5_dev_config *config =3D &priv->config; > - struct rte_mem_config *mcfg =3D rte_eal_get_configuration()->mem_config= ; > const struct rte_memseg_list *msl; > const struct rte_memseg *ms; > struct mlx5_mr *mr =3D NULL; > @@ -684,7 +683,7 @@ mlx5_mr_create_primary(struct rte_eth_dev *dev, struc= t mlx5_mr_cache *entry, > * just single page. If not, go on with the big chunk atomically from > * here. > */ > - rte_rwlock_read_lock(&mcfg->memory_hotplug_lock); > + rte_mcfg_mem_read_lock(); > data_re =3D data; > if (len > msl->page_sz && > !rte_memseg_contig_walk(mr_find_contig_memsegs_cb, &data_re)) { > @@ -702,7 +701,7 @@ mlx5_mr_create_primary(struct rte_eth_dev *dev, struc= t mlx5_mr_cache *entry, > */ > data.start =3D RTE_ALIGN_FLOOR(addr, msl->page_sz); > data.end =3D data.start + msl->page_sz; > - rte_rwlock_read_unlock(&mcfg->memory_hotplug_lock); > + rte_mcfg_mem_read_unlock(); > mr_free(mr); > goto alloc_resources; > } > @@ -722,7 +721,7 @@ mlx5_mr_create_primary(struct rte_eth_dev *dev, struc= t mlx5_mr_cache *entry, > DEBUG("port %u found MR for %p on final lookup, abort", > dev->data->port_id, (void *)addr); > rte_rwlock_write_unlock(&sh->mr.rwlock); > - rte_rwlock_read_unlock(&mcfg->memory_hotplug_lock); > + rte_mcfg_mem_read_unlock(); > /* > * Must be unlocked before calling rte_free() because > * mlx5_mr_mem_event_free_cb() can be called inside. > @@ -790,12 +789,12 @@ mlx5_mr_create_primary(struct rte_eth_dev *dev, str= uct mlx5_mr_cache *entry, > /* Lookup can't fail. */ > assert(entry->lkey !=3D UINT32_MAX); > rte_rwlock_write_unlock(&sh->mr.rwlock); > - rte_rwlock_read_unlock(&mcfg->memory_hotplug_lock); > + rte_mcfg_mem_read_unlock(); > return entry->lkey; > err_mrlock: > rte_rwlock_write_unlock(&sh->mr.rwlock); > err_memlock: > - rte_rwlock_read_unlock(&mcfg->memory_hotplug_lock); > + rte_mcfg_mem_read_unlock(); > err_nolock: > /* > * In case of error, as this can be called in a datapath, a warning > diff --git a/drivers/net/virtio/virtio_user/virtio_user_dev.c b/drivers/n= et/virtio/virtio_user/virtio_user_dev.c > index e743695e4..c3ab9a21d 100644 > --- a/drivers/net/virtio/virtio_user/virtio_user_dev.c > +++ b/drivers/net/virtio/virtio_user/virtio_user_dev.c > @@ -125,7 +125,6 @@ is_vhost_user_by_type(const char *path) > int > virtio_user_start_device(struct virtio_user_dev *dev) > { > - struct rte_mem_config *mcfg =3D rte_eal_get_configuration()->mem_config= ; > uint64_t features; > int ret; >=20 > @@ -142,7 +141,7 @@ virtio_user_start_device(struct virtio_user_dev *dev) > * replaced when we get proper supports from the > * memory subsystem in the future. > */ > - rte_rwlock_read_lock(&mcfg->memory_hotplug_lock); > + rte_mcfg_mem_read_lock(); > pthread_mutex_lock(&dev->mutex); >=20 > if (is_vhost_user_by_type(dev->path) && dev->vhostfd < 0) > @@ -180,12 +179,12 @@ virtio_user_start_device(struct virtio_user_dev *de= v) >=20 > dev->started =3D true; > pthread_mutex_unlock(&dev->mutex); > - rte_rwlock_read_unlock(&mcfg->memory_hotplug_lock); > + rte_mcfg_mem_read_unlock(); >=20 > return 0; > error: > pthread_mutex_unlock(&dev->mutex); > - rte_rwlock_read_unlock(&mcfg->memory_hotplug_lock); > + rte_mcfg_mem_read_unlock(); > /* TODO: free resource here or caller to check */ > return -1; > } > --=20 > 2.17.1