From: Andrew Morton <akpm@digeo.com>
To: William Lee Irwin III <wli@holomorphy.com>
Cc: linux-mm@kvack.org
Subject: Re: hugetlbfs-2.5.39-3
Date: Sun, 29 Sep 2002 17:52:34 -0700 [thread overview]
Message-ID: <3D97A052.276A6D59@digeo.com> (raw)
In-Reply-To: <20020930003558.GO22942@holomorphy.com>
William Lee Irwin III wrote:
>
>> ..
> +int hugetlb_prefault(struct address_space *mapping, struct vm_area_struct *vma)
> +{
> + struct mm_struct *mm = current->mm;
> + unsigned long addr;
> + int ret = 0;
> +
> + BUG_ON(vma->vm_start & ~HPAGE_MASK);
> + BUG_ON(vma->vm_end & ~HPAGE_MASK);
> +
> + spin_lock(&mm->page_table_lock);
> + for (addr = vma->vm_start; addr < vma->vm_end; addr += HPAGE_SIZE) {
> + unsigned long idx;
> + pte_t *pte = huge_pte_alloc(mm, addr);
> + struct page *page;
> +
> + if (!pte) {
> + ret = -ENOMEM;
> + goto out;
> + }
> + if (!pte_none(*pte))
> + continue;
> +
> + idx = ((addr - vma->vm_start) >> HPAGE_SHIFT)
> + + (vma->vm_pgoff >> (HPAGE_SHIFT - PAGE_SHIFT));
> + page = find_get_page(mapping, idx);
> + if (!page) {
> + page = alloc_hugetlb_page();
> + if (!page) {
> + ret = -ENOMEM;
> + goto out;
> + }
> + add_to_page_cache(page, mapping, idx);
> + }
> + set_huge_pte(mm, vma, page, pte, vma->vm_flags & VM_WRITE);
> + }
> +out:
> + spin_unlock(&mm->page_table_lock);
> + return ret;
> +}
huge_pte_alloc() is a sleeping function.
When you plug that one, I'd appreciate it if you could find a way
of not taking mapping->page_lock inside mm->page_table_lock. Those
locks have "no relationship" at present (I think), and it'd be nice
to keep it that way.
But putting page_lock inside page_table_lock would be the right
ordering if it's unavoidable. page_lock is a very inner lock,
and shall become a very short-held one.
So I suggest you do the "is it there, no, allocate it, is it there
now, yes, oh gee we raced" thing.
Apart from that - nifty.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/
next prev parent reply other threads:[~2002-09-30 0:52 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-09-30 0:35 hugetlbfs-2.5.39-3 William Lee Irwin III
2002-09-30 0:52 ` Andrew Morton [this message]
2002-09-30 3:44 ` hugetlbfs-2.5.39-3 Andrew Morton
2002-09-30 21:27 ` hugetlbfs-2.5.39-5 (was Re: hugetlbfs-2.5.39-3) William Lee Irwin III
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=3D97A052.276A6D59@digeo.com \
--to=akpm@digeo.com \
--cc=linux-mm@kvack.org \
--cc=wli@holomorphy.com \
/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