From patchwork Fri Aug 25 16:41:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Namhyung Kim X-Patchwork-Id: 13366143 Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BAA3A1079A for ; Fri, 25 Aug 2023 16:41:57 +0000 (UTC) Received: from mail-pl1-x636.google.com (mail-pl1-x636.google.com [IPv6:2607:f8b0:4864:20::636]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6E1DF2121; Fri, 25 Aug 2023 09:41:55 -0700 (PDT) Received: by mail-pl1-x636.google.com with SMTP id d9443c01a7336-1bdc243d62bso8839825ad.3; Fri, 25 Aug 2023 09:41:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1692981715; x=1693586515; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:sender:from:to:cc:subject:date:message-id:reply-to; bh=3QJes05NERO623clvngPrcz5iKhTHEmajQSFREZ7RHQ=; b=jxoI1LtcqwdpP75jgx1mtveqD+kyGqFmGdEnkbMYOcHujRlLjYHHYhQYXblsfcddN3 MSi5+QuNpaYQexiECkD6C9k1uvbjs/HEPj5BQjOGTNvWI66TDeL3m81b0kckF5TGbzau ayiRLNicgIvn9oPG3wc6zrIkaKp0LHISWiN+P+OsjyzwRFgpcyukZJ6PcwwRJ4DUcYLh K+l0EbeVOSRoHoF5dnCra7QREkZrvdD0/ZCKrDWKrrnVx/wSEJfmJMhHr7oqNCot5mTU nx0jvb2HfEdvn9Y6wyedZJ5sGsTLv5QYbGjXiSxx8o1Q1KN05CFfo9n7n2g2i+DXb0Pa u3qQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692981715; x=1693586515; 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=3QJes05NERO623clvngPrcz5iKhTHEmajQSFREZ7RHQ=; b=DCxvDGUG5at1sV/FGrzmf/tn9pjyOmc/vLH9FY6Bb+s3xW5KPNhQuersAhWWx1u1Pa BAT4EthPLfXPLaH0xzvQb+ShqUVszLYvf2gVpD3lyxsmNe/PBYUZygF+n88g4ohtlQdP sw+X8+mISQ0OEuXNGwz4/7GSEXFApY2vuQM8KzC1n94vygL8xqf8+S8jdREashhTtj/Y OdhZYP+bQUEGaZm9kGizNL5ApNq29Bkx39J7lk4zQUuFr3S7MVWLWiH7Wq7wdNB1nfRh TEL7GhQQ0S5a6CHsjcQxZCj9UHa9Vz/FvvXzdcSO5RO6Xyz9Zw1/UwTO283ZSWmeYITm 33OQ== X-Gm-Message-State: AOJu0YyfFsWMl//InjVDHd1H/zrKwJcC0Tbms9xuOU+2FqTPfj8DmG9x WeXIlxs9XkXyCK/r617j5pRz5VR4Kkk= X-Google-Smtp-Source: AGHT+IF8i7jha5yussgSKZnvLHR2KUUvlM8uSielz0FaWw1Zw38xKLDQbajXkdl1d/zFB+agBHZJDg== X-Received: by 2002:a17:902:e884:b0:1bc:3944:9391 with SMTP id w4-20020a170902e88400b001bc39449391mr19002224plg.25.1692981714726; Fri, 25 Aug 2023 09:41:54 -0700 (PDT) Received: from bangji.hsd1.ca.comcast.net ([2601:647:6780:42e0:a7ba:1788:3b00:4316]) by smtp.gmail.com with ESMTPSA id a6-20020a170902ecc600b001a5fccab02dsm1938755plh.177.2023.08.25.09.41.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Aug 2023 09:41:54 -0700 (PDT) Sender: Namhyung Kim From: Namhyung Kim To: Arnaldo Carvalho de Melo , Jiri Olsa Cc: Ian Rogers , Adrian Hunter , Peter Zijlstra , Ingo Molnar , LKML , linux-perf-users@vger.kernel.org, bpf@vger.kernel.org Subject: [PATCH 1/3] perf test: Skip 6.2 kernel for bpf-filter test Date: Fri, 25 Aug 2023 09:41:50 -0700 Message-ID: <20230825164152.165610-1-namhyung@kernel.org> X-Mailer: git-send-email 2.42.0.rc1.204.g551eb34607-goog Precedence: bulk X-Mailing-List: bpf@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Spam-Status: No, score=-1.5 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 The BPF sample filtering requires two kernel changes below: * bpf_cast_to_kernel_ctx() kfunc (added in v6.2) * setting perf_sample_data->sample_flags (finished in v6.3) The perf tools can check bpf_cast_to_kernel_ctx() easily so it can refuse BPF filters on those old kernels (v6.1 and earlier). But checking sample_flags appears to be difficult so current code won't work on v6.2 kernel. That's unfortunate but I don't know what's the correct way to handle it. For now, let's skip v6.2 kernels explicitly (if failed) in the test. Fixes: 9575ecdd198a ("perf test: Add perf record sample filtering test") Reported-by: Arnaldo Carvalho de Melo Signed-off-by: Namhyung Kim --- tools/perf/tests/shell/record_bpf_filter.sh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tools/perf/tests/shell/record_bpf_filter.sh b/tools/perf/tests/shell/record_bpf_filter.sh index e76ea861b92c..31c593966e8c 100755 --- a/tools/perf/tests/shell/record_bpf_filter.sh +++ b/tools/perf/tests/shell/record_bpf_filter.sh @@ -49,6 +49,12 @@ test_bpf_filter_basic() { fi if perf script -i "${perfdata}" -F ip | grep 'ffffffff[0-9a-f]*' then + if uname -r | grep -q ^6.2 + then + echo "Basic bpf-filter test [Skipped unsupported kernel]" + err=2 + return + fi echo "Basic bpf-filter test [Failed invalid output]" err=1 return From patchwork Fri Aug 25 16:41:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Namhyung Kim X-Patchwork-Id: 13366144 Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 624CA1079A for ; Fri, 25 Aug 2023 16:41:59 +0000 (UTC) Received: from mail-pl1-x62e.google.com (mail-pl1-x62e.google.com [IPv6:2607:f8b0:4864:20::62e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1DD6D212C; Fri, 25 Aug 2023 09:41:57 -0700 (PDT) Received: by mail-pl1-x62e.google.com with SMTP id d9443c01a7336-1bf5c314a57so9081295ad.1; Fri, 25 Aug 2023 09:41:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1692981716; x=1693586516; 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=cUtgrW6eNd+ei4mrqfgy4UMuQKUiyhEwVP11RhXLPpE=; b=Jc8X8yAx1DkKrdHZdfxfOShgApLb+rIQH7GDU1xK03aYl4kfwcTVeUL1Nva2yxD/Bk PWlIz+A+sF72o7hsB8GmFaHzRX4VE712f70f+YXRE0J9DunyUQqCy6SIJTOAB9Oco7Nz 9SIniGHbc4J5yKHQULUAvnKvyNfmA9Yuq6FWnbNOQGhkjWpK+LlRve8peiO8wGv45Hfr bAmb5zD583GpZ6jAlItk1HsNfXxHf3TkTuXc2tVW3WCVTn8pfYmrg5Us8nuK8PRJEFjg 7dVkDYFBHAlHofdteF2X3eItKSBeBabNmHMNL0GSFXe9NTMY9wanhEL2jxCp61o+dAMs WCpQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692981716; x=1693586516; 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=cUtgrW6eNd+ei4mrqfgy4UMuQKUiyhEwVP11RhXLPpE=; b=HO6+47q5TBgO/F+RX+mC8h/iLF1OeB7BnoUHyIrQDOlZA/tLuYRrYgrNMWC3izXBzM KRNc6IZItlABld86EizNXQiTPCzojoVRm4zD4/o2aNf3LYTzwFDS/rlbulVNFwoKsBYN cyTiazbw5otSQpcDs3DhHBviVHmFtGm1mAl4iiuRe9Co4V6sXmPUMGOwjFV1d2Lt94H6 i1SiCdLvB21swhtJTtkPtgKY/jbhLhDgF/KAi3uv4QxJuRQkYGQS0LYrUcsnGC/XZOpv ACvstwS9cheoQz4l2iHcHItsh81+mrQyPFWXPXORp6eYo12P9wRfRWQ6G0Ai4WNFjYzZ TeGw== X-Gm-Message-State: AOJu0Yy2jI2TxGXdONx14UQqH0c1V6F8ef7rwdIjp6UVS4SJNjd7clVz 2gIWUZsMjQmesBS5k1r3+yU= X-Google-Smtp-Source: AGHT+IGBzD+cTTDWVDeNmzMsaaNe4yOvAqQcp4oy39lViMnAhnidtdmiguACypbme5KwYbGWBM5kXQ== X-Received: by 2002:a17:902:744a:b0:1bc:9794:22ef with SMTP id e10-20020a170902744a00b001bc979422efmr15194104plt.1.1692981716413; Fri, 25 Aug 2023 09:41:56 -0700 (PDT) Received: from bangji.hsd1.ca.comcast.net ([2601:647:6780:42e0:a7ba:1788:3b00:4316]) by smtp.gmail.com with ESMTPSA id a6-20020a170902ecc600b001a5fccab02dsm1938755plh.177.2023.08.25.09.41.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Aug 2023 09:41:55 -0700 (PDT) Sender: Namhyung Kim From: Namhyung Kim To: Arnaldo Carvalho de Melo , Jiri Olsa Cc: Ian Rogers , Adrian Hunter , Peter Zijlstra , Ingo Molnar , LKML , linux-perf-users@vger.kernel.org, bpf@vger.kernel.org, stable@vger.kernel.org, Song Liu Subject: [PATCH 2/3] perf test: Fix perf stat bpf counters test on Intel Date: Fri, 25 Aug 2023 09:41:51 -0700 Message-ID: <20230825164152.165610-2-namhyung@kernel.org> X-Mailer: git-send-email 2.42.0.rc1.204.g551eb34607-goog In-Reply-To: <20230825164152.165610-1-namhyung@kernel.org> References: <20230825164152.165610-1-namhyung@kernel.org> Precedence: bulk X-Mailing-List: bpf@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Spam-Status: No, score=-1.5 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 As of now, bpf counters (bperf) don't support event groups. But the default perf stat includes topdown metrics if supported (on recent Intel machines) which require groups. That makes perf stat exiting. $ sudo perf stat --bpf-counter true bpf managed perf events do not yet support groups. Actually the test explicitly uses cycles event only, but it missed to pass the option when it checks the availability of the command. Fixes: 2c0cb9f56020d ("perf test: Add a shell test for 'perf stat --bpf-counters' new option") Cc: stable@vger.kernel.org Cc: Song Liu Signed-off-by: Namhyung Kim Reviewed-by: Song Liu --- tools/perf/tests/shell/stat_bpf_counters.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/perf/tests/shell/stat_bpf_counters.sh b/tools/perf/tests/shell/stat_bpf_counters.sh index 513cd1e58e0e..a87bb2814b4c 100755 --- a/tools/perf/tests/shell/stat_bpf_counters.sh +++ b/tools/perf/tests/shell/stat_bpf_counters.sh @@ -22,10 +22,10 @@ compare_number() } # skip if --bpf-counters is not supported -if ! perf stat --bpf-counters true > /dev/null 2>&1; then +if ! perf stat -e cycles --bpf-counters true > /dev/null 2>&1; then if [ "$1" = "-v" ]; then echo "Skipping: --bpf-counters not supported" - perf --no-pager stat --bpf-counters true || true + perf --no-pager stat -e cycles --bpf-counters true || true fi exit 2 fi From patchwork Fri Aug 25 16:41:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Namhyung Kim X-Patchwork-Id: 13366145 Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EBBBC1079A for ; Fri, 25 Aug 2023 16:41:59 +0000 (UTC) Received: from mail-pf1-x42c.google.com (mail-pf1-x42c.google.com [IPv6:2607:f8b0:4864:20::42c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 979F92121; Fri, 25 Aug 2023 09:41:58 -0700 (PDT) Received: by mail-pf1-x42c.google.com with SMTP id d2e1a72fcca58-68bed286169so1043812b3a.1; Fri, 25 Aug 2023 09:41:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1692981718; x=1693586518; 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=FW4E+AM7YfY1SfwCvaK4TvyMvmZxYdEKJUfQGWCuPjs=; b=nO1w4DJNHgyLYN+YaD2UH1IU6QsEOHPw+OcMe40j0TSIrzFaDNU25vWWX4csZVlYcN EKZlbArr9MKOdcCzrJwmkGbD0ujewuWri1rneVPwUZa+qQh8JCbgOK3+P+UNQn7hNnkc b/0kauIQgro4FVCMvVeoMzRT3tS8ngyu3pRoj9UA0Yuy0IH+6vAwQtMkMhQPyXphZuyv o3/s8rBICYtouECK7KdaJOwxp0fSgMZINTpK75C0srYFeitinC8ZuzwJcsUustNuNs9u M1M4VHfJVZaS0V5k6norBY2xiX1/Q1pj42tFr+KWRGsRBbuJ7Q34qx4+QnR9yCxxDFYJ lGUw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692981718; x=1693586518; 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=FW4E+AM7YfY1SfwCvaK4TvyMvmZxYdEKJUfQGWCuPjs=; b=TPWxV05K49lAnl2fdfxQy3w/rJur8EzsoIZ+KySKrbWeHN429k1/x84RSpFfveoOwT Y4L/SpeQvVOMOYFlmKs3lE1AcEvMeF60DvckI4Ye0+Z9oXUQLoVsizc4Uzy+Eit22qnD I6WfVIqAKHiU/AOGZ8CWns0FlL76CGn+/qAv2s3MoyX40qZoO3cbJcxHlQIOA/HEsB00 GCry0jtcHo8GMo35WGqeNwAadwuZHHvsohb4fCjV4RK05Ok60EiJOTtCrmB5JoNghoSp 928jRdVsa7WwQeEPjew53QLWRyd+KOlhw03aUUZ7dZIEX5Z92z7I/hvxHBZ3YKyvzfFD gxTg== X-Gm-Message-State: AOJu0YwK4cWPA83BW/xPOJkRjRl6m+zl6/x9sN9bM4tBxkzYu4FM5hHj pLvPsz11ZhBh8TD8OLLJqlIH9hzvgB8= X-Google-Smtp-Source: AGHT+IH76Uy9dWfkzhunLc6Inzv3riPINmhk+8c2nZQNB9rYOK3YNOq3x/747NYqsfjgA52CB0xHsA== X-Received: by 2002:a05:6a20:ceaf:b0:147:e55f:ccf3 with SMTP id if47-20020a056a20ceaf00b00147e55fccf3mr19396079pzb.47.1692981717962; Fri, 25 Aug 2023 09:41:57 -0700 (PDT) Received: from bangji.hsd1.ca.comcast.net ([2601:647:6780:42e0:a7ba:1788:3b00:4316]) by smtp.gmail.com with ESMTPSA id a6-20020a170902ecc600b001a5fccab02dsm1938755plh.177.2023.08.25.09.41.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Aug 2023 09:41:57 -0700 (PDT) Sender: Namhyung Kim From: Namhyung Kim To: Arnaldo Carvalho de Melo , Jiri Olsa Cc: Ian Rogers , Adrian Hunter , Peter Zijlstra , Ingo Molnar , LKML , linux-perf-users@vger.kernel.org, bpf@vger.kernel.org Subject: [PATCH 3/3] perf test: Enhance perf stat cgroup BPF counter test Date: Fri, 25 Aug 2023 09:41:52 -0700 Message-ID: <20230825164152.165610-3-namhyung@kernel.org> X-Mailer: git-send-email 2.42.0.rc1.204.g551eb34607-goog In-Reply-To: <20230825164152.165610-1-namhyung@kernel.org> References: <20230825164152.165610-1-namhyung@kernel.org> Precedence: bulk X-Mailing-List: bpf@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Spam-Status: No, score=-1.5 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 It has system-wide test and cpu-list test but the cpu-list test fails sometimes. It runs sleep command on CPU1 and measure both user.slice and system.slice cgroups by default (on systemd-based systems). But if the system was idle enough, sometime the system.slice gets no count and it makes the test failing. Maybe that's because it only looks at the CPU1, let's add CPU0 to increase the chance it finds some tasks. Fixes: 7901086014bba ("perf test: Add a new test for perf stat cgroup BPF counter") Reported-by: Arnaldo Carvalho de Melo Signed-off-by: Namhyung Kim --- tools/perf/tests/shell/stat_bpf_counters_cgrp.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/perf/tests/shell/stat_bpf_counters_cgrp.sh b/tools/perf/tests/shell/stat_bpf_counters_cgrp.sh index a74440a00b6b..e75d0780dc78 100755 --- a/tools/perf/tests/shell/stat_bpf_counters_cgrp.sh +++ b/tools/perf/tests/shell/stat_bpf_counters_cgrp.sh @@ -60,7 +60,7 @@ check_system_wide_counted() check_cpu_list_counted() { - check_cpu_list_counted_output=$(perf stat -C 1 --bpf-counters --for-each-cgroup ${test_cgroups} -e cpu-clock -x, taskset -c 1 sleep 1 2>&1) + check_cpu_list_counted_output=$(perf stat -C 0,1 --bpf-counters --for-each-cgroup ${test_cgroups} -e cpu-clock -x, taskset -c 1 sleep 1 2>&1) if echo ${check_cpu_list_counted_output} | grep -q -F "