Skip to content
This repository has been archived by the owner on Jun 28, 2024. It is now read-only.

Commit

Permalink
Merge pull request #2737 from jcvenegas/qemu-virtiofs-vmx-rdseed-exit
Browse files Browse the repository at this point in the history
ci: Fix the build of experimental QEMU w/ virtiofs and metrics-virtiofsd CI
  • Loading branch information
likebreath authored Aug 14, 2020
2 parents a72e9a7 + 0f26e2f commit 64a96c8
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 11 deletions.
16 changes: 6 additions & 10 deletions .ci/install_runtime.sh
Original file line number Diff line number Diff line change
Expand Up @@ -77,16 +77,12 @@ case "${KATA_HYPERVISOR}" in
enable_hypervisor_config "${PKGDEFAULTSDIR}/configuration-qemu-virtiofs.toml"
else
enable_hypervisor_config "${PKGDEFAULTSDIR}/configuration-qemu.toml"
if [ "$CI" == true ] && [ "$(uname -m)" == "x86_64" ]; then
qemu_version="$(get_version "assets.hypervisor.qemu.version")"
qemu_major="$(echo ${qemu_version} | cut -d. -f1)"
qemu_minor="$(echo ${qemu_version} | cut -d. -f2)"
if [[ ${qemu_major} -ge 5 || ( ${qemu_major} -eq 4 && ${qemu_minor} -ge 2 ) ]]; then
# Due to a KVM bug, vmx-rdseed-exit must be disabled in QEMU >= 4.2
# see https://github.com/kata-containers/runtime/pull/2355#issuecomment-625469252
sudo sed -i 's|^cpu_features="|cpu_features="-vmx-rdseed-exit,|g' "${runtime_config_path}"
fi
fi
fi
if [ "$CI" == true ] && [ "$(uname -m)" == "x86_64" ]; then
# Due to a KVM bug, vmx-rdseed-exit must be disabled in QEMU >= 4.2
# All CI now uses qemu 5.0+, disabled in the time..
# see https://github.com/kata-containers/runtime/pull/2355#issuecomment-625469252
sudo sed -i 's|^cpu_features="|cpu_features="-vmx-rdseed-exit,|g' "${runtime_config_path}"
fi
;;
*)
Expand Down
56 changes: 55 additions & 1 deletion metrics/density/docker_memory_usage.sh
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,60 @@ get_pss_memory(){
echo "$avg"
}

ppid() {
local pid
pid=$(ps -p "${1:-nopid}" -o ppid=)
echo "${pid//[[:blank:]]/}"
}

# This function measures the PSS average
# memory of virtiofsd.
# It is a special case of get_pss_memory,
# virtiofsd forks itself so, smem sees the process
# two times, this function sum both pss values:
# pss_virtiofsd=pss_fork + pss_parent
get_pss_memory_virtiofsd() {
mem_amount=0
count=0
avg=0

virtiofsd_path=${1:-}
if [ -z "${virtiofsd_path}" ]; then
die "virtiofsd_path not provided"
fi

virtiofsd_pids=$(ps aux | grep [v]irtiofsd | awk '{print $2}')
data=$(sudo smem --no-header -P "^${virtiofsd_path}" -c pid -c "pid pss")

for p in ${virtiofsd_pids}; do
parent_pid=$(ppid ${p})
cmd="$(cat /proc/${p}/cmdline | tr -d '\0')"
cmd_parent="$(cat /proc/${parent_pid}/cmdline | tr -d '\0')"
if [ "${cmd}" != "${cmd_parent}" ]; then
pss_parent=$(printf "%s" "${data}" | grep "\s^${p}" | awk '{print $2}')

fork=$(pgrep -P ${p})

pss_fork=$(printf "%s" "${data}" | grep "^\s*${fork}" | awk '{print $2}')
pss_process=$((pss_fork + pss_parent))

# Save all the smem results
# This will help us to retrieve raw information
echo "${pss_process}" >>$MEM_TMP_FILE

if ((pss_process > 0)); then
mem_amount=$((pss_process + mem_amount))
((count++))
fi
fi
done

if (( $count > 0 ));then
avg=$(bc -l <<< "scale=2; $mem_amount / $count")
fi
echo "${avg}"
}

get_individual_memory(){
# Getting all the individual container information
first_process_name=$(cat $PS_TMP_FILE | awk 'NR==1' | awk -F "/" '{print $NF}' | sed 's/[[:space:]]//g')
Expand Down Expand Up @@ -252,7 +306,7 @@ EOF
die "Failed to find PSS for $HYPERVISOR_PATH"
fi

virtiofsd_mem="$(get_pss_memory "$VIRTIOFSD_PATH")"
virtiofsd_mem="$(get_pss_memory_virtiofsd "$VIRTIOFSD_PATH")"
if [ "$virtiofsd_mem" == "0" ]; then
echo >&2 "WARNING: Failed to find PSS for $VIRTIOFSD_PATH"
fi
Expand Down

0 comments on commit 64a96c8

Please sign in to comment.