Add checking code that kmalloc gave large enough allocation.

Zero allocated memory.
Per-thread stat collection framework.