* question on memory map cleanup stuff
@ 2004-10-18 22:57 Chris Friesen
2004-10-18 23:14 ` William Lee Irwin III
0 siblings, 1 reply; 5+ messages in thread
From: Chris Friesen @ 2004-10-18 22:57 UTC (permalink / raw)
To: Linux Kernel Mailing List
I've got a small feature that maps a page of kernel memory to userspace via a
syscall, then uses that page for various things.
Currently, I'm marking the page reserved, then exporting it via
remap_page_range(). This means that I need to clean up my mapping whenever the
memory map is destroyed (process death, exec(), daemonize, etc.).
It appears that I should be able to put my cleanup code in exit_mmap(). Since
the cleanup code calls do_munmap() on the address, I would want to call it
before taking mm->page_table_lock, correct?
Also, normally I would hold mm->mmap_sem before calling do_munmap(). Would I
still need this if I'm calling it from exit_mmap()? Presumably nobody else can
get at it anymore...
Thanks,
Chris
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: question on memory map cleanup stuff
2004-10-18 22:57 question on memory map cleanup stuff Chris Friesen
@ 2004-10-18 23:14 ` William Lee Irwin III
2004-10-18 23:39 ` Chris Friesen
2004-10-19 18:19 ` Chris Friesen
0 siblings, 2 replies; 5+ messages in thread
From: William Lee Irwin III @ 2004-10-18 23:14 UTC (permalink / raw)
To: Chris Friesen; +Cc: Linux Kernel Mailing List
On Mon, Oct 18, 2004 at 04:57:20PM -0600, Chris Friesen wrote:
> I've got a small feature that maps a page of kernel memory to userspace via
> a syscall, then uses that page for various things.
> Currently, I'm marking the page reserved, then exporting it via
> remap_page_range(). This means that I need to clean up my mapping whenever
> the memory map is destroyed (process death, exec(), daemonize, etc.).
> It appears that I should be able to put my cleanup code in exit_mmap().
> Since the cleanup code calls do_munmap() on the address, I would want to
> call it before taking mm->page_table_lock, correct?
> Also, normally I would hold mm->mmap_sem before calling do_munmap(). Would
> I still need this if I'm calling it from exit_mmap()? Presumably nobody
> else can get at it anymore...
vma->vm_ops->close() often suffices for such without disturbing the core.
-- wli
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: question on memory map cleanup stuff
2004-10-18 23:14 ` William Lee Irwin III
@ 2004-10-18 23:39 ` Chris Friesen
2004-10-19 18:19 ` Chris Friesen
1 sibling, 0 replies; 5+ messages in thread
From: Chris Friesen @ 2004-10-18 23:39 UTC (permalink / raw)
To: William Lee Irwin III; +Cc: Linux Kernel Mailing List
William Lee Irwin III wrote:
> vma->vm_ops->close() often suffices for such without disturbing the core.
Ah. That looks promising.
Thanks.
Chris
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: question on memory map cleanup stuff
2004-10-18 23:14 ` William Lee Irwin III
2004-10-18 23:39 ` Chris Friesen
@ 2004-10-19 18:19 ` Chris Friesen
2004-10-19 18:24 ` William Lee Irwin III
1 sibling, 1 reply; 5+ messages in thread
From: Chris Friesen @ 2004-10-19 18:19 UTC (permalink / raw)
To: William Lee Irwin III; +Cc: Linux Kernel Mailing List
William Lee Irwin III wrote:
> On Mon, Oct 18, 2004 at 04:57:20PM -0600, Chris Friesen wrote:
>
>>I've got a small feature that maps a page of kernel memory to userspace via
>>a syscall, then uses that page for various things.
>>Currently, I'm marking the page reserved, then exporting it via
>>remap_page_range(). This means that I need to clean up my mapping whenever
>>the memory map is destroyed (process death, exec(), daemonize, etc.).
> vma->vm_ops->close() often suffices for such without disturbing the core.
I'm running into a problem.
At the time of close(), I need to figure out which page to unreserve and free.
However, when I call
follow_page(vma->vm_mm, vma->vm_start, 0);
it returns zero. How do I go from vma to page?
Chris
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: question on memory map cleanup stuff
2004-10-19 18:19 ` Chris Friesen
@ 2004-10-19 18:24 ` William Lee Irwin III
0 siblings, 0 replies; 5+ messages in thread
From: William Lee Irwin III @ 2004-10-19 18:24 UTC (permalink / raw)
To: Chris Friesen; +Cc: Linux Kernel Mailing List
William Lee Irwin III wrote:
>> vma->vm_ops->close() often suffices for such without disturbing the core.
On Tue, Oct 19, 2004 at 12:19:00PM -0600, Chris Friesen wrote:
> I'm running into a problem.
> At the time of close(), I need to figure out which page to unreserve and
> free. However, when I call
> follow_page(vma->vm_mm, vma->vm_start, 0);
> it returns zero. How do I go from vma to page?
You generally need to keep track of this yourself, as during ->close()
the pagetables have already been destroyed. linear_page_index() can
tell you the offset into the object the vma maps, but ultimately, you
have to track the pages yourself. vma->vm_private_data can be used to
attach various accounting structures to the vma.
-- wli
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2004-10-19 19:04 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-10-18 22:57 question on memory map cleanup stuff Chris Friesen
2004-10-18 23:14 ` William Lee Irwin III
2004-10-18 23:39 ` Chris Friesen
2004-10-19 18:19 ` Chris Friesen
2004-10-19 18:24 ` William Lee Irwin III
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).