From patchwork Tue Dec 4 17:47:31 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 10712297 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id BEEC613BF for ; Tue, 4 Dec 2018 17:47:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B2F612BD78 for ; Tue, 4 Dec 2018 17:47:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A783E2BD85; Tue, 4 Dec 2018 17:47:40 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 52BAF2BD78 for ; Tue, 4 Dec 2018 17:47:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726073AbeLDRrj (ORCPT ); Tue, 4 Dec 2018 12:47:39 -0500 Received: from mail-yb1-f196.google.com ([209.85.219.196]:36368 "EHLO mail-yb1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726038AbeLDRrj (ORCPT ); Tue, 4 Dec 2018 12:47:39 -0500 Received: by mail-yb1-f196.google.com with SMTP id w203so3372489ybg.3 for ; Tue, 04 Dec 2018 09:47:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda-com.20150623.gappssmtp.com; s=20150623; h=from:to:subject:date:message-id:in-reply-to:references; bh=PNem2NL5fu2OhKSUpx777wY1UDGuyATbaD4VZNtn5yg=; b=wDVI6jycnOCyV2AAMdeVw432AAxBfktihv1TFNNpqOdkZq+xUYNkEMpjlx2CWmdy4P KA83CyS3ozd/cAaOGI9pMJjVZvmCWr7w/tdxxeHj7xod2XRWccb5BvRHd8WcZL9JnEVx XH7+aa9VP+jP3CNI21oBLiYhD+J5a3ah/nIyZf6Bw5n4vihqKj1vuH0q4ZLILzQm2NT9 Sr0JpcRbI01DaSt8Ueq6eHItf3pyrKtFz6Dg5VzYsQX7goLnds2xnuw2aIElz93VaplB VdpibcKGkQtu+u8B8u+P6P7dLXWWnj4zxY1CfG3vUdB6YwV45ljz5lJJb5HaWj7hlyuk dUVw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=PNem2NL5fu2OhKSUpx777wY1UDGuyATbaD4VZNtn5yg=; b=oNEk3hMNaReiJxzzBnByRoUAZrCLn8HnxOHvthTOlh6zonU4JZujO7HVKwxZwgRO5N pxpLlareJSK7f3qjqNsDfJFkD7NguwzrtCA3JSeh+6wb6ltS6ljMV/XuEMoVceOKZ1yf 4Sb2l/n8sJlnLnsGcF/HTlDiDMHlhrvLqSOO42HZMDlSw8fXR2PaNFTxOxZVVoAF10OH U54l1P0nY8+yIfCfgOcLTRBEOczw111LOJCW86+HdkD+g+CCDcxZ7wvkGJ7DAewGViyC Bi3d9h9ZTBVmmN7t48cK3mBnqVTMMRtWkRNQPEFKeZ/odxJAxXO28YCWHAvfWvTwwVl7 D6Lg== X-Gm-Message-State: AA+aEWZyNxwFEz3meh3WFkAk0qK86Shzw9ZZbzpFblGN1T8YY2A5QgXt IT071JG2+uoVcRbvCMg52naoCSDVprE= X-Google-Smtp-Source: AFSGD/XZS2EL3Ihant6wuXWp9MCYzp8og9pJemLHJF0SMJTtX6OsS27GCpxdKrqfyYzHCwYRTpxumw== X-Received: by 2002:a25:7a43:: with SMTP id v64-v6mr20806442ybc.187.1543945658197; Tue, 04 Dec 2018 09:47:38 -0800 (PST) Received: from localhost ([107.15.81.208]) by smtp.gmail.com with ESMTPSA id u81sm5453682ywf.6.2018.12.04.09.47.37 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 04 Dec 2018 09:47:37 -0800 (PST) From: Josef Bacik To: linux-block@vger.kernel.org, kernel-team@fb.com, osandov@fb.com Subject: [PATCH 1/3] blktests: add cgroup2 infrastructure Date: Tue, 4 Dec 2018 12:47:31 -0500 Message-Id: <20181204174733.7423-2-josef@toxicpanda.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20181204174733.7423-1-josef@toxicpanda.com> References: <20181204174733.7423-1-josef@toxicpanda.com> Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP In order to test io.latency and other cgroup related things we need some supporting helpers to setup and tear down cgroup2. This adds support for checking that we can even configure cgroup2 things, set them up if need be, and then add the cleanup stuff to the main cleanup function so everything is always in a clean state. Signed-off-by: Josef Bacik --- check | 2 ++ common/rc | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+) diff --git a/check b/check index ebd87c097e25..1c9dbc518fa1 100755 --- a/check +++ b/check @@ -294,6 +294,8 @@ _cleanup() { done unset RESTORE_CPUS_ONLINE fi + + _cleanup_cgroup2 } _call_test() { diff --git a/common/rc b/common/rc index 8a892bcd5fde..a785f2329687 100644 --- a/common/rc +++ b/common/rc @@ -202,3 +202,51 @@ _test_dev_in_hotplug_slot() { _filter_xfs_io_error() { sed -e 's/^\(.*\)64\(: .*$\)/\1\2/' } + +_cgroup2_base_dir() +{ + grep cgroup2 /proc/mounts | awk '{ print $2 }' +} + +_cleanup_cgroup2() +{ + _dir=$(_cgroup2_base_dir)/blktests + [ -d "${_dir}" ] || return + + for i in $(find ${_dir} -type d | tac) + do + rmdir $i + done +} + +_have_cgroup2() +{ + if ! grep -q 'cgroup2' /proc/mounts; then + SKIP_REASON="This test requires cgroup2" + return 1 + fi + return 0 +} + +_have_cgroup2_controller_file() +{ + _have_cgroup2 || return 1 + + _controller=$1 + _file=$2 + _dir=$(_cgroup2_base_dir) + + if ! grep -q ${_controller} ${_dir}/cgroup.controllers; then + SKIP_REASON="No support for ${_controller} cgroup controller" + return 1 + fi + + mkdir ${_dir}/blktests + echo "+${_controller}" > ${_dir}/cgroup.subtree_control + if [ ! -f ${_dir}/blktests/${_file} ]; then + _cleanup_cgroup2 + SKIP_REASON="Cgroup file ${_file} doesn't exist" + return 1 + fi + return 0 +} From patchwork Tue Dec 4 17:47:32 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 10712299 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 236EF13AF for ; Tue, 4 Dec 2018 17:47:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 16F442BD7D for ; Tue, 4 Dec 2018 17:47:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0B44E2BDA4; Tue, 4 Dec 2018 17:47:43 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EFA8E2BD7D for ; Tue, 4 Dec 2018 17:47:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726078AbeLDRrl (ORCPT ); Tue, 4 Dec 2018 12:47:41 -0500 Received: from mail-yw1-f46.google.com ([209.85.161.46]:37116 "EHLO mail-yw1-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726038AbeLDRrl (ORCPT ); Tue, 4 Dec 2018 12:47:41 -0500 Received: by mail-yw1-f46.google.com with SMTP id h193so7325575ywc.4 for ; Tue, 04 Dec 2018 09:47:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda-com.20150623.gappssmtp.com; s=20150623; h=from:to:subject:date:message-id:in-reply-to:references; bh=cpp233uzRBKsfChjZCjS2W9+E8WvGYpADU5EZ/6mWnM=; b=XOFZAOXbXNnB24Q+VnpCwHdQbgo7YSQQ1kzaisYwmy7yBW384jZdStbtQRFsuvNki4 lmCDAq6YdzHZ75eXG9y0AuGZFml2aSES2od/ielYM+ku1HDBttHKP/VpWyv0Xgry6XSe y9c6DDTTNxVe77ftqUIVYFafipJBOI5ieIbyNRxtGYHw67aNQSyvw0xl/yYrd/TrsKtI UiwZ5A+eGq6aRwEIropU0aEE6+6qSpYZXZLMK3t5bQ85rVkxwG/fbB1ufREts9X9vaxj rszpRbnWzL0ttvtVI1uh3mkEYb09BzXQrlQ6Bh/uYNe8hetV1N4UDIV/pf/dC/BUOm8V +7Gw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=cpp233uzRBKsfChjZCjS2W9+E8WvGYpADU5EZ/6mWnM=; b=nFbUH424xmx1KJs4q5fQFBk/nSj4QRp8kGZuTug50X3Ak/5lFBPFWW8nbfTvG6JR1F W9GiF8VEEjGKnF+dXn51kkM2QOO50MMO+/n/nhx+UNAoTv3U+1pcNjr1rjs9HnmEc2se AZqNzzljXmPhCPcZ/OLFiLpnnW9pK0H9lfrgHpn8l6+heELFmE2mwwKD3gfIN8ZltFMe lAcKU5OZmpmkSupq7Ui85DGFHK+xaGJI4JaSYUSib5Wgfs4kowFJdxbqIuL8EGQimqDy JJb8ZPGtI9/L4fbM+5nilMDQd6IiGDhGvE/T9OWFySNM8OwiSDTVFoYHRiPdx8wJ3+lX vHQQ== X-Gm-Message-State: AA+aEWbTEOpjm9o67rA8cswGR8/fW5cvAcgyyah1U4pB5zK0qr0Jzzlh PklUtARFA08V7VgEJUmG06ZyAR0NJUs= X-Google-Smtp-Source: AFSGD/V+zWLF67PUUZz7prKD5rnNXU3P2G4snpofixYia1F1R1WlfD74mh0IElz3IntOV3CgFu841Q== X-Received: by 2002:a81:3e05:: with SMTP id l5mr21292101ywa.508.1543945659843; Tue, 04 Dec 2018 09:47:39 -0800 (PST) Received: from localhost ([107.15.81.208]) by smtp.gmail.com with ESMTPSA id m67sm5385553ywb.54.2018.12.04.09.47.39 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 04 Dec 2018 09:47:39 -0800 (PST) From: Josef Bacik To: linux-block@vger.kernel.org, kernel-team@fb.com, osandov@fb.com Subject: [PATCH 2/3] blktests: add python scripts for parsing fio json output Date: Tue, 4 Dec 2018 12:47:32 -0500 Message-Id: <20181204174733.7423-3-josef@toxicpanda.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20181204174733.7423-1-josef@toxicpanda.com> References: <20181204174733.7423-1-josef@toxicpanda.com> Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP I wrote these scripts for xfstests, just copying them over to blktests as well. The terse output fio support that blktests doesn't get all of the various fio performance things that we may want to look at, this gives us a lot of flexibility around getting specific values out of the fio results data. Signed-off-by: Josef Bacik --- src/FioResultDecoder.py | 64 +++++++++++++++++++++++++++++++++++++++++++++++++ src/fio-key-value.py | 28 ++++++++++++++++++++++ 2 files changed, 92 insertions(+) create mode 100644 src/FioResultDecoder.py create mode 100644 src/fio-key-value.py diff --git a/src/FioResultDecoder.py b/src/FioResultDecoder.py new file mode 100644 index 000000000000..d004140c0fdf --- /dev/null +++ b/src/FioResultDecoder.py @@ -0,0 +1,64 @@ +# SPDX-License-Identifier: GPL-2.0 + +import json + +class FioResultDecoder(json.JSONDecoder): + """Decoder for decoding fio result json to an object for our database + + This decodes the json output from fio into an object that can be directly + inserted into our database. This just strips out the fields we don't care + about and collapses the read/write/trim classes into a flat value structure + inside of the jobs object. + + For example + "write" : { + "io_bytes" : 313360384, + "bw" : 1016, + } + + Get's collapsed to + + "write_io_bytes" : 313360384, + "write_bw": 1016, + + Currently any dict under 'jobs' get's dropped, with the exception of 'read', + 'write', and 'trim'. For those sub sections we drop any dict's under those. + + Attempt to keep this as generic as possible, we don't want to break every + time fio changes it's json output format. + """ + _ignore_types = ['dict', 'list'] + _override_keys = ['lat_ns', 'lat'] + _io_ops = ['read', 'write', 'trim'] + + _transform_keys = { 'lat': 'lat_ns' } + + def decode(self, json_string): + """This does the dirty work of converting everything""" + default_obj = super(FioResultDecoder, self).decode(json_string) + obj = {} + obj['global'] = {} + obj['global']['time'] = default_obj['time'] + obj['jobs'] = [] + for job in default_obj['jobs']: + new_job = {} + for key,value in job.iteritems(): + if key not in self._io_ops: + if value.__class__.__name__ in self._ignore_types: + continue + new_job[key] = value + continue + for k,v in value.iteritems(): + if k in self._override_keys: + if k in self._transform_keys: + k = self._transform_keys[k] + for subk,subv in v.iteritems(): + collapsed_key = "{}_{}_{}".format(key, k, subk) + new_job[collapsed_key] = subv + continue + if v.__class__.__name__ in self._ignore_types: + continue + collapsed_key = "{}_{}".format(key, k) + new_job[collapsed_key] = v + obj['jobs'].append(new_job) + return obj diff --git a/src/fio-key-value.py b/src/fio-key-value.py new file mode 100644 index 000000000000..208e9a453a19 --- /dev/null +++ b/src/fio-key-value.py @@ -0,0 +1,28 @@ +# SPDX-License-Identifier: GPL-2.0 + +import FioResultDecoder +import json +import argparse +import sys +import platform + +parser = argparse.ArgumentParser() +parser.add_argument('-j', '--jobname', type=str, + help="The jobname we want our key from.", + required=True) +parser.add_argument('-k', '--key', type=str, + help="The key we want the value of", required=True) +parser.add_argument('result', type=str, + help="The result file read") +args = parser.parse_args() + +json_data = open(args.result) +data = json.load(json_data, cls=FioResultDecoder.FioResultDecoder) + +for job in data['jobs']: + if job['jobname'] == args.jobname: + if args.key not in job: + print('') + else: + print("{}".format(job[args.key])) + break From patchwork Tue Dec 4 17:47:33 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 10712301 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2798F13BF for ; Tue, 4 Dec 2018 17:47:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1B1AC2BD7D for ; Tue, 4 Dec 2018 17:47:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0F6F62BDA4; Tue, 4 Dec 2018 17:47:44 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 850402BD7D for ; Tue, 4 Dec 2018 17:47:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726084AbeLDRrn (ORCPT ); Tue, 4 Dec 2018 12:47:43 -0500 Received: from mail-yw1-f67.google.com ([209.85.161.67]:41534 "EHLO mail-yw1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726038AbeLDRrn (ORCPT ); Tue, 4 Dec 2018 12:47:43 -0500 Received: by mail-yw1-f67.google.com with SMTP id f65so7322216ywc.8 for ; Tue, 04 Dec 2018 09:47:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda-com.20150623.gappssmtp.com; s=20150623; h=from:to:subject:date:message-id:in-reply-to:references; bh=9sSAI94rKwlTvPeeHqFhwpCg8kW+5V6l/J9eOc/rNm0=; b=Lo5jgy7zACJGq/VoS8U1xbPA6//TwlnlpBSacWAro4o0AKPMNXloD9gdjFcqSIO0OL 8ru7ynJUExzGRV8rFXLNLL2UlyFJ6XiteqwgezIkZDh01Z4we2AEppqXVdKPRgdsvxmq FLrJAqasQWP/eKxvuyTFZi88LvubB3LgWrK5p/KyCIqjVy6wWMs0R+AqbFCIz1fx2OxC jZgqHJ5wrjdWgUynVb1oT/+GVm/6kKDzkGWusNyfx8FbRB2IZad4H13b9HhjtR2c/7gt tVDDJFWYzMN3YR2SwtPZj++9NhIQjxKtXJqk2tIxpQxCzv+klTov5tW3obzth6jJR5JJ zO1Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=9sSAI94rKwlTvPeeHqFhwpCg8kW+5V6l/J9eOc/rNm0=; b=iVcX4kIUqQ9QLb2MC70DuWuhBUa3BI56uRYVHrvW957N/TYIfA/ZhgqCA/sXykTuZ9 FqAt91M4fHaVr6nYUfkt9Wi2XRwj8Hqozvi+URNZYxTTtPlg9RJrdsQl6sejqPNkTmLj RsNUk5jKVWKoHEURSc7BqlqIBwEenVSYmy2aUbXQkJ6jY06aH0Y8+d/C5KrRHNphj+q3 hUsXikJmALlxxDnNkmfGcTSmrojNr7x1gJYQK1kBxJvL7kyu1kmwgTa+e1EDZuixHB6k Ru/TCaJvDe1j+iDZyKc2FNwcFkHt52DanyQcCw2OO9aF5nx0kkeI678UO+VIG2Jiu33z FdFQ== X-Gm-Message-State: AA+aEWbOMTJ9NL5GIJ/aqmYLxsJVMoxJW0eHNAhJjMySwDfyfjDOaZil d3/UuRiX7THfAQggTeBHIyi0ZDmsDdg= X-Google-Smtp-Source: AFSGD/XPZOstM28X+BmJshmk5idGoQCDQPumNuy0f9BD03wp7hnr7weEvFWx70B7/dG3QhEXkNqpiw== X-Received: by 2002:a81:27cc:: with SMTP id n195mr21121801ywn.243.1543945661390; Tue, 04 Dec 2018 09:47:41 -0800 (PST) Received: from localhost ([107.15.81.208]) by smtp.gmail.com with ESMTPSA id x4sm20227295ywj.80.2018.12.04.09.47.40 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 04 Dec 2018 09:47:40 -0800 (PST) From: Josef Bacik To: linux-block@vger.kernel.org, kernel-team@fb.com, osandov@fb.com Subject: [PATCH 3/3] blktests: block/025: an io.latency test Date: Tue, 4 Dec 2018 12:47:33 -0500 Message-Id: <20181204174733.7423-4-josef@toxicpanda.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20181204174733.7423-1-josef@toxicpanda.com> References: <20181204174733.7423-1-josef@toxicpanda.com> Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This is a test to verify io.latency is working properly. It does this by first running a fio job by itself to figure out how fast it runs. Then we calculate some thresholds, set up 2 cgroups, a fast and a slow cgroup, and then run the same job in both groups simultaneously. We should see the slow group get throttled until the first cgroup is able to finish, and then the slow cgroup will be allowed to finish. Signed-off-by: Josef Bacik --- tests/block/025 | 133 ++++++++++++++++++++++++++++++++++++++++++++++++++++ tests/block/025.out | 1 + 2 files changed, 134 insertions(+) create mode 100644 tests/block/025 create mode 100644 tests/block/025.out diff --git a/tests/block/025 b/tests/block/025 new file mode 100644 index 000000000000..88ce7cca944e --- /dev/null +++ b/tests/block/025 @@ -0,0 +1,133 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-3.0+ +# +# Test io.latency to make sure it's protecting the higher priority group +# properly. + +. tests/block/rc + +DESCRIPTION="test the io.latency interface to make sure it's working right" + +requires() { + _have_cgroup2_controller_file io io.latency && _have_fio && \ + _have_program python +} + +_fio_results_key() { + _job=$1 + _key=$2 + _resultfile=$3 + + python src/fio-key-value.py -k $_key -j $_job $_resultfile +} + +test_device() { + local fio_config_single fio_config_double fio_results fio_args qd + + fio_config_single=${TMPDIR}/single.fio + fio_config_double=${TMPDIR}/double.fio + fio_results=${TMPDIR}/025.json + fio_args="--output-format=json --output=${fio_results}" + qd=$(cat ${TEST_DEV_SYSFS}/queue/nr_requests) + + cat << EOF > "${fio_config_single}" + [fast] + filename=${TEST_DEV} + direct=1 + allrandrepeat=1 + readwrite=randrw + size=4G + ioengine=libaio + iodepth=${qd} + fallocate=none + randseed=12345 +EOF + + cat << EOF > "${fio_config_double}" + [global] + filename=${TEST_DEV} + direct=1 + allrandrepeat=1 + readwrite=randrw + size=4G + ioengine=libaio + iodepth=${qd} + fallocate=none + randseed=12345 + + [fast] + cgroup=blktests/fast + + [slow] + cgroup=blktests/slow +EOF + # We run the test once so we have an idea of how fast this workload will + # go with nobody else doing IO on the device. + if ! fio ${fio_args} ${fio_config_single}; then + echo "fio exited with status $?" + return 1 + fi + + _time_taken=$(_fio_results_key fast job_runtime ${fio_results}) + if [ "${_time_taken}" = "" ]; then + echo "fio doesn't report job_runtime" + return 1 + fi + + echo "normal time taken ${_time_taken}" >> $FULL + + # There's no way to predict how the two workloads are going to affect + # each other, so we weant to set thresholds to something reasonable so + # we can verify io.latency is doing something. This means we set 15% + # for the fast cgroup, just to give us enough wiggle room as throttling + # doesn't happen immediately. But if we have a super fast disk we could + # run both groups really fast and make it under our fast threshold, so + # we need to set a threshold for the slow group at 50%. We assume that + # if it was faster than 50% of the fast threshold then we probably + # didn't throttle and we can assume io.latency is broken. + _fast_thresh=$((${_time_taken} + ${_time_taken} * 15 / 100)) + _slow_thresh=$((${_time_taken} + ${_time_taken} * 50 / 100)) + echo "fast threshold time is ${_fast_thresh}" >> $FULL + echo "slow threshold time is ${_slow_thresh}" >> $FULL + + # Create teh cgroup files + _dir=$(_cgroup2_base_dir)/blktests + echo "+io" > ${_dir}/cgroup.subtree_control + mkdir ${_dir}/fast + mkdir ${_dir}/slow + + # We set teh target to 1usec because we could have a fast device that is + # capable of remarkable IO latencies that would skew the test. It needs + # to be low enough that we do actually throttle the slow group, + # otherwise the test will fail when there's nothing wrong. + _major=$((0x$(stat -c "%t" ${TEST_DEV}))) + _minor=$((0x$(stat -c "%T" ${TEST_DEV}))) + echo "${_major}:${_minor} is our device" >> $FULL + if ! echo "${_major}:${_minor} target=1" > ${_dir}/fast/io.latency; then + echo "Failed to set our latency target" + return 1 + fi + + if ! fio ${fio_args} ${fio_config_double}; then + echo "fio exited with status $?" + return 1 + fi + + _fast_time=$(_fio_results_key fast job_runtime ${fio_results}) + echo "Fast time ${_fast_time}" >> $FULL + _slow_time=$(_fio_results_key slow job_runtime ${fio_results}) + echo "Slow time ${_slow_time}" >> $FULL + + if [ ${_fast_thresh} -lt ${_fast_time} ]; then + echo "Too much of a performance drop for the protected workload" + return 1 + fi + + if [ ${_slow_thresh} -gt ${_slow_time} ]; then + echo "The slow group does not appear to have been throttled" + return 1 + fi + + echo "Silence is golden" + return 0 +} diff --git a/tests/block/025.out b/tests/block/025.out new file mode 100644 index 000000000000..c19ff631b9b5 --- /dev/null +++ b/tests/block/025.out @@ -0,0 +1 @@ +Silence is golden