Why Kernel Shared Memory is 0 on Ubuntu 12.04?

KSMD won't do anything unless application software tells it to by calling madvise(MADV_MERGEABLE). Most likely, you aren't using any application software that uses KSMD's services.

MADV_MERGEABLE (since Linux 2.6.32):

Enable Kernel Samepage Merging (KSM) for the pages in the range specified by addr and length. The kernel regularly scans those areas of user memory that have been marked as mergeable, looking for pages with identical content. These are replaced by a single write-protected page (which is automatically copied if a process later wants to update the content of the page). KSM only merges private anonymous pages (see mmap(2)).

The KSM feature is intended for applications that generate many instances of the same data (e.g., virtualization systems such as KVM). It can consume a lot of processing power; use with care. See the kernel source file Documentation/vm/ksm.txt for more details. The MADV_MERGEABLE and MADV_UNMERGEABLE operations are only available if the kernel was configured with CONFIG_KSM.