Merge tag 'virtio-next-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git...
[~shefty/rdma-dev.git] / mm / highmem.c
index 2a07f97..b32b70c 100644 (file)
@@ -98,8 +98,8 @@ struct page *kmap_to_page(void *vaddr)
 {
        unsigned long addr = (unsigned long)vaddr;
 
-       if (addr >= PKMAP_ADDR(0) && addr <= PKMAP_ADDR(LAST_PKMAP)) {
-               int i = (addr - PKMAP_ADDR(0)) >> PAGE_SHIFT;
+       if (addr >= PKMAP_ADDR(0) && addr < PKMAP_ADDR(LAST_PKMAP)) {
+               int i = PKMAP_NR(addr);
                return pte_page(pkmap_page_table[i]);
        }
 
@@ -138,8 +138,7 @@ static void flush_all_zero_pkmaps(void)
                 * So no dangers, even with speculative execution.
                 */
                page = pte_page(pkmap_page_table[i]);
-               pte_clear(&init_mm, (unsigned long)page_address(page),
-                         &pkmap_page_table[i]);
+               pte_clear(&init_mm, PKMAP_ADDR(i), &pkmap_page_table[i]);
 
                set_page_address(page, NULL);
                need_flush = 1;
@@ -325,11 +324,7 @@ struct page_address_map {
        struct list_head list;
 };
 
-/*
- * page_address_map freelist, allocated from page_address_maps.
- */
-static struct list_head page_address_pool;     /* freelist */
-static spinlock_t pool_lock;                   /* protects page_address_pool */
+static struct page_address_map page_address_maps[LAST_PKMAP];
 
 /*
  * Hash table bucket
@@ -394,14 +389,7 @@ void set_page_address(struct page *page, void *virtual)
 
        pas = page_slot(page);
        if (virtual) {          /* Add */
-               BUG_ON(list_empty(&page_address_pool));
-
-               spin_lock_irqsave(&pool_lock, flags);
-               pam = list_entry(page_address_pool.next,
-                               struct page_address_map, list);
-               list_del(&pam->list);
-               spin_unlock_irqrestore(&pool_lock, flags);
-
+               pam = &page_address_maps[PKMAP_NR((unsigned long)virtual)];
                pam->page = page;
                pam->virtual = virtual;
 
@@ -414,9 +402,6 @@ void set_page_address(struct page *page, void *virtual)
                        if (pam->page == page) {
                                list_del(&pam->list);
                                spin_unlock_irqrestore(&pas->lock, flags);
-                               spin_lock_irqsave(&pool_lock, flags);
-                               list_add_tail(&pam->list, &page_address_pool);
-                               spin_unlock_irqrestore(&pool_lock, flags);
                                goto done;
                        }
                }
@@ -426,20 +411,14 @@ done:
        return;
 }
 
-static struct page_address_map page_address_maps[LAST_PKMAP];
-
 void __init page_address_init(void)
 {
        int i;
 
-       INIT_LIST_HEAD(&page_address_pool);
-       for (i = 0; i < ARRAY_SIZE(page_address_maps); i++)
-               list_add(&page_address_maps[i].list, &page_address_pool);
        for (i = 0; i < ARRAY_SIZE(page_address_htable); i++) {
                INIT_LIST_HEAD(&page_address_htable[i].lh);
                spin_lock_init(&page_address_htable[i].lock);
        }
-       spin_lock_init(&pool_lock);
 }
 
 #endif /* defined(CONFIG_HIGHMEM) && !defined(WANT_PAGE_VIRTUAL) */