The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* Locking pages in memory
@ 2004-06-02  8:55 dahood
  0 siblings, 0 replies; only message in thread
From: dahood @ 2004-06-02  8:55 UTC (permalink / raw)
  To: linux-kernel

Hi,

I'm trying to lock some pages from a mmaped user memory (say user_addr). (mmap on a file)
For this I did the following (in a kernel module):
1. with get_user I fault every page into the memory, then I get the physical address of each page.
2. I put PG_reserved and do a get_page on each page.
3. After I finish using the memory, I truncate the file used for mmap to 0, and close the file descriptor(this is done in user space).
4. In kernel space, I do set_page_count to 1, for every page, clear PG_reserved, and do put_page.

My problem is that in kernel 2.4, this works perfectly, while in 2.6, when I do put_page, I get an bad state on page, because page_mapped is not 0 (page->pte.direct != 0), which means that the page in take into account into rmap. But because the page is PG_reserved, I think it shoudn't be.

Is there is something more that I should do in kernel 2.6 if I'm using reserved pages, more than in 2.4?  

In kernel 2.4, I know that is my responsability to set the page count to 1, when I'm sure that there is no one else using the pages, and put_page to kernel. 

I tried a workaround in 2.6, by setting page->pte.direct=0, before doing the final put_page. In this way, the put_page function is happy, but when I try do large allocation in user space program, I keep getting segmentation fault, so I think that the pte.direct hack is not ok.

Thank you,
Dan

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2004-06-02  8:56 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-06-02  8:55 Locking pages in memory dahood

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox