Presuming that we lookup the memtype of an address far more often than we modify the PAT ranges, favour the reader.
Signed-off-by: Chris Wilson <ch...@chris-wilson.co.uk> --- arch/x86/mm/pat.c | 20 ++++++++++---------- 1 files changed, 10 insertions(+), 10 deletions(-) diff --git a/arch/x86/mm/pat.c b/arch/x86/mm/pat.c index 18d4aa9..8cc67e5 100644 --- a/arch/x86/mm/pat.c +++ b/arch/x86/mm/pat.c @@ -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, unsigned long req_type, 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, unsigned long req_type, "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), @@ -355,9 +355,9 @@ int free_memtype(u64 start, u64 end) return -EINVAL; } - spin_lock(&memtype_lock); + write_lock(&memtype_lock); entry = rbt_memtype_erase(start, end); - spin_unlock(&memtype_lock); + write_unlock(&memtype_lock); if (!entry) { printk(KERN_INFO "%s:%d freeing invalid memtype %Lx-%Lx\n", @@ -390,13 +390,13 @@ static unsigned long lookup_memtype(u64 paddr) if (x86_platform.is_untracked_pat_range(paddr, paddr + PAGE_SIZE)) return _PAGE_CACHE_WB; - spin_lock(&memtype_lock); + read_lock(&memtype_lock); entry = rbt_memtype_lookup(paddr); if (entry != NULL) rettype = entry->type; - spin_unlock(&memtype_lock); + read_unlock(&memtype_lock); if (rettype != -1) return rettype; @@ -754,9 +754,9 @@ static struct memtype *memtype_get_idx(loff_t pos) 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; -- 1.7.5.4 _______________________________________________ Intel-gfx mailing list Intel-gfx@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/intel-gfx