linux-bcache.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Giuseppe Della Bianca <giusdbg@gmail.com>
To: linux-bcache@vger.kernel.org
Subject: [BCACHE] Forcing the PD controller to follow the disks activity time
Date: Sun, 16 May 2021 21:42:55 +0200	[thread overview]
Message-ID: <1786458.tdWV9SEqCh@exnet.gdb.it> (raw)

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)"










                 reply	other threads:[~2021-05-16 19:43 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1786458.tdWV9SEqCh@exnet.gdb.it \
    --to=giusdbg@gmail.com \
    --cc=linux-bcache@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).