[dpdk-dev,v5,08/26] eal: do not panic on memzone initialization fails

Message ID 20170227161811.12309-9-aconole@redhat.com (mailing list archive)
State Superseded, archived
Headers

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation fail Compilation issues

Commit Message

Aaron Conole Feb. 27, 2017, 4:17 p.m. UTC
  When memzone initialization fails, report the error to the calling
application rather than panic().  Without a good way of detaching /
releasing hugepages, at this point the application will have to restart.

Signed-off-by: Aaron Conole <aconole@redhat.com>
---
 lib/librte_eal/linuxapp/eal/eal.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
  

Comments

Bruce Richardson Feb. 28, 2017, 2:27 p.m. UTC | #1
On Mon, Feb 27, 2017 at 11:17:53AM -0500, Aaron Conole wrote:
> When memzone initialization fails, report the error to the calling
> application rather than panic().  Without a good way of detaching /
> releasing hugepages, at this point the application will have to restart.
> 
> Signed-off-by: Aaron Conole <aconole@redhat.com>
> ---
>  lib/librte_eal/linuxapp/eal/eal.c | 7 +++++--
>  1 file changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/lib/librte_eal/linuxapp/eal/eal.c b/lib/librte_eal/linuxapp/eal/eal.c
> index a671ed4..1e54ca1 100644
> --- a/lib/librte_eal/linuxapp/eal/eal.c
> +++ b/lib/librte_eal/linuxapp/eal/eal.c
> @@ -839,8 +839,11 @@ rte_eal_init(int argc, char **argv)
>  	/* the directories are locked during eal_hugepage_info_init */
>  	eal_hugedirs_unlock();
>  
> -	if (rte_eal_memzone_init() < 0)
> -		rte_panic("Cannot init memzone\n");
> +	if (rte_eal_memzone_init() < 0) {
> +		RTE_LOG(ERR, EAL, "Cannot init memzone\n");

Any particular reason why not "rte_eal_init_alert" as with the other
cases?

/Bruce
  
Aaron Conole Feb. 28, 2017, 2:46 p.m. UTC | #2
Bruce Richardson <bruce.richardson@intel.com> writes:

> On Mon, Feb 27, 2017 at 11:17:53AM -0500, Aaron Conole wrote:
>> When memzone initialization fails, report the error to the calling
>> application rather than panic().  Without a good way of detaching /
>> releasing hugepages, at this point the application will have to restart.
>> 
>> Signed-off-by: Aaron Conole <aconole@redhat.com>
>> ---
>>  lib/librte_eal/linuxapp/eal/eal.c | 7 +++++--
>>  1 file changed, 5 insertions(+), 2 deletions(-)
>> 
>> diff --git a/lib/librte_eal/linuxapp/eal/eal.c b/lib/librte_eal/linuxapp/eal/eal.c
>> index a671ed4..1e54ca1 100644
>> --- a/lib/librte_eal/linuxapp/eal/eal.c
>> +++ b/lib/librte_eal/linuxapp/eal/eal.c
>> @@ -839,8 +839,11 @@ rte_eal_init(int argc, char **argv)
>>  	/* the directories are locked during eal_hugepage_info_init */
>>  	eal_hugedirs_unlock();
>>  
>> -	if (rte_eal_memzone_init() < 0)
>> -		rte_panic("Cannot init memzone\n");
>> +	if (rte_eal_memzone_init() < 0) {
>> +		RTE_LOG(ERR, EAL, "Cannot init memzone\n");
>
> Any particular reason why not "rte_eal_init_alert" as with the other
> cases?

I only used rte_eal_init_alert() for cases which occur before logging
happens, but I am not opposed to switching it for all the cases.  I'll
swap them all for v6.

Thanks again for the review, Bruce!

-Aaron
  

Patch

diff --git a/lib/librte_eal/linuxapp/eal/eal.c b/lib/librte_eal/linuxapp/eal/eal.c
index a671ed4..1e54ca1 100644
--- a/lib/librte_eal/linuxapp/eal/eal.c
+++ b/lib/librte_eal/linuxapp/eal/eal.c
@@ -839,8 +839,11 @@  rte_eal_init(int argc, char **argv)
 	/* the directories are locked during eal_hugepage_info_init */
 	eal_hugedirs_unlock();
 
-	if (rte_eal_memzone_init() < 0)
-		rte_panic("Cannot init memzone\n");
+	if (rte_eal_memzone_init() < 0) {
+		RTE_LOG(ERR, EAL, "Cannot init memzone\n");
+		rte_errno = ENODEV;
+		return -1;
+	}
 
 	if (rte_eal_tailqs_init() < 0)
 		rte_panic("Cannot init tail queues for objects\n");