Re: [PATCH] Bug in mremap

Wolfram Gloger (wmglo@dent.med.uni-muenchen.de)
20 May 1999 10:35:49 -0000


> While preparing a patch for 2.3, I happened to notice that
> mremap (if it moves the mapping changes the offset into whats mapped)!
>
> It does this with got 2.2.9 & 2.0.32.
>- new_vma->vm_offset = vma->vm_offset + (addr - vma->vm_start);

The original looks correct to me. If you remap the `complete' VMA,
(addr - vma->vm_start) will be zero and the offset will remain
unchanged. If however, you remap only the trailing part of a file
VMA, the new offset will have to be adjusted by a positive value. Am
I missing sth ?

> The fact that this hasn't shown up before amazes me. The only
> explanation I can think of this is both a linux specifc syscall
> (so doesn't get used much) and only really useful for anonymous
> pages (where the offset into the mapping doesn't matter anyway.

Yes, but note that mremap() is used quite extensively for anonymous
pages, because realloc() uses it for large reallocations (I've
verified that e.g. GNU Emacs does these quite often).

Regards,
Wolfram.

-- 
`Surf the sea, not double-u three...'
wmglo@dent.med.uni-muenchen.de

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/