### This a benchmark that stresses THP allocations in a specific manner.
###
### THPCOMPACT_ANONSIZE is split based on the number of active threads at
### each stage of the test. The active memory for a thread is referred
### to as THREAD_ANONSIZE
###
### 1. It first creates a large THREAD_ANONSIZE anonymous mapping that is THP
###    aligned, specifies madvise(MADV_HUGEPAGE) and faults it. It then punches
###    holes in the (hopefully) THP mapping that are naturally aligned and
###    half the size of a THP. This mapping is a migration source that frees
###    pageblocks as the pages are moved. At this point, the migration source
###    only has anonymous pages.
###
### 2. It then creates a THREAD_ANONSIZE/2 anonymous mapping that is not yet
###    faulted. The size of this mapping represents the sum of the holes created
###    in step 1.
###
### 3. A file mapping is created of size THREAD_FILE and the file is
###    read-faulted. These are also potential migration sources as some of
###    the holes will be used to store file-backed pages.
###
### 4. Finally the anonymous mapping created at step 2 is faulted while
###    recording the time to fault, the locality and whether a huge page
###    is used.
###
### The overall size of the workload is such that it should fit in memory while
### requiring compaction to allocate THPs for the final mapping.

export MMTESTS="thpcompact"

# Test disk to setup (optional)
#export TESTDISK_RAID_DEVICES=
#export TESTDISK_RAID_MD_DEVICE=/dev/md0
#export TESTDISK_RAID_OFFSET=63
#export TESTDISK_RAID_SIZE=250019532
#export TESTDISK_RAID_TYPE=raid0
#export TESTDISK_PARTITION=/dev/sda6
#export TESTDISK_FILESYSTEM=xfs
#export TESTDISK_MKFS_PARAM="-f -d agcount=8"
#export TESTDISK_MOUNT_ARGS=inode64,delaylog,logbsize=262144,nobarrier

# List of monitors
export MONITOR_FTRACE_EVENTS="
	compaction/mm_compaction_begin
	compaction/mm_compaction_defer_compaction
	compaction/mm_compaction_deferred
	compaction/mm_compaction_defer_reset
	compaction/mm_compaction_end
	compaction/mm_compaction_finished
	compaction/mm_compaction_isolate_freepages
	compaction/mm_compaction_isolate_migratepages
	compaction/mm_compaction_kcompactd_sleep
	compaction/mm_compaction_kcompactd_wake
	compaction/mm_compaction_migratepages
	compaction/mm_compaction_suitable
	compaction/mm_compaction_try_to_compact_pages
	compaction/mm_compaction_wakeup_kcompactd
	kmem/mm_page_alloc_extfrag"
export RUN_MONITOR=yes
export MONITORS_ALWAYS=
export MONITORS_GZIP="proc-vmstat proc-buddyinfo proc-pagetypeinfo mpstat"
export MONITORS_WITH_LATENCY="vmstat"
export MONITOR_UPDATE_FREQUENCY=1

# thpcompact
export THPCOMPACT_MIN_THREADS=1
export THPCOMPACT_MAX_THREADS=$((NUMCPUS*4))
if [ $THPCOMPACT_MAX_THREADS -gt 32 ]; then
	export THPCOMPACT_MAX_THREADS=32
fi
export THPCOMPACT_ANONSIZE=$((MEMTOTAL_BYTES*8/10))
export THPCOMPACT_FILESIZE=$((THPCOMPACT_ANONSIZE/4))

export TESTDISK_MIN_SIZE=$((THPCOMPACT_FILESIZE*5/4))
