flat assembler
Message board for the users of flat assembler.

Index > Main > memory defragging and the x86 IO MMU

Author
Thread Post new topic Reply to topic
gens



Joined: 18 Feb 2013
Posts: 161
gens
main memory to user MMU, as in the "normal" one, is basically a big table of page addresses, no ?
so the kernel can (and does) write in it what ever it wants and it shows in the user process

but the IO MMU (of which i see there are more kinds) can't ?

problem i'm thinking of is device DMA buffers, that have to have a flat piece of memory
popular solution it seems is to reserve a piece of memory at boot for when drivers need it

so why can't the kernel just stop a process or two, copy from the blocks of memory it needs to some other then just modify the page table to point to the other thing

if i got it right (in contrast to absolutely wrong), would there be concurrency problems ?

also on the IO MMU thing
if i have a process that maps shared memory with another process then copies its contents to a DMA'd buffer
can i just tell the (theoretical kernel) to change the table in the IO MMU to point to the other memory page ?

thx for answers
PS don't spare me, i wonder how much i understand wrong
Post 04 May 2014, 02:02
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17669
Location: In your JS exploiting you and your system
revolution
Not sure what you are asking. Are you making an OS and want to know how to handle memory paging?
Post 04 May 2014, 02:31
View user's profile Send private message Visit poster's website Reply with quote
gens



Joined: 18 Feb 2013
Posts: 161
gens
the first part is something that was brought up as a problem for gpu drivers that need large flat pieces in physical memory
in linux more specifically

the IO MMU part is for a program i'm making that gets DMA'd pages from the kernel, that are to the sound card
also in linux (alsa mmap'ed ring buffer; aka "zero-copy", that is DMA)

but i'm asking is it possible to do on "modern" x86 computers
and if so how complicated would it be
Post 04 May 2014, 02:46
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17669
Location: In your JS exploiting you and your system
revolution
gens wrote:
but i'm asking is it possible to do on "modern" x86 computers ...
Is it possible to do what? Memory paging? DMA? Asking the kernel for particular page mappings? Confused
Post 04 May 2014, 02:51
View user's profile Send private message Visit poster's website Reply with quote
gens



Joined: 18 Feb 2013
Posts: 161
gens
ye, sry
its two questions
linux is the goal, but i'm asking in general

first one is basically run time physical memory defragging
if you need a big piece of contiguous physical memory and there is none due to fragmentation
can you find a piece then check what process owns the page after it then copy that page somewhere else and change the processes page table to point to the new one
in a multicpu environment, to make it more complicated

other one is can you change the DMA... physical RAM pointer i guess while the device is running, and how hard would that be
Post 04 May 2014, 03:26
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17669
Location: In your JS exploiting you and your system
revolution
gens wrote:
i'm asking in general
gens wrote:
first one is basically run time physical memory defragging if you need a big piece of contiguous physical memory and there is none due to fragmentation can you find a piece then check what process owns the page after it then copy that page somewhere else and change the processes page table to point to the new one
Yes, it is possible. Although I'm not sure which OS kernels would support such a thing. Check your OS to see how it manages things.
gens wrote:
other one is can you change the DMA... physical RAM pointer i guess while the device is running, and how hard would that be
Yes it is possible. But it depends upon your device, its driver and its capabilities in general. And, once again, it also depends upon your OS support.

As to how difficult it would be, well, once again it depends upon many factors, but my guess would be it is not going to be easy for you unless you are very familiar with how everything is interacting.
Post 04 May 2014, 03:31
View user's profile Send private message Visit poster's website Reply with quote
gens



Joined: 18 Feb 2013
Posts: 161
gens
linux doesn't, i think kolibrios doesn't and i'm pretty sure none of the other can

would be nice thou, that a kernel can get a big DMA buffer without reserving memory at boot
in linux it would have to be in memory management (has two now, one for devices and one general) and in process scheduler and idk where else

probably not something i can do, but still interesting to me

edit:
https://lwn.net/images/pdf/LDD3/ch15.pdf
and
http://oreilly.com/catalog/linuxkernel/chapter/ch10.html
lots of reading...
Post 04 May 2014, 03:40
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.

Website powered by rwasa.