making 256TB user process vmem ,,,, is this possible??

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
criny
Posts: 7
Joined: Sun Jul 27, 2014 1:19 pm

making 256TB user process vmem ,,,, is this possible??

Post by criny »

I'm know devloping linux-like new model kernel just for fun...

I want to make user process use full virtual memory space 256TB in x86_64 machine...

I can't get answer now...

also... I'm not newbe in making kernel...

IDTR must indicate virtual memory address to execute interrupt handler......... and.... many thing there is to make system call environment..I know....

hm..... does anyone know about this????

may be my question look so fool.... but I want to make it possible if x86 mahchine supports it.....


Give me some Good idea guys~~~ XD
User avatar
bluemoon
Member
Member
Posts: 1761
Joined: Wed Dec 01, 2010 3:41 am
Location: Hong Kong

Re: making 256TB user process vmem ,,,, is this possible??

Post by bluemoon »

Not so simple.

First, let's look at how much address space on x86_64: it's 256T, but then you would reserve some for kernel and page stuff, so technically, no, you only have 256T - "kernel space", although you may squeeze the kernel to tiny bits.

But don't give up, the above scenario assume the question was giving 256T space access which can be accessed directly. There are other technique like overlay/swap to provide even more accessible memory to an application, if you really need that much.
criny
Posts: 7
Joined: Sun Jul 27, 2014 1:19 pm

Re: making 256TB user process vmem ,,,, is this possible??

Post by criny »

thanku guy....
i already have enough knowledge in x86 architecture... so I know it may be difficult.... because I haven't saw the kernel supporting fully-256TB-virtual-memory-user-process ... even in educational kernel program...

I want to make it possible just because of making kernel model sooooooooooooo easy.....XD
criny
Posts: 7
Joined: Sun Jul 27, 2014 1:19 pm

Re: making 256TB user process vmem ,,,, is this possible??

Post by criny »

I made it possible just ago XD
User avatar
SpyderTL
Member
Member
Posts: 1074
Joined: Sun Sep 19, 2010 10:05 pm

Re: making 256TB user process vmem ,,,, is this possible??

Post by SpyderTL »

64-bit Long mode requires paging to be enabled, so you would have to define 262,144 pages (4MB pages) for each application, including the kernel.

That's over 4MB of page tables for each application.

Am I right about this?
Project: OZone
Source: GitHub
Current Task: LIB/OBJ file support
"The more they overthink the plumbing, the easier it is to stop up the drain." - Montgomery Scott
stlw
Member
Member
Posts: 357
Joined: Fri Apr 04, 2008 6:43 am
Contact:

Re: making 256TB user process vmem ,,,, is this possible??

Post by stlw »

SpyderTL wrote:64-bit Long mode requires paging to be enabled, so you would have to define 262,144 pages (4MB pages) for each application, including the kernel.

That's over 4MB of page tables for each application.

Am I right about this?
There are no 4MB pages in long mode.
But servers with sooo much memory usually don't stop on available 2MB and use 1Gb pages.

Stanislav
User avatar
SpyderTL
Member
Member
Posts: 1074
Joined: Sun Sep 19, 2010 10:05 pm

Re: making 256TB user process vmem ,,,, is this possible??

Post by SpyderTL »

You are correct. I meant 4KB pages, which is even worse. Although the page entries are only 8 bytes, not 16 as I was using above.

So that would be... 549 GB of page tables for each application... #-o

So, how do you get 1 GB pages?
Project: OZone
Source: GitHub
Current Task: LIB/OBJ file support
"The more they overthink the plumbing, the easier it is to stop up the drain." - Montgomery Scott
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: making 256TB user process vmem ,,,, is this possible??

Post by Combuster »

64-bit mode supports at least 4K and 2M pages. 1G pages is a more recent feature. You'd set it just like the size bit for 2M pages but then on a higher table.

There might be some CR4/EFER things involved but I haven't checked.
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
User avatar
SpyderTL
Member
Member
Posts: 1074
Joined: Sun Sep 19, 2010 10:05 pm

Re: making 256TB user process vmem ,,,, is this possible??

Post by SpyderTL »

Found this interesting article about performance comparisons between 4KB, 2MB and 1GB page sizes, if anyone is interested.

http://www.pvk.ca/Blog/2014/02/18/how-b ... -pages-be/

But back to my original question, if you were going to give applications a 256 TB address space, does that mean that each application would need over 500 GB of page tables? If so, I guess that makes 4KB page tables impossible.

