4 basedir=$(dirname "$0")
5 . "${basedir}"/check-dpdk-supported-arch.sh
7 # Overall that could require up to 1.2G for hugepages in the test environment
9 # Some page sizes like e.g. 1G might not be available in all test environments
10 # The test still configures 1 page of 1G size.
11 # One of two things will happen, depending on the test environment:
12 # - has 1G huge page size => they will tried to be allocated (usually env is
13 # too small, but we want to see it fail gracefully for that)
14 # We will not check for the 1G alloc, as we know it often fails in small adt's
15 # - has no 1G huge page size (HW feature) => we check if it fails gracefully
19 DPDK_CONF="/etc/dpdk/dpdk.conf"
20 DPDK_INTERF="/etc/dpdk/interfaces"
23 MMDIR="/sys/kernel/mm/hugepages/${1}"
25 if [ -d "$MMDIR" -a -r "$MMDIR/nr_hugepages" ]; then
26 hpcount=$(cat "$MMDIR/nr_hugepages")
27 if [ "${hpcount}" -ne "${EXPECTHP}" ]; then
28 echo "Hugepages (${hpcount}) not as expected (${EXPECTHP})"
31 echo "Hugepages ok (${hpcount})"
42 echo "Status after ${MARK}"
43 echo "Status of the Service"
44 ${PRE} status "${POST}" || true
46 GOTSTATUS=$(${PRE} status "${POST}" | awk '/^ *Active: / { print $2 }')
47 if [ "${GOTSTATUS}" != "${EXPECTEDSTATUS}" ]; then
48 echo "Service status (${GOTSTATUS}) not as expected (${EXPECTEDSTATUS})"
51 echo "Service status (${GOTSTATUS}) as expected"
54 echo "Status of hugetlbfs mount points"
55 # this section is ok to create bad RCs when no mounts are available
57 grep hugetlbfs < /proc/mounts
58 htlbfscount=$(grep -c hugetlbfs < /proc/mounts)
61 # we have to reduce the expected mountpoint count in case some sizes are
62 # not supported by the current kernel/environment
63 if [ ${EXPMPCOUNT} -gt 0 ]; then
64 if [ ! -d /sys/kernel/mm/hugepages/hugepages-2048kB ]; then
65 EXPMPCOUNT=$((EXPMPCOUNT-1))
67 if [ ! -d /sys/kernel/mm/hugepages/hugepages-16384kB ]; then
68 EXPMPCOUNT=$((EXPMPCOUNT-1))
70 if [ ! -d /sys/kernel/mm/hugepages/hugepages-1048576kB ]; then
71 EXPMPCOUNT=$((EXPMPCOUNT-1))
75 if [ "${htlbfscount}" -eq "${EXPMPCOUNT}" ]; then
76 echo "MP Count (${htlbfscount}) as expected (${EXPMPCOUNT})"
78 echo "MP Count (${htlbfscount}) not as expected (${EXPMPCOUNT})"
82 # check if setting HP worked
83 if [ "${EXPMPCOUNT}" -ne "0" ]; then
84 checkhp "hugepages-2048kB" "${EXPECT2MHP}"
85 checkhp "hugepages-16384kB" "${EXPECT16MHP}"
86 # We do not check 1G/16M alloc, as it is known to be often not available
91 # help a bit with memory fragmentation regarding huge page allocation
93 echo 3 > /proc/sys/vm/drop_caches
95 # stopping and resetting Service
96 systemctl stop dpdk.service || /bin/true
97 systemctl reset-failed dpdk.service || /bin/true
99 echo "Unmounting all potential hugetlbfs mounts"
100 awk '/hugetlbfs/ {print $2}' /proc/mounts | while read hugetlbmount; do
101 umount -v "$hugetlbmount"
106 # We want to verify that
107 # - initially our environment has no hugetlbfs mount
108 # - a system without hugetlbfs mount gets it mounted
109 # - a restart of the service does neither drop nor duplicate the mount
113 printf "\n\n### Checking Type %s ###\n" "${TYPE}"
115 checkstatus "${TYPE}-BEGIN" 0 "${PRE}" "${POST}" "inactive"
116 echo "### Starting Service ###"
117 ${PRE} start "${POST}"
118 checkstatus "${TYPE}-START" 3 "${PRE}" "${POST}" "active"
119 echo "### Restarting Service ###"
120 ${PRE} restart "${POST}"
121 checkstatus "${TYPE}-RESTART" 3 "${PRE}" "${POST}" "active"
124 echo "NR_2M_PAGES=$EXPECT2MHP" >> ${DPDK_CONF}
125 echo "NR_1G_PAGES=$EXPECT1GHP" >> ${DPDK_CONF}
126 echo "NR_16M_PAGES=$EXPECT16MHP" >> ${DPDK_CONF}
128 # We can't rely on any real device for DPDK tests in adt-* environments. But
129 # we can expect all kind of broken configuration not to break it (would be
130 # detected via set -e).
131 # So add all kind of known-to-be-broken definitions and expect it not to fail.
132 cat <<EOF > ${DPDK_INTERF}
134 pTi 0000:04:00.0 uio-pci-generic
136 0000:04:00.0 uio-pci-generic
139 # non existing device
140 pci 1234:56:78.9 uio-pci-generic
143 # some had issues in the past caused by different init systems, so we test all
145 checkinitstyle "/etc/init.d/dpdk" "" "Direct"
146 # System V style init
147 checkinitstyle "service dpdk" "" "SysV"
149 checkinitstyle "systemctl" "dpdk.service" "SystemD"