Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 109031
b: refs/heads/master
c: 80c5e73
h: refs/heads/master
i:
  109029: 93519b3
  109027: 2f1bf7f
  109023: 700dec3
v: v3
  • Loading branch information
Venki Pallipadi authored and Ingo Molnar committed Aug 20, 2008
1 parent 72a5649 commit c4f0e9d
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 3 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: c6744955d0ec0cb485c28c51eeb7185e260f6172
refs/heads/master: 80c5e73d6028e0f03ab0c70e7c4cbf98ac2e0c43
33 changes: 31 additions & 2 deletions trunk/arch/x86/mm/pat.c
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,9 @@ static int chk_conflict(struct memtype *new, struct memtype *entry,
return -EBUSY;
}

static struct memtype *cached_entry;
static u64 cached_start;

/*
* req_type typically has one of the:
* - _PAGE_CACHE_WB
Expand Down Expand Up @@ -280,26 +283,47 @@ int reserve_memtype(u64 start, u64 end, unsigned long req_type,

spin_lock(&memtype_lock);

if (cached_entry && start >= cached_start)
entry = cached_entry;
else
entry = list_entry(&memtype_list, struct memtype, nd);

/* Search for existing mapping that overlaps the current range */
where = NULL;
list_for_each_entry(entry, &memtype_list, nd) {
list_for_each_entry_continue(entry, &memtype_list, nd) {
if (end <= entry->start) {
where = entry->nd.prev;
cached_entry = list_entry(where, struct memtype, nd);
break;
} else if (start <= entry->start) { /* end > entry->start */
err = chk_conflict(new, entry, new_type);
if (!err) {
dprintk("Overlap at 0x%Lx-0x%Lx\n",
entry->start, entry->end);
where = entry->nd.prev;
cached_entry = list_entry(where,
struct memtype, nd);
}
break;
} else if (start < entry->end) { /* start > entry->start */
err = chk_conflict(new, entry, new_type);
if (!err) {
dprintk("Overlap at 0x%Lx-0x%Lx\n",
entry->start, entry->end);
where = &entry->nd;
cached_entry = list_entry(entry->nd.prev,
struct memtype, nd);

/*
* Move to right position in the linked
* list to add this new entry
*/
list_for_each_entry_continue(entry,
&memtype_list, nd) {
if (start <= entry->start) {
where = entry->nd.prev;
break;
}
}
}
break;
}
Expand All @@ -314,6 +338,8 @@ int reserve_memtype(u64 start, u64 end, unsigned long req_type,
return err;
}

cached_start = start;

if (where)
list_add(&new->nd, where);
else
Expand Down Expand Up @@ -343,6 +369,9 @@ int free_memtype(u64 start, u64 end)
spin_lock(&memtype_lock);
list_for_each_entry(entry, &memtype_list, nd) {
if (entry->start == start && entry->end == end) {
if (cached_entry == entry || cached_start == start)
cached_entry = NULL;

list_del(&entry->nd);
kfree(entry);
err = 0;
Expand Down

0 comments on commit c4f0e9d

Please sign in to comment.