We need a list of all of the different page directory formats and their maximum address space. Is that already in the wiki somewhere?

Just running the numbers, it looks like:

4KB = 4GB
4KB + PAE = 4GB?
PSE (4MB) = 4TB?
PSE + PAE (2MB) = 2TB?
1GB = 1PB?

While larger page table sizes allow you to define "higher" page addresses, you are still limited to 1,048,576 total page entries, regardless of which page table format you use.

Is this correct?

I found all of the table format information on Wikipedia: http://en.wikipedia.org/wiki/Page_(computer_memory)

According to that page, these are the only page table formats available on x86 and x86-64 platforms. Itanium has several additional formats, but I'm ignoring those.

Am I missing something, or is the only way to provide an application with a real 256TB address space to use 1 GB pages (on very new hardware)?
Project: OZone
Source: GitHub
Current Task: LIB/OBJ file support
"The more they overthink the plumbing, the easier it is to stop up the drain." - Montgomery Scott
dschatz
Member
Member
Posts: 61
Joined: Wed Nov 10, 2010 10:55 pm

Re: making 256TB user process vmem ,,,, is this possible??

Post by dschatz »

Everyone seems to be missing the fact that you can fault in the address space, so you can just unmap regions and reuse the page tables to map in new regions. So I don't think supporting a large address space is a problem from this perspective.
User avatar
SpyderTL
Member
Member
Posts: 1074
Joined: Sun Sep 19, 2010 10:05 pm

Re: making 256TB user process vmem ,,,, is this possible??

Post by SpyderTL »

Does that mean that, technically, you could just have 1 4KB page, and you could just swap in the requested page and at the same time "swap" in the requested page table entry and then jump back to the faulting instruction?

I know it would be slow, but technically would it work?
Project: OZone
Source: GitHub
Current Task: LIB/OBJ file support
"The more they overthink the plumbing, the easier it is to stop up the drain." - Montgomery Scott
User avatar
iansjack
Member
Member
Posts: 4709
Joined: Sat Mar 31, 2012 3:07 am
Location: Chichester, UK

Re: making 256TB user process vmem ,,,, is this possible??

Post by iansjack »

No. At the very least you need an unchangeable page for the fault handler.
User avatar
Brendan
Member
Member
Posts: 8561
Joined: Sat Jan 15, 2005 12:00 am
Location: At his keyboard!
Contact:

Re: making 256TB user process vmem ,,,, is this possible??

Post by Brendan »

Hi,
SpyderTL wrote:Does that mean that, technically, you could just have 1 4KB page, and you could just swap in the requested page and at the same time "swap" in the requested page table entry and then jump back to the faulting instruction?

I know it would be slow, but technically would it work?
In the virtual address space; you must have:
  • An IDT with a minimum of 14 entries
  • A TSS (at least the stack related parts of a TSS)
  • A GDT with a minimum of 4 entries (excluding the "NULL" entry which can overlap something else)
  • Interrupt handlers (that may be minimal stub/s that do little more than switch to the kernel's virtual address space)
  • A (potentially tiny) stack that the interrupt handler/s can use
In theory (with severe performance implications) all of that can be crammed into a single 4 KiB page. Note: If you run applications at CPL=0 then you can do it without a TSS, but all the rest is still needed and it'd still need a minimum of a single 4 KiB page.

In addition to that; consider an instruction like "push dword [0x1234FFFF]". For this instruction to succeed (without page faults); at a minimum the code at RIP, the top of the stack, and the data at address 0x1234FFFF must all be in the virtual address space at the same time. There are other "3 memory location" instructions (e.g. "movsd") but there are no "4 memory location" instructions (that I can think of). However, all of the locations maybe be misaligned; such that the CPU needs 2 pages to fetch the entire instruction, 2 pages to access each piece of data, etc.

This means that a minimum of 7 pages (2 for code, 2 for data, 2 for user stack or data, plus one for kernel) need to be mapped into the virtual address space to guarantee that all possible instructions can be executed successfully and all exceptions can work correctly.
criny wrote:I want to make user process use full virtual memory space 256TB in x86_64 machine...
An alternative is to have "thread specific storage". For example, if you split the virtual address space into 1 GiB of "process space", 2 GiB of "thread space" and 1 GiB of "kernel space"; then a process with 131072 threads would end up having a total of "1 + 2*131072 GiB" of virtual memory (or slightly more than 256 TiB of virtual memory) and you wouldn't even need a 64-bit CPU to do that.


Cheers,

Brendan
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.
Post Reply