[haiku-gsoc] Re: Implementation Queries

  • From: Adrien Destugues <pulkomandy@xxxxxxxxxxxxx>
  • To: haiku-gsoc@xxxxxxxxxxxxx
  • Date: Tue, 27 Jun 2017 23:24:54 +0200

On Wed, Jun 28, 2017 at 02:42:50AM +0530, Vivek Roy wrote:

Hamish,

Linux's kobject used a kzalloc and if I understand everything correctly, it
doesn't have to be physically contiguous memory, right?

Contiguous memory is useful only when you are dealing with hardware. For
example if you are doing DMA transfers on it, or anything low-level that
would bypass the MMU.

Basically, if you are getting the physical address of allocated memory
for something, then it likely needs to be contiguous. If you don't, then
you don't have the problem and you can allocate memory the "normal" way.

This is so the hardware (DMA controller, graphics card, ...) can access
the memory as a single chunk. When the CPU accesses the memory, it goes
through the MMU which can hide the fact that the physical memory was
actually allocated in small chunks far apart from one another. But when
the other components of the computer access the memory, they don't go
through the MMU, so they need to deal with physical addresses. And
usually, they can't gather the data from many small chunks, they expect
a single large block of contiguous memory to operate on.

-- 
Adrien.

Other related posts: