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")) {