net: dsa: mv88e6060: use the correct InitReady bit
[firefly-linux-kernel-4.4.55.git] / mm / zsmalloc.c
index a8ff24a296931b660c36a51ca6ec30702bb5dce3..9f15bdd9163c2360edf2e070023b6099b683a85c 100644 (file)
@@ -16,7 +16,7 @@
  * struct page(s) to form a zspage.
  *
  * Usage of struct page fields:
- *     page->first_page: points to the first component (0-order) page
+ *     page->private: points to the first component (0-order) page
  *     page->index (union with page->freelist): offset of the first object
  *             starting in this page. For the first page, this is
  *             always 0, so we use this field (aka freelist) to point
@@ -26,8 +26,7 @@
  *
  *     For _first_ page only:
  *
- *     page->private (union with page->first_page): refers to the
- *             component page after the first page
+ *     page->private: refers to the component page after the first page
  *             If the page is first_page for huge object, it stores handle.
  *             Look at size_class->huge.
  *     page->freelist: points to the first free object in zspage.
@@ -167,9 +166,14 @@ enum zs_stat_type {
        OBJ_USED,
        CLASS_ALMOST_FULL,
        CLASS_ALMOST_EMPTY,
-       NR_ZS_STAT_TYPE,
 };
 
+#ifdef CONFIG_ZSMALLOC_STAT
+#define NR_ZS_STAT_TYPE        (CLASS_ALMOST_EMPTY + 1)
+#else
+#define NR_ZS_STAT_TYPE        (OBJ_USED + 1)
+#endif
+
 struct zs_size_stat {
        unsigned long objs[NR_ZS_STAT_TYPE];
 };
@@ -448,19 +452,23 @@ static int get_size_class_index(int size)
 static inline void zs_stat_inc(struct size_class *class,
                                enum zs_stat_type type, unsigned long cnt)
 {
-       class->stats.objs[type] += cnt;
+       if (type < NR_ZS_STAT_TYPE)
+               class->stats.objs[type] += cnt;
 }
 
 static inline void zs_stat_dec(struct size_class *class,
                                enum zs_stat_type type, unsigned long cnt)
 {
-       class->stats.objs[type] -= cnt;
+       if (type < NR_ZS_STAT_TYPE)
+               class->stats.objs[type] -= cnt;
 }
 
 static inline unsigned long zs_stat_get(struct size_class *class,
                                enum zs_stat_type type)
 {
-       return class->stats.objs[type];
+       if (type < NR_ZS_STAT_TYPE)
+               return class->stats.objs[type];
+       return 0;
 }
 
 #ifdef CONFIG_ZSMALLOC_STAT
@@ -765,7 +773,7 @@ static struct page *get_first_page(struct page *page)
        if (is_first_page(page))
                return page;
        else
-               return page->first_page;
+               return (struct page *)page_private(page);
 }
 
 static struct page *get_next_page(struct page *page)
@@ -950,7 +958,7 @@ static struct page *alloc_zspage(struct size_class *class, gfp_t flags)
         * Allocate individual pages and link them together as:
         * 1. first page->private = first sub-page
         * 2. all sub-pages are linked together using page->lru
-        * 3. each sub-page is linked to the first page using page->first_page
+        * 3. each sub-page is linked to the first page using page->private
         *
         * For each size class, First/Head pages are linked together using
         * page->lru. Also, we set PG_private to identify the first page
@@ -975,7 +983,7 @@ static struct page *alloc_zspage(struct size_class *class, gfp_t flags)
                if (i == 1)
                        set_page_private(first_page, (unsigned long)page);
                if (i >= 1)
-                       page->first_page = first_page;
+                       set_page_private(page, (unsigned long)first_page);
                if (i >= 2)
                        list_add(&page->lru, &prev_page->lru);
                if (i == class->pages_per_zspage - 1)   /* last page */