Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 43043
b: refs/heads/master
c: ea7322d
h: refs/heads/master
i:
  43041: 1487917
  43039: 1545cce
v: v3
  • Loading branch information
Andi Kleen authored and Andi Kleen committed Dec 7, 2006
1 parent f789088 commit f18f1ff
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 27 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: 74b47a7844501445d41d704fe7c626f4b1819508
refs/heads/master: ea7322decb974a4a3e804f96a0201e893ff88ce3
58 changes: 32 additions & 26 deletions trunk/arch/x86_64/mm/pageattr.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,34 +61,40 @@ static struct page *split_large_page(unsigned long address, pgprot_t prot,
return base;
}


static void flush_kernel_map(void *address)
static void cache_flush_page(void *adr)
{
if (0 && address && cpu_has_clflush) {
/* is this worth it? */
int i;
for (i = 0; i < PAGE_SIZE; i += boot_cpu_data.x86_clflush_size)
asm volatile("clflush (%0)" :: "r" (address + i));
} else
asm volatile("wbinvd":::"memory");
if (address)
__flush_tlb_one(address);
else
__flush_tlb_all();
int i;
for (i = 0; i < PAGE_SIZE; i += boot_cpu_data.x86_clflush_size)
asm volatile("clflush (%0)" :: "r" (adr + i));
}

static void flush_kernel_map(void *arg)
{
struct list_head *l = (struct list_head *)arg;
struct page *pg;

/* When clflush is available always use it because it is
much cheaper than WBINVD */
if (!cpu_has_clflush)
asm volatile("wbinvd" ::: "memory");
list_for_each_entry(pg, l, lru) {
void *adr = page_address(pg);
if (cpu_has_clflush)
cache_flush_page(adr);
__flush_tlb_one(adr);
}
}

static inline void flush_map(unsigned long address)
static inline void flush_map(struct list_head *l)
{
on_each_cpu(flush_kernel_map, (void *)address, 1, 1);
on_each_cpu(flush_kernel_map, l, 1, 1);
}

static struct page *deferred_pages; /* protected by init_mm.mmap_sem */
static LIST_HEAD(deferred_pages); /* protected by init_mm.mmap_sem */

static inline void save_page(struct page *fpage)
{
fpage->lru.next = (struct list_head *)deferred_pages;
deferred_pages = fpage;
list_add(&fpage->lru, &deferred_pages);
}

/*
Expand Down Expand Up @@ -207,18 +213,18 @@ int change_page_attr(struct page *page, int numpages, pgprot_t prot)

void global_flush_tlb(void)
{
struct page *dpage;
struct page *pg, *next;
struct list_head l;

down_read(&init_mm.mmap_sem);
dpage = xchg(&deferred_pages, NULL);
list_replace_init(&deferred_pages, &l);
up_read(&init_mm.mmap_sem);

flush_map((dpage && !dpage->lru.next) ? (unsigned long)page_address(dpage) : 0);
while (dpage) {
struct page *tmp = dpage;
dpage = (struct page *)dpage->lru.next;
ClearPagePrivate(tmp);
__free_page(tmp);
flush_map(&l);

list_for_each_entry_safe(pg, next, &l, lru) {
ClearPagePrivate(pg);
__free_page(pg);
}
}

Expand Down

0 comments on commit f18f1ff

Please sign in to comment.