Re: your mail

Maciej Zenczykowski
2004-02-11T01:09:47Z

On Tue, 10 Feb 2004, Bloch, Jack wrote:

> I have a system with 2GB of memory. One of my processes calls mmap to try to
> map a 100MB file into memory. This calls fails with -ENOMEM. I rebuilt the
> kernel with a few debug printk statements in mmap.c to see where the failure
> was occurring it occurred in the function arch_get_unmapped_area. the code
> is as follows:
>
> for (vma = find_vma(mm, addr); ; vma = vma->vm_next) {
> /* At this point: (!vma || addr < vma->vm_end). */
> unsigned long __heap_stack_gap;
> if (TASK_SIZE - len < addr)
> {

it's valid there's no point in searching further for an area of at least
len bytes. The user area is 0 .. TASK_SIZE-1. The addr is the address
currently being checked, the len is the requested length. if addr+len is
greater or equal to TASK_SIZE then the current addr (which is increasing
within this loop) already causes such a mapping to overflow into kernel
space (exceeds the TASK_SIZE virtual address limit). This is precisely as
expected.

I'd assume your program has fragmented memory to such a level that a
single consecutive 100 MB area is no longer free (not that hard to do,
since TASK_SIZE is 3 GB).

Cheers,
MaZe.