From patchwork Fri Apr 12 18:50:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Kacur X-Patchwork-Id: 788538 Received: from mail-yb1-f181.google.com (mail-yb1-f181.google.com [209.85.219.181]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0472954F87 for ; Fri, 12 Apr 2024 18:51:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.181 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712947893; cv=none; b=uQthdakXMOamwV2/dNRrfdEMvpP2SUX2qSGunTMzniltRiXpXnojQEQv+mNF5OCPSkvyCxoLJiwReYcp4rHjy5PVMFCPYUSU28UxIDjxNK6jLZmXHlxA/QUA3QZrFZb/0hjaTmyiFxwuxcZMx0eq6BMmQqudlcNRcsJD21dOxbQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712947893; c=relaxed/simple; bh=zRf08E/euspiAsmAPxvlABO5dKqo06j0IfcivLx6Ttk=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=n1RuZkkG7uCWvsQmIivluWLL15FPYYpBhRF1DoBe0E7GaymW9R14OAm105sNI9TIyWOv+ZJHz/7jdpAP7LmX7GkYimzNA+xy/jBqA7Xbn+9twXwmQlsxA8SYLNT4rUBvGXhcyhoEhZ0u3JR1nIUQ5nTUAP40TBmHlAi35+oHxsI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=j146JWSO; arc=none smtp.client-ip=209.85.219.181 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="j146JWSO" Received: by mail-yb1-f181.google.com with SMTP id 3f1490d57ef6-dcc73148611so1411583276.3 for ; Fri, 12 Apr 2024 11:51:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1712947890; x=1713552690; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:sender:from:to:cc:subject:date:message-id:reply-to; bh=5Ne34t1ABkSiXU3G+sKa7u4BaZfKvUiRaV+hzM5X+GY=; b=j146JWSOh9OanqjklVDKE5WvXlHRQrs2eCaOOngEmXiKAdIZv9LjKNrz0Zmfrb/iUi Tr6yBONLw1XY5RRFrItkdaRHHy2kgDsrZDj/qwynIZutBWp+4ZZc+prKW+OkCzb3DFiE i24bT8ZU9J2zwmFSTe9rUYd5/HppR7EN6QyXCET8xn23hIZyUxZJhsFWo98YeFQgWGeg Ekh/9wP6N7UyzNIOoPjBraraCRXzz6HeoBFneHPajp3KosDIEKpaaCJLNFpGI7GKTwNj MKidUClaKL4nwszkzh4RxQVKQ8Den6ax0OYcsl1zZgcpZQmMPBELWe/no5uLEZt9I0uY Bd1Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712947890; x=1713552690; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:sender:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=5Ne34t1ABkSiXU3G+sKa7u4BaZfKvUiRaV+hzM5X+GY=; b=KJp8sxLVvn3Qq9GkTkPyk4faGGAIE50mNiRtnFGTUiHpBjtS62WDksmFBujI1aERA4 STvHJq7r1DjdFpZ2Pd9mpCqZnn3yx7GA3ypCH8Wu1AGzZRnW073FVO5cf2WP/9zNm96Q e+XtVfpbj6rKopJOO6UPE0gnm9/tqiF2rtdOHjn0d0tPsce+zXsuH2v1DS1FoSCVEx0f YflfknCTPwgPuGv8y9NJ7+EnSGwOxZMVZX9tfUOCm7fY0QUNQ1e3jNypiR7HihR8GAwk 3GuBem7YHQ+Ehw09yvbsEZQ9P1MT3Rkv4MP+ofGOmjWzJ4Z3Ikoa/4iJHPBMBR58rQcO g4CQ== X-Gm-Message-State: AOJu0YyOknp5EPcjVWhPrsHmjn36AeEwjgz9aThcZpRBoxmv05R6dqwr VyYRq0UpNXa058d6LHusKcOORenWq00x2kA6JvgJBo0bcqA1YuxBeaCVPw== X-Google-Smtp-Source: AGHT+IGj7qQcKoqIKcxN/8HWP+NrumRD+fC4KPqdEs2pcI/Tk4GCnNKWtzcNC6xEHeLf6nJIr1A8pA== X-Received: by 2002:a25:dc06:0:b0:de0:f811:be41 with SMTP id y6-20020a25dc06000000b00de0f811be41mr3564579ybe.14.1712947890391; Fri, 12 Apr 2024 11:51:30 -0700 (PDT) Received: from fionn.redhat.com ([74.12.5.183]) by smtp.gmail.com with ESMTPSA id dj12-20020a056214090c00b0069b3bfdea09sm2628750qvb.60.2024.04.12.11.51.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Apr 2024 11:51:29 -0700 (PDT) Sender: John Kacur From: John Kacur To: RT Cc: Clark Williams , Kate Carcia Poulin , Juri Lelli , Daniel Bristot de Oliveria , John Kacur Subject: [PATCH 1/2] rteval: Cyclictest.py: Make standalone file work again Date: Fri, 12 Apr 2024 14:50:51 -0400 Message-ID: <20240412185052.87056-1-jkacur@redhat.com> X-Mailer: git-send-email 2.44.0 Precedence: bulk X-Mailing-List: linux-rt-users@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Make standalone Cyclictest.py work again for testing purposes - remove unused parse_cpulist_from_config - Instead of "import as", use "from" and the requested functionality - Obtain the default buckets from the ModuleParameters to use if a number is not otherwise provided - set the cpulist to "" if not otherwise provided - add a few docstrings to functions - obtain a default cpulist from online_cpus for the standalone test Signed-off-by: John Kacur --- rteval/modules/measurement/cyclictest.py | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/rteval/modules/measurement/cyclictest.py b/rteval/modules/measurement/cyclictest.py index 722422589d62..671426e13c4d 100644 --- a/rteval/modules/measurement/cyclictest.py +++ b/rteval/modules/measurement/cyclictest.py @@ -16,10 +16,8 @@ import math import libxml2 from rteval.Log import Log from rteval.modules import rtevalModulePrototype -from rteval.systopology import cpuinfo, parse_cpulist_from_config -import rteval.cpulist_utils as cpulist_utils - -expand_cpulist = cpulist_utils.expand_cpulist +from rteval.systopology import cpuinfo, SysTopology +from rteval.cpulist_utils import expand_cpulist, collapse_cpulist class RunData: '''class to keep instance data from a cyclictest run''' @@ -190,10 +188,11 @@ class Cyclictest(rtevalModulePrototype): # Create a RunData object per CPU core self.__numanodes = int(self.__cfg.setdefault('numanodes', 0)) self.__priority = int(self.__cfg.setdefault('priority', 95)) - self.__buckets = int(self.__cfg.setdefault('buckets', 2000)) + default_buckets = ModuleParameters()["buckets"]["default"] + self.__buckets = int(self.__cfg.setdefault('buckets', default_buckets)) self.__numcores = 0 self.__cyclicdata = {} - self.__cpulist = self.__cfg.cpulist + self.__cpulist = self.__cfg.setdefault('cpulist', "") self.__cpus = [str(c) for c in expand_cpulist(self.__cpulist)] self.__numcores = len(self.__cpus) @@ -393,14 +392,13 @@ class Cyclictest(rtevalModulePrototype): return rep_n - def ModuleInfo(): return {"parallel": True, "loads": True} - def ModuleParameters(): + """ default parameters """ return {"interval": {"descr": "Base interval of the threads in microseconds", "default": 100, "metavar": "INTV_US"}, @@ -421,6 +419,7 @@ def ModuleParameters(): def create(params, logger): + """ Instantiate a Cyclictest measurement module object """ return Cyclictest(params, logger) @@ -438,9 +437,7 @@ if __name__ == '__main__': cfg.AppendConfig('cyclictest', prms) cfg_ct = cfg.GetSection('cyclictest') - cfg_ct.reportdir = "." - cfg_ct.buckets = 200 - # cfg_ct.breaktrace = 30 + cfg_ct.cpulist = collapse_cpulist(SysTopology().online_cpus()) runtime = 10 From patchwork Fri Apr 12 18:50:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Kacur X-Patchwork-Id: 790107 Received: from mail-yw1-f173.google.com (mail-yw1-f173.google.com [209.85.128.173]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 69908502A9 for ; Fri, 12 Apr 2024 18:51:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.173 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712947895; cv=none; b=qJAJ09EV0LVxqOeDOo+OVf5DAp09cQm95YOsuv6kCaOWTFscqgXeyCHLtegyxIAv03/gNdjmFcIJhf2vdQCIRYkJSSskyahtpP6ftCsckiOTGjcf63puqB/XDoBHUMkTr4hjc09hG0M9YX1FmY5VE30vxmDfNX/Ol01Okp9/pKk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712947895; c=relaxed/simple; bh=XzGwgVP800Qqt0Lq6nPLDXvFOpY4463WqkJRzjgbiR0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Q0k01kXd5kTvzNeFWmeGH+0ZJlxk6wrjx1POM6d/2PcoqlHXzjI+8sxc3tudmD9DE6rWqpDq53CZq4AH0OPIbLKIUDerTv6WqaeyvjS01ZwFp3FBcAClPNIpN/xHNUHBGzvBw+JzfNrr9HfFSsOt6S0izJaIvUhB5y2aG/B0yD8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=X8i6DuDZ; arc=none smtp.client-ip=209.85.128.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="X8i6DuDZ" Received: by mail-yw1-f173.google.com with SMTP id 00721157ae682-6150670d372so11856967b3.1 for ; Fri, 12 Apr 2024 11:51:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1712947892; x=1713552692; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:from:to:cc:subject:date :message-id:reply-to; bh=PP9TvVmT/+srt8gV2VQaWYsPoljM418Ggkc6YqQj+QY=; b=X8i6DuDZ91aHGtzKEfGhpXa1c/YHLQV2FcLmmiwuAvGsbNeS7Oi8h4hSvzn6A2DdpY 4dd5GAJcJcn2Rw0oaWgEoi8yRPdlEHIrys31yZNp2emOR3Z56XFuNbXT2kmO25lwSc4y TK569TDYYv3rofpSiaklZMS6L2JNIR5ULwPQ1y2zBtzn8Y4tv36Hxwq/4BhRa7SlDmBP P90WTX3TORfkomgYcCioBLhVDM81JXkVhENPNYF4mL7cNVzemOS/0zECO5e+A7gmuhT6 KddKboYHhFVQxCEutqgTGWraBUQOCGsoqq7fjPaH74/nrvGj06rFur8ayHDl1HUAZmgM K16Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712947892; x=1713552692; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=PP9TvVmT/+srt8gV2VQaWYsPoljM418Ggkc6YqQj+QY=; b=g4JYYnHMdrs7TgOXD9fKf8roQ++odKlZwKN3ckVBTiRLunp095JI5NRQrpzqBAGfyQ tdXPoCYF4THuE2SUCTUROzpmwALowSsTM2nJDiKL9TG51hEgJpnQmozOVPFZ3gK+CmRa Mg6IQWteWojB4q0/9xQM4g+60SySyaOtWIqbCV562o9OiYK1KoyzBWvEaz7FlYT040sa NkPwPk6sR/af6QIjxUEh9iv62rIf8DvY7wHMBtPRT7YrizmCo3GJwK232Vw27AvrYJZU CCJYToNRmALXG0rTttYegzjFuCFsClpHgkbtwOxPKHpWdC0szXaA7E4srMCh+he8w/YF N2sA== X-Gm-Message-State: AOJu0Yx8GFMC2b1dTx44/vYjWCeUUp/dRmcXvDB4+ha4huLLCPkVl3BH xLdyQNePMjhoJf/tpZ0rgcGPBvFx8gapTupVtLFa9/Sg/WEHuaWW4F7gxw== X-Google-Smtp-Source: AGHT+IEgjNqWg3JYi2nXzHcF0mFCH7a3J1P7/+NU46Vlzsquuvt/UBUgW1ecvTANcRz5MhDDNwOXlA== X-Received: by 2002:a81:7e06:0:b0:618:517b:9dcf with SMTP id o6-20020a817e06000000b00618517b9dcfmr3107070ywn.22.1712947891797; Fri, 12 Apr 2024 11:51:31 -0700 (PDT) Received: from fionn.redhat.com ([74.12.5.183]) by smtp.gmail.com with ESMTPSA id dj12-20020a056214090c00b0069b3bfdea09sm2628750qvb.60.2024.04.12.11.51.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Apr 2024 11:51:31 -0700 (PDT) Sender: John Kacur From: John Kacur To: RT Cc: Clark Williams , Kate Carcia Poulin , Juri Lelli , Daniel Bristot de Oliveria , John Kacur Subject: [PATCH 2/2] rteval: Add rtla timerlat as a measurement module Date: Fri, 12 Apr 2024 14:50:52 -0400 Message-ID: <20240412185052.87056-2-jkacur@redhat.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240412185052.87056-1-jkacur@redhat.com> References: <20240412185052.87056-1-jkacur@redhat.com> Precedence: bulk X-Mailing-List: linux-rt-users@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 This is the first step to adding timerlat as a measurement module With this change you can run timerlat as a standalone rteval file like this (as root) python rteval/modules/measurement/timerlat.py You can also modify your rteval.conf to list timerlat in the [measurement] section, for example like this [measurement] cyclictest: module timerlat: module and then both measurement moduels will be run from rteval, for example rteval -D -d5m --measurement-cpulist=1-5 Will run rteval with Debug info, for 5m and cyclictest and timerlat will run on cpus 1-5 and load modules will run on the other available cpus. Currently MakeReport just prints to standard out the same information that timerlat outputs, in otherwords, there is no processing into xml yet. Also, there is no way to invoke tracing at the time, but that will be added soon! Signed-off-by: John Kacur --- rteval-cmd | 1 + rteval/modules/measurement/timerlat.py | 131 +++++++++++++++++++++++++ 2 files changed, 132 insertions(+) create mode 100644 rteval/modules/measurement/timerlat.py diff --git a/rteval-cmd b/rteval-cmd index c72bc614ad78..5cb6d7a44523 100755 --- a/rteval-cmd +++ b/rteval-cmd @@ -247,6 +247,7 @@ if __name__ == '__main__': if not config.HasSection('measurement'): config.AppendConfig('measurement', { 'cyclictest' : 'module', + 'timerlat' : 'module', 'sysstat' : 'module'}) # Prepare log levels before loading modules, not to have unwanted log messages diff --git a/rteval/modules/measurement/timerlat.py b/rteval/modules/measurement/timerlat.py new file mode 100644 index 000000000000..d4e78de8d2a2 --- /dev/null +++ b/rteval/modules/measurement/timerlat.py @@ -0,0 +1,131 @@ +# SPDX-License-Identifier: GPL-2.0-or-later +# +# Copyright 2024 John Kacur +# +""" timerlat.py - objectd to manage rtla timerlat """ +import os +import subprocess +import signal +import time +import tempfile +import libxml2 +from rteval.Log import Log +from rteval.modules import rtevalModulePrototype +from rteval.systopology import cpuinfo, SysTopology +from rteval.cpulist_utils import expand_cpulist, collapse_cpulist + +class Timerlat(rtevalModulePrototype): + """ measurement modules for rteval """ + def __init__(self, config, logger=None): + rtevalModulePrototype.__init__(self, 'measurement', 'timerlat', logger) + + self.__cfg = config + + self.__numanodes = int(self.__cfg.setdefault('numanodes', 0)) + self.__priority = int(self.__cfg.setdefault('priority', 95)) + + self.__cpulist = self.__cfg.setdefault('cpulist', "") + self.__cpus = [str(c) for c in expand_cpulist(self.__cpulist)] + self.__numcores = len(self.__cpus) + + self.__timerlat_out = None + self.__timerlat_err = None + self.__started = False + self._log(Log.DEBUG, f"system using {self.__numcores} cpu cores") + + + def _WorkloadSetup(self): + self.__timerlat_process = None + + def _WorkloadBuild(self): + self._setReady() + + def _WorkloadPrepare(self): + self.__cmd = ['rtla', 'timerlat', 'hist', '-P', f'f:{int(self.__priority)}', '-u'] + self.__cmd.append(f'-c{self.__cpulist}') + self._log(Log.DEBUG, f'self.__cmd = {self.__cmd}') + self.__timerlat_out = tempfile.SpooledTemporaryFile(mode='w+b') + self.__timerlat_err = tempfile.SpooledTemporaryFile(mode='w+b') + + def _WorkloadTask(self): + if self.__started: + return + + self._log(Log.DEBUG, f'starting with cmd: {" ".join(self.__cmd)}') + + self.__timerlat_out.seek(0) + self.__timerlat_err.seek(0) + try: + self.__timerlat_process = subprocess.Popen(self.__cmd, + stdout=self.__timerlat_out, + stderr=self.__timerlat_err, + stdin=None) + self.__started = True + except OSError: + self.__started = False + + def WorkloadAlive(self): + if self.__started: + return self.__timerlat_process.poll() is None + return False + + def _WorkloadCleanup(self): + if not self.__started: + return + while self.__timerlat_process.poll() is None: + self._log(Log.DEBUG, "Sending SIGINT") + os.kill(self.__timerlat_process.pid, signal.SIGINT) + time.sleep(2) + + self._setFinished() + self.__started = False + + def MakeReport(self): + self.__timerlat_out.seek(0) + for line in self.__timerlat_out: + line = bytes.decode(line) + print(line) + self.__timerlat_out.close() + + +def ModuleInfo(): + """ Required measurement module information """ + return {"parallel": True, + "loads": True} + +def ModuleParameters(): + """ default parameters """ + return {"priority": {"descr": "Run rtla timerlat with this priority", + "default": 95, + "metavar": "PRIO" } + } + +def create(params, logger): + """ Instantiate a Timerlat measurement module object""" + return Timerlat(params, logger) + +if __name__ == '__main__': + from rteval.rtevalConfig import rtevalConfig + + l = Log() + l.SetLogVerbosity(Log.INFO|Log.DEBUG|Log.ERR|Log.WARN) + + cfg = rtevalConfig({}, logger=l) + prms = {} + modprms = ModuleParameters() + for c, p in list(modprms.items()): + prms[c] = p['default'] + cfg.AppendConfig('timerlat', prms) + + cfg_tl = cfg.GetSection('timerlat') + cfg_tl.cpulist = collapse_cpulist(SysTopology().online_cpus()) + + RUNTIME = 10 + + tl = Timerlat(cfg_tl, l) + tl._WorkloadSetup() + tl._WorkloadPrepare() + tl._WorkloadTask() + time.sleep(RUNTIME) + tl._WorkloadCleanup() + tl.MakeReport()