DPDK patches and discussions
 help / color / mirror / Atom feed
* [PATCH 0/2] fix mmap retcode check fail
@ 2023-02-06 10:53 Chengwen Feng
  2023-02-06 10:53 ` [PATCH 1/2] eal: fix mmap fail regarded as success Chengwen Feng
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Chengwen Feng @ 2023-02-06 10:53 UTC (permalink / raw)
  To: thomas, ferruh.yigit; +Cc: dev

This patchset contains two patch which fix mmap retcode check fail.

Chengwen Feng (2):
  eal: fix mmap fail regarded as success
  raw/ifpga/base: fix mmap retcode check fail

 drivers/raw/ifpga/base/opae_hw_api.c | 4 ++--
 lib/eal/freebsd/eal_hugepage_info.c  | 2 +-
 lib/eal/linux/eal_hugepage_info.c    | 2 +-
 3 files changed, 4 insertions(+), 4 deletions(-)

-- 
2.17.1


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 1/2] eal: fix mmap fail regarded as success
  2023-02-06 10:53 [PATCH 0/2] fix mmap retcode check fail Chengwen Feng
@ 2023-02-06 10:53 ` Chengwen Feng
  2023-02-09  9:04   ` David Marchand
  2023-02-06 10:53 ` [PATCH 2/2] raw/ifpga/base: fix mmap retcode check fail Chengwen Feng
  2023-02-09  9:04 ` [PATCH 0/2] " David Marchand
  2 siblings, 1 reply; 7+ messages in thread
From: Chengwen Feng @ 2023-02-06 10:53 UTC (permalink / raw)
  To: thomas, ferruh.yigit, Bruce Richardson, Anatoly Burakov; +Cc: dev

The map_shared_memory() function should treat mmap MAP_FAILED as NULL
because callers compare it with NULL to determine whether the map is
failed.

Fixes: 764bf26873b9 ("add FreeBSD support")
Fixes: cb97d93e9d3b ("mem: share hugepage info primary and secondary")
Cc: stable@dpdk.org

Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
---
 lib/eal/freebsd/eal_hugepage_info.c | 2 +-
 lib/eal/linux/eal_hugepage_info.c   | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/eal/freebsd/eal_hugepage_info.c b/lib/eal/freebsd/eal_hugepage_info.c
index 9dbe375bd3..e58e618469 100644
--- a/lib/eal/freebsd/eal_hugepage_info.c
+++ b/lib/eal/freebsd/eal_hugepage_info.c
@@ -33,7 +33,7 @@ map_shared_memory(const char *filename, const size_t mem_size, int flags)
 	}
 	retval = mmap(NULL, mem_size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
 	close(fd);
-	return retval;
+	return retval == MAP_FAILED ? NULL : retval;
 }
 
 static void *
diff --git a/lib/eal/linux/eal_hugepage_info.c b/lib/eal/linux/eal_hugepage_info.c
index a1b6cb31ff..24411d9c5b 100644
--- a/lib/eal/linux/eal_hugepage_info.c
+++ b/lib/eal/linux/eal_hugepage_info.c
@@ -50,7 +50,7 @@ map_shared_memory(const char *filename, const size_t mem_size, int flags)
 	retval = mmap(NULL, mem_size, PROT_READ | PROT_WRITE,
 			MAP_SHARED, fd, 0);
 	close(fd);
-	return retval;
+	return retval == MAP_FAILED ? NULL : retval;
 }
 
 static void *
-- 
2.17.1


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 2/2] raw/ifpga/base: fix mmap retcode check fail
  2023-02-06 10:53 [PATCH 0/2] fix mmap retcode check fail Chengwen Feng
  2023-02-06 10:53 ` [PATCH 1/2] eal: fix mmap fail regarded as success Chengwen Feng
@ 2023-02-06 10:53 ` Chengwen Feng
  2023-02-07  1:11   ` Huang, Wei
  2023-02-07  7:16   ` Xu, Rosen
  2023-02-09  9:04 ` [PATCH 0/2] " David Marchand
  2 siblings, 2 replies; 7+ messages in thread
From: Chengwen Feng @ 2023-02-06 10:53 UTC (permalink / raw)
  To: thomas, ferruh.yigit, Rosen Xu, Tianfei Zhang, Wei Huang; +Cc: dev

The MAP_FAILED should be used to determine whether the mapping is
successful.

Fixes: e41856b515ce ("raw/ifpga/base: enhance driver reliability in multi-process")
Cc: stable@dpdk.org

Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
---
 drivers/raw/ifpga/base/opae_hw_api.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/raw/ifpga/base/opae_hw_api.c b/drivers/raw/ifpga/base/opae_hw_api.c
index 1117c3e160..6d48d227d6 100644
--- a/drivers/raw/ifpga/base/opae_hw_api.c
+++ b/drivers/raw/ifpga/base/opae_hw_api.c
@@ -380,7 +380,7 @@ static pthread_mutex_t *opae_adapter_mutex_open(struct opae_adapter *adapter)
 				PROT_READ | PROT_WRITE, MAP_SHARED,
 				shm_id, 0);
 		adapter->lock = (pthread_mutex_t *)ptr;
