From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S964897Ab0CONVQ (ORCPT ); Mon, 15 Mar 2010 09:21:16 -0400 Received: from relay3.sgi.com ([192.48.152.1]:40590 "EHLO relay.sgi.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S964876Ab0CONVN (ORCPT ); Mon, 15 Mar 2010 09:21:13 -0400 Message-Id: <20100315132110.834268286@gulag1.americas.sgi.com> User-Agent: quilt/0.47-1 Date: Mon, 15 Mar 2010 08:21:05 -0500 From: holt@sgi.com To: Ingo Molnar , "H. Peter Anvin" , Thomas Gleixner Cc: Venkatesh Pallipadi , Venkatesh Pallipadi , Suresh Siddha , Linux Kernel Mailing List , x86@kernel.org Subject: [patch 2/2] x86,pat Convert memtype_lock into an rw_lock. References: <20100315132103.228021253@gulag1.americas.sgi.com> Content-Disposition: inline; filename=memtype_rwlock_V3 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 To: H. Peter Anvin To: Thomas Gleixner Signed-off-by: Robin Holt Cc: Venkatesh Pallipadi Cc: Venkatesh Pallipadi Cc: Suresh Siddha Cc: Linux Kernel Mailing List 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;