Skip to content
This repository has been archived by the owner on Aug 29, 2023. It is now read-only.

Nub question - ksmtuned need? #83

Open
dipol0 opened this issue Feb 22, 2023 · 1 comment
Open

Nub question - ksmtuned need? #83

dipol0 opened this issue Feb 22, 2023 · 1 comment

Comments

@dipol0
Copy link

dipol0 commented Feb 22, 2023

OS - Ubunru 22.04. I pathch kernel v5.17.9 UKSM. Ok. I have - /sys/kernel/mm/uksm (NOT ksm)

Have ksmtuned service running on system with patch and get in log:

Feb 22 17:42:04 cloud ksmtuned[2153]: /usr/sbin/ksmtuned: строка 61: /sys/kernel/mm/ksm/run: Нет такого файла или каталога
Feb 22 17:43:04 cloud ksmtuned[2153]: /usr/sbin/ksmtuned: строка 61: /sys/kernel/mm/ksm/run: Нет такого файла или каталога
Feb 22 17:44:04 cloud ksmtuned[2153]: /usr/sbin/ksmtuned: строка 61: /sys/kernel/mm/ksm/run: Нет такого файла или каталога
Feb 22 17:45:04 cloud ksmtuned[2153]: /usr/sbin/ksmtuned: строка 61: /sys/kernel/mm/ksm/run: Нет такого файла или каталога
Feb 22 17:46:04 cloud ksmtuned[2153]: /usr/sbin/ksmtuned: строка 61: /sys/kernel/mm/ksm/run: Нет такого файла или каталога
Feb 22 17:47:04 cloud ksmtuned[2153]: /usr/sbin/ksmtuned: строка 61: /sys/kernel/mm/ksm/run: Нет такого файла или каталога
Feb 22 17:48:04 cloud ksmtuned[2153]: /usr/sbin/ksmtuned: строка 61: /sys/kernel/mm/ksm/run: Нет такого файла или каталога
Feb 22 17:49:04 cloud ksmtuned[2153]: /usr/sbin/ksmtuned: строка 61: /sys/kernel/mm/ksm/run: Нет такого файла или каталога
Feb 22 17:50:04 cloud ksmtuned[2153]: /usr/sbin/ksmtuned: строка 61: /sys/kernel/mm/ksm/run: Нет такого файла или каталога
Feb 22 17:51:04 cloud ksmtuned[2153]: /usr/sbin/ksmtuned: строка 61: /sys/kernel/mm/ksm/run: Нет такого файла или каталога
Feb 22 17:53:04 cloud ksmtuned[2153]: message repeated 2 times: [ /usr/sbin/ksmtuned: строка 61: /sys/kernel/mm/ksm/run: Нет такого файла или каталога]
Feb 22 17:54:04 cloud ksmtuned[2153]: /usr/sbin/ksmtuned: строка 61: /sys/kernel/mm/ksm/run: Нет такого файла или каталога
Feb 22 17:55:04 cloud ksmtuned[2153]: /usr/sbin/ksmtuned: строка 61: /sys/kernel/mm/ksm/run: Нет такого файла или каталога
Feb 22 17:56:04 cloud ksmtuned[2153]: /usr/sbin/ksmtuned: строка 61: /sys/kernel/mm/ksm/run: Нет такого файла или каталога
Feb 22 17:59:05 cloud ksmtuned[2153]: message repeated 3 times: [ /usr/sbin/ksmtuned: строка 61: /sys/kernel/mm/ksm/run: Нет такого файла или каталога]
Feb 22 18:00:05 cloud ksmtuned[2153]: /usr/sbin/ksmtuned: строка 61: /sys/kernel/mm/ksm/run: Нет такого файла или каталога
Feb 22 18:01:05 cloud ksmtuned[2153]: /usr/sbin/ksmtuned: строка 61: /sys/kernel/mm/ksm/run: Нет такого файла или каталога
Feb 22 18:02:05 cloud ksmtuned[2153]: /usr/sbin/ksmtuned: строка 61: /sys/kernel/mm/ksm/run: Нет такого файла или каталога
Feb 22 18:03:05 cloud ksmtuned[2153]: /usr/sbin/ksmtuned: строка 61: /sys/kernel/mm/ksm/run: Нет такого файла или каталога
Feb 22 18:04:05 cloud ksmtuned[2153]: /usr/sbin/ksmtuned: строка 61: /sys/kernel/mm/ksm/run: Нет такого файла или каталога

