Re: question on memory map cleanup stuff

William Lee Irwin III
2004-10-18T23:14:40Z

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