From patchwork Tue Aug 13 13:23:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Clark X-Patchwork-Id: 13762040 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E244DC52D7B for ; Tue, 13 Aug 2024 13:26:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=G8nva4x7yooIvcMdEZLd+2R1OWdlEwTPtLBsl8/711k=; b=mWdzCXMux7SGjq959vaRdva49D pfpjIzkkS3Dsc9MRuRijd9OUljUFUMT05s2xHPU/w7zQMrQnHivg7O0BEYzNqM3l9kS1DvH4EqrJH FuC2UOSRXkTqaG0OH6TqDvrKn8QhCu8nWS0f/sQmUftUIoBUhs2yOgApyu6sppum2F4KaFh6a8FxX WV06ZbLSjGkSkdyco+zybl3LVnx1kF2AtFul0l59i1NRi8Y6KPkYFHjuZcDkYFiH/k5HmvG6bqllH zQI8b9qAFwCQ/x5kf4Akq3NAS8MZLXWMxd8rJT2TurWlNb9IxiQCDasOvPA6713gvywrXBRXaL8w1 Ya5+xabA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sdrXJ-00000003rWV-0KNh; Tue, 13 Aug 2024 13:26:05 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sdrWH-00000003rBL-2lUv for linux-arm-kernel@bombadil.infradead.org; Tue, 13 Aug 2024 13:25:02 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Transfer-Encoding:MIME-Version :References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=G8nva4x7yooIvcMdEZLd+2R1OWdlEwTPtLBsl8/711k=; b=jvsFhrYJRPabwqu6+5ooTaBFg8 6bAVKenCNonbWNcnivgNFaymomyvni1ZeitwAbNgsh+/6E9588GyTUAqFdnGjMxU96E09KqF02/Tp nzwtta6ycaxNDBZRhkgxie7CxZiRgcCCpJAC6asunu6Rmho9Sn7SI5O92H/xBFxFyGSiREipdrMOR g6Swka9hkp9U09VGh2cjzBfX/cT4B0HqfiKjnGGVt70Gi/68gD6jQK51JLuR3k589gYLKDehwGE72 wAGQ8SrPkuVY+hoNLO7chRKK+W+G3Ansg5Da5UM/QOhc6e3hyxGMz8a5MBE1cS24rPvsMAe8gWO// 3GAVRI/A==; Received: from mail-wm1-x332.google.com ([2a00:1450:4864:20::332]) by desiato.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sdrWE-00000007nPP-0jFJ for linux-arm-kernel@lists.infradead.org; Tue, 13 Aug 2024 13:25:00 +0000 Received: by mail-wm1-x332.google.com with SMTP id 5b1f17b1804b1-42817bee9e8so41151815e9.3 for ; Tue, 13 Aug 2024 06:24:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1723555495; x=1724160295; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=G8nva4x7yooIvcMdEZLd+2R1OWdlEwTPtLBsl8/711k=; b=dK2kAYHzxwMCPfs+vA3MUdAQMLKKPkKEpU9Hjrrp0O6pokFm7xyk2b4ZiHXzOMg3Bo wXv3ZbEAtuV/Uf0oeO5WW+3SkXkAV7+d3GCIThS6nym6GQ3a9N7Mt7/AdVwYTvfxEmny xi/aAyePCEaO3K0JatB1gK8mwlA94qIPqS8e4dyXHpfZAbJnmqjoWcdXJY5o3OcsCuLj jmdnPVn8h+G64yeq3G9RU/VL1seWGQRL0w6NEae8ftblewqlmOiFBQiVbu+deoP/CGoO FH3XqbBvNH8B+m27ozrbnRJcWTyOXBZOFJjwAqAlxZdkPcEIrrxVVIYsiNbKWddCzShy 4X9g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723555495; x=1724160295; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=G8nva4x7yooIvcMdEZLd+2R1OWdlEwTPtLBsl8/711k=; b=kccyLrXSeVIIPfQi8T4THQsC/ECDg4L3jB8cBI241SWZnRQ/443jemSbpqToQ6dZ2Q wxq6bYFwNZFt8pWr7nZkR+fFtc38biQPzxjaB2ADjqHHNxgm8tOR8v5KOqYoQpQql1q4 sM+KIxVGJKAGIhJNTuw7VALTknpCMAkF93vR1P6qiRUgZNihv6XvDtPCGemtlnaW0EiV bM9hvyUO/MnHL2deo/rL4MHLIhT12N+MVtTHTPASPzuPG9MOGuG7wX8vooJ58UbkuaYG Bw3qx/A5gc6Rt1BygzI3LagqQju7Vk+RXFWY/ImwZx79LFEHYIWJMCuaRkJn2ux5biIJ c/GA== X-Forwarded-Encrypted: i=1; AJvYcCUvt1R+zHHojWDOPf/4DaUi+ukdbXGEijV7r+FgbN5efQ6Fl9KXnBeK84gBBflmebd2xL2FePHO7xDB0Ro6WEpkL+bNaZ552aWfE/D6HbIFj/OWUWs= X-Gm-Message-State: AOJu0YxoOc/FJZg+iUBFThnqz7YyB/L5Eb3ER8HGX9XqWooYOkfehN5r g5VMKJF9xxmSRyTfQ5e5ELd5BugazVocXbOj5GWPg7DuWsmDTMXPqvtb2/IxokU= X-Google-Smtp-Source: AGHT+IEB1qfIIkAEbIEcPEEgKpvjsK/gwklipRfgBKtNp6pSHRtCu9iLJZf0fYv5sQNz+N8Z4iTFNA== X-Received: by 2002:a05:600c:3b07:b0:429:994:41a2 with SMTP id 5b1f17b1804b1-429d47f19f2mr27005205e9.7.1723555494826; Tue, 13 Aug 2024 06:24:54 -0700 (PDT) Received: from localhost.localdomain ([89.47.253.130]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4290c738d21sm223186625e9.12.2024.08.13.06.24.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Aug 2024 06:24:54 -0700 (PDT) From: James Clark To: irogers@google.com, linux-perf-users@vger.kernel.org Cc: James Clark , John Garry , Will Deacon , Mike Leach , Leo Yan , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Adrian Hunter , "Liang, Kan" , Yang Jihong , Ze Gao , Dominique Martinet , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH 1/7] perf stat: Initialize instead of overwriting clock event Date: Tue, 13 Aug 2024 14:23:09 +0100 Message-Id: <20240813132323.98728-2-james.clark@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240813132323.98728-1-james.clark@linaro.org> References: <20240813132323.98728-1-james.clark@linaro.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240813_142458_482438_3FA88B85 X-CRM114-Status: GOOD ( 16.24 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org This overwrite relies on the clock event remaining at index 0 and is quite a way down from where the array is initialized, making it easy to miss. Just initialize it with the correct clock event to begin with. Signed-off-by: James Clark --- tools/perf/builtin-stat.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c index 1f92445f7480..a65f58f8783f 100644 --- a/tools/perf/builtin-stat.c +++ b/tools/perf/builtin-stat.c @@ -1817,7 +1817,9 @@ static int add_default_attributes(void) { struct perf_event_attr default_attrs0[] = { - { .type = PERF_TYPE_SOFTWARE, .config = PERF_COUNT_SW_TASK_CLOCK }, + { .type = PERF_TYPE_SOFTWARE, .config = target__has_cpu(&target) ? + PERF_COUNT_SW_CPU_CLOCK : + PERF_COUNT_SW_TASK_CLOCK }, { .type = PERF_TYPE_SOFTWARE, .config = PERF_COUNT_SW_CONTEXT_SWITCHES }, { .type = PERF_TYPE_SOFTWARE, .config = PERF_COUNT_SW_CPU_MIGRATIONS }, { .type = PERF_TYPE_SOFTWARE, .config = PERF_COUNT_SW_PAGE_FAULTS }, @@ -2030,9 +2032,6 @@ static int add_default_attributes(void) if (!evsel_list->core.nr_entries) { /* No events so add defaults. */ - if (target__has_cpu(&target)) - default_attrs0[0].config = PERF_COUNT_SW_CPU_CLOCK; - if (evlist__add_default_attrs(evsel_list, default_attrs0) < 0) return -1; if (perf_pmus__have_event("cpu", "stalled-cycles-frontend")) { From patchwork Tue Aug 13 13:23:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Clark X-Patchwork-Id: 13762041 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 3F293C52D7C for ; Tue, 13 Aug 2024 13:26:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=5mUMDC/pIRcRlMc7URQ4bqWH4ou9rkjeyAIxTsLOjwA=; b=jtWo1EnSc0KIm60+DDsv9kWpdJ u1WFOZH6UAFJeW5vXU+YZYULj28Gw9FpPNRvqvkA+7q/YXxSHg+lLgSJVBFaNbDifzxrZa++ebndM apUznifgYlGdGUNNRDQRoWlbfSJ6hhW9vFJNToFMCn3MFka2cDVzxSPMt4yQaXDGLF5FJnQdCFvcq rU6OHTbdOfJUx/Gsk3i3A/Zd7GtV1v9yXkcrIKCQVYQCnNJ84C7hLtWg8Wly4W8Uf5YAZ6PwLbQ7N DK5Ah/K2/KffHYg9qmx+gZUzapiZZhdLDzJH17xAYRT5a6DolkbCOFycfcL8mw4hk/9hYfqKH/QsU eFMwuX+w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sdrXt-00000003ri9-06xJ; Tue, 13 Aug 2024 13:26:41 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sdrWO-00000003rEV-3q9x for linux-arm-kernel@bombadil.infradead.org; Tue, 13 Aug 2024 13:25:08 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Transfer-Encoding:MIME-Version :References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=5mUMDC/pIRcRlMc7URQ4bqWH4ou9rkjeyAIxTsLOjwA=; b=qRqVwRWUa76Uh7I/ntoK7MKj0e 6MY1xp8lGrQoCHOCi+mnSuV0DJPG7zRNTDXU9mdsst+/uabS+mU2wmLNQdw4x19zEOXGRc+EkPT15 XYm34ykaFltpMw7fPDYBoFa1i7qODl6BOwKCHHKRR/GJlsgZQLtBR93xzzhASMe7Jxb9lZlzx9nyO Exdvaa0eqdPWUq6LIYcp2ld6/O8lRqnbQNNMOuUaM628qLMSbOzInDafCNeUZBo7mioOqzuHnCcOi vteTaRywVet5xD8Ia6iy3OMVckw0cLKfXBw8tkD0hfJu+btbA7W/grktKR7RicnqrSOODJDJL1Vvk eVMS9bCg==; Received: from mail-wm1-x329.google.com ([2a00:1450:4864:20::329]) by desiato.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sdrWL-00000007nPz-3bsB for linux-arm-kernel@lists.infradead.org; Tue, 13 Aug 2024 13:25:07 +0000 Received: by mail-wm1-x329.google.com with SMTP id 5b1f17b1804b1-428e3129851so40531635e9.3 for ; Tue, 13 Aug 2024 06:25:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1723555503; x=1724160303; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=5mUMDC/pIRcRlMc7URQ4bqWH4ou9rkjeyAIxTsLOjwA=; b=rC2e2pI+45Nh88M/UcmzB+MUIWvNBZqh8RIFQyuROmuPWQB5lpD3UMnJgh43LC1q8T qBE2kJLSmL1L40DIb0p6EwalIzePdNF7dsXX73TySnbc8XFQTIJJ3b9bV+jDjt5Y5s5v bCRuIfzKHdolbVcL5vgg1dwXEUlblrZOF5ggj2bI2Y9lkILBIXeI4gL5DIL5OouZipXU 1X8DLZrAAgm/peUtNd1YxVU0ASX7KYcldItwNylcOJkHuDBHV/fJMSZsxvztXqEI7nxa rhech5aFN3Lu5j4pRZGv9Oxum5BV0dGg9COnmxfXdcHKMpSRrkDQl+9Ba0klCrc4VAal eMUQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723555503; x=1724160303; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=5mUMDC/pIRcRlMc7URQ4bqWH4ou9rkjeyAIxTsLOjwA=; b=Khbt1ZmMWp/Y3A2kHmIgabPUrqA4lyMVJpyAZExsb05aFxdRVwYTqMJT3s5nhAdLUe OjYLk1rKQpjA//ltl2a0tjbkocJY/XSDFfHdvOlOq2ZYbS6BetXu3IV6x7sQDrzFMtaH dHZENhQ3EZhLoeci5ji1fP1rQfoslo5bp/m3iXymJcn9WiUhouADemWFOVgKoxEvK3Va bNG9hIG0BiKz+yqPuNTjxQgFRkndFcPv+KhYvu6iQt1G5PK5ZW+fV0BawUZ6c1ijaH+d rCnPdrJYklsrX2XhcW2o1vu8b74KQRB4m0DFd6HCgOKbzV0W38TOCPETvA7duhywqknV 8sZQ== X-Forwarded-Encrypted: i=1; AJvYcCV+mzboGb2FWtyBJpA6zD4dOWTqJ+3kBUUQKkOzXfS3xksCQVKVWKU/Fg3nwZ3oAgeeLOJGG22V9Fpb5Q+SKjs5tf55Zoy1r2uYy/0Wr3FMYTy+8fM= X-Gm-Message-State: AOJu0YyXmCGeh+8EhaMms5YcM2z6gckUiaxWmGBfimX9pAfweS4jrNDE b7QW9PHtn9kWD81EJ9HplfJ0XjGmheXhEEaS/jz7WKjia4ntin0Q6Jd20oJyeM4= X-Google-Smtp-Source: AGHT+IGw1QWxHLTWtfvThNKdG+ceHa5O84W33fyasp2TM4dbvhwsCi+UKFDYqmXqt/QG5hQn4Fsr4g== X-Received: by 2002:a05:600c:1d2a:b0:426:6388:d59f with SMTP id 5b1f17b1804b1-429d47f4ac1mr26464035e9.1.1723555503354; Tue, 13 Aug 2024 06:25:03 -0700 (PDT) Received: from localhost.localdomain ([89.47.253.130]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4290c738d21sm223186625e9.12.2024.08.13.06.25.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Aug 2024 06:25:02 -0700 (PDT) From: James Clark To: irogers@google.com, linux-perf-users@vger.kernel.org Cc: James Clark , John Garry , Will Deacon , Mike Leach , Leo Yan , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Adrian Hunter , "Liang, Kan" , Yang Jihong , Ze Gao , Dominique Martinet , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH 2/7] perf stat: Remove unused default_null_attrs Date: Tue, 13 Aug 2024 14:23:10 +0100 Message-Id: <20240813132323.98728-3-james.clark@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240813132323.98728-1-james.clark@linaro.org> References: <20240813132323.98728-1-james.clark@linaro.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240813_142506_084187_2CA34EE8 X-CRM114-Status: GOOD ( 14.74 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org All current implementations of arch_evlist__add_default_attrs() do nothing if nr_attrs is 0. To avoid confusion that it's used, remove it. It appears that it used to be used as a mechanism to add topdown events, but this is now done separately. Signed-off-by: James Clark --- tools/perf/builtin-stat.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c index a65f58f8783f..cf6a1923811b 100644 --- a/tools/perf/builtin-stat.c +++ b/tools/perf/builtin-stat.c @@ -1930,7 +1930,6 @@ static int add_default_attributes(void) (PERF_COUNT_HW_CACHE_RESULT_MISS << 16) }, }; - struct perf_event_attr default_null_attrs[] = {}; const char *pmu = parse_events_option_args.pmu_filter ?: "all"; /* Set attrs if no event is selected and !null_run: */ @@ -2072,10 +2071,6 @@ static int add_default_attributes(void) evlist__splice_list_tail(evsel_list, &metric_evlist->core.entries); evlist__delete(metric_evlist); } - - /* Platform specific attrs */ - if (evlist__add_default_attrs(evsel_list, default_null_attrs) < 0) - return -1; } /* Detailed events get appended to the event list: */ From patchwork Tue Aug 13 13:23:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Clark X-Patchwork-Id: 13762135 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 88795C52D7C for ; Tue, 13 Aug 2024 14:30:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=r+kJ+/NC06vZ9X8R6p8mtg0vV2q4/5EH3hEIt7Tb/aw=; b=WuVA287TJVC6uXNKWgd2S6ZQyp tsGOuj9KWxzaYo09dHnCC53Q8L6wKM7m+u4R0/DVDxpGpPmcx7howhH1022Ld3Il2a6RvuVOn2igS fxHdtLpTfNJRfxLod4JUXmKjo9j+MagpWUzrnBBfJdqW+sdZDLW8U4XkUxjPQettC1BhT/T+ABwrc w0gGUb2WqOyU2NIqoR9A89t9tV/x4eDAmGe8UWgRQOVDPlIGcWJWHqwhs4lYLVUMIWCYPMN9SCAxh +UhBAmslhV+yOStV0KYi4p8BsXX1Vf5UradiqCOeBpipZ9lmJVaYxJ4UVwS7g8yga2G8jw0ucmvdL UaBarWmw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sdsXi-000000041Rj-30SX; Tue, 13 Aug 2024 14:30:34 +0000 Received: from mail-wr1-x434.google.com ([2a00:1450:4864:20::434]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sdrWU-00000003rFA-2FKw for linux-arm-kernel@lists.infradead.org; Tue, 13 Aug 2024 13:25:15 +0000 Received: by mail-wr1-x434.google.com with SMTP id ffacd0b85a97d-367ab76d5e1so2496532f8f.3 for ; Tue, 13 Aug 2024 06:25:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1723555512; x=1724160312; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=r+kJ+/NC06vZ9X8R6p8mtg0vV2q4/5EH3hEIt7Tb/aw=; b=Ghqbwc5fHlC/821+HmSx3sIL4LherlJtjTwmCuW6ggsuKiVTMBqz3RZgqTN96gbnpu c+Eti6YcgKjW9f1OSg/whBRT1TlUd4kR+LY1zXPERCDGrbRK2oEziJ2VFJ+4jZE8VnXF X8F2hpT0cs+YSJDITfAQPSjMl8oFitdiYNpk0x+DVMRYYn0eh2JfP5b6T+qrZc2F07RD wPw1mb6Fl92rZxkkVUzeLpAS4WxK7sn+Ln9h7nZpHQUgjLo2FlUxd20i6a9GFk2sg8JJ VUS3nUUQEs3IO38Y9pXc5kSV3ZKzTQt1vt2OYoILzWJOiZfDr0fsZ6krB14o6kdJWd7J Qaqw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723555512; x=1724160312; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=r+kJ+/NC06vZ9X8R6p8mtg0vV2q4/5EH3hEIt7Tb/aw=; b=DeJQLy+ex28HUBnU+5JX10YJ8ZFJLiDPFtieNWYiWPUJsHIZjxKAZeyEMkkoOzQ99v PYMeIfRD7KXIqG9AlFvI4pf1YkrJJQrLdWpebzB/g3mIcsZFxE6Hr8jR/axn5HRqW/mg 1LVGGvczYyw4TgKXOD9yxsu0sunqXSdagbPh2mALApQZ5U2og2Evq2wvfGeBMCb8OGRv +Fl94Uvg61JebFGU0e3Q4SEUokhdoi5e5qSEvzoPIxKxReq6jlmVxiDRzy4S5ea14rIf wyaPXC4cdNDKvdoUeB+MEy/kiVp2T/C+Bsc+7Hal6N8HJqts1DMB+NjWf+APhjaiQVWV fc6A== X-Forwarded-Encrypted: i=1; AJvYcCXcpqzFHH5mueiAStHKYVz+VuzbbRz46+NDJY91eTTWNYtwDSVux7bnxdo2fFwO1zaklmjtWcNSlmHdkHOLCKoRYn/lGEiNWIiU7OWlfe85NeHWQJc= X-Gm-Message-State: AOJu0YwzsntI6KdPZCA59ew9TktwssHyMdqYh58xRlv8DJPAEHs3MsZi cHed7woTYPAxP4sTK7omQl0ZqJset4IGG6zJpP3SPLRJ9dxIxTlPHlbahePyb7Y= X-Google-Smtp-Source: AGHT+IGjXdWWrJsG8ue7FAAFzotqCer/0Jr9WoBguXbU5v52cPPA7AkQerMal8MjToQlhspx2O6d6Q== X-Received: by 2002:adf:8b1e:0:b0:367:992f:4ac4 with SMTP id ffacd0b85a97d-3716cc542a0mr2499815f8f.0.1723555511781; Tue, 13 Aug 2024 06:25:11 -0700 (PDT) Received: from localhost.localdomain ([89.47.253.130]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4290c738d21sm223186625e9.12.2024.08.13.06.25.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Aug 2024 06:25:11 -0700 (PDT) From: James Clark To: irogers@google.com, linux-perf-users@vger.kernel.org Cc: James Clark , John Garry , Will Deacon , Mike Leach , Leo Yan , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Adrian Hunter , "Liang, Kan" , Dominique Martinet , Yang Jihong , Ze Gao , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH 3/7] perf evsel: Use the same arch_evsel__hw_name() on arm64 as x86 Date: Tue, 13 Aug 2024 14:23:11 +0100 Message-Id: <20240813132323.98728-4-james.clark@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240813132323.98728-1-james.clark@linaro.org> References: <20240813132323.98728-1-james.clark@linaro.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240813_062514_611949_758ACDAF X-CRM114-Status: GOOD ( 21.38 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Both of these platforms share the same extended type ID mechanism, so share the implementation of the evsel name lookup. Signed-off-by: James Clark --- tools/perf/arch/arm64/util/Build | 1 + tools/perf/arch/arm64/util/evsel.c | 7 +++++++ tools/perf/arch/x86/util/evsel.c | 17 +---------------- tools/perf/util/evsel.c | 24 ++++++++++++++++++++++++ tools/perf/util/evsel.h | 2 +- 5 files changed, 34 insertions(+), 17 deletions(-) create mode 100644 tools/perf/arch/arm64/util/evsel.c diff --git a/tools/perf/arch/arm64/util/Build b/tools/perf/arch/arm64/util/Build index 343ef7589a77..45c77f747d54 100644 --- a/tools/perf/arch/arm64/util/Build +++ b/tools/perf/arch/arm64/util/Build @@ -1,3 +1,4 @@ +perf-util-y += evsel.o perf-util-y += header.o perf-util-y += machine.o perf-util-y += perf_regs.o diff --git a/tools/perf/arch/arm64/util/evsel.c b/tools/perf/arch/arm64/util/evsel.c new file mode 100644 index 000000000000..6974f72ee37f --- /dev/null +++ b/tools/perf/arch/arm64/util/evsel.c @@ -0,0 +1,7 @@ +// SPDX-License-Identifier: GPL-2.0 +#include "util/evsel.h" + +int arch_evsel__hw_name(struct evsel *evsel, char *bf, size_t size) +{ + return evsel__hw_name_ext_type_id(evsel, bf, size); +} diff --git a/tools/perf/arch/x86/util/evsel.c b/tools/perf/arch/x86/util/evsel.c index 090d0f371891..771b35fef61a 100644 --- a/tools/perf/arch/x86/util/evsel.c +++ b/tools/perf/arch/x86/util/evsel.c @@ -49,22 +49,7 @@ bool arch_evsel__must_be_in_group(const struct evsel *evsel) int arch_evsel__hw_name(struct evsel *evsel, char *bf, size_t size) { - u64 event = evsel->core.attr.config & PERF_HW_EVENT_MASK; - u64 pmu = evsel->core.attr.config >> PERF_PMU_TYPE_SHIFT; - const char *event_name; - - if (event < PERF_COUNT_HW_MAX && evsel__hw_names[event]) - event_name = evsel__hw_names[event]; - else - event_name = "unknown-hardware"; - - /* The PMU type is not required for the non-hybrid platform. */ - if (!pmu) - return scnprintf(bf, size, "%s", event_name); - - return scnprintf(bf, size, "%s/%s/", - evsel->pmu_name ? evsel->pmu_name : "cpu", - event_name); + return evsel__hw_name_ext_type_id(evsel, bf, size); } static void ibs_l3miss_warn(void) diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c index bc603193c477..19f4d0e71733 100644 --- a/tools/perf/util/evsel.c +++ b/tools/perf/util/evsel.c @@ -584,6 +584,30 @@ int __weak arch_evsel__hw_name(struct evsel *evsel, char *bf, size_t size) return scnprintf(bf, size, "%s", __evsel__hw_name(evsel->core.attr.config)); } +/* + * Version of evsel__hw_name() used on platforms where perf_pmus__supports_extended_type() + * may be true and the type needs to be extracted and masked. + */ +int evsel__hw_name_ext_type_id(struct evsel *evsel, char *bf, size_t size) +{ + u64 event = evsel->core.attr.config & PERF_HW_EVENT_MASK; + u64 pmu = evsel->core.attr.config >> PERF_PMU_TYPE_SHIFT; + const char *event_name; + + if (event < PERF_COUNT_HW_MAX && evsel__hw_names[event]) + event_name = evsel__hw_names[event]; + else + event_name = "unknown-hardware"; + + /* The PMU type is not required for the non-hybrid platform. */ + if (!pmu) + return scnprintf(bf, size, "%s", event_name); + + return scnprintf(bf, size, "%s/%s/", + evsel->pmu_name ? evsel->pmu_name : "cpu", + event_name); +} + static int evsel__hw_name(struct evsel *evsel, char *bf, size_t size) { int r = arch_evsel__hw_name(evsel, bf, size); diff --git a/tools/perf/util/evsel.h b/tools/perf/util/evsel.h index 80b5f6dd868e..f95fc2919462 100644 --- a/tools/perf/util/evsel.h +++ b/tools/perf/util/evsel.h @@ -299,7 +299,7 @@ extern const char *const evsel__sw_names[PERF_COUNT_SW_MAX]; extern char *evsel__bpf_counter_events; bool evsel__match_bpf_counter_events(const char *name); int arch_evsel__hw_name(struct evsel *evsel, char *bf, size_t size); - +int evsel__hw_name_ext_type_id(struct evsel *evsel, char *bf, size_t size); int __evsel__hw_cache_type_op_res_name(u8 type, u8 op, u8 result, char *bf, size_t size); const char *evsel__name(struct evsel *evsel); bool evsel__name_is(struct evsel *evsel, const char *name); From patchwork Tue Aug 13 13:23:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Clark X-Patchwork-Id: 13762042 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id EA38AC52D7B for ; Tue, 13 Aug 2024 13:28:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=zR7iuyHffj9f//oCwmpY+WujZl20YxAEXMdQ/mInORg=; b=pXJfPQXIT0nteOLv3K7CLoMwoG LIAUAv045J0LtKLaLWinnqrz8Wd6UEJhCHNmNC6Rz/x2inUD5bofA0LW6wlq7t1i+iuEZ7UitxUJT dJ23MEeDeE+o492varNT3UojEmtnn/TxD/SZ1mnrt0SA8gYvLEP2nozV3CjfqL/L9c9RJJha19Wye x6EizQ3cuME6u3CGcOGsrYrLGlGFyd7OnuEmMA0PChjPvaJyTQcqfB1bF43gZOGLGqzWqTY+lGzxD /0LIeyv7zvYrPi0d/tG2UDauhIxYDuq8AMHf1+OZvyKxE4fhN2zLeR49qQg669XahTDucDvBXZbrk oM2KhNuw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sdrZ2-00000003s89-3fu7; Tue, 13 Aug 2024 13:27:52 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sdrWg-00000003rKG-1Ikc for linux-arm-kernel@bombadil.infradead.org; Tue, 13 Aug 2024 13:25:26 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Transfer-Encoding:MIME-Version :References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=zR7iuyHffj9f//oCwmpY+WujZl20YxAEXMdQ/mInORg=; b=MCgel/mnQE1g7+rBnFUIWUuEF8 eieSlrS4YVjQoxhsJlXHIGC2AlveqZ6WamDGOlftfIQdQ0OSeTIBqf47aXXPym7o5tu5s9wI9f2qh 7E2YSX4pWR7Ri1ye0BVzxc+0RDhbBYVP6XSRuqvWDC7TJyZKqqOgMyevBxkiewJnbOoDNWliuLzdW 9MXM0ExMYgU1ESAUiV8VPzWBzqmecqabnvWayjztkj4l+At5oLnH4TVKa6dwknOkenHfuLygS6fAC i6SmF2u4kEAXl1o4UnW7N2biocl5J094ms/wQKYQyeM0JRhtBvkagWDGUCslf7nfpL9GAxBRtR/au FG/pFy1w==; Received: from mail-wm1-x333.google.com ([2a00:1450:4864:20::333]) by desiato.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sdrWc-00000007nQx-3Sp1 for linux-arm-kernel@lists.infradead.org; Tue, 13 Aug 2024 13:25:25 +0000 Received: by mail-wm1-x333.google.com with SMTP id 5b1f17b1804b1-42808071810so41616365e9.1 for ; Tue, 13 Aug 2024 06:25:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1723555520; x=1724160320; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=zR7iuyHffj9f//oCwmpY+WujZl20YxAEXMdQ/mInORg=; b=jUsYTK3LZdlivBOIADfce86jM+BiUKQdJtyxGwcUTlIfltjPF743aks6VhZ9FFLa6I OPw8sxoFLEcdyR9HIuD5RqVDCxgHLBS9IgfDex8oi0qfq257dFngbxTHFIFjPwcIzCn4 kw0A6IbsxvFgIf1s0ZAswO4JXUEk+GBOP+u9cV83POtj08Re6788WF1x5X+KWGv4a2II F9OmltEIVrg5wBsCV9+DIKoqEAZIuP1nMzl45QSqitbionlDTsuVnk026Kw1eTjSB5cj 6pLsi3BJ5j7uH9KVx0exYWWdn1ooyAY5pDlZQpZcXbJ7TUDwYT7KJsctEibqlUrwgNxQ 3ZkQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723555520; x=1724160320; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=zR7iuyHffj9f//oCwmpY+WujZl20YxAEXMdQ/mInORg=; b=Dg9m91A5KAD2Z39cNWdr+ToLzT60phFwHBJ46R6zzM5L9gQN4sXEYY8RgAwKrNpv/q 4KFvlh4NXkt7SVdumbYHMLeTjalxBKrAMgUH4i5o1ibSnEUG4Xq7YpzIbQw22GxB/RRR 2GkuR6tEK+SO8E8q9vfsudiHaIfv2HS2DMTcqSO99jDqi+CxkdogIzGjQ+sSLZkf1qYB cYouFjVBG1XEmHwg4zOs7Jg1WtNx5hp2HD3al6YWcnZ8CYSnsmfasGxO3coOS8xOD8Ju DvK9ovTERso6e6Om89RM+ptJf2ayaefn383wdKHcg5fGxKFqS/K/VAWuIPtuAHCuOhfu W0yw== X-Forwarded-Encrypted: i=1; AJvYcCU494WMOzlmEsh86WM+JMucFi036HlACSXhG+QrEyCj74+yGiHUzYtbqSww1UKd145yojjabRIhj569ZAUHv70MyGmksrK+a6TcJMTJGKjilkJz7h4= X-Gm-Message-State: AOJu0YxzolzrjqYu00Xof6o18MSVrEOEaGQGMytEia93vdb5BPpBS1ZA MiJJfApM1D6sHCxk+LGqLlcGRw3LbZO8Ko0vXu5VW9ykxukQc6yLJIjP2ernJMI= X-Google-Smtp-Source: AGHT+IE4O1HeOB7Ir8sD2A/JqXloTOsBz328BQAjDg9uiSlJQr+ktC91pK7XIkyLaypNjbj27p76ag== X-Received: by 2002:a05:600c:548b:b0:427:ff3b:7a20 with SMTP id 5b1f17b1804b1-429d486fea7mr30226825e9.27.1723555520303; Tue, 13 Aug 2024 06:25:20 -0700 (PDT) Received: from localhost.localdomain ([89.47.253.130]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4290c738d21sm223186625e9.12.2024.08.13.06.25.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Aug 2024 06:25:20 -0700 (PDT) From: James Clark To: irogers@google.com, linux-perf-users@vger.kernel.org Cc: James Clark , John Garry , Will Deacon , Mike Leach , Leo Yan , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Adrian Hunter , "Liang, Kan" , Yang Jihong , Ze Gao , Dominique Martinet , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH 4/7] perf evsel: Remove duplicated __evsel__hw_name() code Date: Tue, 13 Aug 2024 14:23:12 +0100 Message-Id: <20240813132323.98728-5-james.clark@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240813132323.98728-1-james.clark@linaro.org> References: <20240813132323.98728-1-james.clark@linaro.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240813_142523_212788_AA15ED43 X-CRM114-Status: GOOD ( 13.45 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org __evsel__hw_name() does the same thing so use it instead. Signed-off-by: James Clark --- tools/perf/util/evsel.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c index 19f4d0e71733..ba960a39f104 100644 --- a/tools/perf/util/evsel.c +++ b/tools/perf/util/evsel.c @@ -592,12 +592,7 @@ int evsel__hw_name_ext_type_id(struct evsel *evsel, char *bf, size_t size) { u64 event = evsel->core.attr.config & PERF_HW_EVENT_MASK; u64 pmu = evsel->core.attr.config >> PERF_PMU_TYPE_SHIFT; - const char *event_name; - - if (event < PERF_COUNT_HW_MAX && evsel__hw_names[event]) - event_name = evsel__hw_names[event]; - else - event_name = "unknown-hardware"; + const char *event_name = __evsel__hw_name(event); /* The PMU type is not required for the non-hybrid platform. */ if (!pmu) From patchwork Tue Aug 13 13:23:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Clark X-Patchwork-Id: 13762043 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id AE653C52D7C for ; Tue, 13 Aug 2024 13:28:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=YJPiTzck/wj4Bl8bp1dFvT+bnyHvEgyjm9lLc0sAxDQ=; b=cREEX1AriZ6oE0uTv2GU6E9WVv 5mLGrKI0s0p0BllaaCBKsSl/I6i3xci4SzGRDTLi2I5clSUI59dynhKXXsKG99bD5hJ3N59FzB7Jd H1f6CGNP3Di0vu96WPjj6K8ED3Wih8BOmih1AjQ5tMZHyn75Su1WP+NKBhNzwcZf8OKzEzP1abyB6 shmUe2aLp+TqmfVIHgQ0fyp1lHYuRu2eUZRTXw0ylnLLM5/gxyYFMOXfIugzLeD96karW0NiZjnRD S0OrToNEtNWpZnLjxzSfJwG6tnqWoVs7KrATSP+kCG/AZ4SgMGLvfNz1bORWe930uyq7gu/qxKrIX 5P8sXspA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sdrZc-00000003sDz-1wlQ; Tue, 13 Aug 2024 13:28:28 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sdrWp-00000003rNb-18wS for linux-arm-kernel@bombadil.infradead.org; Tue, 13 Aug 2024 13:25:35 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Transfer-Encoding:MIME-Version :References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=YJPiTzck/wj4Bl8bp1dFvT+bnyHvEgyjm9lLc0sAxDQ=; b=XbxXX6eUPrW038xB3wIsi1zsDd 2hwYVeFlJaKOSYA2oKX3EOsGwCxrRsFhCeceuDYqnOD6TPP3FCQnx8FZLV/r1U6iPrTg4tHBZ0tr2 UD0pgC5ljfclrv/IaCxpCA4qcq1gVjvJ1B9aEhoDPFWeNCL/VyVFkqpfgW467N4WJbGNrcR2rGFmf kzrzpfFUJLuc2Jb4rr7BjI8vd+a04zL9PFel92phIHGaGHluhaTgF0xKlIRJsIpvbWXIw0flMuvNP 0sAow6h8WfxDtk7jiik8oJLTuszFjItI+l2N7NqSwQOOXepOSjOmDVj3TCoXNc+byJD9VmgHinqx2 HJk7gPwA==; Received: from mail-wm1-x330.google.com ([2a00:1450:4864:20::330]) by desiato.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sdrWk-00000007nS3-0dbj for linux-arm-kernel@lists.infradead.org; Tue, 13 Aug 2024 13:25:32 +0000 Received: by mail-wm1-x330.google.com with SMTP id 5b1f17b1804b1-428e3129851so40535615e9.3 for ; Tue, 13 Aug 2024 06:25:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1723555529; x=1724160329; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=YJPiTzck/wj4Bl8bp1dFvT+bnyHvEgyjm9lLc0sAxDQ=; b=vhwGVkxHRcFT+PIfS2187v/kmqVpB79y5Ssha0BQC77g2Ti7M1fWmntPnmRtzizQnX RdhWnRuRlPbG941UlLZdH29rxILiwXzF+N/Xo7GQ2iO7rFJjLovzFLXerRZAuZOWyzRi ZGImuy3I1nd6gPXRZYJ9Qp+jfSiVeyow0z1eo6yGT0+vABexgY18OZd8t02xw0KofCOS 5/7MHZZcRWce0lI+TCk1waALdtFjPlrg+JDmKYMrinAf9yA9FatiJu89hF37gZnMGU1g EIVMdV66lyNMHEVtZtHSYXQWHA8LwMCtSjyly/F1ItO79l0XAk6JACMAxq7jzgqjmwKc NiVg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723555529; x=1724160329; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=YJPiTzck/wj4Bl8bp1dFvT+bnyHvEgyjm9lLc0sAxDQ=; b=PSL0CejGLCUDnygplNAUImWJpLSKzE0ooMQKJoKZCnD2HXGjnRhuum4fxbznmWnWLY MIAfU/HSm06CXFMCWYW1+STUU3MmEcKf55rYdU6vT5yFtctg96TdAy4GQNHGfVLQiPa1 ugMHSTtVsoaVi0urVsDAO/+eRcEQDZ2KzHzCDEhLUiA4UN1yUMsLO9HjQavsEtNZLe0l us7yM2fHTZcsA/MEGIN0Rl0ThBEHEU14zupQA6Yx8uJojrNwxsDMAWnwX7Y8gBcljsU0 4t2hpD2stG7NoHJ3QM95UGo5prji64i4XhsXjtsBCtxxRCJB041oHlAKjC1zEfTzzVap kX1Q== X-Forwarded-Encrypted: i=1; AJvYcCXo7H1hjHLJguhMf4yUWFPVqmcoTqS84nieXmjgGHvwP9axvyx+vQvnpv7LhUYDxgTrHtvL9fl4j1X6dqWQByIQfAZQruit9j2BTKGYk2jJWBwjGWQ= X-Gm-Message-State: AOJu0YylZJrqrOuYUsSyQ/e73u1MTiMXakTmm8UY7ClAlWRC9pcvHbZC gI8qFS0o4doqvX7mwZ6uk77KtzI81QlU1QyBsYQa/8qyOdsfDscVfjJR0+yFLII= X-Google-Smtp-Source: AGHT+IGpUiL8HI1I4dgUEXAngk1hqDYSTUpCg0rDVeIRHKgEB9vHTQ+oOqXVgzYYIWv7xtQbj8/VkA== X-Received: by 2002:a05:600c:358c:b0:428:ea8e:b48a with SMTP id 5b1f17b1804b1-429d47f49fbmr28609085e9.8.1723555528866; Tue, 13 Aug 2024 06:25:28 -0700 (PDT) Received: from localhost.localdomain ([89.47.253.130]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4290c738d21sm223186625e9.12.2024.08.13.06.25.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Aug 2024 06:25:28 -0700 (PDT) From: James Clark To: irogers@google.com, linux-perf-users@vger.kernel.org Cc: James Clark , John Garry , Will Deacon , Mike Leach , Leo Yan , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Adrian Hunter , "Liang, Kan" , Dominique Martinet , Yang Jihong , Ze Gao , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH 5/7] perf evlist: Use hybrid default attrs whenever extended type is supported Date: Tue, 13 Aug 2024 14:23:13 +0100 Message-Id: <20240813132323.98728-6-james.clark@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240813132323.98728-1-james.clark@linaro.org> References: <20240813132323.98728-1-james.clark@linaro.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240813_142530_453095_59DCA37C X-CRM114-Status: GOOD ( 18.37 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org For x86, a hybrid version of ___evlist__add_default_attrs() was added to support default perf stat events. This can actually be used whenever perf_pmus__supports_extended_type() is true, which now makes default perf stat arguments work properly on Arm big.LITTLE: $ perf stat ... 3347093940 armv8_cortex_a53/cycles/ # 0.563 GHz (98.99%) 3295523067 armv8_cortex_a57/cycles/ # 0.554 GHz (67.07%) ... Signed-off-by: James Clark --- tools/perf/arch/x86/util/evlist.c | 65 ------------------------------- tools/perf/util/evlist.c | 65 +++++++++++++++++++++++++++---- tools/perf/util/evlist.h | 6 +-- 3 files changed, 59 insertions(+), 77 deletions(-) diff --git a/tools/perf/arch/x86/util/evlist.c b/tools/perf/arch/x86/util/evlist.c index b1ce0c52d88d..bbe6240c7f71 100644 --- a/tools/perf/arch/x86/util/evlist.c +++ b/tools/perf/arch/x86/util/evlist.c @@ -8,71 +8,6 @@ #include "topdown.h" #include "evsel.h" -static int ___evlist__add_default_attrs(struct evlist *evlist, - struct perf_event_attr *attrs, - size_t nr_attrs) -{ - LIST_HEAD(head); - size_t i = 0; - - for (i = 0; i < nr_attrs; i++) - event_attr_init(attrs + i); - - if (perf_pmus__num_core_pmus() == 1) - return evlist__add_attrs(evlist, attrs, nr_attrs); - - for (i = 0; i < nr_attrs; i++) { - struct perf_pmu *pmu = NULL; - - if (attrs[i].type == PERF_TYPE_SOFTWARE) { - struct evsel *evsel = evsel__new(attrs + i); - - if (evsel == NULL) - goto out_delete_partial_list; - list_add_tail(&evsel->core.node, &head); - continue; - } - - while ((pmu = perf_pmus__scan_core(pmu)) != NULL) { - struct perf_cpu_map *cpus; - struct evsel *evsel; - - evsel = evsel__new(attrs + i); - if (evsel == NULL) - goto out_delete_partial_list; - evsel->core.attr.config |= (__u64)pmu->type << PERF_PMU_TYPE_SHIFT; - cpus = perf_cpu_map__get(pmu->cpus); - evsel->core.cpus = cpus; - evsel->core.own_cpus = perf_cpu_map__get(cpus); - evsel->pmu_name = strdup(pmu->name); - list_add_tail(&evsel->core.node, &head); - } - } - - evlist__splice_list_tail(evlist, &head); - - return 0; - -out_delete_partial_list: - { - struct evsel *evsel, *n; - - __evlist__for_each_entry_safe(&head, n, evsel) - evsel__delete(evsel); - } - return -1; -} - -int arch_evlist__add_default_attrs(struct evlist *evlist, - struct perf_event_attr *attrs, - size_t nr_attrs) -{ - if (!nr_attrs) - return 0; - - return ___evlist__add_default_attrs(evlist, attrs, nr_attrs); -} - int arch_evlist__cmp(const struct evsel *lhs, const struct evsel *rhs) { if (topdown_sys_has_perf_metrics() && diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c index 1417f9a23083..e0c31399beb6 100644 --- a/tools/perf/util/evlist.c +++ b/tools/perf/util/evlist.c @@ -5,6 +5,7 @@ * Parts came from builtin-{top,stat,record}.c, see those files for further * copyright notes. */ +#include "pmus.h" #include #include #include @@ -338,24 +339,74 @@ int evlist__add_attrs(struct evlist *evlist, struct perf_event_attr *attrs, size return -1; } -int __evlist__add_default_attrs(struct evlist *evlist, struct perf_event_attr *attrs, size_t nr_attrs) + +static int __evlist__add_default_attrs_ext_type(struct evlist *evlist, + struct perf_event_attr *attrs, + size_t nr_attrs) { - size_t i; + LIST_HEAD(head); + size_t i = 0; for (i = 0; i < nr_attrs; i++) event_attr_init(attrs + i); - return evlist__add_attrs(evlist, attrs, nr_attrs); + for (i = 0; i < nr_attrs; i++) { + struct perf_pmu *pmu = NULL; + + if (attrs[i].type == PERF_TYPE_SOFTWARE) { + struct evsel *evsel = evsel__new(attrs + i); + + if (evsel == NULL) + goto out_delete_partial_list; + list_add_tail(&evsel->core.node, &head); + continue; + } + + while ((pmu = perf_pmus__scan_core(pmu)) != NULL) { + struct perf_cpu_map *cpus; + struct evsel *evsel; + + evsel = evsel__new(attrs + i); + if (evsel == NULL) + goto out_delete_partial_list; + evsel->core.attr.config |= (__u64)pmu->type << PERF_PMU_TYPE_SHIFT; + cpus = perf_cpu_map__get(pmu->cpus); + evsel->core.cpus = cpus; + evsel->core.own_cpus = perf_cpu_map__get(cpus); + evsel->pmu_name = strdup(pmu->name); + list_add_tail(&evsel->core.node, &head); + } + } + + evlist__splice_list_tail(evlist, &head); + + return 0; + +out_delete_partial_list: + { + struct evsel *evsel, *n; + + __evlist__for_each_entry_safe(&head, n, evsel) + evsel__delete(evsel); + } + return -1; } -__weak int arch_evlist__add_default_attrs(struct evlist *evlist, - struct perf_event_attr *attrs, - size_t nr_attrs) +int __evlist__add_default_attrs(struct evlist *evlist, struct perf_event_attr *attrs, + size_t nr_attrs) { + size_t i; + if (!nr_attrs) return 0; - return __evlist__add_default_attrs(evlist, attrs, nr_attrs); + if (perf_pmus__supports_extended_type()) + return __evlist__add_default_attrs_ext_type(evlist, attrs, nr_attrs); + + for (i = 0; i < nr_attrs; i++) + event_attr_init(attrs + i); + + return evlist__add_attrs(evlist, attrs, nr_attrs); } struct evsel *evlist__find_tracepoint_by_id(struct evlist *evlist, int id) diff --git a/tools/perf/util/evlist.h b/tools/perf/util/evlist.h index cccc34da5a02..06d1eeacc0d1 100644 --- a/tools/perf/util/evlist.h +++ b/tools/perf/util/evlist.h @@ -106,12 +106,8 @@ int evlist__add_attrs(struct evlist *evlist, struct perf_event_attr *attrs, size int __evlist__add_default_attrs(struct evlist *evlist, struct perf_event_attr *attrs, size_t nr_attrs); -int arch_evlist__add_default_attrs(struct evlist *evlist, - struct perf_event_attr *attrs, - size_t nr_attrs); - #define evlist__add_default_attrs(evlist, array) \ - arch_evlist__add_default_attrs(evlist, array, ARRAY_SIZE(array)) + __evlist__add_default_attrs(evlist, array, ARRAY_SIZE(array)) int arch_evlist__cmp(const struct evsel *lhs, const struct evsel *rhs); From patchwork Tue Aug 13 13:23:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Clark X-Patchwork-Id: 13762044 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 9682CC52D7B for ; Tue, 13 Aug 2024 13:29:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=FXow/HXS2t6eZsIhNK0KrvK5I+CXmczupsEF4/wQsaM=; b=BsduNrgF5jJoR7c0PKVwZCduPA t1WvEosSY6cnc4O2UwbiWw/eqPqnduuIG/7k7RF+gr2j7LhVQwWyhVyfnQfoKvZMQ7chty+tnzjVh YRgo4+JGTWfUx/DmXYNDHLbkiHASR1Bi2B8YxXvLTcHpWuYhTZiCoJ2zyhIrCFgNhHMIaojDH90G1 6/1ygQRIlenvhjmTSztGULfNuqah4xR17L+iCgzDas35od49FBb7DZE2a5NH+eWCHC9hs0QA0tWub BTN/qbPG5PC9Omk1bgGJkyNabw2uVoFffpAOFeB/RnRjMu/V+Cj5fZTrgziG/SXE35Ye1gUcw4EZW ccu9Uc8A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sdraC-00000003sNc-2hvj; Tue, 13 Aug 2024 13:29:04 +0000 Received: from mail-wm1-x330.google.com ([2a00:1450:4864:20::330]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sdrWt-00000003rPE-28SQ for linux-arm-kernel@lists.infradead.org; Tue, 13 Aug 2024 13:25:40 +0000 Received: by mail-wm1-x330.google.com with SMTP id 5b1f17b1804b1-428fb103724so36911065e9.1 for ; Tue, 13 Aug 2024 06:25:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1723555537; x=1724160337; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=FXow/HXS2t6eZsIhNK0KrvK5I+CXmczupsEF4/wQsaM=; b=xr29Zl/otHnCqMx7F/22OqaXL8fDYa66cOOc82s0HpN0/SphQMF3hvKOIALSnIDHy/ Bm4oOrnssZlmvDkom9oGPwSLvnI3+K5XfKz1bt0fqIbsgtNL2S0xz/MTgReg0H7WHCTp Pxok1aggwXxV0Gdoref/yWjcwjrzHTcBGqlnmDDpUhrWxjUBBklms13PhyWtfzI1ivqj t41DpljcQ4Igol4r4yf4oZjNgS9hqwj/Mr9+54HHWioOkMad0569WSEaBiSjwEPCvCN8 7JB2BrX9SSAcir8s/8bb4xlekO6Iai35/IUEMYuXBPuyv6cXqUWVEjCOJ9z106TE8Q6L 5ipQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723555537; x=1724160337; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=FXow/HXS2t6eZsIhNK0KrvK5I+CXmczupsEF4/wQsaM=; b=WBaoT221q/u1Qw24Lbk/U3ahkmPnVH/+VOLF34/rA9Kab7Q2XKrZ6V9akGfZPhBFVX B9nuL1pMOJrgvhqR05O0lyeLKQ+BNmh61xCtAX36SvBr6uCuFYTejR/PhMTHY6zp42jk n+ikGGDZCEKHMcTbf7nJbgcRBTvv8oFaMXQVe3+tT9mqvsE5AhX6rnt/ktHQ0vL690h6 1DhgebEMI5ONPH8RLRVu9SOyigRmdlPQVr4qqADV8kcN/vH9NhJGimw0gK73cOPHRd6e RlkfVOK4r/jeNBLSk9XcrdAvUJNQvvbmhHsKeVEpBHhwK5HbfOP+559KWVHntm74K1nN Evmg== X-Forwarded-Encrypted: i=1; AJvYcCXG9h1yk9hY7gQquVNkIg6QmjCC1PDlWmDc3jil6kL4W6fAaCjgs1xaD+1Dc23j6nq01hpzSu5dyp+YLzUl4xaR/5eE0nk/uTTGTVfpTbxlTinmF8U= X-Gm-Message-State: AOJu0YwRdIIpqot9WMmqCJoSQvyUWEyBvWaaHEl7eppmlBAPTgv8cT7B 6NI3vO2tbQV0ietvBP3rXP4G4Sy0OvjtVzliBW05K7kNoMPRjeiWLcApczHctss= X-Google-Smtp-Source: AGHT+IGc9t+MTAwYwGAaBX95OSnKFftghFZ3NfLAkZ7AAvwA9zVwqXl0BELY2LWwoeQ2oa+XAXA1ag== X-Received: by 2002:a05:600c:3550:b0:424:a401:f012 with SMTP id 5b1f17b1804b1-429d6269733mr21164045e9.3.1723555537440; Tue, 13 Aug 2024 06:25:37 -0700 (PDT) Received: from localhost.localdomain ([89.47.253.130]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4290c738d21sm223186625e9.12.2024.08.13.06.25.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Aug 2024 06:25:36 -0700 (PDT) From: James Clark To: irogers@google.com, linux-perf-users@vger.kernel.org Cc: James Clark , John Garry , Will Deacon , Mike Leach , Leo Yan , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Adrian Hunter , "Liang, Kan" , Yang Jihong , Dominique Martinet , Ze Gao , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH 6/7] perf test: Make stat test work on DT devices Date: Tue, 13 Aug 2024 14:23:14 +0100 Message-Id: <20240813132323.98728-7-james.clark@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240813132323.98728-1-james.clark@linaro.org> References: <20240813132323.98728-1-james.clark@linaro.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240813_062539_568656_9478D600 X-CRM114-Status: GOOD ( 13.87 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org PMUs aren't listed in /sys/devices/ on DT devices, so change the search directory to /sys/bus/event_source/devices which works everywhere. Also add armv8_cortex_* as a known PMU type to search for to make the test run on more devices. Signed-off-by: James Clark --- tools/perf/tests/shell/stat.sh | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/tools/perf/tests/shell/stat.sh b/tools/perf/tests/shell/stat.sh index 3f1e67795490..525d0c44fdc6 100755 --- a/tools/perf/tests/shell/stat.sh +++ b/tools/perf/tests/shell/stat.sh @@ -117,16 +117,18 @@ test_cputype() { # Find a known PMU for cputype. pmu="" - for i in cpu cpu_atom armv8_pmuv3_0 + devs="/sys/bus/event_source/devices" + for i in $devs/cpu $devs/cpu_atom $devs/armv8_pmuv3_0 $devs/armv8_cortex_* do - if test -d "/sys/devices/$i" + i_base=$(basename "$i") + if test -d "$i" then - pmu="$i" + pmu="$i_base" break fi - if perf stat -e "$i/instructions/" true > /dev/null 2>&1 + if perf stat -e "$i_base/instructions/" true > /dev/null 2>&1 then - pmu="$i" + pmu="$i_base" break fi done From patchwork Tue Aug 13 13:23:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Clark X-Patchwork-Id: 13762054 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 0E592C52D7C for ; Tue, 13 Aug 2024 13:30:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=Vqh5EYvMFCPE5arJzUrVuYN8olqKoGJkP7ilX3wyAGI=; b=bFUGqWkVvGrZG/Z+3gBdtfe7js duIvofS/HWY/piH2mVFGcSo4+B+HaBirQb98Bft66PfYCPqlx4bIBkKRj6iFtDy6HIGazWfvYwlxt FIU0w2FLwGz6bP8eBgFA/j1GE4FPJEgFOyqZsJGSXsckCEiIe4a2Fenp7ToCBeuDPHnGYPn52uGtc s6rtCFdj4LihdXLJcgWY7OTOCvZYzhPfclnJEtaP6OVW7sPN3qV4kXA3A5Bci5NGnTfD128Cn2RKX 4ZYsyX+7HheN4B9aMCs3YfBqzHA5kis18pFC/oNwrkWUzwVXf/la+guxAXRvvFfqGFvEht6iBmoDe ArKKkahA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sdrbD-00000003shk-045I; Tue, 13 Aug 2024 13:30:07 +0000 Received: from mail-lf1-x135.google.com ([2a00:1450:4864:20::135]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sdrX2-00000003rS4-26rs for linux-arm-kernel@lists.infradead.org; Tue, 13 Aug 2024 13:25:49 +0000 Received: by mail-lf1-x135.google.com with SMTP id 2adb3069b0e04-5314c6dbaa5so4846783e87.2 for ; Tue, 13 Aug 2024 06:25:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1723555546; x=1724160346; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Vqh5EYvMFCPE5arJzUrVuYN8olqKoGJkP7ilX3wyAGI=; b=gYwHaKSnYE+otctin+90ML+Xm5HFLVFGKYrOshfMLRTE/uOM2GUjosAfH8tVjLEaX6 7lcrMVdj7NDqPyYVqJHMeRInbvm1TlV9nXbCDbNHi0Bh403xRgjgOTchf0Ey+GRF757k l56PQ2W+oI76ZIzWo2TD5vrGzN/4f3qhK0XOmf6GEMBBAMvjPJiibbewz2uFFiwQm8JS MRFVVGimKxEzjdvP83ZSjMKTkMa0fPLu/YE4NzjYgt8A918awZwloZrk9jZjJeNVSSli Oi+ExVG/LFctoxpReJN45aUoVpZg30YOPldxaOtx8wU4ZEF9iPoaIiEkIvjK4GjB5SAv 2VBA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723555546; x=1724160346; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Vqh5EYvMFCPE5arJzUrVuYN8olqKoGJkP7ilX3wyAGI=; b=u+blBwftzE4P0yjKviM1rVvxa0C4m74Re7dvXdq0/iU6dFtLrDlqk9kWWQPqeowmLI mgWnU/LJQCL8Vxnr6FK4hlTfRLIJJsGbQ8J5qSrl7JQ3TcEKzejKbWfQeDAyhUWa6kwK VGhIBI6iqB4yf9i4T/wBgrLZYsRawh4WHVegJT4P/YeFv07vgQWMCt99E4AzC/AwOHDw jXXEc5/GAm6RhRtLU0X0nbBBC8ydM2LTD4Ghq/hZ5PkLf7OeP9/835vMZOs0VaWUKME2 EP7hHuymKHQ4wQyt4LnsMDMNKz+7lioWFjlpkBYCPbijOq8/a4W8VPIlv1CR9eDce/FR 4C+w== X-Forwarded-Encrypted: i=1; AJvYcCUXRXOEtOmjhq9JurLTlJK73Yo6EHew+SEmzoLIBEEsYvMAg+R75QiSSM9j1RQI/H8eB75KN3ZClrBLAAU2z/8f2dqQmpaTd98nfi0xMJo3VCUEqgc= X-Gm-Message-State: AOJu0YzutwNVbq7Xp935/XCcgWJeWXEurPUwEHkWbHijCOPEmjuLW7Pq tPZrnfCZrD5nu0KKtS5tk4043wwjOL4o2yhKewh5H9J04Xak9c44p25078DBOvY= X-Google-Smtp-Source: AGHT+IHMLVGDigrqektOOEcKtHUBUrZ0H1yBfl4W0aPOysz0l5q5wIN+XwIpSkq9sMLm2xPQfj7tKA== X-Received: by 2002:a05:6512:2348:b0:52c:e0e1:9ae3 with SMTP id 2adb3069b0e04-53213694527mr2503106e87.57.1723555546132; Tue, 13 Aug 2024 06:25:46 -0700 (PDT) Received: from localhost.localdomain ([89.47.253.130]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4290c738d21sm223186625e9.12.2024.08.13.06.25.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Aug 2024 06:25:45 -0700 (PDT) From: James Clark To: irogers@google.com, linux-perf-users@vger.kernel.org Cc: James Clark , John Garry , Will Deacon , Mike Leach , Leo Yan , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Adrian Hunter , "Liang, Kan" , Yang Jihong , Dominique Martinet , Ze Gao , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH 7/7] perf test: Add a test for default perf stat command Date: Tue, 13 Aug 2024 14:23:15 +0100 Message-Id: <20240813132323.98728-8-james.clark@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240813132323.98728-1-james.clark@linaro.org> References: <20240813132323.98728-1-james.clark@linaro.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240813_062548_630549_587BD724 X-CRM114-Status: GOOD ( 13.01 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Test that one cycles event is opened for each core PMU when "perf stat" is run without arguments. Signed-off-by: James Clark --- tools/perf/tests/shell/stat.sh | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/tools/perf/tests/shell/stat.sh b/tools/perf/tests/shell/stat.sh index 525d0c44fdc6..7118cfc37f48 100755 --- a/tools/perf/tests/shell/stat.sh +++ b/tools/perf/tests/shell/stat.sh @@ -148,6 +148,26 @@ test_cputype() { echo "cputype test [Success]" } +test_hybrid() { + # Test the default stat command on hybrid devices opens one cycles event for + # each CPU type. + echo "hybrid test" + + # Count the number of core PMUs + pmus=$(ls /sys/bus/event_source/devices/*/cpus 2>/dev/null | wc -l) + + # Run default Perf stat + cycles_events=$(perf stat -- true 2>&1 | grep "cycles" | wc -l) + + if [ "$pmus" -ne "$cycles_events" ] + then + echo "hybrid test [Found $pmus PMUs but $cycles_events cycles events. Failed]" + err=1 + return + fi + echo "hybrid test [Success]" +} + test_default_stat test_stat_record_report test_stat_record_script @@ -155,4 +175,5 @@ test_stat_repeat_weak_groups test_topdown_groups test_topdown_weak_groups test_cputype +test_hybrid exit $err