Thanks for your answer.
I want to know how much memory the kernel is currently using -- text+data+heap+stack, if possible. I understand that heap and stack can be gleaned by looking at Slab and KernelStack in /proc/meminfo, but I don't know how can I account for the kernel code and other data.
In case you're wondering why the heck I want to know this, I'm trying to estimate how much physical memory I actually need in a system, by comparing memory usage to available memory. Subtracting buffers+cache from free memory gives me how much memory is being used by user processes, without accounting for memory used by the kernel.
Any rules (either hard and fast, or rules of thumb) on how much memory should be free before the system "senses" memory pressure would also help. My goal is to detect memory shortages (long) before the system starts hitting swap space.
Best regards,
Ricardo