From patchwork Tue Dec 13 11:47:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Clark X-Patchwork-Id: 32775 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:e747:0:0:0:0:0 with SMTP id c7csp69518wrn; Tue, 13 Dec 2022 03:54:56 -0800 (PST) X-Google-Smtp-Source: AA0mqf4q4iAh2WvKznZ2Mch81svcNnwpc1nn9mkuKlY1mBz89ylbpmsXTyA34PQXjFsYFnSFL1aO X-Received: by 2002:a05:6a20:9594:b0:a3:aabe:54b8 with SMTP id iu20-20020a056a20959400b000a3aabe54b8mr23671410pzb.38.1670932495751; Tue, 13 Dec 2022 03:54:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670932495; cv=none; d=google.com; s=arc-20160816; b=FI/HhKQjSxZts0K0W8fxb0E2LzLOd4eCXmyiCOn/a3YUFvI2Xn8OiERzdwzONgilQp xww2OrrytH4vILNwhOEwJ3O6t5tNDk5TxXrQqUCVVutzsH4K+Dj08RHQ9iXlo0i+sR0s BUw38QeXv0MNK61ztugJUdVDwz9NlBjRXfWodMZICbibCcp9055q451FG3Zw7d+lDj+s t1PWXp5pKxCuYVKdSC5E8EbLiPHfTyELTG4qrb2t7rxGnGrySs/EmorHm6TNA0eci9bn XZZe8AScsgI6/HRhKrb10eAIaP43KaVN30we+P5RrmHmyucEH/Oy1IqDUh53zfo682ea N/8A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=k9fWIRSYB8bpTYlURR2842NnJ0+NscShFSnXz6Rc7Rk=; b=xwBjkSncYJ4bB8eWbEBI5w+EC0MqgM86u362K1JaIFYKbvSVMiI/te2xxdQFXUdJzf nRDeaJABx0FbHK/6DXnSmc1aKDq+PLmahfcpOGTVFKnsSuPDrxcza2cOBIRQEXLubdFK Y1LqF1nCXJVnbbCwh9r+peY7DmClU8NAlUE3bLayinjmsZ8CEI7uVS1quFw5Z6IyPfby s+StnI/bKob0dZEyt29HpeJIdGs5SEAMutToLprAG8ZQXTlGX1ylWS5c+KeaNqX/Sn5H 2gOUCU7Zb8ojuXYlBeXxVCsQcMhzBJnffXp5xdRp+XvFaj8k9wGMbuBX68hkE88/v7o5 P/RA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c17-20020a631c11000000b00438766f903asi11627778pgc.490.2022.12.13.03.54.42; Tue, 13 Dec 2022 03:54:55 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235280AbiLMLud (ORCPT + 99 others); Tue, 13 Dec 2022 06:50:33 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44858 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235274AbiLMLu0 (ORCPT ); Tue, 13 Dec 2022 06:50:26 -0500 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id A4B6510FFE; Tue, 13 Dec 2022 03:50:24 -0800 (PST) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id DEC191682; Tue, 13 Dec 2022 03:51:04 -0800 (PST) Received: from e126815.warwick.arm.com (e126815.arm.com [10.32.32.26]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id BB3683F5A1; Tue, 13 Dec 2022 03:50:22 -0800 (PST) From: James Clark To: linux-perf-users@vger.kernel.org Cc: James Clark , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , linux-kernel@vger.kernel.org, bpf@vger.kernel.org Subject: [PATCH v2 1/4] perf test: Add ability to test exit code for attr tests Date: Tue, 13 Dec 2022 11:47:36 +0000 Message-Id: <20221213114739.2312862-2-james.clark@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221213114739.2312862-1-james.clark@arm.com> References: <20221213114739.2312862-1-james.clark@arm.com> MIME-Version: 1.0 X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1752099712491309981?= X-GMAIL-MSGID: =?utf-8?q?1752099712491309981?= Currently the return value is used to skip the test, but sometimes it can be useful to test if a certain command should return a certain exit code. Signed-off-by: James Clark --- tools/perf/tests/attr.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/tools/perf/tests/attr.py b/tools/perf/tests/attr.py index cb39ac46bc73..cf40df472918 100644 --- a/tools/perf/tests/attr.py +++ b/tools/perf/tests/attr.py @@ -129,7 +129,8 @@ class Event(dict): # - needs to specify: # 'command' - perf command name # 'args' - special command arguments -# 'ret' - expected command return value (0 by default) +# 'ret' - Skip test if Perf doesn't exit with this value (0 by default) +# 'test_ret'- If set to 'true', fail test instead of skipping for 'ret' argument # 'arch' - architecture specific test (optional) # comma separated list, ! at the beginning # negates it. @@ -155,6 +156,8 @@ class Test(object): except: self.ret = 0 + self.test_ret = parser.getboolean('config', 'test_ret', fallback=False) + try: self.arch = parser.get('config', 'arch') log.warning("test limitation '%s'" % self.arch) @@ -232,7 +235,10 @@ class Test(object): log.info(" '%s' ret '%s', expected '%s'" % (cmd, str(ret), str(self.ret))) if not data_equal(str(ret), str(self.ret)): - raise Unsup(self) + if self.test_ret: + raise Fail(self, "Perf exit code failure") + else: + raise Unsup(self) def compare(self, expect, result): match = {} From patchwork Tue Dec 13 11:47:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Clark X-Patchwork-Id: 32776 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:e747:0:0:0:0:0 with SMTP id c7csp69555wrn; Tue, 13 Dec 2022 03:54:59 -0800 (PST) X-Google-Smtp-Source: AA0mqf4UmBHlZVsJ6FciFRTXDZmDWFCJbTcAlXp7+o5lYvdSP2JxsnT6/kOgBACW6L6pUCmSa1RB X-Received: by 2002:a17:903:234f:b0:189:9676:28a1 with SMTP id c15-20020a170903234f00b00189967628a1mr27101485plh.35.1670932499366; Tue, 13 Dec 2022 03:54:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670932499; cv=none; d=google.com; s=arc-20160816; b=bIeD51eIWsOxYnawlpepi/QpUGb0gIxH9BKYuv88HaU4JcjsU+M5sw0YqjIoe1swEY v+3U7LtYskSjrmI5Cjmiee+WwYzqUOQj9In5ztGDp/+4uI9JdFBJ3hLmtc1g+hXyib89 n6IN0ropGZIDiRHidHNelmyV9qhZePvgbEmw8RLXd99wutPQ3RPVFPwDSrssvNOrnpua N/043NP8CnVt9rh5ScQkWlTwndZndCFlq24zID9lRT/1v+quLKVO0N21macP951LhPKj KsmKn0pO2R0bPkPCkoqHW9qVHpIIjZ38HrqQ3XxGYuFZ+5OeQfjZb3LiZeFuC7Vb1e65 rjDg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=zhHUBOgpfIW1k/emvz/2sOKCRYuYfTs+EYHdYNeIzxo=; b=trzm6o60K+eYOtVH5dyf+zZ20t/nIJa/5uRTdKueRn7KtUX1Nk0q2f5NzgXusjmdZv FMMvT4HFEFeywTPLqUCGkLbPLQASsON72mCwkWOo0wbtzAuU7rs96lcGZdMStNeNAlm4 +HoyP8BDxvM/inmZvdiUPtv5LZPCsla9t/Q4GPnZ/PLR4HYsY4GCEXzdmh3Ipk4xvvyW +GS8bUl4P63ZZjkajxYshmbIFxhiAU6MyuLjmA/7bCwqAAK+ZIEFEmnNZB+POdr5k4BO Q3cx8vEUE/C2PiPF9Cf8BYpYevsHoSVBmGK4d67EG/Dqr+sGHlehOjJm7Ug2B92YbQeL Wh1w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ij22-20020a170902ab5600b001895e356f00si11657099plb.152.2022.12.13.03.54.46; Tue, 13 Dec 2022 03:54:59 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235386AbiLMLug (ORCPT + 99 others); Tue, 13 Dec 2022 06:50:36 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44972 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235299AbiLMLu2 (ORCPT ); Tue, 13 Dec 2022 06:50:28 -0500 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 0023A1057F; Tue, 13 Dec 2022 03:50:26 -0800 (PST) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 4D4FE1688; Tue, 13 Dec 2022 03:51:07 -0800 (PST) Received: from e126815.warwick.arm.com (e126815.arm.com [10.32.32.26]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 2A2993F5A1; Tue, 13 Dec 2022 03:50:25 -0800 (PST) From: James Clark To: linux-perf-users@vger.kernel.org Cc: James Clark , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , linux-kernel@vger.kernel.org, bpf@vger.kernel.org Subject: [PATCH v2 2/4] perf test: Add mechanism for skipping attr tests on auxiliary vector values Date: Tue, 13 Dec 2022 11:47:37 +0000 Message-Id: <20221213114739.2312862-3-james.clark@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221213114739.2312862-1-james.clark@arm.com> References: <20221213114739.2312862-1-james.clark@arm.com> MIME-Version: 1.0 X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1752099716373645505?= X-GMAIL-MSGID: =?utf-8?q?1752099716373645505?= This can be used to skip tests or provide different test values on different platforms. For example to run a test only where Arm SVE is present add this to the config section: auxv = auxv["AT_HWCAP"] & 0x200000 == 0x200000 The value is a freeform Python expression that is evaled in the context of a map called "auxv" that contains the decoded auxiliary vector. Signed-off-by: James Clark --- tools/perf/tests/attr.py | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/tools/perf/tests/attr.py b/tools/perf/tests/attr.py index cf40df472918..eceb6d022141 100644 --- a/tools/perf/tests/attr.py +++ b/tools/perf/tests/attr.py @@ -8,7 +8,9 @@ import glob import optparse import tempfile import logging +import re import shutil +import subprocess try: import configparser @@ -134,6 +136,8 @@ class Event(dict): # 'arch' - architecture specific test (optional) # comma separated list, ! at the beginning # negates it. +# 'auxv' - Truthy statement that is evaled in the scope of the auxv map. When false, +# the test is skipped. For example 'auxv["AT_HWCAP"] == 10'. (optional) # # [eventX:base] # - one or multiple instances in file @@ -164,6 +168,7 @@ class Test(object): except: self.arch = '' + self.auxv = parser.get('config', 'auxv', fallback=None) self.expect = {} self.result = {} log.debug(" loading expected events"); @@ -175,7 +180,28 @@ class Test(object): else: return True - def skip_test(self, myarch): + def skip_test_auxv(self): + def new_auxv(a, pattern): + items = list(filter(None, pattern.split(a))) + # AT_HWCAP is hex but doesn't have a prefix, so special case it + if items[0] == "AT_HWCAP": + value = int(items[-1], 16) + else: + try: + value = int(items[-1], 0) + except: + value = items[-1] + return (items[0], value) + + if not self.auxv: + return False + auxv = subprocess.check_output("LD_SHOW_AUXV=1 sleep 0", shell=True) \ + .decode(sys.stdout.encoding) + pattern = re.compile(r"[: ]+") + auxv = dict([new_auxv(a, pattern) for a in auxv.splitlines()]) + return not eval(self.auxv) + + def skip_test_arch(self, myarch): # If architecture not set always run test if self.arch == '': # log.warning("test for arch %s is ok" % myarch) @@ -225,9 +251,12 @@ class Test(object): def run_cmd(self, tempdir): junk1, junk2, junk3, junk4, myarch = (os.uname()) - if self.skip_test(myarch): + if self.skip_test_arch(myarch): raise Notest(self, myarch) + if self.skip_test_auxv(): + raise Notest(self, "auxv skip") + cmd = "PERF_TEST_ATTR=%s %s %s -o %s/perf.data %s" % (tempdir, self.perf, self.command, tempdir, self.args) ret = os.WEXITSTATUS(os.system(cmd)) From patchwork Tue Dec 13 11:47:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Clark X-Patchwork-Id: 32777 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:e747:0:0:0:0:0 with SMTP id c7csp69744wrn; Tue, 13 Dec 2022 03:55:23 -0800 (PST) X-Google-Smtp-Source: AA0mqf7gb1dKxbJubWdQ9IIxq/whVOwSLaZ7Te6z/eDw+C31JyW2RIyF9iSt8AjoysYgn+9RFFkx X-Received: by 2002:a17:902:ce03:b0:189:1cc6:c4 with SMTP id k3-20020a170902ce0300b001891cc600c4mr24137038plg.56.1670932523025; Tue, 13 Dec 2022 03:55:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670932523; cv=none; d=google.com; s=arc-20160816; b=hvrzR/y1e7FCtsP4ERc0YbrbKoABVGBAQI4qQQOYd99ME36SxAygpOlMK3ggcRXlh0 NqPb4IyWh497GP6Xv/E1QZXUtJyA/5MfYztH038QiMLdjB6uzJc2v3/LAxKM7kjkjps0 hcIXJrgKLPUNzb6Tc/oWVFoBEqQdKn8LUbxpaK5KHy1hiLrdblezs77wLPCZO7c5rHFU 1/y6HsNlYDGUmNZitOd1jIZ3zMVBptzRIm+wEvluiOJep4gBFV/6pBXG8nEFY5WoBq4t I5kjKu1GcjpPqDVj7PBJhLIu7CT2TSSI+OUK0ZUpnZa5g60BAW/MsMX5S95L92k1l7Ik lLvA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=rWPdzOukqJReNeGmMbblgWbKbrMGHgcUqPln9idDQR0=; b=tgAI8+UdrMc2xOHV9s6AmOaQFCUGQmq1b4rXMMDKPIjXDOnSe98Ji/3vfmBIBd2ZUm o2o5vI2kgWAOWi1rAhFNEGIWJ615rY45Z/ZyOHnjD9XCqEWZ5DwfgibpNmUz2cNYyT8Z mrJodo5cnVUE7ovgbyg/R1yXMVFhciGqbNz1E7SbK67xX9bGX9z8pRgxl0QzjfJoPT66 uvBHR/gc5zSjIanYgWiY1P5UGfvYKhw1ENBuo+1qc2SIfgmOf+ZsiFTIjKyglixR9sxG A3ksM8ezq9U0pdgTOR5ilLc6oeY7csk/0mhLYrOBXpvf9sNnWMY86QrwpLyNOiOfPvnk +m2A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t8-20020a170902e84800b00189c3cb41a6si4565650plg.93.2022.12.13.03.55.09; Tue, 13 Dec 2022 03:55:22 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235393AbiLMLul (ORCPT + 99 others); Tue, 13 Dec 2022 06:50:41 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45068 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235355AbiLMLua (ORCPT ); Tue, 13 Dec 2022 06:50:30 -0500 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 6BEDE11820; Tue, 13 Dec 2022 03:50:29 -0800 (PST) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id AFDF0168F; Tue, 13 Dec 2022 03:51:09 -0800 (PST) Received: from e126815.warwick.arm.com (e126815.arm.com [10.32.32.26]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 8B9243F5A1; Tue, 13 Dec 2022 03:50:27 -0800 (PST) From: James Clark To: linux-perf-users@vger.kernel.org Cc: James Clark , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , linux-kernel@vger.kernel.org, bpf@vger.kernel.org Subject: [PATCH v2 3/4] perf test: Add mechanism for skipping attr tests on kernel versions Date: Tue, 13 Dec 2022 11:47:38 +0000 Message-Id: <20221213114739.2312862-4-james.clark@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221213114739.2312862-1-james.clark@arm.com> References: <20221213114739.2312862-1-james.clark@arm.com> MIME-Version: 1.0 X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1752099740727257027?= X-GMAIL-MSGID: =?utf-8?q?1752099740727257027?= The first two version numbers are used since that is where the ABI changes happen, so seems to be the most useful for now. 'Until' is exclusive and 'since' is inclusive so that the same version number can be used to mark a point where the change comes into effect. This allows keeping the tests in a state where new tests will also pass on older kernels if the existence of a new feature isn't explicitly broadcast by the kernel. For example extended user regs are currently discovered by trial and error calls to perf_event_open. Signed-off-by: James Clark --- tools/perf/tests/attr.py | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/tools/perf/tests/attr.py b/tools/perf/tests/attr.py index eceb6d022141..ccfef861e931 100644 --- a/tools/perf/tests/attr.py +++ b/tools/perf/tests/attr.py @@ -6,6 +6,7 @@ import os import sys import glob import optparse +import platform import tempfile import logging import re @@ -125,6 +126,11 @@ class Event(dict): if not data_equal(self[t], other[t]): log.warning("expected %s=%s, got %s" % (t, self[t], other[t])) +def parse_version(version): + if not version: + return None + return [int(v) for v in version.split(".")[0:2]] + # Test file description needs to have following sections: # [config] # - just single instance in file @@ -138,7 +144,9 @@ class Event(dict): # negates it. # 'auxv' - Truthy statement that is evaled in the scope of the auxv map. When false, # the test is skipped. For example 'auxv["AT_HWCAP"] == 10'. (optional) -# +# 'kernel_since' - Inclusive kernel version from which the test will start running. Only the +# first two values are supported, for example "6.1" (optional) +# 'kernel_until' - Exclusive kernel version from which the test will stop running. (optional) # [eventX:base] # - one or multiple instances in file # - expected values assignments @@ -169,6 +177,8 @@ class Test(object): self.arch = '' self.auxv = parser.get('config', 'auxv', fallback=None) + self.kernel_since = parse_version(parser.get('config', 'kernel_since', fallback=None)) + self.kernel_until = parse_version(parser.get('config', 'kernel_until', fallback=None)) self.expect = {} self.result = {} log.debug(" loading expected events"); @@ -180,6 +190,16 @@ class Test(object): else: return True + def skip_test_kernel_since(self): + if not self.kernel_since: + return False + return not self.kernel_since <= parse_version(platform.release()) + + def skip_test_kernel_until(self): + if not self.kernel_until: + return False + return not parse_version(platform.release()) < self.kernel_until + def skip_test_auxv(self): def new_auxv(a, pattern): items = list(filter(None, pattern.split(a))) @@ -257,6 +277,12 @@ class Test(object): if self.skip_test_auxv(): raise Notest(self, "auxv skip") + if self.skip_test_kernel_since(): + raise Notest(self, "old kernel skip") + + if self.skip_test_kernel_until(): + raise Notest(self, "new kernel skip") + cmd = "PERF_TEST_ATTR=%s %s %s -o %s/perf.data %s" % (tempdir, self.perf, self.command, tempdir, self.args) ret = os.WEXITSTATUS(os.system(cmd)) From patchwork Tue Dec 13 11:47:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Clark X-Patchwork-Id: 32778 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:e747:0:0:0:0:0 with SMTP id c7csp69993wrn; Tue, 13 Dec 2022 03:55:52 -0800 (PST) X-Google-Smtp-Source: AA0mqf433b6bBx1Ll5QU5SvXiDzMzkAt2te9/P/DMEN3VSuhPseuN10XUn9s7fC3aZcywEo/KDmi X-Received: by 2002:a17:902:f548:b0:18e:c6b0:b2f6 with SMTP id h8-20020a170902f54800b0018ec6b0b2f6mr13436444plf.14.1670932551854; Tue, 13 Dec 2022 03:55:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670932551; cv=none; d=google.com; s=arc-20160816; b=IFDQeAk+ef51gHOY8QWqAy0BbCY3s5xG0jXcRkeJTq4xUX5TAP6PSv1d8qCYGd8NXg Dth+nSIjj0UNrI3hIIxIijvytk2sBaIfMhRIwlnQ6bueotlTo8qt8g960VcIIzoMf2tB TQOddJHE4VOuilgktp89R9vu2TfqhQEO2bxKKJyjmS66dCKOmtXnlh7APWwflJA62TZe 4Y4L2K7FR8H0jamIBSRwIfEm5kRsphpJyF9ZJ3mS53xD3D5dmz8mgiTsCmMzK/JSNBhd fxhdxE696ZHaf8uGCvGBvTvGQ/AqpVD3Y9U3YycL5C26RjY6is7rNsxam8O0Wp6HK2bB AqOA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=iPXrI6wqcifxFihFsjxp2jiWct4a5R8F6ZfsZ/ihcVY=; b=zE5My5EAcMOpVU96U841H4K3t+dkO9oyabLasBHBtFE2aI17DHhOT4Uw08gBDaVgSx 2RitPUoNDIVz/ptveqcK2IbXhKFUrUuayXdb2Hw5fqcCfYosSu+JcLm79TKAnQA5g2rA PhZwu7xdPhLYrQDkQQ0kDBSsWCeK0vWwhgltd9Vc+NbDZLGMJFVRFp3ybvwo00NgJDEt JFHToyiH/Cci1bRIzBrzRKvu+l3Ap663TR5te5bcl4akXq2mV6UxHvgxi4FTmxf/69lA 0QBF6EhM+8HloNjxIp7eC50aH+vf9nAGHtc49SQ7G4KIAKzDnweb1bARM4RN4iQ2WvxR frlw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y62-20020a636441000000b0043946964302si13157148pgb.173.2022.12.13.03.55.38; Tue, 13 Dec 2022 03:55:51 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235355AbiLMLvA (ORCPT + 99 others); Tue, 13 Dec 2022 06:51:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45008 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235361AbiLMLud (ORCPT ); Tue, 13 Dec 2022 06:50:33 -0500 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id B922813E37; Tue, 13 Dec 2022 03:50:31 -0800 (PST) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 1CFBE2F4; Tue, 13 Dec 2022 03:51:12 -0800 (PST) Received: from e126815.warwick.arm.com (e126815.arm.com [10.32.32.26]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id EE4863F5A1; Tue, 13 Dec 2022 03:50:29 -0800 (PST) From: James Clark To: linux-perf-users@vger.kernel.org Cc: James Clark , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , linux-kernel@vger.kernel.org, bpf@vger.kernel.org Subject: [PATCH v2 4/4] perf test arm64: Add attr tests for new VG register Date: Tue, 13 Dec 2022 11:47:39 +0000 Message-Id: <20221213114739.2312862-5-james.clark@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221213114739.2312862-1-james.clark@arm.com> References: <20221213114739.2312862-1-james.clark@arm.com> MIME-Version: 1.0 X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1752099771536816961?= X-GMAIL-MSGID: =?utf-8?q?1752099771536816961?= Ensure that the availability of the VG register behaves as expected depending on the kernel version and SVE support. Signed-off-by: James Clark --- .../attr/test-record-user-regs-no-sve-aarch64 | 9 +++++++++ .../attr/test-record-user-regs-old-sve-aarch64 | 10 ++++++++++ .../tests/attr/test-record-user-regs-sve-aarch64 | 14 ++++++++++++++ 3 files changed, 33 insertions(+) create mode 100644 tools/perf/tests/attr/test-record-user-regs-no-sve-aarch64 create mode 100644 tools/perf/tests/attr/test-record-user-regs-old-sve-aarch64 create mode 100644 tools/perf/tests/attr/test-record-user-regs-sve-aarch64 diff --git a/tools/perf/tests/attr/test-record-user-regs-no-sve-aarch64 b/tools/perf/tests/attr/test-record-user-regs-no-sve-aarch64 new file mode 100644 index 000000000000..fbb065842880 --- /dev/null +++ b/tools/perf/tests/attr/test-record-user-regs-no-sve-aarch64 @@ -0,0 +1,9 @@ +# Test that asking for VG fails if the system doesn't support SVE. This +# applies both before and after the feature was added in 6.1 +[config] +command = record +args = --no-bpf-event --user-regs=vg kill >/dev/null 2>&1 +ret = 129 +test_ret = true +arch = aarch64 +auxv = auxv["AT_HWCAP"] & 0x200000 == 0 diff --git a/tools/perf/tests/attr/test-record-user-regs-old-sve-aarch64 b/tools/perf/tests/attr/test-record-user-regs-old-sve-aarch64 new file mode 100644 index 000000000000..15ebfc3418e3 --- /dev/null +++ b/tools/perf/tests/attr/test-record-user-regs-old-sve-aarch64 @@ -0,0 +1,10 @@ +# Test that asking for VG always fails on old kernels because it was +# added in 6.1. This applies to systems that either support or don't +# support SVE. +[config] +command = record +args = --no-bpf-event --user-regs=vg kill >/dev/null 2>&1 +ret = 129 +test_ret = true +arch = aarch64 +kernel_until = 6.1 diff --git a/tools/perf/tests/attr/test-record-user-regs-sve-aarch64 b/tools/perf/tests/attr/test-record-user-regs-sve-aarch64 new file mode 100644 index 000000000000..c598c803221d --- /dev/null +++ b/tools/perf/tests/attr/test-record-user-regs-sve-aarch64 @@ -0,0 +1,14 @@ +# Test that asking for VG works if the system has SVE and after the +# feature was added in 6.1 +[config] +command = record +args = --no-bpf-event --user-regs=vg kill >/dev/null 2>&1 +ret = 1 +test_ret = true +arch = aarch64 +auxv = auxv["AT_HWCAP"] & 0x200000 == 0x200000 +kernel_since = 6.1 + +[event:base-record] +sample_type=4359 +sample_regs_user=70368744177664