From: dahood@post.ro
To: linux-kernel@vger.kernel.org
Subject: Locking pages in memory
Date: Wed, 2 Jun 2004 11:55:47 +0300 (EEST) [thread overview]
Message-ID: <40BD9615.000002.22735@server.post.ro> (raw)
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
reply other threads:[~2004-06-02 8:56 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=40BD9615.000002.22735@server.post.ro \
--to=dahood@post.ro \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox