* [dpdk-dev] API in dpdk to get total free physical memory
@ 2017-10-05 5:56 Venumadhav Josyula
2017-10-05 9:02 ` Burakov, Anatoly
0 siblings, 1 reply; 6+ messages in thread
From: Venumadhav Josyula @ 2017-10-05 5:56 UTC (permalink / raw)
To: dev; +Cc: Venumadhav Josyula
Hi All,
Like 'rte_eal_get_physmem_size' api to the total size of the physical memory. Is there an API to get to get total free memory physical memory available ?
We want such API we are planning to implement such API for the same
/* get the total size of memory */
uint64_t
rte_eal_get_physmem_free(int socket_id)
{
const struct rte_mem_config *mcfg;
unsigned i = 0;
uint64_t total_len = 0;
/* get pointer to global configuration */
mcfg = rte_eal_get_configuration()->mem_config;
for (i=0; i<RTE_MAX_MEMSEG; i++) {
if (mcfg->free_memseg[i].addr == NULL)
break;
if (mcfg->free_memseg[i].len == 0)
continue;
/* bad socket ID */
if (socket_id != SOCKET_ID_ANY &&
mcfg->free_memseg[i].socket_id != SOCKET_ID_ANY &&
socket_id != mcfg->free_memseg[i].socket_id)
continue;
total_len += mcfg->free_memseg[i].len;
}
return total_len;
}
Thanks,
Regards
Venu
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [dpdk-dev] API in dpdk to get total free physical memory
2017-10-05 5:56 [dpdk-dev] API in dpdk to get total free physical memory Venumadhav Josyula
@ 2017-10-05 9:02 ` Burakov, Anatoly
0 siblings, 0 replies; 6+ messages in thread
From: Burakov, Anatoly @ 2017-10-05 9:02 UTC (permalink / raw)
To: Venumadhav Josyula, dev
On 05-Oct-17 6:56 AM, Venumadhav Josyula wrote:
> Hi All,
>
> Like 'rte_eal_get_physmem_size' api to the total size of the physical memory. Is there an API to get to get total free memory physical memory available ?
>
> We want such API we are planning to implement such API for the same
>
> /* get the total size of memory */
> uint64_t
> rte_eal_get_physmem_free(int socket_id)
> {
> const struct rte_mem_config *mcfg;
> unsigned i = 0;
> uint64_t total_len = 0;
>
> /* get pointer to global configuration */
> mcfg = rte_eal_get_configuration()->mem_config;
>
> for (i=0; i<RTE_MAX_MEMSEG; i++) {
> if (mcfg->free_memseg[i].addr == NULL)
> break;
>
> if (mcfg->free_memseg[i].len == 0)
> continue;
>
> /* bad socket ID */
> if (socket_id != SOCKET_ID_ANY &&
> mcfg->free_memseg[i].socket_id != SOCKET_ID_ANY &&
> socket_id != mcfg->free_memseg[i].socket_id)
> continue;
>
> total_len += mcfg->free_memseg[i].len;
> }
>
> return total_len;
> }
>
> Thanks,
> Regards
> Venu
>
Hi Venu,
I don't think there is such an API, so you're welcome to submit a patch.
--
Thanks,
Anatoly
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [dpdk-dev] Api in dpdk to get total free physical memory
2018-03-09 9:59 ` Venumadhav Josyula
@ 2018-03-09 10:56 ` Burakov, Anatoly
0 siblings, 0 replies; 6+ messages in thread
From: Burakov, Anatoly @ 2018-03-09 10:56 UTC (permalink / raw)
To: Venumadhav Josyula, Venumadhav Josyula, dev
On 09-Mar-18 9:59 AM, Venumadhav Josyula wrote:
> Hi Anatoly,
>
> Like we have api, rte_eal_get_physmem_size, which returns the total
> memory physical Ram memory. This is eal_common_memory.c, we need
> following following which would return free memory. For that that I was
> referring we need to api get the free physical ram memory
> ‘rte_eal_get_physmem_free’ for the we wanted to submit patch.
>
> Thanks,
>
> Regards
>
> Venumadhav
Hi Venumadhav,
Yes, i understand what you're referring to. I'm just saying that 1)
getting malloc heap stats will provide you with similar (and arguably
more practically useful) information, and 2) there are changes
(hopefully) coming that will lessen usefulness of such an API because it
would be possible to allocate hugepages at runtime, instead of
preallocating them at startup.
You're welcome to submit your patches, of course, but i would question
the usefulness of such an API in light of coming changes to memory
subsystem, because the "free" memory will not be the actual amount of
free memory you have. Imagine the following:
// you have roughly 1MB of free memory
free_mem = rte_eal_get_free_mem();
printf("%luMB\n", free_mem >> 20); // prints "1MB"
rte_malloc(1 << 20); // allocate 1MB of memory
// causes allocation of 1G page
free_mem = rte_eal_get_free_mem();
printf("%luMB\n", free_mem >> 20); // prints "1024MB"
A second ago you had 1MB of "free space", next second you have 1G free
space, despite the fact that you didn't free any memory - you just
allocated more pages. "Amount of free space" will have little meaning
when you can allocate more pages on the fly. I hope i've explained it
clearly enough.
>
> *From:*dev [mailto:dev-bounces@dpdk.org] *On Behalf Of *Burakov, Anatoly
> *Sent:* Friday, March 09, 2018 2:36 PM
> *To:* Venumadhav Josyula <vjosyula@gmail.com>; dev@dpdk.org
> *Subject:* Re: [dpdk-dev] Api in dpdk to get total free physical memory
>
> On 08-Mar-18 9:36 PM, Venumadhav Josyula wrote:
> > Hi All,
> >
> >
> >
> > Like ‘rte_eal_get_physmem_size’ api to the total size of the physical
> > memory. Is there an API to get to get total free memory physical memory
> > available ?
> >
> >
> >
> > We want such API we are planning to implement such API for the same
> >
> >
> >
> > /* get the total size of memory */
> >
> > uint64_t
> >
> > rte_eal_get_physmem_free(int socket_id)
> >
> > {
> >
> > const struct rte_mem_config *mcfg;
> >
> > unsigned i = 0;
> >
> > uint64_t total_len = 0;
> >
> >
> >
> > /* get pointer to global configuration */
> >
> > mcfg = rte_eal_get_configuration()->mem_config;
> >
> >
> >
> > for (i=0; i<RTE_MAX_MEMSEG; i++) {
> >
> > if (mcfg->free_memseg[i].addr == NULL)
> >
> > break;
> >
> >
> >
> > if (mcfg->free_memseg[i].len == 0)
> >
> > continue;
> >
> >
> >
> > /* bad socket ID */
> >
> > if (socket_id != SOCKET_ID_ANY &&
> >
> > mcfg->free_memseg[i].socket_id != SOCKET_ID_ANY &&
> >
> > socket_id != mcfg->free_memseg[i].socket_id)
> >
> > continue;
> >
> >
> >
> > total_len += mcfg->free_memseg[i].len;
> >
> > }
> >
> >
> >
> > return total_len;
> >
> > }
> >
> >
> >
> > Thanks,
> >
> > Regards
> >
> > Venu
> >
>
> All memory is registered on the heap, so you might want to look at heap
> stats to get the same information :) It would also arguably be more
> useful because just the size of memory will not tell you how much you
> can allocate, because memory may be heavily fragmented, and heap stats
> will also tell you biggest free memory block size.
>
> Bear in mind, however, that there is work in progress [1] to enable
> mapping/unmapping hugepages at runtime, which would make such an API
> more or less useless - just because you don't have much free space *now*
> doesn't mean you can't allocate more :)
>
> [1] http://dpdk.org/ml/archives/dev/2018-March/092070.html
>
> --
> Thanks,
> Anatoly
>
--
Thanks,
Anatoly
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [dpdk-dev] Api in dpdk to get total free physical memory
2018-03-09 9:05 ` Burakov, Anatoly
@ 2018-03-09 9:59 ` Venumadhav Josyula
2018-03-09 10:56 ` Burakov, Anatoly
0 siblings, 1 reply; 6+ messages in thread
From: Venumadhav Josyula @ 2018-03-09 9:59 UTC (permalink / raw)
To: Burakov, Anatoly, Venumadhav Josyula, dev
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset=UTF-8, Size: 2789 bytes --]
Hi Anatoly,
Like we have api, rte_eal_get_physmem_size, which returns the total memory physical Ram memory. This is eal_common_memory.c, we need following following which would return free memory. For that that I was referring we need to api get the free physical ram memory ârte_eal_get_physmem_freeâ for the we wanted to submit patch.
Thanks,
Regards
Venumadhav
From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Burakov, Anatoly
Sent: Friday, March 09, 2018 2:36 PM
To: Venumadhav Josyula <vjosyula@gmail.com>; dev@dpdk.org
Subject: Re: [dpdk-dev] Api in dpdk to get total free physical memory
On 08-Mar-18 9:36 PM, Venumadhav Josyula wrote:
> Hi All,
>
>
>
> Like ârte_eal_get_physmem_sizeâ api to the total size of the physical
> memory. Is there an API to get to get total free memory physical memory
> available ?
>
>
>
> We want such API we are planning to implement such API for the same
>
>
>
> /* get the total size of memory */
>
> uint64_t
>
> rte_eal_get_physmem_free(int socket_id)
>
> {
>
> const struct rte_mem_config *mcfg;
>
> unsigned i = 0;
>
> uint64_t total_len = 0;
>
>
>
> /* get pointer to global configuration */
>
> mcfg = rte_eal_get_configuration()->mem_config;
>
>
>
> for (i=0; i<RTE_MAX_MEMSEG; i++) {
>
> if (mcfg->free_memseg[i].addr == NULL)
>
> break;
>
>
>
> if (mcfg->free_memseg[i].len == 0)
>
> continue;
>
>
>
> /* bad socket ID */
>
> if (socket_id != SOCKET_ID_ANY &&
>
> mcfg->free_memseg[i].socket_id != SOCKET_ID_ANY &&
>
> socket_id != mcfg->free_memseg[i].socket_id)
>
> continue;
>
>
>
> total_len += mcfg->free_memseg[i].len;
>
> }
>
>
>
> return total_len;
>
> }
>
>
>
> Thanks,
>
> Regards
>
> Venu
>
All memory is registered on the heap, so you might want to look at heap
stats to get the same information :) It would also arguably be more
useful because just the size of memory will not tell you how much you
can allocate, because memory may be heavily fragmented, and heap stats
will also tell you biggest free memory block size.
Bear in mind, however, that there is work in progress [1] to enable
mapping/unmapping hugepages at runtime, which would make such an API
more or less useless - just because you don't have much free space *now*
doesn't mean you can't allocate more :)
[1] http://dpdk.org/ml/archives/dev/2018-March/092070.html<http://dpdk.org/ml/archives/dev/2018-March/092070.html>
--
Thanks,
Anatoly
\x16º&}êëº\x1c¢+b×¥r
®#\x1a¯ÝuÓvÛM|Eën®sÚ¶\x17Þ®»¡Ê("¶)ízW(\x17z+Þuúèh\x1aÓh§µé\¢i kM¢×¥rµßwã]úÛFòvd¢¸\x0f¢Ë_\x1c"¶\x11\x1213âw]ÅóÎEÜ7èׯvd¢¸\x05®/Lj½´×ÍuÓuûMtÐ!\x13\ ©Eë.Ô óÄ\x0ez\x1a¶Ög§¶)æzË\x1aåÀbå)yÑZÇyÇ¢½ç_®¨®É kM8ø§µé\¢mtïm=ßÆò¢»&tÖ7â×¥r°ØDHÄÏý2Òü1ÄE \0\x11-¹è`Hp7ó=1ªöÓ_4ÛNuÓO4Ñq1´º(§]W"º'>í\x01Q
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [dpdk-dev] Api in dpdk to get total free physical memory
2018-03-08 21:36 [dpdk-dev] Api " Venumadhav Josyula
@ 2018-03-09 9:05 ` Burakov, Anatoly
2018-03-09 9:59 ` Venumadhav Josyula
0 siblings, 1 reply; 6+ messages in thread
From: Burakov, Anatoly @ 2018-03-09 9:05 UTC (permalink / raw)
To: Venumadhav Josyula, dev
On 08-Mar-18 9:36 PM, Venumadhav Josyula wrote:
> Hi All,
>
>
>
> Like ‘rte_eal_get_physmem_size’ api to the total size of the physical
> memory. Is there an API to get to get total free memory physical memory
> available ?
>
>
>
> We want such API we are planning to implement such API for the same
>
>
>
> /* get the total size of memory */
>
> uint64_t
>
> rte_eal_get_physmem_free(int socket_id)
>
> {
>
> const struct rte_mem_config *mcfg;
>
> unsigned i = 0;
>
> uint64_t total_len = 0;
>
>
>
> /* get pointer to global configuration */
>
> mcfg = rte_eal_get_configuration()->mem_config;
>
>
>
> for (i=0; i<RTE_MAX_MEMSEG; i++) {
>
> if (mcfg->free_memseg[i].addr == NULL)
>
> break;
>
>
>
> if (mcfg->free_memseg[i].len == 0)
>
> continue;
>
>
>
> /* bad socket ID */
>
> if (socket_id != SOCKET_ID_ANY &&
>
> mcfg->free_memseg[i].socket_id != SOCKET_ID_ANY &&
>
> socket_id != mcfg->free_memseg[i].socket_id)
>
> continue;
>
>
>
> total_len += mcfg->free_memseg[i].len;
>
> }
>
>
>
> return total_len;
>
> }
>
>
>
> Thanks,
>
> Regards
>
> Venu
>
All memory is registered on the heap, so you might want to look at heap
stats to get the same information :) It would also arguably be more
useful because just the size of memory will not tell you how much you
can allocate, because memory may be heavily fragmented, and heap stats
will also tell you biggest free memory block size.
Bear in mind, however, that there is work in progress [1] to enable
mapping/unmapping hugepages at runtime, which would make such an API
more or less useless - just because you don't have much free space *now*
doesn't mean you can't allocate more :)
[1] http://dpdk.org/ml/archives/dev/2018-March/092070.html
--
Thanks,
Anatoly
^ permalink raw reply [flat|nested] 6+ messages in thread
* [dpdk-dev] Api in dpdk to get total free physical memory
@ 2018-03-08 21:36 Venumadhav Josyula
2018-03-09 9:05 ` Burakov, Anatoly
0 siblings, 1 reply; 6+ messages in thread
From: Venumadhav Josyula @ 2018-03-08 21:36 UTC (permalink / raw)
To: dev
Hi All,
Like ‘rte_eal_get_physmem_size’ api to the total size of the physical
memory. Is there an API to get to get total free memory physical memory
available ?
We want such API we are planning to implement such API for the same
/* get the total size of memory */
uint64_t
rte_eal_get_physmem_free(int socket_id)
{
const struct rte_mem_config *mcfg;
unsigned i = 0;
uint64_t total_len = 0;
/* get pointer to global configuration */
mcfg = rte_eal_get_configuration()->mem_config;
for (i=0; i<RTE_MAX_MEMSEG; i++) {
if (mcfg->free_memseg[i].addr == NULL)
break;
if (mcfg->free_memseg[i].len == 0)
continue;
/* bad socket ID */
if (socket_id != SOCKET_ID_ANY &&
mcfg->free_memseg[i].socket_id != SOCKET_ID_ANY &&
socket_id != mcfg->free_memseg[i].socket_id)
continue;
total_len += mcfg->free_memseg[i].len;
}
return total_len;
}
Thanks,
Regards
Venu
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2018-03-09 10:56 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-10-05 5:56 [dpdk-dev] API in dpdk to get total free physical memory Venumadhav Josyula
2017-10-05 9:02 ` Burakov, Anatoly
2018-03-08 21:36 [dpdk-dev] Api " Venumadhav Josyula
2018-03-09 9:05 ` Burakov, Anatoly
2018-03-09 9:59 ` Venumadhav Josyula
2018-03-09 10:56 ` Burakov, Anatoly
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).