]> git.karo-electronics.de Git - karo-tx-linux.git/blobdiff - include/linux/slub_def.h
net: Fix build failure due to lockdep_sock_is_held().
[karo-tx-linux.git] / include / linux / slub_def.h
index ac5143f95ee665106a5aaccfad0447d36d44ed41..665cd0cd18b8b1f3d9933dcda96bd5624e7c0a3b 100644 (file)
@@ -130,4 +130,15 @@ static inline void *virt_to_obj(struct kmem_cache *s,
 void object_err(struct kmem_cache *s, struct page *page,
                u8 *object, char *reason);
 
+static inline void *nearest_obj(struct kmem_cache *cache, struct page *page,
+                               void *x) {
+       void *object = x - (x - page_address(page)) % cache->size;
+       void *last_object = page_address(page) +
+               (page->objects - 1) * cache->size;
+       if (unlikely(object > last_object))
+               return last_object;
+       else
+               return object;
+}
+
 #endif /* _LINUX_SLUB_DEF_H */