Merge branch 'userns-for-v5.12' of git://git.kernel.org/pub/scm/linux/kernel/git...
[linux-2.6-microblaze.git] / mm / util.c
index 8c9b7d1..5487022 100644 (file)
--- a/mm/util.c
+++ b/mm/util.c
@@ -982,3 +982,34 @@ int __weak memcmp_pages(struct page *page1, struct page *page2)
        kunmap_atomic(addr1);
        return ret;
 }
+
+/**
+ * mem_dump_obj - Print available provenance information
+ * @object: object for which to find provenance information.
+ *
+ * This function uses pr_cont(), so that the caller is expected to have
+ * printed out whatever preamble is appropriate.  The provenance information
+ * depends on the type of object and on how much debugging is enabled.
+ * For example, for a slab-cache object, the slab name is printed, and,
+ * if available, the return address and stack trace from the allocation
+ * of that object.
+ */
+void mem_dump_obj(void *object)
+{
+       if (kmem_valid_obj(object)) {
+               kmem_dump_obj(object);
+               return;
+       }
+       if (vmalloc_dump_obj(object))
+               return;
+       if (!virt_addr_valid(object)) {
+               if (object == NULL)
+                       pr_cont(" NULL pointer.\n");
+               else if (object == ZERO_SIZE_PTR)
+                       pr_cont(" zero-size pointer.\n");
+               else
+                       pr_cont(" non-paged memory.\n");
+               return;
+       }
+       pr_cont(" non-slab/vmalloc memory.\n");
+}