Rajat Jain | 1 Aug 2006 07:48
Picon

Why "high memory" in x86?

Hi list,

I recently read that the concept of "High Memory" was introduced
because certain architectures are capable of physically addressing
larger amounts of memory than they can virtually address (physical
address space > virtual address space). I also read that nowadays
"high Memory" exists only in x86.

1) Why is virtual memory > 896 MB on x86 designated as high memory?
AFAIK x86 has 4 GB of virtual address space (=physical address space?)

2) Has the "high Memory" concept got anything to do with PAE (Page
Address Extention) feature of x86?

3) Do any other architectures than x86 have the concept of high memory?

TIA,

Rajat
-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in
the body of a message to majordomo <at> vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs

panthini.pandit | 1 Aug 2006 07:44

binfmt_elf.o as loadable module in 2.4.20

Hi,
 
1. Is it safe to have binfmt_elf.o as loadable module in 2.4.x kernel?
 
    " It's almost inconceivable that you wouldn't have this executable interpreter bound into the base kernel (if for no other reason that your insmod is probably       an ELF executable). However, it is conceptually possible to leave it out of the base kernel and insert it as an LKM."
 
2. If a binfmt_elf.o is inbuilt in kernel, What should happen if i insert the same module (seperately compiled *.o) again into that kernel?
 
cat /proc/ksyms on my running system which has built in binfmt_elf.o, doesn't show symbols related to binfmt_elf.o but still it generates application coredump upon seg-fault.
I added some printks, compiled binfmt_elf.o and inserted in running kernel. After inserting the module, i can see the symbols in cat /proc/ksyms. Now when i generated application seg-fault, core dump was generated as before but I could find my printks in /var/log/messages. which indicates, that the code is flowing from there.
 
The question is if the code is flowing from binfmt_elf.o, how coredump was getting generated before i inserted it.
One possibility is:
 
As in most of the systems, binfmt_elf.o is default built inside the kernel. So running kernel was already having it and when I inserted the same module again, the symbols got overwritten. and thats why i get the printks in dmesg. But if the module is built in the kernel, why it is not showing symbols in cat /proc/ksyms?
 
3. In 2.6 kernel configuration, the same cannot be compiled as module. Can any one tell me the reason behind this?
 
Thanks & Regards,
Panthini
 
Daniel Rodrick | 1 Aug 2006 08:06
Picon

Regarding the gfp mask "GFP_NOFS"

Hi,

As mentioned in Robert Love's book on Linux kernel development:

"The mask GFP_NOFS to kmalloc specifies that the allocation can block
and can initiate disk I/O, if it must, but will not initiate a
filesystem operation. This is the flag to use in filesystem code when
you cannot start another filesystem operation."

When it came to GFP_NOIO mask that says that no Disk IO should be
initiated to free memory; I could digest that very well since Disk IO
could be initiated to swap a process to disk to free memory.

But I could not understand why and how could a filesystem request be
initiated in order to free memory (the case avoided by GFP_NOFS)?

What am I missing here?

Thanks,

Dan

--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/

Daniel Rodrick | 1 Aug 2006 08:51
Picon

Single physical memory location has multiple virtual addresses?

Hi,

Suppose I have a kernel module that dynamically allocates memory (via
kmalloc) for user space. Now my doubt is whether this chunk of
physical memory would have two virtual addresses?

- One virtual address that will be used by kernel to refer to the
memory (the address returned by kmalloc)

- One virtual address as will be seen by the user space application?

Is my understanding correct?

Thanks,

Dan
-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in
the body of a message to majordomo <at> vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs

Thomas Petazzoni | 1 Aug 2006 09:02
Gravatar

Re: Why "high memory" in x86?

Hi,

Le Tue, 1 Aug 2006 11:18:16 +0530,
"Rajat Jain" <rajat.noida.india <at> gmail.com> a écrit :

> I recently read that the concept of "High Memory" was introduced
> because certain architectures are capable of physically addressing
> larger amounts of memory than they can virtually address (physical
> address space > virtual address space). I also read that nowadays
> "high Memory" exists only in x86.
> 
> 1) Why is virtual memory > 896 MB on x86 designated as high memory?
> AFAIK x86 has 4 GB of virtual address space (=physical address space?)
> 

If you're talking about CONFIG_HIGHMEM, then no, it's not really
designed for when you have more physical memory than it's possible to
virtually access. It's because the Linux kernel decided to split all
4GB virtual address spaces into two parts: 3 GB for the application, 1
GB for the kernel. The 1 GB for the kernel is an identity mapping of
the physical memory, which allows the kernel to access very simply all
the physical memory.

