LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   about memory? (https://www.linuxquestions.org/questions/programming-9/about-memory-152873/)

eshwar_ind 03-02-2004 11:50 PM

about memory?
 
Hi!
Can any body explain me about kernel memory zones?
What is high memory, lowmemory, and DMA?
On what basis we decide which part of the memory belongs to which Zone?
Which among those doesnt belong virtual memory?
thanks in advance
please reply me
bye,
Eshwar:Pengy:

cjcuk 03-03-2004 01:25 AM

The numbers are offsets from zero, not sizes.

ZONE_DMA: pages below 16MB ( exclusive )
ZONE_NORMAL: pages above 16MB ( inclusive ) and below 896MB ( exclusive )
ZONE_HIGH: pages above 896MB ( inclusive )

``The ZONE_DMA and ZONE_NORMAL zones include the "normal" pages of memory that be directly accessed by the kernel throught the linear mapping in the fourth gigabyte of the linear address space. [ ... ] the ZONE_HIGHMEM zone includes page of memory that cannot be directly accessed by the kernel through the linear mapping in the fourth gigabyte ...'' - `Understanding The Linux Kernel', 2nd Edition

What exactly do you want explaining about this, and what for?

eshwar_ind 03-03-2004 01:35 AM

I am studying the book Device drivers by Rubini. I havent understood about those memory zones.

Directly mapping means not going through page tables right?

What is this fourth gigabyte? you have only explained me about 896MBs
which is lessthan 1 GB.
Still i havent understood. Could you please give little more explanation?
Thanks .
bye
Eshwar

cjcuk 03-03-2004 02:07 AM

Sorry, I forgot to mention that my knowledge ( and the book I was quoting from ) is heavily towards IA32 -- so I am not sure if all of this is applicable elsewhere.

The 4th GB is 0xc0000000 and up. This is the part of the process address space that can only be accessed when in kernel mode.

To be honest with you, we could spend a very long time talking about this -- it is a very extensive topic. So, you either need to narrow your question down ( you can give a reference to something in the Rubini book if you want, I have a copy somewhere around here ) or you really need to find good reference on this ( as an example of how extensive memory management is, the book I referred to is 700 pages and approximately one third of it relates to memory management -- and then it is sometimes IA32-centric ). If you can afford it, I would recommend the book, as an entry point more than anything else.

eshwar_ind 03-03-2004 03:26 AM

Thank you very much Mr. Cjcuk !
If you have enough time, Just give me a general idea about those memory zones.
What are those memory zones, their purpose and how they vary from each other ( in Linux context and on any bus architecture) ?

I got strucked up while reading that "getting hold of memory" and "hardware management" chapters from that rubini book.

If i could get a general idea of those memory zones I can
continue studying that book, otherwise i cant.

I know what is DMA. But havent heard that there is a special memory zone for it.
Give me the details about that book(memory management) if possible i will buy it.
I might be distrubing you . Sorry.
Thanks once again.

cjcuk 03-03-2004 04:54 AM

Do not worry about disturbing me, if I did not have the time or inclination I would not reply.

The book is, ``Understanding the Linux Kernel'', 2nd Edition. It is written by D Bovet and M Cesati, and published by O'Reilly. The ISBN is 0-596-00213-0. It is not cheap, but is not really expensive. I think it is quite good.

Here is a brief explanation of how the zones differ...

Initially, the DMA in ZONE_DMA is not a general case of the acronym occuring. It is referring to the DMA performed in the usage of ISA. This memory, thus, has to refer to specific points in the physical locations.

The ZONE_HIGHMEM refers to memory that is not directly mapped ( the pages are not mapped into the 4th GB during kernel page table initialisation ), mainly due to limitations in the architectures ability to directly address that memory.

ZONE_NORMAL is pretty much the rest.

Is that enough for you to continue reading?

eshwar_ind 03-03-2004 05:25 AM

thanks Mr.cjcuk
Can you elobarate the term not directly mapped?
The addresses for NORMAL and DMA zones are mapped through pagetables right? or wrong? ( or pagetables also contain the same address as logical or virtual address)
just this is enough.
Actually i have a bad habit that if i dont understand a single sentence, I get the feeling of not understanding whole chapter.

cjcuk 03-03-2004 06:31 AM

To explain what I mean by not directly mapped. The mappings all occur in the 4th GB. This means you can only have 1GB of mappings, and 128MB disappears in overhead and other junk -- hence the 896MB mapped, and the lack of ability to map the rest. The directly mapped zones ( ZONE_DMA and ZONE_NORMAL ) have mappings here. The page tables are then coping with the translation of requests inside this 1GB mapping to the physical addresses.

Is that clear enough? Feel free to ask if you are still unsure. I do not want to write an essay on it, but I am not sure if I am being too brief.

eshwar_ind 03-03-2004 06:39 AM

Then where the ZONE_HiGH is mapped?
Does CPU address it directly?

cjcuk 03-03-2004 06:59 AM

Well, the kernel dealing with ZONE_HIGHMEM is where the problems start. This is really the reason that we deal in pages so much. At the point when you want to map anything inside ZONE_HIGHMEM, you can no longer be given a linear address and so have to be given a page frame descriptor. There are three methods used for then working with these page frames:

1) Permanent mappings: the mappings are added to a special page table
2) Temporary mappings: there a small set of spaces for high memory mappings available, use one
3) The mappings done for non-contiguous areas are capable of doing it. This is a more complex subject. If you need the in-depth knowledge, I can continue -- but, it gets fairly long from here on.

eshwar_ind 03-03-2004 07:09 AM

What is that pageframe descriptor?

cjcuk 03-03-2004 07:20 AM

Quote:

Originally posted by eshwar_ind
What is that pageframe descriptor?
$(LINUXSRCDIR)/include/linux/mm.h: find `struct page'. Information regarding it starts at line 170 in my 2.4.25 sources.

eshwar_ind 03-03-2004 07:56 AM

I understood a little.
there in that structure we have last field as
void * virtual.
if system is configured with high memory we have that element.
we have "virtual" value null for NORMAL AND DMA PAGES. for HIGH MEMORY we have a valid value right. This is what differentiates between pages of High and other memory Zones right?
I want to ask you so many doubts regarding that but i am afraid i asked somany.
First i will try to understand about the elements of that structure. There after i will ask you my doubts.
Thank you very much.
You are simply superb.
Thanks again.

cjcuk 03-03-2004 08:02 AM

The virtual member of the structure is actually, very nearly, the opposite of what you said there.

eshwar_ind 03-03-2004 08:04 AM

That means null for High memory and some valid value for NORMAL and DMA ZONES


All times are GMT -5. The time now is 08:05 PM.