[dpdk-dev,v2] support free hugepages

Message ID 1414561659-7408-1-git-send-email-haifeng.lin@huawei.com (mailing list archive)
State Changes Requested, archived
Headers

Commit Message

Linhaifeng Oct. 29, 2014, 5:47 a.m. UTC
  rte_eal_hugepage_free() is used for unlink all hugepages.If you want to
free all hugepages you must make sure that you have stop to use it,and you
must call this function before exit process.

Signed-off-by: linhaifeng <haifeng.lin@huawei.com>
---
 .../lib/librte_eal/common/include/rte_memory.h     | 11 ++++++++
 .../lib/librte_eal/linuxapp/eal/eal_memory.c       | 31 ++++++++++++++++++++++
 2 files changed, 42 insertions(+)
  

Comments

Michael Qiu Oct. 29, 2014, 6:14 a.m. UTC | #1
在 10/29/2014 1:49 PM, linhaifeng 写道:
> rte_eal_hugepage_free() is used for unlink all hugepages.If you want to
> free all hugepages you must make sure that you have stop to use it,and you
> must call this function before exit process.
>
> Signed-off-by: linhaifeng <haifeng.lin@huawei.com>
> ---
>  .../lib/librte_eal/common/include/rte_memory.h     | 11 ++++++++
>  .../lib/librte_eal/linuxapp/eal/eal_memory.c       | 31 ++++++++++++++++++++++
>  2 files changed, 42 insertions(+)
>
> diff --git a/dpdk/dpdk-1.7.0/lib/librte_eal/common/include/rte_memory.h b/dpdk/dpdk-1.7.0/lib/librte_eal/common/include/rte_memory.h
> index 4cf8ea9..f6ad95f 100644
> --- a/dpdk/dpdk-1.7.0/lib/librte_eal/common/include/rte_memory.h
> +++ b/dpdk/dpdk-1.7.0/lib/librte_eal/common/include/rte_memory.h
> @@ -172,6 +172,17 @@ unsigned rte_memory_get_nchannel(void);
>   */
>  unsigned rte_memory_get_nrank(void);
>  
> +/**
> + * Unlink all hugepages which created by dpdk.
> + *
> + * @param void
> + *
> + * @return
> + *       0: successfully
> + *       negative: error
> + */
> +int rte_eal_hugepage_free(void);
> +
>  #ifdef RTE_LIBRTE_XEN_DOM0
>  /**
>   * Return the physical address of elt, which is an element of the pool mp.
> diff --git a/dpdk/dpdk-1.7.0/lib/librte_eal/linuxapp/eal/eal_memory.c b/dpdk/dpdk-1.7.0/lib/librte_eal/linuxapp/eal/eal_memory.c
> index f2454f4..109207c 100644
> --- a/dpdk/dpdk-1.7.0/lib/librte_eal/linuxapp/eal/eal_memory.c
> +++ b/dpdk/dpdk-1.7.0/lib/librte_eal/linuxapp/eal/eal_memory.c
> @@ -98,6 +98,13 @@
>  #include "eal_filesystem.h"
>  #include "eal_hugepages.h"
>  
> +struct hugepage_table {
> +	struct hugepage_file *hugepg_tbl;
> +	unsigned nr_hugefiles;
> +};
> +
> +static struct hugepage_table g_hugepage_table;
> +
>  /**
>   * @file
>   * Huge page mapping under linux
> @@ -1202,6 +1209,7 @@ rte_eal_hugepage_init(void)
>  						(unsigned)
>  							(used_hp[i].hugepage_sz / 0x100000),
>  						j);
> +				g_hugepage_table.nr_hugefiles += used_hp[i].num_pages[j];
>  			}
>  		}
>  	}
> @@ -1237,6 +1245,8 @@ rte_eal_hugepage_init(void)
>  		goto fail;
>  	}
>  
> +	g_hugepage_table.hugepg_tbl = hugepage;
> +
>  	/* free the temporary hugepage table */
>  	free(tmp_hp);
>  	tmp_hp = NULL;
> @@ -1487,6 +1497,27 @@ error:
>  	return -1;
>  }
>  
> +int
> +rte_eal_hugepage_free(void)
> +{
> +	struct hugepage_file *hugepg_tbl = g_hugepage_table.hugepg_tbl;
> +	unsigned i;
> +	unsigned nr_hugefiles = g_hugepage_table.nr_hugefiles;
> +	int ret = 0;
> +
> +	for (i = 0; i < nr_hugefiles; i++) {
> +		ret = unlink(hugepg_tbl[i].filepath);
> +		if (ret != 0) {
> +			RTE_LOG(ERR, EAL, "Failed to unlink %s", hugepg_tbl[i].filepath);
> +			return ret;
> +		}
> +		hugepg_tbl[i].orig_va = NULL;

BTW, is it better to first set hugepg_tbl[i].orig_vato NULL, then unlink
filepath?
It may be not a good idea to first remove then set to NULL.

Thanks,
Michael

> +	}
> +
> +	RTE_LOG(INFO, EAL, "unlink %u hugepage files\n", nr_hugefiles);
> +	return ret;
> +}
> +
>  static int
>  rte_eal_memdevice_init(void)
>  {
  
Linhaifeng Oct. 29, 2014, 6:40 a.m. UTC | #2
On 2014/10/29 14:14, Qiu, Michael wrote:
> 在 10/29/2014 1:49 PM, linhaifeng 写道:
>> rte_eal_hugepage_free() is used for unlink all hugepages.If you want to
>> free all hugepages you must make sure that you have stop to use it,and you
>> must call this function before exit process.
>>
>> Signed-off-by: linhaifeng <haifeng.lin@huawei.com>
>> ---
>>  .../lib/librte_eal/common/include/rte_memory.h     | 11 ++++++++
>>  .../lib/librte_eal/linuxapp/eal/eal_memory.c       | 31 ++++++++++++++++++++++
>>  2 files changed, 42 insertions(+)
>>
>> diff --git a/dpdk/dpdk-1.7.0/lib/librte_eal/common/include/rte_memory.h b/dpdk/dpdk-1.7.0/lib/librte_eal/common/include/rte_memory.h
>> index 4cf8ea9..f6ad95f 100644
>> --- a/dpdk/dpdk-1.7.0/lib/librte_eal/common/include/rte_memory.h
>> +++ b/dpdk/dpdk-1.7.0/lib/librte_eal/common/include/rte_memory.h
>> @@ -172,6 +172,17 @@ unsigned rte_memory_get_nchannel(void);
>>   */
>>  unsigned rte_memory_get_nrank(void);
>>  
>> +/**
>> + * Unlink all hugepages which created by dpdk.
>> + *
>> + * @param void
>> + *
>> + * @return
>> + *       0: successfully
>> + *       negative: error
>> + */
>> +int rte_eal_hugepage_free(void);
>> +
>>  #ifdef RTE_LIBRTE_XEN_DOM0
>>  /**
>>   * Return the physical address of elt, which is an element of the pool mp.
>> diff --git a/dpdk/dpdk-1.7.0/lib/librte_eal/linuxapp/eal/eal_memory.c b/dpdk/dpdk-1.7.0/lib/librte_eal/linuxapp/eal/eal_memory.c
>> index f2454f4..109207c 100644
>> --- a/dpdk/dpdk-1.7.0/lib/librte_eal/linuxapp/eal/eal_memory.c
>> +++ b/dpdk/dpdk-1.7.0/lib/librte_eal/linuxapp/eal/eal_memory.c
>> @@ -98,6 +98,13 @@
>>  #include "eal_filesystem.h"
>>  #include "eal_hugepages.h"
>>  
>> +struct hugepage_table {
>> +	struct hugepage_file *hugepg_tbl;
>> +	unsigned nr_hugefiles;
>> +};
>> +
>> +static struct hugepage_table g_hugepage_table;
>> +
>>  /**
>>   * @file
>>   * Huge page mapping under linux
>> @@ -1202,6 +1209,7 @@ rte_eal_hugepage_init(void)
>>  						(unsigned)
>>  							(used_hp[i].hugepage_sz / 0x100000),
>>  						j);
>> +				g_hugepage_table.nr_hugefiles += used_hp[i].num_pages[j];
>>  			}
>>  		}
>>  	}
>> @@ -1237,6 +1245,8 @@ rte_eal_hugepage_init(void)
>>  		goto fail;
>>  	}
>>  
>> +	g_hugepage_table.hugepg_tbl = hugepage;
>> +
>>  	/* free the temporary hugepage table */
>>  	free(tmp_hp);
>>  	tmp_hp = NULL;
>> @@ -1487,6 +1497,27 @@ error:
>>  	return -1;
>>  }
>>  
>> +int
>> +rte_eal_hugepage_free(void)
>> +{
>> +	struct hugepage_file *hugepg_tbl = g_hugepage_table.hugepg_tbl;
>> +	unsigned i;
>> +	unsigned nr_hugefiles = g_hugepage_table.nr_hugefiles;
>> +	int ret = 0;
>> +
>> +	for (i = 0; i < nr_hugefiles; i++) {
>> +		ret = unlink(hugepg_tbl[i].filepath);
>> +		if (ret != 0) {
>> +			RTE_LOG(ERR, EAL, "Failed to unlink %s", hugepg_tbl[i].filepath);
>> +			return ret;
>> +		}
>> +		hugepg_tbl[i].orig_va = NULL;
> 
> BTW, is it better to first set hugepg_tbl[i].orig_vato NULL, then unlink
> filepath?
> It may be not a good idea to first remove then set to NULL.
> 
> Thanks,
> Michael
> 

If first set hugepg_tbl[i].orig_va to NULL,then failed to unlink you have to restore hugepg_tbl[i].orig_va.
So I first to unlink for less codes.

>> +	}
>> +
>> +	RTE_LOG(INFO, EAL, "unlink %u hugepage files\n", nr_hugefiles);
>> +	return ret;
>> +}
>> +
>>  static int
>>  rte_eal_memdevice_init(void)
>>  {
> 
> 
> .
>
  
Michael Qiu Oct. 29, 2014, 8:04 a.m. UTC | #3
10/29/2014 2:41 PM, Linhaifeng :
>
> On 2014/10/29 14:14, Qiu, Michael wrote:
>> 在 10/29/2014 1:49 PM, linhaifeng 写道:
>>> rte_eal_hugepage_free() is used for unlink all hugepages.If you want to
>>> free all hugepages you must make sure that you have stop to use it,and you
>>> must call this function before exit process.
>>>
>>> Signed-off-by: linhaifeng <haifeng.lin@huawei.com>
>>> ---
>>>  .../lib/librte_eal/common/include/rte_memory.h     | 11 ++++++++
>>>  .../lib/librte_eal/linuxapp/eal/eal_memory.c       | 31 ++++++++++++++++++++++
>>>  2 files changed, 42 insertions(+)
>>>
>>> diff --git a/dpdk/dpdk-1.7.0/lib/librte_eal/common/include/rte_memory.h b/dpdk/dpdk-1.7.0/lib/librte_eal/common/include/rte_memory.h
>>> index 4cf8ea9..f6ad95f 100644
>>> --- a/dpdk/dpdk-1.7.0/lib/librte_eal/common/include/rte_memory.h
>>> +++ b/dpdk/dpdk-1.7.0/lib/librte_eal/common/include/rte_memory.h
>>> @@ -172,6 +172,17 @@ unsigned rte_memory_get_nchannel(void);
>>>   */
>>>  unsigned rte_memory_get_nrank(void);
>>>  
>>> +/**
>>> + * Unlink all hugepages which created by dpdk.
>>> + *
>>> + * @param void
>>> + *
>>> + * @return
>>> + *       0: successfully
>>> + *       negative: error
>>> + */
>>> +int rte_eal_hugepage_free(void);
>>> +
>>>  #ifdef RTE_LIBRTE_XEN_DOM0
>>>  /**
>>>   * Return the physical address of elt, which is an element of the pool mp.
>>> diff --git a/dpdk/dpdk-1.7.0/lib/librte_eal/linuxapp/eal/eal_memory.c b/dpdk/dpdk-1.7.0/lib/librte_eal/linuxapp/eal/eal_memory.c
>>> index f2454f4..109207c 100644
>>> --- a/dpdk/dpdk-1.7.0/lib/librte_eal/linuxapp/eal/eal_memory.c
>>> +++ b/dpdk/dpdk-1.7.0/lib/librte_eal/linuxapp/eal/eal_memory.c
>>> @@ -98,6 +98,13 @@
>>>  #include "eal_filesystem.h"
>>>  #include "eal_hugepages.h"
>>>  
>>> +struct hugepage_table {
>>> +	struct hugepage_file *hugepg_tbl;
>>> +	unsigned nr_hugefiles;
>>> +};
>>> +
>>> +static struct hugepage_table g_hugepage_table;
>>> +
>>>  /**
>>>   * @file
>>>   * Huge page mapping under linux
>>> @@ -1202,6 +1209,7 @@ rte_eal_hugepage_init(void)
>>>  						(unsigned)
>>>  							(used_hp[i].hugepage_sz / 0x100000),
>>>  						j);
>>> +				g_hugepage_table.nr_hugefiles += used_hp[i].num_pages[j];
>>>  			}
>>>  		}
>>>  	}
>>> @@ -1237,6 +1245,8 @@ rte_eal_hugepage_init(void)
>>>  		goto fail;
>>>  	}
>>>  
>>> +	g_hugepage_table.hugepg_tbl = hugepage;
>>> +
>>>  	/* free the temporary hugepage table */
>>>  	free(tmp_hp);
>>>  	tmp_hp = NULL;
>>> @@ -1487,6 +1497,27 @@ error:
>>>  	return -1;
>>>  }
>>>  
>>> +int
>>> +rte_eal_hugepage_free(void)
>>> +{
>>> +	struct hugepage_file *hugepg_tbl = g_hugepage_table.hugepg_tbl;
>>> +	unsigned i;
>>> +	unsigned nr_hugefiles = g_hugepage_table.nr_hugefiles;
>>> +	int ret = 0;
>>> +
>>> +	for (i = 0; i < nr_hugefiles; i++) {
>>> +		ret = unlink(hugepg_tbl[i].filepath);
>>> +		if (ret != 0) {
>>> +			RTE_LOG(ERR, EAL, "Failed to unlink %s", hugepg_tbl[i].filepath);
>>> +			return ret;
>>> +		}
>>> +		hugepg_tbl[i].orig_va = NULL;
>> BTW, is it better to first set hugepg_tbl[i].orig_vato NULL, then unlink
>> filepath?
>> It may be not a good idea to first remove then set to NULL.
>>
>> Thanks,
>> Michael
>>
> If first set hugepg_tbl[i].orig_va to NULL,then failed to unlink you have to restore hugepg_tbl[i].orig_va.
> So I first to unlink for less codes.

But it may be a big issue(not safe) when you unlink the path before you
set the pointer to NULL,  another thing is , why you need to restore the
orig_va since the app will exit? Even you need to restore it just one or
two lines code, I think it is not a big deal.

Thanks,
Michael
>
>>> +	}
>>> +
>>> +	RTE_LOG(INFO, EAL, "unlink %u hugepage files\n", nr_hugefiles);
>>> +	return ret;
>>> +}
>>> +
>>>  static int
>>>  rte_eal_memdevice_init(void)
>>>  {
>>
>> .
>>
  
Linhaifeng Oct. 29, 2014, 8:15 a.m. UTC | #4
On 2014/10/29 16:04, Qiu, Michael wrote:
> 10/29/2014 2:41 PM, Linhaifeng :
>>
>> On 2014/10/29 14:14, Qiu, Michael wrote:
>>> 在 10/29/2014 1:49 PM, linhaifeng 写道:
>>>> rte_eal_hugepage_free() is used for unlink all hugepages.If you want to
>>>> free all hugepages you must make sure that you have stop to use it,and you
>>>> must call this function before exit process.
>>>>
>>>> Signed-off-by: linhaifeng <haifeng.lin@huawei.com>
>>>> ---
>>>>  .../lib/librte_eal/common/include/rte_memory.h     | 11 ++++++++
>>>>  .../lib/librte_eal/linuxapp/eal/eal_memory.c       | 31 ++++++++++++++++++++++
>>>>  2 files changed, 42 insertions(+)
>>>>
>>>> diff --git a/dpdk/dpdk-1.7.0/lib/librte_eal/common/include/rte_memory.h b/dpdk/dpdk-1.7.0/lib/librte_eal/common/include/rte_memory.h
>>>> index 4cf8ea9..f6ad95f 100644
>>>> --- a/dpdk/dpdk-1.7.0/lib/librte_eal/common/include/rte_memory.h
>>>> +++ b/dpdk/dpdk-1.7.0/lib/librte_eal/common/include/rte_memory.h
>>>> @@ -172,6 +172,17 @@ unsigned rte_memory_get_nchannel(void);
>>>>   */
>>>>  unsigned rte_memory_get_nrank(void);
>>>>  
>>>> +/**
>>>> + * Unlink all hugepages which created by dpdk.
>>>> + *
>>>> + * @param void
>>>> + *
>>>> + * @return
>>>> + *       0: successfully
>>>> + *       negative: error
>>>> + */
>>>> +int rte_eal_hugepage_free(void);
>>>> +
>>>>  #ifdef RTE_LIBRTE_XEN_DOM0
>>>>  /**
>>>>   * Return the physical address of elt, which is an element of the pool mp.
>>>> diff --git a/dpdk/dpdk-1.7.0/lib/librte_eal/linuxapp/eal/eal_memory.c b/dpdk/dpdk-1.7.0/lib/librte_eal/linuxapp/eal/eal_memory.c
>>>> index f2454f4..109207c 100644
>>>> --- a/dpdk/dpdk-1.7.0/lib/librte_eal/linuxapp/eal/eal_memory.c
>>>> +++ b/dpdk/dpdk-1.7.0/lib/librte_eal/linuxapp/eal/eal_memory.c
>>>> @@ -98,6 +98,13 @@
>>>>  #include "eal_filesystem.h"
>>>>  #include "eal_hugepages.h"
>>>>  
>>>> +struct hugepage_table {
>>>> +	struct hugepage_file *hugepg_tbl;
>>>> +	unsigned nr_hugefiles;
>>>> +};
>>>> +
>>>> +static struct hugepage_table g_hugepage_table;
>>>> +
>>>>  /**
>>>>   * @file
>>>>   * Huge page mapping under linux
>>>> @@ -1202,6 +1209,7 @@ rte_eal_hugepage_init(void)
>>>>  						(unsigned)
>>>>  							(used_hp[i].hugepage_sz / 0x100000),
>>>>  						j);
>>>> +				g_hugepage_table.nr_hugefiles += used_hp[i].num_pages[j];
>>>>  			}
>>>>  		}
>>>>  	}
>>>> @@ -1237,6 +1245,8 @@ rte_eal_hugepage_init(void)
>>>>  		goto fail;
>>>>  	}
>>>>  
>>>> +	g_hugepage_table.hugepg_tbl = hugepage;
>>>> +
>>>>  	/* free the temporary hugepage table */
>>>>  	free(tmp_hp);
>>>>  	tmp_hp = NULL;
>>>> @@ -1487,6 +1497,27 @@ error:
>>>>  	return -1;
>>>>  }
>>>>  
>>>> +int
>>>> +rte_eal_hugepage_free(void)
>>>> +{
>>>> +	struct hugepage_file *hugepg_tbl = g_hugepage_table.hugepg_tbl;
>>>> +	unsigned i;
>>>> +	unsigned nr_hugefiles = g_hugepage_table.nr_hugefiles;
>>>> +	int ret = 0;
>>>> +
>>>> +	for (i = 0; i < nr_hugefiles; i++) {
>>>> +		ret = unlink(hugepg_tbl[i].filepath);
>>>> +		if (ret != 0) {
>>>> +			RTE_LOG(ERR, EAL, "Failed to unlink %s", hugepg_tbl[i].filepath);
>>>> +			return ret;
>>>> +		}
>>>> +		hugepg_tbl[i].orig_va = NULL;
>>> BTW, is it better to first set hugepg_tbl[i].orig_vato NULL, then unlink
>>> filepath?
>>> It may be not a good idea to first remove then set to NULL.
>>>
>>> Thanks,
>>> Michael
>>>
>> If first set hugepg_tbl[i].orig_va to NULL,then failed to unlink you have to restore hugepg_tbl[i].orig_va.
>> So I first to unlink for less codes.
> 
> But it may be a big issue(not safe) when you unlink the path before you
> set the pointer to NULL,  another thing is , why you need to restore the
> orig_va since the app will exit? Even you need to restore it just one or
> two lines code, I think it is not a big deal.
> 
> Thanks,
> Michael

Thank you,Michael

Yes,it's not safe to unlink the path before set the pointer to NULL.I will fix it.

BTW.is need to return error when failed to unlink?May be not need?
>>
>>>> +	}
>>>> +
>>>> +	RTE_LOG(INFO, EAL, "unlink %u hugepage files\n", nr_hugefiles);
>>>> +	return ret;
>>>> +}
>>>> +
>>>>  static int
>>>>  rte_eal_memdevice_init(void)
>>>>  {
>>>
>>> .
>>>
> 
> 
> .
>
  
Matthew Hall Oct. 30, 2014, 3:17 a.m. UTC | #5
On Wed, Oct 29, 2014 at 01:47:39PM +0800, linhaifeng wrote:
> +int
> +rte_eal_hugepage_free(void)
> +{
> +	struct hugepage_file *hugepg_tbl = g_hugepage_table.hugepg_tbl;
> +	unsigned i;
> +	unsigned nr_hugefiles = g_hugepage_table.nr_hugefiles;
> +	int ret = 0;
> +
> +	for (i = 0; i < nr_hugefiles; i++) {
> +		ret = unlink(hugepg_tbl[i].filepath);
> +		if (ret != 0) {
> +			RTE_LOG(ERR, EAL, "Failed to unlink %s", hugepg_tbl[i].filepath);
> +			return ret;

I would say, don't exit just because one couldn't be freed. Free everything 
you can but exit with an error so people can know what happened.

Thanks for the patch, good idea!

Matthew.
  
Thomas Monjalon Oct. 30, 2014, 3:32 p.m. UTC | #6
2014-10-29 13:47, linhaifeng:
> rte_eal_hugepage_free() is used for unlink all hugepages.If you want to
> free all hugepages you must make sure that you have stop to use it,and you
> must call this function before exit process.
> 
> Signed-off-by: linhaifeng <haifeng.lin@huawei.com>

Thanks for raising the need.
There is a discussion in the thread of the first version of this patch.
Neil suggests an automatic clean-up with hugepage refcounting.
It seems to be a good idea.

So this patch won't be integrated as is.
  

Patch

diff --git a/dpdk/dpdk-1.7.0/lib/librte_eal/common/include/rte_memory.h b/dpdk/dpdk-1.7.0/lib/librte_eal/common/include/rte_memory.h
index 4cf8ea9..f6ad95f 100644
--- a/dpdk/dpdk-1.7.0/lib/librte_eal/common/include/rte_memory.h
+++ b/dpdk/dpdk-1.7.0/lib/librte_eal/common/include/rte_memory.h
@@ -172,6 +172,17 @@  unsigned rte_memory_get_nchannel(void);
  */
 unsigned rte_memory_get_nrank(void);
 
+/**
+ * Unlink all hugepages which created by dpdk.
+ *
+ * @param void
+ *
+ * @return
+ *       0: successfully
+ *       negative: error
+ */
+int rte_eal_hugepage_free(void);
+
 #ifdef RTE_LIBRTE_XEN_DOM0
 /**
  * Return the physical address of elt, which is an element of the pool mp.
diff --git a/dpdk/dpdk-1.7.0/lib/librte_eal/linuxapp/eal/eal_memory.c b/dpdk/dpdk-1.7.0/lib/librte_eal/linuxapp/eal/eal_memory.c
index f2454f4..109207c 100644
--- a/dpdk/dpdk-1.7.0/lib/librte_eal/linuxapp/eal/eal_memory.c
+++ b/dpdk/dpdk-1.7.0/lib/librte_eal/linuxapp/eal/eal_memory.c
@@ -98,6 +98,13 @@ 
 #include "eal_filesystem.h"
 #include "eal_hugepages.h"
 
+struct hugepage_table {
+	struct hugepage_file *hugepg_tbl;
+	unsigned nr_hugefiles;
+};
+
+static struct hugepage_table g_hugepage_table;
+
 /**
  * @file
  * Huge page mapping under linux
@@ -1202,6 +1209,7 @@  rte_eal_hugepage_init(void)
 						(unsigned)
 							(used_hp[i].hugepage_sz / 0x100000),
 						j);
+				g_hugepage_table.nr_hugefiles += used_hp[i].num_pages[j];
 			}
 		}
 	}
@@ -1237,6 +1245,8 @@  rte_eal_hugepage_init(void)
 		goto fail;
 	}
 
+	g_hugepage_table.hugepg_tbl = hugepage;
+
 	/* free the temporary hugepage table */
 	free(tmp_hp);
 	tmp_hp = NULL;
@@ -1487,6 +1497,27 @@  error:
 	return -1;
 }
 
+int
+rte_eal_hugepage_free(void)
+{
+	struct hugepage_file *hugepg_tbl = g_hugepage_table.hugepg_tbl;
+	unsigned i;
+	unsigned nr_hugefiles = g_hugepage_table.nr_hugefiles;
+	int ret = 0;
+
+	for (i = 0; i < nr_hugefiles; i++) {
+		ret = unlink(hugepg_tbl[i].filepath);
+		if (ret != 0) {
+			RTE_LOG(ERR, EAL, "Failed to unlink %s", hugepg_tbl[i].filepath);
+			return ret;
+		}
+		hugepg_tbl[i].orig_va = NULL;
+	}
+
+	RTE_LOG(INFO, EAL, "unlink %u hugepage files\n", nr_hugefiles);
+	return ret;
+}
+
 static int
 rte_eal_memdevice_init(void)
 {