mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: William Lee Irwin III <wli@holomorphy.com>
To: linux-kernel@vger.kernel.org
Subject: [8/11] hugetlb: reduce inode usage in prefault_key()
Date: Tue, 12 Nov 2002 00:28:53 -0800	[thread overview]
Message-ID: <E18BWPl-0005KK-00@holomorphy> (raw)

This expands out prefault_key() into its hugetlb_prefault() component, but
substitutes stubs to abstract out inode access.

 hugetlbpage.c |   48 +++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 47 insertions(+), 1 deletion(-)


diff -urpN htlb-2.5.47-7/arch/i386/mm/hugetlbpage.c htlb-2.5.47-8/arch/i386/mm/hugetlbpage.c
--- htlb-2.5.47-7/arch/i386/mm/hugetlbpage.c	2002-11-11 22:21:49.000000000 -0800
+++ htlb-2.5.47-8/arch/i386/mm/hugetlbpage.c	2002-11-11 22:32:00.000000000 -0800
@@ -371,9 +371,55 @@ static int check_size_prot(struct inode 
 	return 0;
 }
 
+struct page *key_find_page(struct hugetlb_key *key, unsigned long index)
+{
+	return find_get_page(key->in->i_mapping, index);
+}
+
+void key_add_page(struct page *page, struct hugetlb_key *key, unsigned long index)
+{
+	add_to_page_cache(page, key->in->i_mapping, index);
+}
+
 static int prefault_key(struct hugetlb_key *key, struct vm_area_struct *vma)
 {
-	return hugetlb_prefault(key->in->i_mapping, 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 = key_find_page(key, idx);
+		if (!page) {
+			page = alloc_hugetlb_page();
+			if (!page) {
+				ret = -ENOMEM;
+				goto out;
+			}
+			key_add_page(page, key, idx);
+			unlock_page(page);
+		}
+		set_huge_pte(mm, vma, page, pte, vma->vm_flags & VM_WRITE);
+	}
+out:
+	spin_unlock(&mm->page_table_lock);
+	return ret;
 }
 
 static int alloc_shared_hugetlb_pages(int key, unsigned long addr, unsigned long len, int prot, int flag)

                 reply	other threads:[~2002-11-12  8:24 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=E18BWPl-0005KK-00@holomorphy \
    --to=wli@holomorphy.com \
    --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

all inboxes | Powered by JetHome®