However, it has the drawback that when having more than 1 GB of
physical memory, things get harder. CONFIG_HIGHMEM allows to access
more than 1 GB of physical memory. It does it by mapping temporarly
physical pages that are above 1 GB. In fact, it's not 1 GB that is
identically-mapped, but 896 MB, the rest (1 GB - 896 MB) is used for the
temporary mappings needed to access pages above 896 MB.

My explanation might be a bit confusing (it's early in the morning,
here). I'd suggest you to read « Understanding the Linux Virtual Memory
Manager »,
http://www.phptr.com/content/images/0131453483/downloads/gorman_book.pdf

> 2) Has the "high Memory" concept got anything to do with PAE (Page
> Address Extention) feature of x86?

I don't think so.

> 3) Do any other architectures than x86 have the concept of high
> memory?

64 bits architecture, no. Other 32 bits architecture, maybe, but I'm
not sure.

Sincerly,

Thomas
--

-- 
Thomas Petazzoni - thomas.petazzoni <at> enix.org
http://{thomas,sos,kos}.enix.org - http://www.toulibre.org
http://www.{livret,agenda}dulibre.org

--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/

Christophe Lucas | 1 Aug 2006 09:49

Re: Why "high memory" in x86?

Rajat Jain (rajat.noida.india <at> gmail.com) wrote:
> Hi list,
> 
> I recently read that the concept of "High Memory" was introduced
> because certain architectures are capable of physically addressing
> larger amounts of memory than they can virtually address (physical
> address space > virtual address space). I also read that nowadays
> "high Memory" exists only in x86.
> 
> 1) Why is virtual memory > 896 MB on x86 designated as high memory?
> AFAIK x86 has 4 GB of virtual address space (=physical address space?)

Perhaps I will say some mistakes, please correct me if it is.
Kernel map hardware memory addresses as identical in 3GB->4GB in address
space by means of paging. So 4GB - 3GB = 1G, if you have more than 1G, kernel
must use high memory = mapping and unmapping pages for memory above 1GB.

Sorry if it is ugly mistake ;-)

> 2) Has the "high Memory" concept got anything to do with PAE (Page
> Address Extention) feature of x86?

I don't know.

> 3) Do any other architectures than x86 have the concept of high memory?

Ditto.

Have a nice day,
--

-- 
			 - Christophe -

--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/

Parav Pandit | 1 Aug 2006 10:21
Picon
Favicon

Re: lsmod Used count

When drivers have char. or block devices than its
fine.
What about SCSI, network, USB drivers which are not
accessed via /dev interface and instead they are
access directly by diff. process and come through
different paths.

Regards,
Parav Pandit

--- Anupam Kapoor <anupam.kapoor <at> gmail.com> wrote:

> > If we can get the process id which are using it,
> than
> > also it is fine.
> what about using lsof... ?
> 
> 
> -- 
> In the beginning was the lambda, and the lambda was
> with Emacs, and
> Emacs was the lambda.
> 
> --
> Kernelnewbies: Help each other learn about the Linux
> kernel.
> Archive:      
> http://mail.nl.linux.org/kernelnewbies/
> FAQ:           http://kernelnewbies.org/faq/
> 
> 

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/

Rajendra | 1 Aug 2006 11:18

Re: Why "high memory" in x86?

The reason for the high memory is this.

   o Linux divides the address space into two parts, user and kernel.
   o Kernel gets 1 GB of address space while user gets 3GB virtual 
address space.
   o Kernel needs to access all of the  memory so ideally it needs 4 GB 
of virtual addresses.
   o But since only 1 GB (i.e. beyond 0xc000 0000) is available, so we 
call the rest as
      high memory (approx 3 GB)
   o The high memory is accessed using temp. page table entries that map 
the high memory
      areas in kernel address space.
   o The high memory region is mostly allocated to the user space programs.

hope it answers the question !

regd,
~rpm
Rajat Jain wrote:

> Hi list,
>
> I recently read that the concept of "High Memory" was introduced
> because certain architectures are capable of physically addressing
> larger amounts of memory than they can virtually address (physical
> address space > virtual address space). I also read that nowadays
> "high Memory" exists only in x86.
>
> 1) Why is virtual memory > 896 MB on x86 designated as high memory?
> AFAIK x86 has 4 GB of virtual address space (=physical address space?)
>
> 2) Has the "high Memory" concept got anything to do with PAE (Page
> Address Extention) feature of x86?
>
> 3) Do any other architectures than x86 have the concept of high memory?
>
> TIA,
>
> Rajat
> -
> To unsubscribe from this list: send the line "unsubscribe 
> linux-newbie" in
> the body of a message to majordomo <at> vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.linux-learn.org/faqs
>

