[v4,0/2] rcu: Dump memory object info if callback function is invalid

Message ID 20230802130918.1132-1-thunder.leizhen@huaweicloud.com
Headers
Series rcu: Dump memory object info if callback function is invalid |

Message

Leizhen (ThunderTown) Aug. 2, 2023, 1:09 p.m. UTC
  From: Zhen Lei <thunder.leizhen@huawei.com>

v3 --> v4:
1. Remove kmem_valid_obj() and convert kmem_dump_obj() to work the same way
   as vmalloc_dump_obj().
2. In kernel/rcu/rcu.h
-#include <linux/mm.h>
+#include <linux/slab.h>

v2 --> v3:
1. I made statistics about the source of 'rhp'. kmem_valid_obj() accounts for
   more than 97.5%, and vmalloc accounts for less than 1%. So change call
   mem_dump_obj() to call kmem_dump_obj() can meet debugging requirements and
   avoid the potential deadlock risk of vmalloc_dump_obj().
-		mem_dump_obj(rhp);
+		if (kmem_valid_obj(rhp))
+			kmem_dump_obj(rhp);

   The discussion about vmap_area_lock deadlock in v2:
   https://lkml.org/lkml/2022/11/11/493

2. Provide static inline empty functions for kmem_valid_obj() and kmem_dump_obj()
   when CONFIG_PRINTK=n.

v1 --> v2:
1. Remove condition "(unsigned long)rhp->func & 0x3", it have problems on x86.
2. Paul E. McKenney helped me update the commit message, thanks.


Zhen Lei (2):
  mm: Remove kmem_valid_obj()
  rcu: Dump memory object info if callback function is invalid

 include/linux/slab.h  |  5 +++--
 kernel/rcu/rcu.h      |  7 +++++++
 kernel/rcu/srcutiny.c |  1 +
 kernel/rcu/srcutree.c |  1 +
 kernel/rcu/tasks.h    |  1 +
 kernel/rcu/tiny.c     |  1 +
 kernel/rcu/tree.c     |  1 +
 mm/slab_common.c      | 41 +++++++++++------------------------------
 mm/util.c             |  4 +---
 9 files changed, 27 insertions(+), 35 deletions(-)