From patchwork Mon Dec 19 20:17:32 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Namhyung Kim X-Patchwork-Id: 34747 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:e747:0:0:0:0:0 with SMTP id c7csp2597193wrn; Mon, 19 Dec 2022 12:21:19 -0800 (PST) X-Google-Smtp-Source: AA0mqf4CWrAZbeKLwku0WOWC2QyQokTQxQ8qRsormBbBQDf40YNgBy1fUbToA+kVP6LGyRTrk26X X-Received: by 2002:a05:6a20:a012:b0:a6:713d:4343 with SMTP id p18-20020a056a20a01200b000a6713d4343mr50939393pzj.5.1671481278833; Mon, 19 Dec 2022 12:21:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671481278; cv=none; d=google.com; s=arc-20160816; b=UQKBmnd2uz9HsoF9ssxGDb3vBOXOS3QF8Ew2aPNW9XtAI0zPuVAikLrpkd+YvLvhW1 rVlQQEBk/5rUHqgbvLj85wjDxElRyNt5ijj04LQFDcI9uoEPkePrkTYz9dotsKdVXlP2 IcQxhh2zNGRNbHb88WQd/NCohq4/2efXv0J8kpowuHqjalzvEHtOuPKQeujOqL3RbYsp Io6or+Dzc+1cFl1CIKq5aSLyc+IeEbxHNU3GqNhqeG6zcSJG4CL8yNmcfzp9x5Dml2Nh iDRpWbyRyPlkrc25wVoJO/Tibdzg/VnonaPmK+CA/x9cW8pAjhN7yj/U+aBMgiVBxgDO 0cyQ== 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:sender :dkim-signature; bh=E/YKT1JJIPuRoA7Hx7R8arjPSGFufHSp1KclETKmED4=; b=wxpDrSrua4LUDhvTgEl8/2Hr94BXutWMjC0zu01Za6nxME4v59lhpbFTpxf+70+215 S6S2RG2URczZYqs+wU3IEZx3YYfrLtX3obrcnszlFaWhzz3SnSPXB3qj5qwaCnsLUGBu Jhf6CLMJ3DgZY4ZL02MBF0E6H0xFhTGZ7bYT2MKguiU5WJopFjxXjWB05FQdw2HAFA3y 4+UXOh/ZEkYwsJ/yHl6ubQ49bORUkjfUkzHcE15qx2nCoIrftK5z7ySac8Se28esXps+ dfP6X9Z5wb15T95xnxMTdBcxTziNxigmn+bcNyU5GDIPSjs+Maslt8yKsTeSLjEoCnI7 06dA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=HVbC+Iu6; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id cp6-20020a056a00348600b005726ac39d2esi11014750pfb.30.2022.12.19.12.21.06; Mon, 19 Dec 2022 12:21:18 -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; dkim=pass header.i=@gmail.com header.s=20210112 header.b=HVbC+Iu6; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232578AbiLSUSM (ORCPT + 99 others); Mon, 19 Dec 2022 15:18:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43788 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232502AbiLSURr (ORCPT ); Mon, 19 Dec 2022 15:17:47 -0500 Received: from mail-pj1-x1029.google.com (mail-pj1-x1029.google.com [IPv6:2607:f8b0:4864:20::1029]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D3F0D64ED; Mon, 19 Dec 2022 12:17:45 -0800 (PST) Received: by mail-pj1-x1029.google.com with SMTP id v23so5007547pju.3; Mon, 19 Dec 2022 12:17:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; 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=E/YKT1JJIPuRoA7Hx7R8arjPSGFufHSp1KclETKmED4=; b=HVbC+Iu6DOauKYKAjXJ43ZOUiX8W5s0QydrESBi85TvL2VmyDCJR/2ymPdVYq/iDf/ IO6JdGU4dwlAukwN6rby4URhzT7owcP4jlDE7KILweEbgmvaWh+tGJlJzYD1tXTVYGSc LWNHMvXZrUg5P/xm50ZkS7+tQkGNaKPvYW9Zn2vDbBdFSpLQ4WgcFx3BMgkEqaEOeGis jWD0VFpNiPZQg5fT8EfCEAdwmkBJFsP4/GCJSNA9Dq1G7InW2qzihT9tyIqEZHighyhM DI/RyyArd/3wL6L81SseIQT4GhJscNZJGGQ+Ozj6E5HBWubdlQs2B2YNCaYU0m9UzYI/ /Epg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=E/YKT1JJIPuRoA7Hx7R8arjPSGFufHSp1KclETKmED4=; b=X7XX/EOCfQbmZeg0Dnr/Oq/qtZc2UMRxaFSQwqe3QkjSewv4gcNcx9/zhtqf4O6NCC 5TXdof5GJh+qAMzcnXAdXnbdMCXFzI63M86OmbMKiaOU5LzGmckqPWsj3/1E2wfoGTZ6 0EUWuA/YoVD4q5pEXVLsCSdpCzRCWb9i98jVpg4J/+0RSElAyc8A3C0RofvfH0+nh1Wr 1qymH484eP7hEVVs7qXQqCoJR2G/aWrC5F7VHQKE/Z2i0ULKMDgtsQh5EhNpmkLh12cW ABBCp6/CB9TQp85x5Wxxpqma6Ssp7XXc/x8lBJ9yO1/UY5D2+f53ETjF8IBXgvtz+8PC t+4Q== X-Gm-Message-State: ANoB5pmZd8DZ19gwS+zUqY1UYv8o9XrY/sIfcBefOtYazmpidil+Rptn Ma29RzfaflyQQaGyNm7EAZs= X-Received: by 2002:a17:90b:2d83:b0:219:e002:1ba3 with SMTP id sj3-20020a17090b2d8300b00219e0021ba3mr46689926pjb.9.1671481065326; Mon, 19 Dec 2022 12:17:45 -0800 (PST) Received: from balhae.hsd1.ca.comcast.net ([2601:647:6780:ff0:735a:2805:e706:5164]) by smtp.gmail.com with ESMTPSA id f10-20020a17090ace0a00b00219220edf0dsm6324260pju.48.2022.12.19.12.17.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Dec 2022 12:17:44 -0800 (PST) Sender: Namhyung Kim From: Namhyung Kim To: Arnaldo Carvalho de Melo , Jiri Olsa Cc: Ingo Molnar , Peter Zijlstra , LKML , Ian Rogers , Adrian Hunter , linux-perf-users@vger.kernel.org, Song Liu , Blake Jones , bpf@vger.kernel.org Subject: [PATCH 6/6] perf test: Update perf lock contention test Date: Mon, 19 Dec 2022 12:17:32 -0800 Message-Id: <20221219201732.460111-7-namhyung@kernel.org> X-Mailer: git-send-email 2.39.0.314.g84b9a713c41-goog In-Reply-To: <20221219201732.460111-1-namhyung@kernel.org> References: <20221219201732.460111-1-namhyung@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE, SPF_PASS autolearn=no 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?1752675153343488604?= X-GMAIL-MSGID: =?utf-8?q?1752675153343488604?= Add more tests for the new filters. $ sudo perf test contention -v 87: kernel lock contention analysis test : --- start --- test child forked, pid 412379 Testing perf lock record and perf lock contention Testing perf lock contention --use-bpf Testing perf lock record and perf lock contention at the same time Testing perf lock contention --threads Testing perf lock contention --lock-addr Testing perf lock contention --type-filter Testing perf lock contention --lock-filter test child finished with 0 ---- end ---- kernel lock contention analysis test: Ok Signed-off-by: Namhyung Kim --- tools/perf/tests/shell/lock_contention.sh | 58 ++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/tools/perf/tests/shell/lock_contention.sh b/tools/perf/tests/shell/lock_contention.sh index cc9ceb9e19ca..b05f1b1ca6c8 100755 --- a/tools/perf/tests/shell/lock_contention.sh +++ b/tools/perf/tests/shell/lock_contention.sh @@ -115,7 +115,7 @@ test_aggr_addr() fi # the perf lock contention output goes to the stderr - perf lock con -a -b -t -E 1 -q -- perf bench sched messaging > /dev/null 2> ${result} + perf lock con -a -b -l -E 1 -q -- perf bench sched messaging > /dev/null 2> ${result} if [ $(cat "${result}" | wc -l) != "1" ]; then echo "[Fail] BPF result count is not 1:" $(cat "${result}" | wc -l) err=1 @@ -123,6 +123,60 @@ test_aggr_addr() fi } +test_type_filter() +{ + echo "Testing perf lock contention --type-filter (w/ spinlock)" + perf lock contention -i ${perfdata} -Y spinlock -q 2> ${result} + if [ $(grep -c -v spinlock "${result}") != "0" ]; then + echo "[Fail] Recorded should not have non-spinlocks:" $(cat "${result}") + err=1 + exit + fi + + if ! perf lock con -b true > /dev/null 2>&1 ; then + return + fi + + perf lock con -a -b -Y spinlock -q -- perf bench sched messaging > /dev/null 2> ${result} + if [ $(grep -c -v spinlock "${result}") != "0" ]; then + echo "[Fail] Recorded should not have non-spinlocks:" $(cat "${result}") + err=1 + exit + fi +} + +test_lock_filter() +{ + echo "Testing perf lock contention --lock-filter (w/ tasklist_lock)" + perf lock contention -i ${perfdata} -l -q 2> ${result} + if [ $(grep -c tasklist_lock "${result}") != "1" ]; then + echo "[Skip] Could not find 'tasklist_lock'" + return + fi + + perf lock contention -i ${perfdata} -L tasklist_lock -q 2> ${result} + + # find out the type of tasklist_lock + local type=$(head -1 "${result}" | awk '{ print $8 }' | sed -e 's/:.*//') + + if [ $(grep -c -v "${type}" "${result}") != "0" ]; then + echo "[Fail] Recorded should not have non-${type} locks:" $(cat "${result}") + err=1 + exit + fi + + if ! perf lock con -b true > /dev/null 2>&1 ; then + return + fi + + perf lock con -a -b -L tasklist_lock -q -- perf bench sched messaging > /dev/null 2> ${result} + if [ $(grep -c -v "${type}" "${result}") != "0" ]; then + echo "[Fail] Recorded should not have non-${type} locks:" $(cat "${result}") + err=1 + exit + fi +} + check test_record @@ -130,5 +184,7 @@ test_bpf test_record_concurrent test_aggr_task test_aggr_addr +test_type_filter +test_lock_filter exit ${err}