Experimental port for stock ICS semc-msm7x30 kernel.
This is an improvement upon KSM. Its features:
1. Full system scan:
It automatically scans all user processes' anonymous VMAs. Kernel-user
interaction to submit a memory area to KSM is no longer needed.
2. Rich area detection based on random sampling:
It automatically detects rich areas containing abundant duplicated
pages based on their randomly-sampled history. Rich areas are given
a full scan speed. Poor areas are sampled at a reasonable speed with very
low CPU consumption.
3. Per-page scan speed improvement:
A new hash algorithm(random_sample_hash) is proposed. Quite usually,
it's enough to distinguish pages by hashing their partial content
instead of full pages. This algorithm can automatically adapt to this
situation. For the best case, only one 32-bit-word/page is needed to get
the hash value for distinguishing pages. For the worst case, it's as fast
as SuperFastHash.
4. Thrashing area avoidance:
Thrashing area(an VMA that has frequent Ksm page break-out) can be
filtered out. My benchmark shows it's more efficient than KSM's per-page
hash value based volatile page detection.
5. Hash-value-based identical page detection:
It no longer uses "memcmp" based page detection any more.
6. Misc changes upon KSM:
* It has a fully x86-opitmized memcmp dedicated for 4-byte-aligned page
comparison. It's much faster than default C version on x86.
* rmap_item now has an struct *page member to loosely cache a
address-->page mapping, which reduces too much time-costly
follow_page().
* The VMA creation/exit procedures are hooked to let the Ultra KSM know.
* try_to_merge_two_pages() now can revert a pte if it fails. No break_ksm
is needed for this case.
Signed-off-by: CTCaer <ctcaer@gmail.com>