From patchwork Tue Nov 14 21:12:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 165095 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:6358:a59:b0:164:83eb:24d7 with SMTP id 25csp2207825rwb; Tue, 14 Nov 2023 13:13:26 -0800 (PST) X-Google-Smtp-Source: AGHT+IEcLdB2NMUHm6XD09qBxKemd9iJUZpsIliY/kfyfCaVW9nw20AP7asX3lmtyA5BSteI3EgI X-Received: by 2002:a05:6a21:1f05:b0:14e:43b0:5f99 with SMTP id ry5-20020a056a211f0500b0014e43b05f99mr7449975pzb.52.1699996406689; Tue, 14 Nov 2023 13:13:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699996406; cv=none; d=google.com; s=arc-20160816; b=KGJGv6oiNo+3qtfgiOkmwumkq4HJ16f4KKstQWvXELpHS/OGIdhJskADCR4e4g4sKH DYh0ow1g9eNHkveQ2Kr1eQ3XWACIwRvx7ydLAXm/BvqX0UassgunZp37JLKSxEilTJOF MVOlWeHw8WUj2/IoGT5IavqSaAMAq75VHw8MFENNfP8qx1VJAWVB+dIrWOxKLSZPvi2Y KPKKUTCTNZ2GDDvAwZKTJu4ppkOmbjBoIRoxACXt2qfP6wvfgJlQmj7510dDYgLWRzbV ZxmePVZ7ywQyye1RgHbCSafcZ/gIN3hmK3o1c5Uu8Q79MhJDv4NbGFF/ya1sU6maxjFz bOkw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:from:subject:mime-version:message-id:date :dkim-signature; bh=9kP7vFMucwkO9DgpHTpA5ugmcWvw1owRDA2lNLDfZSQ=; fh=CvAN0vNvQ5X0yhenCwGsZV3RmHSk2QWLikiMnc36FLY=; b=Q2QuUFrK6GQHjK4iBJxxIazTU7kA9CjrdC5RzizMGTnvJbBX7KlNwswzLcouX9kc53 HhhcstlTh77wKpEerRFSmI3XKBqRfw4CUMXAQZ+HaUzQ1zxFFfd3qFgzLVvaA7bzTkD7 nTIUmRUuybcxhLvcYt/dFCXyKVBO2ChH+MhEWwEfMt4r2g/l+qz55cVg/kXNYjkK1AwP 4uFMN2PWVOoYWqdz7SA/QwuoPNSlDHh3qhhn60mo8ekRKDU0KWJZpuaFI6AuXicBN+hF KQHR3WYfqco0nbG4QaqWat8E3AWX2PUfwaUh7FzHcRddgN8GsKLySLHye2Ov/jx6r+Ts v37Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=pTnaNVkn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id hq10-20020a056a00680a00b006bbfc944748si8025972pfb.315.2023.11.14.13.13.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Nov 2023 13:13:26 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=pTnaNVkn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id DE8D980B7AF6; Tue, 14 Nov 2023 13:13:19 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234045AbjKNVNG (ORCPT + 29 others); Tue, 14 Nov 2023 16:13:06 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43558 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229507AbjKNVNF (ORCPT ); Tue, 14 Nov 2023 16:13:05 -0500 Received: from mail-yw1-x114a.google.com (mail-yw1-x114a.google.com [IPv6:2607:f8b0:4864:20::114a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A5A46D3 for ; Tue, 14 Nov 2023 13:13:01 -0800 (PST) Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-5a8d9dcdd2bso126727917b3.2 for ; Tue, 14 Nov 2023 13:13:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1699996381; x=1700601181; darn=vger.kernel.org; h=to:from:subject:mime-version:message-id:date:from:to:cc:subject :date:message-id:reply-to; bh=9kP7vFMucwkO9DgpHTpA5ugmcWvw1owRDA2lNLDfZSQ=; b=pTnaNVkntULJMaYde3U1icGxyOhz8/3y4ftmBt34UBiC1OqHuvGIv/Z2qHSBfOy6za tNF8fdPlzGxgV8u7gHpkBLyF42Cd4OEBlT22av8MaWFnTTdcZ9kmyzIMm28W1RIn0lXg Qk3HxupPv7+byexmBsmPgDqxQy+HWdf47LVf/nDJoYge4/LIgjO68SyEyyIOG7fGtjTk FtATpJqO0ueinNe2DJxDVqn/3ZTuq8ROXy+zWwgtEazlPp7ZezUGcooF/iTrxmV1Oh5F KLK5UheXHDKxVTNtGVG2xY3cDAtruZyKmfpC8R7bPGZzbfTnVb/FTZ2kUUgP9juWBPUO 3orQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699996381; x=1700601181; h=to:from:subject:mime-version:message-id:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=9kP7vFMucwkO9DgpHTpA5ugmcWvw1owRDA2lNLDfZSQ=; b=to6CP0gx2CJhNadRAb23Kn/JaERkZ80tzVwdttgn3lRwbgf4KeKrdSZ/qgyYRuwGtN Bv5QvRquvHGvcMb4b2s7hMZI/MTNtpxWJymClsSbtZenHzUI7jHLjICAvkk4X2xkGvx2 ctnPnxLdokRJpRWKgFkZn0Adl/sVTu4xLLmCLfosSRMGUPnV3db+MtKCrBHoq01y8jil 62RuNUW8GmL8ocUl4YybLJJtvNBqRgRWDMatta3KNblo6kRhZvEnPnrI4d9xzB2kdODH rtaRYH2qJymXK0h5mbwgMDFwDQqMe8XxxBuMq8Y6jsq1DcI5TBpAS7jTjUdQz+vzo6dx Q7og== X-Gm-Message-State: AOJu0YzGyyB6//QmY9zzqNmzlYx250ppl/u3l9WYI2l0MCBiwpwrCykt EEwb6yBg3TxSsQ/XaeR36278zSE+rmH2 X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:2838:18b7:26f1:2c68]) (user=irogers job=sendgmr) by 2002:a25:6ad7:0:b0:d9a:50d2:a8be with SMTP id f206-20020a256ad7000000b00d9a50d2a8bemr260648ybc.1.1699996380803; Tue, 14 Nov 2023 13:13:00 -0800 (PST) Date: Tue, 14 Nov 2023 13:12:54 -0800 Message-Id: <20231114211254.3137289-1-irogers@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.43.0.rc0.421.g78406f8d94-goog Subject: [RFC PATCH v1] perf evsel: Fallback to task-clock when not system wide From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Ian Rogers , Adrian Hunter , Kan Liang , Yang Jihong , Leo Yan , Sandipan Das , Ravi Bangoria , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, Ajay Kaher , Alexey Makhalov X-Spam-Status: No, score=-8.4 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE, USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Tue, 14 Nov 2023 13:13:19 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1782575432126361415 X-GMAIL-MSGID: 1782575432126361415 When the cycles event isn't available evsel will fallback to the cpu-clock software event. task-clock is similar to cpu-clock but only runs when the process is running. Falling back to cpu-clock when not system wide leads to confusion, by falling back to task-clock it is hoped the confusion is less. Update a nearby comment and debug string for the change. Signed-off-by: Ian Rogers --- tools/perf/util/evsel.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c index a5da74e3a517..e1175313e4bc 100644 --- a/tools/perf/util/evsel.c +++ b/tools/perf/util/evsel.c @@ -2861,18 +2861,19 @@ bool evsel__fallback(struct evsel *evsel, int err, char *msg, size_t msgsize) evsel->core.attr.type == PERF_TYPE_HARDWARE && evsel->core.attr.config == PERF_COUNT_HW_CPU_CYCLES) { /* - * If it's cycles then fall back to hrtimer based - * cpu-clock-tick sw counter, which is always available even if - * no PMU support. + * If it's cycles then fall back to hrtimer based cpu-clock sw + * counter, which is always available even if no PMU support. * * PPC returns ENXIO until 2.6.37 (behavior changed with commit * b0a873e). */ - scnprintf(msg, msgsize, "%s", -"The cycles event is not supported, trying to fall back to cpu-clock-ticks"); - evsel->core.attr.type = PERF_TYPE_SOFTWARE; - evsel->core.attr.config = PERF_COUNT_SW_CPU_CLOCK; + evsel->core.attr.config = evsel->core.system_wide + ? PERF_COUNT_SW_CPU_CLOCK + : PERF_COUNT_SW_TASK_CLOCK; + scnprintf(msg, msgsize, + "The cycles event is not supported, trying to fall back to %s", + evsel->core.system_wide ? "cpu-clock" : "task-clock"); zfree(&evsel->name); return true;