-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in
the body of a message to majordomo <at> vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs

Rajendra | 1 Aug 2006 11:26

Re: Single physical memory location has multiple virtual addresses?

The address returned by kmalloc is valid in kernel only, it will be
something greater then 3GB ie (0xC000 0000). This address can not
be used by user space program, it will cause segfault.  For accessing
any memory from user space you need to create a "vma" entry of the
process so that there is a mapping of some virtual address with the
physical memory allocated by kmalloc.
In short, yes you need two set of page table entries for accessing the
memory allocated by kmalloc. The kernel entry is created by kmalloc
call itself, while the user space entry has to be created by the concerned
module.

For more info on how user programs can map arbit. mem location
see mmap() man page.

regds,
~rpm
Daniel Rodrick wrote:

> Hi,
>
> Suppose I have a kernel module that dynamically allocates memory (via
> kmalloc) for user space. Now my doubt is whether this chunk of
> physical memory would have two virtual addresses?
>
> - One virtual address that will be used by kernel to refer to the
> memory (the address returned by kmalloc)
>
> - One virtual address as will be seen by the user space application?
>
> Is my understanding correct?
>
> Thanks,
>
> Dan
> -
> To unsubscribe from this list: send the line "unsubscribe 
> linux-newbie" in
> the body of a message to majordomo <at> vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.linux-learn.org/faqs
>

-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in
the body of a message to majordomo <at> vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs

Abu M. Muttalib | 1 Aug 2006 11:39
Favicon

the /proc/meminfo statistics

Hi,

I am running the following application.

#include<stdio.h>
#include<stdlib.h>

int main()
{
	unsigned char* arr;
	system("cat /proc/meminfo");
	sleep(25);
	arr = (char *)malloc (1048576);
	system("cat /proc/meminfo");
	sleep(25);
	free(arr);
	system("cat /proc/meminfo");
	sleep(25);
}

I am getting the following meminfo statistics. As I am allocating and
freeing 1024 kb, so I should get the same information through /proc/meminfo:

MemTotal:        14296 kB
MemFree:           912 kB
Buffers:          1448 kB
Cached:           5564 kB
SwapCached:          0 kB
Active:           5480 kB
Inactive:         3664 kB
HighTotal:           0 kB
HighFree:            0 kB
LowTotal:        14296 kB
LowFree:           912 kB
SwapTotal:           0 kB
SwapFree:            0 kB
Dirty:               0 kB
Writeback:           0 kB
Mapped:           5144 kB
Slab:             1560 kB
CommitLimit:      7148 kB
Committed_AS:     6492 kB
PageTables:        188 kB
VmallocTotal:   630784 kB
VmallocUsed:    262560 kB
VmallocChunk:   366588 kB

MemTotal:        14296 kB
MemFree:           920 kB
Buffers:          1448 kB
Cached:           5564 kB
SwapCached:          0 kB
Active:           5492 kB
Inactive:         3660 kB
HighTotal:           0 kB
HighFree:            0 kB
LowTotal:        14296 kB
LowFree:           920 kB
SwapTotal:           0 kB
SwapFree:            0 kB
Dirty:               0 kB
Writeback:           0 kB
Mapped:           5152 kB
Slab:             1544 kB
CommitLimit:      7148 kB
Committed_AS:     7652 kB
PageTables:        188 kB
VmallocTotal:   630784 kB
VmallocUsed:    262560 kB
VmallocChunk:   366588 kB

MemTotal:        14296 kB
MemFree:           924 kB
Buffers:          1448 kB
Cached:           5564 kB
SwapCached:          0 kB
Active:           5488 kB
Inactive:         3660 kB
HighTotal:           0 kB
HighFree:            0 kB
LowTotal:        14296 kB
LowFree:           924 kB
SwapTotal:           0 kB
SwapFree:            0 kB
Dirty:               0 kB
Writeback:           0 kB
Mapped:           5148 kB
Slab:             1544 kB
CommitLimit:      7148 kB
Committed_AS:     6624 kB
PageTables:        188 kB
VmallocTotal:   630784 kB
VmallocUsed:    262560 kB
VmallocChunk:   366588 kB

I think that the values given in first Committed_AS and 3rd Committed_AS
should be same. But the same is not the case. Why its so?

Anticipation and regards,
Abu.

-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in
the body of a message to majordomo <at> vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs


Gmane