linux-bcache.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [BCACHE] Forcing the PD controller to follow the disks activity time
@ 2021-05-16 19:42 Giuseppe Della Bianca
  0 siblings, 0 replies; only message in thread
From: Giuseppe Della Bianca @ 2021-05-16 19:42 UTC (permalink / raw)
  To: linux-bcache

Hi.

I wrote this shell script for get a low dirty data size, and a low cache/backing devices overload.

This script sets a low or very low writeback rate for medium or medium hight disks activity time.
And set medium writeback rate for very low disks activity time.

Then some information is printed in the standard output because this script is executed every second by an applet that displays the information in the user's desktop.

P.S. If this strategy was placed inside bcache, it should set the maximum writeback rate, and the PD controller should be more aggressive with the mimum writeback.


#!/bin/bash

bkDev="sdb"
chDev="nvme"
sysBcBase="/sys/block"

bcDev=`find /sys/block/$bkDev/ | grep -e 'bcache[0-9,a-z,A-Z]\{1,\}' | sed -e 's/.*\///'`
sysBcDev="$sysBcBase/$bcDev/bcache"

bkUsage="0"
chUsage="0"

echo -e "Device: $bcDev"


    while read diskLine
    do
#echo $diskLine >> /tmp/grrr.txt
	read diskName diskUsage  < <(echo $diskLine | sed -e 's/\([0-9,a-z]\{1,\}\).* \([0-9]\{1,\}\)/\1 \2/')

	if [ $(expr "$diskName" : "$bkDev") != 0 ]; then
	    bkUsage=$diskUsage
    	elif [ $(expr "$diskName" : "$chDev") != 0 ]; then
	    chUsage=$diskUsage
	fi
	
	echo -e "Device: $diskName\tUsage: $diskUsage"
    done < <(iostat -dmx --dec=0 -y 1 1 | grep -e "$bkDev\|$chDev")


attWBRateMin=$(cat $sysBcDev/writeback_rate_minimum)
newWBrateMin=$attWBRateMin

if [ "$bkUsage" -le "10" ] && [ "$chUsage" -le "10" ]; then
    if [ "$attWBRateMin" -lt "50000" ]; then
	newWBrateMin=50000;
    fi
elif [ "$bkUsage" -le "20" ] && [ "$chUsage" -le "20" ]; then
    newWBrateMin=10000;
elif [ "$bkUsage" -le "40" ] && [ "$chUsage" -le "40" ]; then
    newWBrateMin=100;
elif [ "$attWBRateMin" -ge "10" ]; then
    newWBrateMin=10;
fi

if [ "$newWBrateMin" != "$attWBRateMin" ]; then echo $newWBrateMin > $sysBcDev/writeback_rate_minimum; fi

echo -e "bkUsage: $bkUsage\tchUsage: $chUsage"
echo -en "Dirty: $(cat $sysBcDev/dirty_data)"
echo -en "   Rate: $(cat $sysBcDev/writeback_rate)"
echo -en "   R.Min: $(cat $sysBcDev/writeback_rate_minimum)\n"



echo -e "$(cat $sysBcDev/writeback_rate_debug)"










^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-05-16 19:43 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-16 19:42 [BCACHE] Forcing the PD controller to follow the disks activity time Giuseppe Della Bianca

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).