Muli Ben-Yehuda's journal

October 25, 2004

Locking user space memory

Filed under: Uncategorized — Muli Ben-Yehuda @ 3:10 PM

A common question is “how do I lock user space memory?”. The context is usually when the memory is going to be used for DMA to or from a device.

The best way is to have user space request the memory from your driver via an mmap() on a character device files. Sometimes, however, this is not feasible. In those cases, you have two choices:

– If you have control of the user space application, use the POSIX mlock() and munlock() APIs.

_ if you only have control of the driver side, use the get_user_pages() API in the kernel. has an excellent article on get_user_pages, and common pitfalls.

Leave a Comment »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Blog at

%d bloggers like this: