linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* Request for clarification regarding huge pages and remapping of virtual to physical address
       [not found] <245378552.87900.1713345083646.ref@mail.yahoo.com>
@ 2024-04-17  9:11 ` sunil bhargo
  2024-04-17  9:17   ` David Hildenbrand
  0 siblings, 1 reply; 4+ messages in thread
From: sunil bhargo @ 2024-04-17  9:11 UTC (permalink / raw)
  To: linux-mm@kvack.org; +Cc: mounesh.b@gmail.com

[-- Attachment #1: Type: text/plain, Size: 577 bytes --]

Hi,
We have an application which relies on virtual address to physical address mapping to remain static. The buffer is allocated using malloc. It is in user space and we were using the mlock thinking that as it would prevent the swapping the va->pa address mapping would be static. But it seems to be a faulty assumption.
If the memory is allocated from huge pages by reserving space upfront at the kernel boot up and then mmap’ing using MAP_HUGETLB, is it assured that virtual address to physical mapping won’t be remapped and will be static ?
Thanks,Sunil Bhargo 

[-- Attachment #2: Type: text/html, Size: 1249 bytes --]

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

* Re: Request for clarification regarding huge pages and remapping of virtual to physical address
  2024-04-17  9:11 ` Request for clarification regarding huge pages and remapping of virtual to physical address sunil bhargo
@ 2024-04-17  9:17   ` David Hildenbrand
  2024-04-17 10:09     ` sunil bhargo
  0 siblings, 1 reply; 4+ messages in thread
From: David Hildenbrand @ 2024-04-17  9:17 UTC (permalink / raw)
  To: sunil bhargo, linux-mm@kvack.org; +Cc: mounesh.b@gmail.com

On 17.04.24 11:11, sunil bhargo wrote:
> Hi,
> 
> We have an application which relies on virtual address to physical 
> address mapping to remain static. The buffer is allocated using 
> malloc. It is in user space and we were using the mlock thinking that as 
> it would prevent the swapping the va->pa address mapping would be 
> static. But it seems to be a faulty assumption.
> 
> If the memory is allocated from huge pages by reserving space upfront at 
> the kernel boot up and then mmap’ing using MAP_HUGETLB, is it assured 
> that virtual address to physical mapping won’t be remapped and will be 
> static ?

Unless you have a kernel that has page migration disabled, no.

You could use secretmem (which is currently not migratabale/swappable/ 
...), but that has very limited capabilities.

A "hack" would be to register that (ordinary) memory using iouring as a 
fixed buffer. That way, it will be longterm pinned and can neither get 
migrated nor swapped out.

-- 
Cheers,

David / dhildenb



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

* Re: Request for clarification regarding huge pages and remapping of virtual to physical address
  2024-04-17  9:17   ` David Hildenbrand
@ 2024-04-17 10:09     ` sunil bhargo
  2024-04-17 15:00       ` David Hildenbrand
  0 siblings, 1 reply; 4+ messages in thread
From: sunil bhargo @ 2024-04-17 10:09 UTC (permalink / raw)
  To: linux-mm@kvack.org, David Hildenbrand; +Cc: mounesh.b@gmail.com

[-- Attachment #1: Type: text/plain, Size: 1331 bytes --]

 David,Thanks for your response. So if i get it right then reserving the memory at boot time with/without the huge page, the page migration can happen ? 

Thanks,Sunil Bhargo

    On Wednesday, April 17, 2024 at 02:47:30 PM GMT+5:30, David Hildenbrand <david@redhat.com> wrote:  
 
 On 17.04.24 11:11, sunil bhargo wrote:
> Hi,
> 
> We have an application which relies on virtual address to physical 
> address mapping to remain static. The buffer is allocated using 
> malloc. It is in user space and we were using the mlock thinking that as 
> it would prevent the swapping the va->pa address mapping would be 
> static. But it seems to be a faulty assumption.
> 
> If the memory is allocated from huge pages by reserving space upfront at 
> the kernel boot up and then mmap’ing using MAP_HUGETLB, is it assured 
> that virtual address to physical mapping won’t be remapped and will be 
> static ?

Unless you have a kernel that has page migration disabled, no.

You could use secretmem (which is currently not migratabale/swappable/ 
...), but that has very limited capabilities.

A "hack" would be to register that (ordinary) memory using iouring as a 
fixed buffer. That way, it will be longterm pinned and can neither get 
migrated nor swapped out.

-- 
Cheers,

David / dhildenb

  

[-- Attachment #2: Type: text/html, Size: 2789 bytes --]

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

* Re: Request for clarification regarding huge pages and remapping of virtual to physical address
  2024-04-17 10:09     ` sunil bhargo
@ 2024-04-17 15:00       ` David Hildenbrand
  0 siblings, 0 replies; 4+ messages in thread
From: David Hildenbrand @ 2024-04-17 15:00 UTC (permalink / raw)
  To: sunil bhargo, linux-mm@kvack.org; +Cc: mounesh.b@gmail.com

On 17.04.24 12:09, sunil bhargo wrote:
> David,
> Thanks for your response. So if i get it right then reserving the memory 
> at boot time with/without the huge page, the page migration can happen ?

I *think* even hugetlb folios allocated/reserved during early boot can 
be migrated in memory later. The chance of that happening is small, 
though. Or I might be wrong :)

Migration of gigantic huge pages (e.g., 1 GiB) is even more unlikely to 
happen.

-- 
Cheers,

David / dhildenb



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

end of thread, other threads:[~2024-04-17 15:00 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <245378552.87900.1713345083646.ref@mail.yahoo.com>
2024-04-17  9:11 ` Request for clarification regarding huge pages and remapping of virtual to physical address sunil bhargo
2024-04-17  9:17   ` David Hildenbrand
2024-04-17 10:09     ` sunil bhargo
2024-04-17 15:00       ` David Hildenbrand

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).