question on memory map cleanup stuff

Chris Friesen
2004-10-18T23:02:15Z

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