This LWN article about memory compaction indicates that memory compaction can be invoked in the linux kernel by
Writing a node number to /proc/sys/vm/compact_node, causing compaction to happen on the indicated NUMA node.
When should I write the node number to the sys entry? I mean what should I detect or read and then write the node to the sys entry? What should be my criteria and how should I measure that criteria before writing to the sys entry?
The other is for the system to fail in an attempt to allocate a higher-order page; in this case, compaction will run as a preferable alternative to freeing pages through direct reclaim. In the absence of an explicit trigger, the compaction algorithm will stay idle; there is a cost to moving pages around which is best avoided if it is not needed.
What is meant by allowing the system to fail? Fail in what way? How can I detect that failure ? By failure does it mean simple request for allocating a higher order page, which was denied ? In this case is the compaction algorithm run automatically, by itself?
My requirement: I'd like to trigger memory compaction by getting an idea of system state and memory fragmentation on the system. And I'd like to know for sure that compaction will help before actually running it.