mm/z3fold.c: allow __GFP_HIGHMEM in z3fold_alloc
[sfrench/cifs-2.6.git] / mm / z3fold.c
index dfcd69d08c1e9336d173657425b8017aadae5fb4..e13c6228cd70e431450cd7f736abee23e53e4d2e 100644 (file)
@@ -101,6 +101,7 @@ struct z3fold_buddy_slots {
  * @refcount:          reference count for the z3fold page
  * @work:              work_struct for page layout optimization
  * @slots:             pointer to the structure holding buddy slots
+ * @pool:              pointer to the containing pool
  * @cpu:               CPU which this page "belongs" to
  * @first_chunks:      the size of the first buddy in chunks, 0 if free
  * @middle_chunks:     the size of the middle buddy in chunks, 0 if free
@@ -114,6 +115,7 @@ struct z3fold_header {
        struct kref refcount;
        struct work_struct work;
        struct z3fold_buddy_slots *slots;
+       struct z3fold_pool *pool;
        short cpu;
        unsigned short first_chunks;
        unsigned short middle_chunks;
@@ -193,8 +195,10 @@ static void compact_page_work(struct work_struct *w);
 static inline struct z3fold_buddy_slots *alloc_slots(struct z3fold_pool *pool,
                                                        gfp_t gfp)
 {
-       struct z3fold_buddy_slots *slots = kmem_cache_alloc(pool->c_handle,
-                                                           gfp);
+       struct z3fold_buddy_slots *slots;
+
+       slots = kmem_cache_alloc(pool->c_handle,
+                                (gfp & ~(__GFP_HIGHMEM | __GFP_MOVABLE)));
 
        if (slots) {
                memset(slots->slot, 0, sizeof(slots->slot));
@@ -320,6 +324,7 @@ static struct z3fold_header *init_z3fold_page(struct page *page,
        zhdr->start_middle = 0;
        zhdr->cpu = -1;
        zhdr->slots = slots;
+       zhdr->pool = pool;
        INIT_LIST_HEAD(&zhdr->buddy);
        INIT_WORK(&zhdr->work, compact_page_work);
        return zhdr;
@@ -426,7 +431,7 @@ static enum buddy handle_to_buddy(unsigned long handle)
 
 static inline struct z3fold_pool *zhdr_to_pool(struct z3fold_header *zhdr)
 {
-       return slots_to_pool(zhdr->slots);
+       return zhdr->pool;
 }
 
 static void __release_z3fold_page(struct z3fold_header *zhdr, bool locked)
@@ -850,7 +855,7 @@ static int z3fold_alloc(struct z3fold_pool *pool, size_t size, gfp_t gfp,
        enum buddy bud;
        bool can_sleep = gfpflags_allow_blocking(gfp);
 
-       if (!size || (gfp & __GFP_HIGHMEM))
+       if (!size)
                return -EINVAL;
 
        if (size > PAGE_SIZE)