- if (mem_used >= (mem_free + mem_buffered + mem_cached))
- {
- mem_used -= mem_free + mem_buffered + mem_cached;
- memory_submit ("used", mem_used);
- memory_submit ("buffered", mem_buffered);
- memory_submit ("cached", mem_cached);
- memory_submit ("free", mem_free);
- }
+ if (mem_total < (mem_free + mem_buffered + mem_cached + mem_slab_total))
+ return (-1);
+
+ mem_used = mem_total - (mem_free + mem_buffered + mem_cached + mem_slab_total);
+
+ /* SReclaimable and SUnreclaim were introduced in kernel 2.6.19
+ * They sum up to the value of Slab, which is available on older & newer
+ * kernels. So SReclaimable/SUnreclaim are submitted if available, and Slab
+ * if not. */
+ if (detailed_slab_info)
+ MEMORY_SUBMIT ("used", mem_used,
+ "buffered", mem_buffered,
+ "cached", mem_cached,
+ "free", mem_free,
+ "slab_unrecl", mem_slab_unreclaimable,
+ "slab_recl", mem_slab_reclaimable);
+ else
+ MEMORY_SUBMIT ("used", mem_used,
+ "buffered", mem_buffered,
+ "cached", mem_cached,
+ "free", mem_free,
+ "slab", mem_slab_total);