### 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 a kernel compilation
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 24GB so kernel build occupies some memory required
# for THP allocations. This is not ideal as limited to memory hotplug
# will not always work but booting mem= can leave assymetric node
# sizes in NUMA machines.
. $SHELLPACK_INCLUDE/include-sizes.sh
get_numa_details
limit_memory $((24*1048576*1024))

# thpchallenge
export THPCHALLENGE_BACKGROUND="kernel-build"
export THPCHALLENGE_KBUILD_JOBS=$NUMCPUS
export THPCHALLENGE_KBUILD_WARMUP=yes
export THPCHALLENGE_MIN_THREADS=1
export THPCHALLENGE_MAX_THREADS=$NUMCPUS
export THPCHALLENGE_THP_WSETSIZE=$((MEMTOTAL_BYTES*8/10))
