From: William Lee Irwin III <wli@holomorphy.com>
To: linux-kernel@vger.kernel.org
Subject: [12/11] hugetlb: fix lack of radix tree locking
Date: Tue, 12 Nov 2002 01:16:40 -0800 [thread overview]
Message-ID: <20021112091640.GZ22031@holomorphy.com> (raw)
This adds a spinlock to each individual key, initializes it and the
atomic counter, and uses it when manipulating the radix tree.
As pointed out by akpm.
hugetlbpage.c | 8 ++++++++
1 files changed, 8 insertions(+)
diff -urpN htlb-2.5.47-11/arch/i386/mm/hugetlbpage.c htlb-2.5.47-12/arch/i386/mm/hugetlbpage.c
--- htlb-2.5.47-11/arch/i386/mm/hugetlbpage.c 2002-11-11 23:27:18.000000000 -0800
+++ htlb-2.5.47-12/arch/i386/mm/hugetlbpage.c 2002-11-12 00:35:02.000000000 -0800
@@ -32,6 +32,7 @@ static spinlock_t htlbpage_lock = SPIN_L
struct hugetlb_key {
struct radix_tree_root tree;
atomic_t count;
+ spinlock_t lock;
int key;
int busy;
uid_t uid;
@@ -392,6 +393,7 @@ static int prefault_key(struct hugetlb_k
BUG_ON(vma->vm_end & ~HPAGE_MASK);
spin_lock(&mm->page_table_lock);
+ spin_lock(&key->lock);
for (addr = vma->vm_start; addr < vma->vm_end; addr += HPAGE_SIZE) {
unsigned long idx;
pte_t *pte = huge_pte_alloc(mm, addr);
@@ -410,6 +412,7 @@ static int prefault_key(struct hugetlb_k
if (!page) {
page = alloc_hugetlb_page();
if (!page) {
+ spin_unlock(&key->lock);
ret = -ENOMEM;
goto out;
}
@@ -418,6 +421,7 @@ static int prefault_key(struct hugetlb_k
}
set_huge_pte(mm, vma, page, pte, vma->vm_flags & VM_WRITE);
}
+ spin_unlock(&key->lock);
out:
spin_unlock(&mm->page_table_lock);
return ret;
@@ -625,6 +629,10 @@ static int __init hugetlb_init(void)
}
htlbpage_max = htlbpagemem = htlbzone_pages = i;
printk("Total HugeTLB memory allocated, %ld\n", htlbpagemem);
+ for (i = 0; i < MAX_ID; ++i) {
+ atomic_init(&htlbpagek[i].count);
+ spinlock_init(&htlbpagek[i].lock);
+ }
return 0;
}
module_init(hugetlb_init);
next reply other threads:[~2002-11-12 9:12 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-11-12 9:16 William Lee Irwin III [this message]
2002-11-12 9:31 ` [12/11] hugetlb: fix lack of radix tree locking 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=20021112091640.GZ22031@holomorphy.com \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.