-		if (ptr) {
+		if (ptr != MAP_FAILED) {
 			dev_info(NULL,
 					"shared memory %s address is %p\n",
 					shm_name, ptr);
@@ -499,7 +499,7 @@ static void *opae_adapter_shm_alloc(struct opae_adapter *adapter)
 		adapter->shm.size = size;
 		adapter->shm.ptr = mmap(NULL, size, PROT_READ | PROT_WRITE,
 							MAP_SHARED, shm_id, 0);
-		if (adapter->shm.ptr) {
+		if (adapter->shm.ptr != MAP_FAILED) {
 			dev_info(NULL,
 					"shared memory %s address is %p\n",
 					shm_name, adapter->shm.ptr);
-- 
2.17.1


^ permalink raw reply	[flat|nested] 7+ messages in thread

* RE: [PATCH 2/2] raw/ifpga/base: fix mmap retcode check fail
  2023-02-06 10:53 ` [PATCH 2/2] raw/ifpga/base: fix mmap retcode check fail Chengwen Feng
@ 2023-02-07  1:11   ` Huang, Wei
  2023-02-07  7:16   ` Xu, Rosen
  1 sibling, 0 replies; 7+ messages in thread
From: Huang, Wei @ 2023-02-07  1:11 UTC (permalink / raw)
  To: Chengwen Feng, thomas, ferruh.yigit, Xu, Rosen, Zhang, Tianfei; +Cc: dev

It looks good.

> -----Original Message-----
> From: Chengwen Feng <fengchengwen@huawei.com>
> Sent: Monday, February 6, 2023 18:53
> To: thomas@monjalon.net; ferruh.yigit@amd.com; Xu, Rosen
> <rosen.xu@intel.com>; Zhang, Tianfei <tianfei.zhang@intel.com>; Huang,
> Wei <wei.huang@intel.com>
> Cc: dev@dpdk.org
> Subject: [PATCH 2/2] raw/ifpga/base: fix mmap retcode check fail
> 
> The MAP_FAILED should be used to determine whether the mapping is
> successful.
> 
> Fixes: e41856b515ce ("raw/ifpga/base: enhance driver reliability in multi-
> process")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
> ---
>  drivers/raw/ifpga/base/opae_hw_api.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/raw/ifpga/base/opae_hw_api.c
> b/drivers/raw/ifpga/base/opae_hw_api.c
> index 1117c3e160..6d48d227d6 100644
> --- a/drivers/raw/ifpga/base/opae_hw_api.c
> +++ b/drivers/raw/ifpga/base/opae_hw_api.c
> @@ -380,7 +380,7 @@ static pthread_mutex_t
> *opae_adapter_mutex_open(struct opae_adapter *adapter)
>  				PROT_READ | PROT_WRITE, MAP_SHARED,
>  				shm_id, 0);
>  		adapter->lock = (pthread_mutex_t *)ptr;
> -		if (ptr) {
> +		if (ptr != MAP_FAILED) {
>  			dev_info(NULL,
>  					"shared memory %s address is %p\n",
>  					shm_name, ptr);
> @@ -499,7 +499,7 @@ static void *opae_adapter_shm_alloc(struct
> opae_adapter *adapter)
>  		adapter->shm.size = size;
>  		adapter->shm.ptr = mmap(NULL, size, PROT_READ |
> PROT_WRITE,
>  							MAP_SHARED,
> shm_id, 0);
> -		if (adapter->shm.ptr) {
> +		if (adapter->shm.ptr != MAP_FAILED) {
>  			dev_info(NULL,
>  					"shared memory %s address is %p\n",
>  					shm_name, adapter->shm.ptr);
> --
> 2.17.1


^ permalink raw reply	[flat|nested] 7+ messages in thread

* RE: [PATCH 2/2] raw/ifpga/base: fix mmap retcode check fail
  2023-02-06 10:53 ` [PATCH 2/2] raw/ifpga/base: fix mmap retcode check fail Chengwen Feng
  2023-02-07  1:11   ` Huang, Wei
@ 2023-02-07  7:16   ` Xu, Rosen
  1 sibling, 0 replies; 7+ messages in thread
From: Xu, Rosen @ 2023-02-07  7:16 UTC (permalink / raw)
  To: Chengwen Feng, thomas, ferruh.yigit, Zhang,  Tianfei, Huang, Wei; +Cc: dev

Hi,

> -----Original Message-----
> From: Chengwen Feng <fengchengwen@huawei.com>
> Sent: Monday, February 6, 2023 6:53 PM
> To: thomas@monjalon.net; ferruh.yigit@amd.com; Xu, Rosen
> <rosen.xu@intel.com>; Zhang, Tianfei <tianfei.zhang@intel.com>; Huang,
> Wei <wei.huang@intel.com>
> Cc: dev@dpdk.org
> Subject: [PATCH 2/2] raw/ifpga/base: fix mmap retcode check fail
> 
> The MAP_FAILED should be used to determine whether the mapping is
> successful.
> 
> Fixes: e41856b515ce ("raw/ifpga/base: enhance driver reliability in multi-
> process")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
> ---
>  drivers/raw/ifpga/base/opae_hw_api.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/raw/ifpga/base/opae_hw_api.c
> b/drivers/raw/ifpga/base/opae_hw_api.c
> index 1117c3e160..6d48d227d6 100644
> --- a/drivers/raw/ifpga/base/opae_hw_api.c
> +++ b/drivers/raw/ifpga/base/opae_hw_api.c
> @@ -380,7 +380,7 @@ static pthread_mutex_t
> *opae_adapter_mutex_open(struct opae_adapter *adapter)
>  				PROT_READ | PROT_WRITE, MAP_SHARED,
>  				shm_id, 0);
>  		adapter->lock = (pthread_mutex_t *)ptr;
> -		if (ptr) {
> +		if (ptr != MAP_FAILED) {
>  			dev_info(NULL,
>  					"shared memory %s address is %p\n",
>  					shm_name, ptr);
> @@ -499,7 +499,7 @@ static void *opae_adapter_shm_alloc(struct
> opae_adapter *adapter)
>  		adapter->shm.size = size;
>  		adapter->shm.ptr = mmap(NULL, size, PROT_READ |
> PROT_WRITE,
>  							MAP_SHARED,
> shm_id, 0);
> -		if (adapter->shm.ptr) {
> +		if (adapter->shm.ptr != MAP_FAILED) {
>  			dev_info(NULL,
>  					"shared memory %s address is %p\n",
>  					shm_name, adapter->shm.ptr);
> --
> 2.17.1

It looks good for me.
Reviewed-by: Rosen Xu <rosen.xu@intel.com>

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/2] eal: fix mmap fail regarded as success
  2023-02-06 10:53 ` [PATCH 1/2] eal: fix mmap fail regarded as success Chengwen Feng
@ 2023-02-09  9:04   ` David Marchand
  0 siblings, 0 replies; 7+ messages in thread
From: David Marchand @ 2023-02-09  9:04 UTC (permalink / raw)
  To: Chengwen Feng
  Cc: thomas, ferruh.yigit, Bruce Richardson, Anatoly Burakov, dev

On Mon, Feb 6, 2023 at 11:59 AM Chengwen Feng <fengchengwen@huawei.com> wrote:
>
> The map_shared_memory() function should treat mmap MAP_FAILED as NULL
> because callers compare it with NULL to determine whether the map is
> failed.
>
> Fixes: 764bf26873b9 ("add FreeBSD support")
> Fixes: cb97d93e9d3b ("mem: share hugepage info primary and secondary")
> Cc: stable@dpdk.org
>
> Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>

Reviewed-by: David Marchand <david.marchand@redhat.com>


-- 
David Marchand


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 0/2] fix mmap retcode check fail
  2023-02-06 10:53 [PATCH 0/2] fix mmap retcode check fail Chengwen Feng
  2023-02-06 10:53 ` [PATCH 1/2] eal: fix mmap fail regarded as success Chengwen Feng
  2023-02-06 10:53 ` [PATCH 2/2] raw/ifpga/base: fix mmap retcode check fail Chengwen Feng
@ 2023-02-09  9:04 ` David Marchand
  2 siblings, 0 replies; 7+ messages in thread
From: David Marchand @ 2023-02-09  9:04 UTC (permalink / raw)
  To: Chengwen Feng; +Cc: thomas, ferruh.yigit, dev

On Mon, Feb 6, 2023 at 11:59 AM Chengwen Feng <fengchengwen@huawei.com> wrote:
>
> This patchset contains two patch which fix mmap retcode check fail.
>
> Chengwen Feng (2):
>   eal: fix mmap fail regarded as success
>   raw/ifpga/base: fix mmap retcode check fail
>
>  drivers/raw/ifpga/base/opae_hw_api.c | 4 ++--
>  lib/eal/freebsd/eal_hugepage_info.c  | 2 +-
>  lib/eal/linux/eal_hugepage_info.c    | 2 +-
>  3 files changed, 4 insertions(+), 4 deletions(-)

Series applied, thanks.


-- 
David Marchand


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2023-02-09  9:04 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-06 10:53 [PATCH 0/2] fix mmap retcode check fail Chengwen Feng
2023-02-06 10:53 ` [PATCH 1/2] eal: fix mmap fail regarded as success Chengwen Feng
2023-02-09  9:04   ` David Marchand
2023-02-06 10:53 ` [PATCH 2/2] raw/ifpga/base: fix mmap retcode check fail Chengwen Feng
2023-02-07  1:11   ` Huang, Wei
2023-02-07  7:16   ` Xu, Rosen
2023-02-09  9:04 ` [PATCH 0/2] " David Marchand

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).