From: Peter Zijlstra <a.p.zijlstra@chello.nl>
To: moreau francis <francis_moreau2000@yahoo.fr>
Cc: linux-kernel <linux-kernel@vger.kernel.org>
Subject: Re: vm: weird behaviour when munmapping
Date: Fri, 17 Nov 2006 13:41:04 +0100 [thread overview]
Message-ID: <1163767265.5968.104.camel@twins> (raw)
In-Reply-To: <20061117113124.75132.qmail@web23112.mail.ird.yahoo.com>
On Fri, 2006-11-17 at 11:31 +0000, moreau francis wrote:
> Hmm, I'm probably missing something but I don't see what. Please be
> nice even if the question is really stupid ;)
>
> I'm looking at mmap.c code and to understand it I decided to implement
> a dumb char device that implement its own foo_mmap() method. In this
> method it defined its own vma ops:
>
> static void foo_vma_open(struct vm_area_struct *vma)
> static void foo_vma_close(struct vm_area_struct *vma)
>
> A dumb application mmap the device in order to make foo_mmap() install
> the vma ops.
>
> mmap(NULL, 16384, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
>
> mmap returned 0x2aaae000 for example. Until now, foo_vma_open() and
> foo_vma_close() are not called.
>
> Now I want to unmap the first part of the previous mapping to see how
> vma ops are called. So I did:
>
> munmap(0x2aaae000, 1024);
>
> and here's what happen:
>
> foo_vma_open(vma) is called with:
> vma->vm_start = 0x2aaae000
> vma->vm_end = 0x2aaaf000
>
> foo_vma_close(vma) is called with:
> vma->vm_start = 0x2aaae000
> vma->vm_end = 0x2aaaf000
>
> However I would have expected:
>
> foo_vma_open(vma) is called with:
> vma->vm_start = 0x2aaaf000
> vma->vm_end = 0x2aaab2000
>
> foo_vma_close(vma) is called with:
> vma->vm_start = 0x2aaae000
> vma->vm_end = 0x2aaaf000
>
> Can anybody tell me why I get this behaviour ?
>
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.
prev parent reply other threads:[~2006-11-17 12:43 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-11-17 11:31 vm: weird behaviour when munmapping moreau francis
2006-11-17 12:41 ` Peter Zijlstra [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1163767265.5968.104.camel@twins \
--to=a.p.zijlstra@chello.nl \
--cc=francis_moreau2000@yahoo.fr \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox