Announcement

Collapse
No announcement yet.

bfq_conf_prompter: Add new module to warn if the BFQ I/O scheduler is misconfigured

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • bfq_conf_prompter: Add new module to warn if the BFQ I/O scheduler is misconfigured

    Hi,
    I have just finished preparing a module that gives a warning if the BFQ I/O scheduler is being used with an incorrect configuration in a disk benchmark, and suggests the right configuration to use. For the moment it only works for existing, throughput-based tests. It will need to be extended for responsiveness and soft real-time-latency tests.

    I don't know the preferred way to submit such a contribution, maybe a pull request on the github repo?

    Anyway, after failing to attach a file to this post (interface says I'm not authorized to), I'm pasting the changes below.

    Looking forward to your feedback,
    Paolo

    From d43ff1feacf5ddea172d909cb2b44a0de698acec Mon Sep 17 00:00:00 2001
    From: Paolo Valente <paolo.valente@linaro.org>
    Date: Tue, 18 Jul 2017 14:14:44 +0200
    Subject: [PATCH] bfq_conf_prompter: Add new module to warn if the BFQ I/O scheduler is misconfigured

    ---
    pts-core/modules/bfq_conf_prompter.php | 79 ++++++++++++++++++++++++++++++++
    pts-core/static/user-config-defaults.xml | 2 +-
    2 files changed, 80 insertions(+), 1 deletion(-)
    create mode 100644 pts-core/modules/bfq_conf_prompter.php

    diff --git a/pts-core/modules/bfq_conf_prompter.php b/pts-core/modules/bfq_conf_prompter.php
    new file mode 100644
    index 0000000..b18e060
    --- /dev/null
    +++ b/pts-core/modules/bfq_conf_prompter.php
    @@ -0,0 +1,79 @@
    +<?php
    +
    +/*
    + Phoronix Test Suite
    + URLs: http://www.phoronix.com, http://www.phoronix-test-suite.com/
    + Copyright (C) 2017, Paolo Valente <paolo.valente@linaro.org>
    +
    + This program is free software; you can redistribute it and/or modify
    + it under the terms of the GNU General Public License as published by
    + the Free Software Foundation; either version 3 of the License, or
    + (at your option) any later version.
    +
    + This program is distributed in the hope that it will be useful,
    + but WITHOUT ANY WARRANTY; without even the implied warranty of
    + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
    + GNU General Public License for more details.
    +
    + You should have received a copy of the GNU General Public License
    + along with this program. If not, see <http://www.gnu.org/licenses/>.
    +*/
    +
    +class bfq_conf_prompter extends pts_module_interface
    +{
    + const module_name = 'BFQ Configuration Prompter';
    + const module_version = '0.1.0';
    + const module_description = 'This module gives a warning if the BFQ I/O scheduler is being used with an incorrect configuration in a disk benchmark, and suggests the right configuration to use. For the moment it only works for existing, throughput-based tests. It will need to be extended for responsiveness and soft real-time-latency tests.';
    + const module_author = 'Paolo Valente <paolo.valente@linaro.org>';
    +
    + public static function module_info()
    + {
    + return 'This module gives a warning if the BFQ I/O scheduler is being used with an incorrect configuration in a disk benchmark, and suggests the right configuration to use. For the moment it only works for existing, throughput-based tests. It will need to be extended for responsiveness and soft real-time-latency tests.';
    + }
    + public static function module_environmental_variables()
    + {
    + return array('SUPPRESS_BFQ_WARNING');
    + }
    + public static function __run_manager_setup()
    + {
    + // Verify SUPPRESS_BFQ_WARNING is not set and is Linux
    + if(getenv('SUPPRESS_BFQ_WARNING') == 1 || !phodevi::is_linux())
    + {
    + return pts_module::MODULE_UNLOAD; // This module doesn't have anything else to do
    + }
    + }
    + public static function __pre_test_run(&$test_run_request)
    + {
    + $hardware = $test_run_request->test_profile->get_test_hardware_type();
    + $disk_scheduler = phodevi::read_property('disk', 'scheduler');
    +
    + if($hardware == 'Disk' && ($disk_scheduler == 'BFQ' || $disk_scheduler == 'BFQ-MQ'))
    + {
    + $mount_options = phodevi::read_property('disk', 'mount-options');
    + $partition = basename($mount_options['device']);
    + $device = pts_strings::keep_in_string($partition, pts_strings::CHAR_LETTER);
    + $low_latency_file = '/sys/block/' . $device . '/queue/iosched/low_latency';
    + $low_latency = shell_exec('cat ' . $low_latency_file);
    +
    + echo $low_latency . PHP_EOL . PHP_EOL;
    +
    + if ($low_latency == 0)
    + return;
    +
    + echo PHP_EOL . "\t\t\t\tWARNING" . PHP_EOL;
    + echo PHP_EOL . 'This is not a disk benchmark to measure responsiveness or latency for' . PHP_EOL;
    + echo 'soft real-time applications, but BFQ is being used in low-latency mode!' . PHP_EOL;
    + echo PHP_EOL . 'In low-latency mode, BFQ sacrifices throughput when needed to guarantee' . PHP_EOL;
    + echo 'either maximum responsiveness or low latency to isochronous I/O (the I/O' . PHP_EOL;
    + echo 'of, e.g., video and audio players).' . PHP_EOL;
    + echo PHP_EOL . 'For this benchmark, please execute' . PHP_EOL;
    + echo 'echo 0 > ' . $low_latency_file . PHP_EOL;
    + echo '(after every switch to BFQ), or set SUPPRESS_BFQ_WARNING to suppress this' . PHP_EOL;
    + echo 'WARNING.' . PHP_EOL;
    + echo PHP_EOL . 'Press any key to continue or CTRL-C to stop the test.';
    + pts_user_io::read_user_input();
    + }
    + }
    +
    +}
    +?>
    diff --git a/pts-core/static/user-config-defaults.xml b/pts-core/static/user-config-defaults.xml
    index 361d625..0f58435 100644
    --- a/pts-core/static/user-config-defaults.xml
    +++ b/pts-core/static/user-config-defaults.xml
    @@ -15,7 +15,7 @@
    <FullOutput>FALSE</FullOutput>
    </General>
    <Modules>
    - <LoadModules>toggle_screensaver, update_checker, graphics_event_checker</LoadModules>
    + <LoadModules>bfq_conf_prompter,toggle_screensave r, update_checker, graphics_event_checker</LoadModules>
    </Modules>
    <Installation>
    <RemoveDownloadFiles>FALSE</RemoveDownloadFiles>
    --
    2.7.4

  • #2
    Hi Paolo,

    Sending a GitHub pull request to the PTS repository would be the preferred way.

    From a quick look through, the work mostly jives with what I had been thinking. Though would likely rename it to perf_tip_prompter or so, so that it can be re-used for other 'performance tips' rather than needing to make a new module for each performance tip when it's mostly boilerplate code.

    It would also probably make more sense to print this message in __pre_run_process rather than __pre_test_run. The pre-run process at least will show prior to starting the test(s) so users can see the message and quit to change their configuration if desired. Using __pre_run_process would also ensure the message is printed just once per test run process rather than each time a disk test happens. Though if going for __pre_run_process you would need to loop through test_run_manager to find the tests in the run queue to see if one is a disk test, but this is a transition I can easily take care of quickly on my end.

    Though I could easily clean that up post-merge, so if you want feel free to just submit it via GitHub and will get it cleaned up and merged.
    Michael Larabel
    http://www.michaellarabel.com/

    Comment

    Working...
    X