mm/util.c: reduce mem_dump_obj() object size
authorJoe Perches <joe@perches.com>
Wed, 5 May 2021 01:38:32 +0000 (18:38 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Wed, 5 May 2021 18:27:25 +0000 (11:27 -0700)
Simplify the code by using a temporary and reduce the object size by
using a single call to pr_cont().  Reverse a test and unindent a block
too.

$ size mm/util.o* (defconfig x86-64)
   text    data     bss     dec     hex filename
   7419     372      40    7831    1e97 mm/util.o.new
   7477     372      40    7889    1ed1 mm/util.o.old

Link: https://lkml.kernel.org/r/a6e105886338f68afd35f7a13d73bcf06b0cc732.camel@perches.com
Signed-off-by: Joe Perches <joe@perches.com>
Reviewed-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
mm/util.c

index 083c5c417cfc79938eac2d6204b96bcb1b5b28c1..972e7a0cda5eacb76d547c63ed3ee20fd490623b 100644 (file)
--- a/mm/util.c
+++ b/mm/util.c
@@ -987,22 +987,26 @@ int __weak memcmp_pages(struct page *page1, struct page *page2)
  */
 void mem_dump_obj(void *object)
 {
+       const char *type;
+
        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");
+
+       if (virt_addr_valid(object))
+               type = "non-slab/vmalloc memory";
+       else if (object == NULL)
+               type = "NULL pointer";
+       else if (object == ZERO_SIZE_PTR)
+               type = "zero-size pointer";
+       else
+               type = "non-paged memory";
+
+       pr_cont(" %s\n", type);
 }
 EXPORT_SYMBOL_GPL(mem_dump_obj);
 #endif