### THPChallenge is a benchmark that allocates THPs while there is interference
### from a background workload.
###
### The THP test creates a number of threads, each of which faults a region that
### is THPCHALLENGE_THP_WSETSIZE/$NR_THREADS in size. Optionally the mapping
### will use madvise. The time to fault each page, the size allocated and the
### locality is recorded.
###
### The "challenge" load is fio inefficiently creating many small files, the
### total size of which is THPCHALLENGE_FIO_WSETSIZE
export MMTESTS="thpchallenge"

# 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

# Limit memory to 16GB per node to save storage and limit runtime
. $SHELLPACK_INCLUDE/include-sizes.sh
get_numa_details
limit_memory $((16*1048576*1024*NUMNODES))

# thpchallenge
export THPCHALLENGE_BACKGROUND="fio-random-reader-inefficient"
export THPCHALLENGE_FIO_THREADS=4
export THPCHALLENGE_MIN_THREADS=$((((NUMCPUS/NUMNODES)-THPCHALLENGE_FIO_THREADS)/4))
export THPCHALLENGE_MAX_THREADS=$THPCHALLENGE_MIN_THREADS
if [ $THPCHALLENGE_MAX_THREADS -le 0 ]; then
	die "Insufficient number of CPUs to run benchmark"
fi
export THPCHALLENGE_THP_WSETSIZE=$((MEMTOTAL_BYTES*8/10))
export THPCHALLENGE_FIO_WSETSIZE=$((MEMTOTAL_BYTES*3/2))
