[patch 2/2] x86,pat Convert memtype_lock into an rw_lock.
From: holt
Date: Mon Mar 15 2010 - 09:21:20 EST
Convert the memtype_lock from a spin_lock to an rw_lock. The first
version of my patch had this and it did improve performance for fault
in times. The atomic page flags patch (first in the series) improves
things much greater for ram pages. This patch is to help the other pages.
To: Ingo Molnar <mingo@xxxxxxxxxx>
To: H. Peter Anvin <hpa@xxxxxxxxx>
To: Thomas Gleixner <tglx@xxxxxxxxxxxxx>
Signed-off-by: Robin Holt <holt@xxxxxxx>
Cc: Venkatesh Pallipadi <venkatesh.pallipadi@xxxxxxxxx>
Cc: Venkatesh Pallipadi <venkatesh.pallipadi@xxxxxxxxx>
Cc: Suresh Siddha <suresh.b.siddha@xxxxxxxxx>
Cc: Linux Kernel Mailing List <linux-kernel@xxxxxxxxxxxxxxx>
Cc: x86@xxxxxxxxxx
---
arch/x86/mm/pat.c | 20 ++++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)
Index: linux-next/arch/x86/mm/pat.c
===================================================================
--- linux-next.orig/arch/x86/mm/pat.c 2010-03-15 08:13:47.262469632 -0500
+++ linux-next/arch/x86/mm/pat.c 2010-03-15 08:13:47.294446141 -0500
@@ -130,7 +130,7 @@ void pat_init(void)
#undef PAT
-static DEFINE_SPINLOCK(memtype_lock); /* protects memtype accesses */
+static DEFINE_RWLOCK(memtype_lock); /* protects memtype accesses */
/*
* Does intersection of PAT memory type and MTRR memory type and returns
@@ -310,7 +310,7 @@ int reserve_memtype(u64 start, u64 end,
new->end = end;
new->type = actual_type;
- spin_lock(&memtype_lock);
+ write_lock(&memtype_lock);
err = rbt_memtype_check_insert(new, new_type);
if (err) {
@@ -318,12 +318,12 @@ int reserve_memtype(u64 start, u64 end,
"track %s, req %s\n",
start, end, cattr_name(new->type), cattr_name(req_type));
kfree(new);
- spin_unlock(&memtype_lock);
+ write_unlock(&memtype_lock);
return err;
}
- spin_unlock(&memtype_lock);
+ write_unlock(&memtype_lock);
dprintk("reserve_memtype added 0x%Lx-0x%Lx, track %s, req %s, ret %s\n",
start, end, cattr_name(new->type), cattr_name(req_type),
@@ -354,9 +354,9 @@ int free_memtype(u64 start, u64 end)
return -EINVAL;
}
- spin_lock(&memtype_lock);
+ write_lock(&memtype_lock);
err = rbt_memtype_erase(start, end);
- spin_unlock(&memtype_lock);
+ write_unlock(&memtype_lock);
if (err) {
printk(KERN_INFO "%s:%d freeing invalid memtype %Lx-%Lx\n",
@@ -400,7 +400,7 @@ static unsigned long lookup_memtype(u64
return rettype;
}
- spin_lock(&memtype_lock);
+ read_lock(&memtype_lock);
entry = rbt_memtype_lookup(paddr);
if (entry != NULL)
@@ -408,7 +408,7 @@ static unsigned long lookup_memtype(u64
else
rettype = _PAGE_CACHE_UC_MINUS;
- spin_unlock(&memtype_lock);
+ read_unlock(&memtype_lock);
return rettype;
}
@@ -748,9 +748,9 @@ static struct memtype *memtype_get_idx(l
if (!print_entry)
return NULL;
- spin_lock(&memtype_lock);
+ read_lock(&memtype_lock);
ret = rbt_memtype_copy_nth_element(print_entry, pos);
- spin_unlock(&memtype_lock);
+ read_unlock(&memtype_lock);
if (!ret) {
return print_entry;
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/