Skip to content

Instantly share code, notes, and snippets.

@bbak
Last active July 7, 2019 12:37
Show Gist options
  • Save bbak/f250e81ae40391630b9b73c673c936f2 to your computer and use it in GitHub Desktop.
Save bbak/f250e81ae40391630b9b73c673c936f2 to your computer and use it in GitHub Desktop.
Show count of used huge pages by process-ID
#!/bin/bash
#
IFS=$'\n'
for item in $(grep '^VmFlags:.* ht' /proc/[0-9]*/smaps | awk -F/ '{print $3}' | uniq); do
printf "%s:\t%d huge pages\n" "$(ps -p $item -o comm,pid --no-headers)" "$(cat /proc/$item/numa_maps | grep -o -P 'huge.*dirty=(\d+)' | sed -n "s/^.*dirty=\([[:digit:]]\{1,3\}\)/\1/p" | paste -s -d+ - | bc)"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment