Skip to contentSkip to conversation

vm: weird behaviour when munmapping

DISCUSSION moreau francis 2 participants 2 messages Nov 17, 2006

lore
Share & tools
lore
#0 lore raw
Quoted 9 lines · Peter Zijlstra

http://lwn.net/Kernel/LDD3/

Chapter 15. Section 'Virtual Memory Areas'.

Basically; vm_ops->open() is not called on the first vma. With this munmap() you split the area in two, and it so happens the new vma is the lower one.

since I did "munmap(0x2aaae000, 1024)" I would say that the the new vma is the _upper_ one.

lower vma: 0x2aaae000 -> 0x2aaaf000
upper vma: 0x2aaaf000 -> 0x2aab2000

Francis

___________________________________________________________________________
Découvrez une nouvelle façon d'obtenir des réponses à toutes vos questions !
Profitez des connaissances, des opinions et des expériences des internautes sur Yahoo! Questions/Réponses
http://fr.answers.yahoo.com

#1 lore raw
Quoted 11 lines · moreau francis
Quoted 9 lines · Peter Zijlstra

http://lwn.net/Kernel/LDD3/

Chapter 15. Section 'Virtual Memory Areas'.

Basically; vm_ops->open() is not called on the first vma. With this munmap() you split the area in two, and it so happens the new vma is the lower one.

Quoted 5 lines

since I did "munmap(0x2aaae000, 1024)" I would say that the the new vma is the _upper_ one.

lower vma: 0x2aaae000 -> 0x2aaaf000
upper vma: 0x2aaaf000 -> 0x2aab2000

that is the remaining VMA, not the new one; we trigger this code:

	/* Does it split the last one? */
	last = find_vma(mm, end);
	if (last && end > last->vm_start) {
		int error = split_vma(mm, last, end, 1);
		if (error)
			return error;
	}

So, since its the last VMA that needs to be split (there is only one), the new VMA is constructed before the old one. Like so:

AAAAAAAAAAAAAAAAAAAAA
BBBBAAAAAAAAAAAAAAAAA

Then you proceed closing, in this case the new one: B.