Question - what i need? Just stop and disable ksmtuned service or need modify /usr/sbin/ksmtuned script for set path to uksm???
Bite a from /usr/sbin/ksmtuned:

if [ -f /etc/ksmtuned.conf ]; then
    . /etc/ksmtuned.conf
fi

debug() {
    if [ -n "$DEBUG" ]; then
        s="`/bin/date`: $*"
        [ -n "$LOGFILE" ] && echo "$s" >> "$LOGFILE" || echo "$s"
    fi
}


KSM_MONITOR_INTERVAL=${KSM_MONITOR_INTERVAL:-60}
KSM_NPAGES_BOOST=${KSM_NPAGES_BOOST:-300}
KSM_NPAGES_DECAY=${KSM_NPAGES_DECAY:--50}

KSM_NPAGES_MIN=${KSM_NPAGES_MIN:-64}
KSM_NPAGES_MAX=${KSM_NPAGES_MAX:-1250}
KSM_SLEEP_MSEC=${KSM_SLEEP_MSEC:-10}

KSM_THRES_COEF=${KSM_THRES_COEF:-20}
KSM_THRES_CONST=${KSM_THRES_CONST:-2048}

total=`awk '/^MemTotal:/ {print $2}' /proc/meminfo`
debug total $total

npages=0
sleep=$[KSM_SLEEP_MSEC * 16 * 1024 * 1024 / total]
[ $sleep -le 10 ] && sleep=10
debug sleep $sleep
thres=$[total * KSM_THRES_COEF / 100]
if [ $KSM_THRES_CONST -gt $thres ]; then
    thres=$KSM_THRES_CONST
fi
debug thres $thres

KSMCTL () {
    case x$1 in
        xstop)
            echo 0 > /sys/kernel/mm/ksm/run
            ;;
        xstart)
           echo $2 > /sys/kernel/mm/ksm/pages_to_scan
            echo $3 > /sys/kernel/mm/ksm/sleep_millisecs
            echo 1 > /sys/kernel/mm/ksm/run
            ;;
    esac
}

committed_memory () {
    local pidlist
    pidlist=$(pgrep -f -d ' ' '^qemu-system.*-enable-kvm')
    if [ -n "$pidlist" ]; then
        ps -p "$pidlist" -o rsz=
    fi | awk '{ sum += $1 }; END { print 0+sum }'
}

free_memory () {
    awk '/^(MemFree|Buffers|Cached):/ {free += $2}; END {print free}' \
                /proc/meminfo
}

increase_npages() {
    local delta
    delta=${1:-0}
    npages=$[npages + delta]
    if [ $npages -lt $KSM_NPAGES_MIN ]; then
        npages=$KSM_NPAGES_MIN
    elif [ $npages -gt $KSM_NPAGES_MAX ]; then
        npages=$KSM_NPAGES_MAX
    fi
    echo $npages
}


adjust () {
    local free committed
    free=`free_memory`
    committed=`committed_memory`
    debug committed $committed free $free
    if [ $[committed + thres] -lt $total -a $free -gt $thres ]; then
        KSMCTL stop
        debug "$[committed + thres] < $total and free > $thres, stop ksm"
        return 1
    fi
    debug "$[committed + thres] > $total, start ksm"
    if [ $free -lt $thres ]; then
        npages=`increase_npages $KSM_NPAGES_BOOST`
        debug "$free < $thres, boost"
    else
        npages=`increase_npages $KSM_NPAGES_DECAY`
        debug "$free > $thres, decay"
    fi
    KSMCTL start $npages $sleep
    debug "KSMCTL start $npages $sleep"
    return 0
}

function nothing () {
    :
}

loop () {
    trap nothing SIGUSR1
    while true
    do
        sleep $KSM_MONITOR_INTERVAL &
        wait $!
        adjust
    done
}

PIDFILE=${PIDFILE-/var/run/ksmtune.pid}
if touch "$PIDFILE"; then
  loop &
  echo $! > "$PIDFILE"
fi
@hieixu
Copy link

hieixu commented May 19, 2023

no. it doesn't need ksmtuned

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants