Merge tag 'clk-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/clk/linux
[linux-2.6-microblaze.git] / include / linux / slub_def.h
index d215378..1be0ed5 100644 (file)
@@ -8,6 +8,7 @@
  * (C) 2007 SGI, Christoph Lameter
  */
 #include <linux/kobject.h>
+#include <linux/reciprocal_div.h>
 
 enum stat_item {
        ALLOC_FASTPATH,         /* Allocation from cpu slab */
@@ -86,6 +87,7 @@ struct kmem_cache {
        unsigned long min_partial;
        unsigned int size;      /* The size of an object including metadata */
        unsigned int object_size;/* The size of an object without metadata */
+       struct reciprocal_value reciprocal_size;
        unsigned int offset;    /* Free pointer offset */
 #ifdef CONFIG_SLUB_CPU_PARTIAL
        /* Number of per cpu partial objects to keep around */
@@ -106,17 +108,7 @@ struct kmem_cache {
        struct list_head list;  /* List of slab caches */
 #ifdef CONFIG_SYSFS
        struct kobject kobj;    /* For sysfs */
-       struct work_struct kobj_remove_work;
 #endif
-#ifdef CONFIG_MEMCG
-       struct memcg_cache_params memcg_params;
-       /* For propagation, maximum size of a stored attr */
-       unsigned int max_attr_size;
-#ifdef CONFIG_SYSFS
-       struct kset *memcg_kset;
-#endif
-#endif
-
 #ifdef CONFIG_SLAB_FREELIST_HARDENED
        unsigned long random;
 #endif
@@ -182,4 +174,23 @@ static inline void *nearest_obj(struct kmem_cache *cache, struct page *page,
        return result;
 }
 
+/* Determine object index from a given position */
+static inline unsigned int __obj_to_index(const struct kmem_cache *cache,
+                                         void *addr, void *obj)
+{
+       return reciprocal_divide(kasan_reset_tag(obj) - addr,
+                                cache->reciprocal_size);
+}
+
+static inline unsigned int obj_to_index(const struct kmem_cache *cache,
+                                       const struct page *page, void *obj)
+{
+       return __obj_to_index(cache, page_address(page), obj);
+}
+
+static inline int objs_per_slab_page(const struct kmem_cache *cache,
+                                    const struct page *page)
+{
+       return page->objects;
+}
 #endif /* _LINUX_SLUB_DEF_H */