From 6cacf27281f08a62ca3bfdbeee5a5afaf04d98de Mon Sep 17 00:00:00 2001 From: Timofey Titovets Date: Sat, 6 May 2017 22:03:42 +0300 Subject: [PATCH] Change mainloop logic Signed-off-by: Timofey Titovets --- ananicy | 34 +++++++++++++++++----------------- ananicy.d/ananicy.conf | 2 +- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/ananicy b/ananicy index 961ec201..a44dea5f 100755 --- a/ananicy +++ b/ananicy @@ -282,25 +282,25 @@ case $1 in check_schedulers check_bins INFO "Start main process" - CHECK_FREQ=${CHECK_FREQ:-15} - while sleep $CHECK_FREQ; do + CHECK_FREQ=${CHECK_FREQ:-0.2s} + for RULE in RULES_CACHE/*; do [ ! -d "$WORK_DIR" ] && break - for FILE in RULES_CACHE/*; do - [ ! -f "$FILE" ] && continue - unset NAME PID NICE IOCLASS IONICE SCHED OOM_SCORE_ADJ - export NAME PID NICE IOCLASS IONICE SCHED OOM_SCORE_ADJ - source "$FILE" - NAME="${NAME//\"/}" - for PID in $( pgrep -f -w "$NAME" ); do - [ -z "$PID" ] && return - [ ! -d "/proc/$PID" ] && continue - [ ! -z "$NICE" ] && renice_w - [ ! -z "$IOCLASS" ] && ionice_class_w - [ ! -z "$IONICE" ] && ionice_w - [ ! -z "$SCHED" ] && schedtool_policy_w - [ ! -z "$OOM_SCORE_ADJ" ] && oom_score_adj_w - done + [ ! -f "$RULE" ] && continue + unset NAME PID NICE IOCLASS IONICE SCHED OOM_SCORE_ADJ + export NAME PID NICE IOCLASS IONICE SCHED OOM_SCORE_ADJ + source "$RULE" + NAME="${NAME//\"/}" + for PID in $( pgrep -f -w "$NAME" ); do + [ -z "$PID" ] && return + [ ! -d "/proc/$PID" ] && continue + [ ! -z "$NICE" ] && renice_w + [ ! -z "$IOCLASS" ] && ionice_class_w + [ ! -z "$IONICE" ] && ionice_w + [ ! -z "$SCHED" ] && schedtool_policy_w + [ ! -z "$OOM_SCORE_ADJ" ] && oom_score_adj_w done + # Pause before processing next rule + sleep $CHECK_FREQ done ;; stop) force_exit ;; diff --git a/ananicy.d/ananicy.conf b/ananicy.d/ananicy.conf index dbdec922..beb515ab 100644 --- a/ananicy.d/ananicy.conf +++ b/ananicy.d/ananicy.conf @@ -1,5 +1,5 @@ ## Ananicy configuration -CHECK_FREQ=15s +CHECK_FREQ=0.2s ## Logging INFO_MSG_NICE_ENABLED=true