Skip to contentSkip to conversation

Show slab memory usage on OOM and SysRq-M (v2)

PATCH In review Pavel Emelianov 3 participants 6 messages Apr 17, 2007 – Apr 18, 2007

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Show slab memory usage on OOM and SysRq-M (v2)

The out_of_memory() function and SysRq-M handler call show_mem() to show the current memory usage state.

This is also helpful to see which slabs are the largest in the system.

Thanks Pekka for good idea of how to make it better.

The nr_pages is stored on kmem_list3 because:

1. as Eric pointed out, we do not want to defeat NUMA optimizations;
2. we do not need for additional LOCK-ed operation on altering this field - l3->list_lock is already taken where needed.

---

drivers/char/sysrq.c +1 -0
index 39cc318..7c27647 100644
@@ -234,6 +234,7 @@ static struct sysrq_key_op sysrq_showsta
 static void sysrq_handle_showmem(int key, struct tty_struct *tty)
 {
 	show_mem();
+	show_slabs();
 }
 static struct sysrq_key_op sysrq_showmem_op = {
 	.handler	= sysrq_handle_showmem,
include/linux/slab.h +6 -0
index 67425c2..1e2919d 100644
@@ -170,6 +170,12 @@ static inline void *kzalloc(size_t size,
 }
 #endif
 
+#ifdef CONFIG_SLAB
+extern void show_slabs(void);
+#else
+#define show_slabs(void)	do { } while (0)
+#endif
+
 #ifndef CONFIG_NUMA
 static inline void *kmalloc_node(size_t size, gfp_t flags, int node)
 {
mm/oom_kill.c +1 -0
index 4bdc7c0..aefdd06 100644
@@ -409,6 +409,7 @@ void out_of_memory(struct zonelist *zone
 			current->comm, gfp_mask, order, current->oomkilladj);
 		dump_stack();
 		show_mem();
+		show_slabs();
 	}
 
 	cpuset_lock();
mm/slab.c +76 -0

137 lines not on this page · raw message

#1 lore raw
Quoted 1 line · Pavel Emelianov

+#define SHOW_TOP_SLABS 10

Real minor nit on this one: SHOW_TOP_SLABS sounds like a bool. "Should I show the top slabs?"

This might be a bit more clear:

#define TOP_NR_SLABS_TO_SHOW 10

or

#define NR_SLABS_TO_SHOW 10

-- Dave

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#2 lore raw
Quoted 1 line · Pavel Emelianov
Quoted 1 line

+#define SHOW_TOP_SLABS 10

Quoted 10 lines · Dave Hansen

Real minor nit on this one: SHOW_TOP_SLABS sounds like a bool. "Should I show the top slabs?"

This might be a bit more clear:

#define TOP_NR_SLABS_TO_SHOW 10

or

#define NR_SLABS_TO_SHOW 10

Yes. Looks much better.

Pekka

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#3 lore raw
In reply to Dave Hansen
Quoted 6 lines · Dave Hansen
Quoted 1 line · Pavel Emelianov

+#define SHOW_TOP_SLABS 10

Real minor nit on this one: SHOW_TOP_SLABS sounds like a bool. "Should I show the top slabs?"

Quoted 7 lines

This might be a bit more clear:

#define TOP_NR_SLABS_TO_SHOW 10

or

#define NR_SLABS_TO_SHOW 10

Agree :) Will fix in a moment.

Quoted 4 lines

-- Dave

Acked-by on v1 1/1
#4 lore raw
In reply to Pavel Emelianov
Quoted 2 lines · Pavel Emelianov

The out_of_memory() function and SysRq-M handler call show_mem() to show the current memory usage state.

I am still somewhat unhappy about the spinlock, but I don't really have a better suggestion either. Other than that, looks good to me.

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#5 lore raw
Quoted 5 lines · Pekka Enberg
Quoted 2 lines · Pavel Emelianov

The out_of_memory() function and SysRq-M handler call show_mem() to show the current memory usage state.

I am still somewhat unhappy about the spinlock, but I don't really

What's wrong with the spinlock? It exists there without my patch, I just make ++/-- of unatomic variable under this lock :)

Quoted 4 lines

have a better suggestion either. Other than that, looks good to me.