lkml.org 
[lkml]   [2010]   [Mar]   [15]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject[patch 2/2] x86,pat Convert memtype_lock into an rw_lock.

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@redhat.com>
To: H. Peter Anvin <hpa@zytor.com>
To: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Robin Holt <holt@sgi.com>
Cc: Venkatesh Pallipadi <venkatesh.pallipadi@intel.com>
Cc: Venkatesh Pallipadi <venkatesh.pallipadi@gmail.com>
Cc: Suresh Siddha <suresh.b.siddha@intel.com>
Cc: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Cc: x86@kernel.org

---

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;


\
 
 \ /
  Last update: 2010-03-15 14:23    [W:0.114 / U:0.344 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site