mm, pagevec: rename pagevec drained field
[sfrench/cifs-2.6.git] / mm / zsmalloc.c
index 308acb9d814b68d006775cb396479c2f328d9865..685049a9048d8e9f8b53041cba43b96317b112fa 100644 (file)
@@ -551,20 +551,23 @@ static int get_size_class_index(int size)
        return min_t(int, ZS_SIZE_CLASSES - 1, idx);
 }
 
+/* type can be of enum type zs_stat_type or fullness_group */
 static inline void zs_stat_inc(struct size_class *class,
-                               enum zs_stat_type type, unsigned long cnt)
+                               int type, unsigned long cnt)
 {
        class->stats.objs[type] += cnt;
 }
 
+/* type can be of enum type zs_stat_type or fullness_group */
 static inline void zs_stat_dec(struct size_class *class,
-                               enum zs_stat_type type, unsigned long cnt)
+                               int type, unsigned long cnt)
 {
        class->stats.objs[type] -= cnt;
 }
 
+/* type can be of enum type zs_stat_type or fullness_group */
 static inline unsigned long zs_stat_get(struct size_class *class,
-                               enum zs_stat_type type)
+                               int type)
 {
        return class->stats.objs[type];
 }
@@ -1346,7 +1349,7 @@ void *zs_map_object(struct zs_pool *pool, unsigned long handle,
         * pools/users, we can't allow mapping in interrupt context
         * because it can corrupt another users mappings.
         */
-       WARN_ON_ONCE(in_interrupt());
+       BUG_ON(in_interrupt());
 
        /* From now on, migration cannot move the object */
        pin_tag(handle);
@@ -1969,6 +1972,14 @@ int zs_page_migrate(struct address_space *mapping, struct page *newpage,
        unsigned int obj_idx;
        int ret = -EAGAIN;
 
+       /*
+        * We cannot support the _NO_COPY case here, because copy needs to
+        * happen under the zs lock, which does not work with
+        * MIGRATE_SYNC_NO_COPY workflow.
+        */
+       if (mode == MIGRATE_SYNC_NO_COPY)
+               return -EINVAL;
+
        VM_BUG_ON_PAGE(!PageMovable(page), page);
        VM_BUG_ON_PAGE(!PageIsolated(page), page);
 
@@ -1983,8 +1994,11 @@ int zs_page_migrate(struct address_space *mapping, struct page *newpage,
 
        spin_lock(&class->lock);
        if (!get_zspage_inuse(zspage)) {
-               ret = -EBUSY;
-               goto unlock_class;
+               /*
+                * Set "offset" to end of the page so that every loops
+                * skips unnecessary object scanning.
+                */
+               offset = PAGE_SIZE;
        }
 
        pos = offset;
@@ -2052,7 +2066,6 @@ unpin_objects:
                }
        }
        kunmap_atomic(s_addr);
-unlock_class:
        spin_unlock(&class->lock);
        migrate_write_unlock(zspage);