Received: by 2002:a05:7412:b130:b0:e2:908c:2ebd with SMTP id az48csp812446rdb; Fri, 17 Nov 2023 13:36:35 -0800 (PST) X-Google-Smtp-Source: AGHT+IG7RWHCWTmUq2Kc9+VwCEE6F4nebDFStkHSL8O8QSEwMfdXeap/ecXfLpCO9w/GT0PWdxFN X-Received: by 2002:a05:6808:f0b:b0:3af:a0bd:45c3 with SMTP id m11-20020a0568080f0b00b003afa0bd45c3mr888506oiw.20.1700256994688; Fri, 17 Nov 2023 13:36:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700256994; cv=none; d=google.com; s=arc-20160816; b=jAlPSGRsx/VzGObyWXlpJZXqvJi41R/cdx3v5m+5Gqbk/YeGLFS/9SS5tYou3uOP10 r55UWUURvGG7r4feecQcbhqM7kqttuFUHmMoCJlR7AAIXZkcwqQEGqIc1ylMAyRnllIU SAF3T0LIgJ/1vj6Sl5bOlLdbTiq6qHvJNXe/mFNl6xeidw6RXvijoRQEawgT2NviKRSt WZKfZLcqJ2he2Ll+LHGkIKoRTFKmQvOy1/B0szvTV3ZAtNDlB/YVVfGY0jEzmXwQDx3j Tiz4ko8MFq9mNGi+xnM8WIwraq85s75zveMm6x6Zik1dlgq27/bYZXlD2S4Ck5Pd35sr yD1A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version; bh=mqZwtp1fxgBq1jrx5hIB/P7VoBA1rYVRuQpa5hoakSo=; fh=fxBVwwRPTfSSTIyhcQ8VriVGsEn4JpkDKM6Hpr9yTTI=; b=HxyY48W4au13W/Vvbqc/IVIS8EZBQO/WcfjIaWkqQ7oGtVl1Kp8roldU2PvIKIlx5S 7UgsfsoWjwJIBm+JxHiEBrWNekesWVYlv8YXwGddk5iuumuXqkPWfoKFb4+HR9tB2StL GyiQCuQ+iQ6fn80Jm/c4P8dnkru5bzSsCRH10FWh3uzwKEGjPgVQPhVPyDcjPI9Is6HU J67kqwcPUkQSyBk/EAvmBAR5K8zj66M1iks2S04WE1BRcfMFhe49OSVMedafuFrK7unc 1rQwmS8cYo6fQH+bh27uqWnxLmvumfxImYtCHhLmxGSr77Z3yRYJj7FvC8spL+p3zPf3 XF0g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id g129-20020a636b87000000b005aba9cdf091si2708580pgc.579.2023.11.17.13.36.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Nov 2023 13:36:34 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 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 (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id A9A3A837FA18; Fri, 17 Nov 2023 13:36:31 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232012AbjKQVgW convert rfc822-to-8bit (ORCPT + 99 others); Fri, 17 Nov 2023 16:36:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58946 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231533AbjKQVgV (ORCPT ); Fri, 17 Nov 2023 16:36:21 -0500 Received: from mail-pf1-f177.google.com (mail-pf1-f177.google.com [209.85.210.177]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 65FB7D5B; Fri, 17 Nov 2023 13:36:18 -0800 (PST) Received: by mail-pf1-f177.google.com with SMTP id d2e1a72fcca58-6bd0e1b1890so2173658b3a.3; Fri, 17 Nov 2023 13:36:18 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700256978; x=1700861778; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=HRmy9y9ac+yTEbZckJJ5+cq8FyHeOZGxr76B8ISJOI0=; b=IcgAX2OZYMiY+/sW2+r7gv8i4oOrCQ/47JWw9YbiE/eOmrNj0BQx9JLkHwtGANcXWi X9wzh0LZXdE3AOUeHbVQ4KssGTmOZ4EHZ1uJlmNp/O4TmhRGlN1dNmds5MimmdXQDbSk iV7vfgE4ZHLfXSra7jMUNRuDEmfrS8PF+L94zufSkImLBIYBik5DujpHZpE3kEYz9sf+ z+Izm0YrNvktzr/SqQ5Mpc9TGgyw7HgWGLDBt/TQzLREcVNxCt1+JajjauiltYEVUSYY ifDlj48fpZjin+nXOjEUCR0FFQUymY7ttrm+k1xgHL7jrs7XeuI7hofUj5puUN/rW7Ja 8H8Q== X-Gm-Message-State: AOJu0YwZK8E8MXX//pNpV/+cxRPUioWevWF0txf9Wu0Mgb6sUIaMFt+9 fKb2XSrTSXwOc3W0LPvDL2JPrf/m3IlsDaxbvgQ= X-Received: by 2002:a05:6a20:4424:b0:185:a90d:3628 with SMTP id ce36-20020a056a20442400b00185a90d3628mr521392pzb.38.1700256977741; Fri, 17 Nov 2023 13:36:17 -0800 (PST) MIME-Version: 1.0 References: <20231114211254.3137289-1-irogers@google.com> In-Reply-To: <20231114211254.3137289-1-irogers@google.com> From: Namhyung Kim Date: Fri, 17 Nov 2023 13:36:06 -0800 Message-ID: Subject: Re: [RFC PATCH v1] perf evsel: Fallback to task-clock when not system wide To: Ian Rogers Cc: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , 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 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT X-Spam-Status: No, score=-1.0 required=5.0 tests=MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.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 (fry.vger.email [0.0.0.0]); Fri, 17 Nov 2023 13:36:31 -0800 (PST) Hi Ian, On Tue, Nov 14, 2023 at 1:13 PM Ian Rogers wrote: > > 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. I think they are almost the same and no meaningful difference. The cpu-clock event also runs only when the task is running if it's a per-task event. > > 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 I'm not sure you can use the system_wide flag for this. IIUC it's to override the target setting in some cases (e.g. a dummy event to track sideband events in all CPUs) and I think you need to check target__has_cpu() instead. But as I said above, it won't make any difference in the output. Conceptually it'd be more natural to use task-clock event for per-task sessions though. Thanks, Namhyung > + ? 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; > -- > 2.43.0.rc0.421.g78406f8d94-goog >