Re: how to get a 64k DMA buffer for a user program?

Ingo Molnar (
Thu, 3 Apr 1997 02:01:17 +0200 (MET DST)

On Thu, 3 Apr 1997, Hannu Savolainen wrote:

> In practice you should implement a simple loadable device driver with just
> open, close and mmap calls. Allocate the memory in init_module() and free
> it in cleanup_module(). Freeing mmapped memory in the close routine seems
> to cause serious problems in some cases.

the clean way is to first send a SIGKILL to the process (you've got to
cache the task which mmaps), then wait for the process to exit (via
p->wait_chldexit), then continue.

The zap_page_range() done in exit() wont free the pages if you've bumped
up their pagemap reference count. (you should do that at allocation time
anyways, especially for DMA buffers, as user-space might spontaneously
unmap pages [crash, exit, accidental or malicious unmap], which frees the
pages, then you DMA into a buffer which is used by another process ...
dang ]).

you could lock the vma (to avoid mass-locking of physical pages), maybe
thats cleaner. Although vma's might get merged which might turn up other

-- mingo