Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp4867849rdb; Tue, 12 Dec 2023 11:27:31 -0800 (PST) X-Google-Smtp-Source: AGHT+IF3e6b0JliQlua80hw7r+P7ojURzRULfLRpsj3FCIKcCkAhTqMNGvftSPdrpi+5i4MnHMAR X-Received: by 2002:a05:6a20:394a:b0:18f:97c:384d with SMTP id r10-20020a056a20394a00b0018f097c384dmr8321859pzg.39.1702409250806; Tue, 12 Dec 2023 11:27:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702409250; cv=none; d=google.com; s=arc-20160816; b=rwl/3h6pTr+PlRfGfbm9FXnpxYfOZRPNpzsUdP5A/aHyoV04Ac2OIGbJtm0cszKLv7 PGVNcSo4gVXtYagoU1I0PHuBMfY4ZikB58AvO33PUNNJhJeKyT8Ql5wPVe+mUggzqWH+ HUEl7y9/4vpPRFuRTk9WhkfIs2I/3fAloho6TmL1ElXe1d1RPgnItaYxp5HU02Jasocm zsR9cspK9M/ruVUD3dBvKaUmtyrrfKC45DiyoRgtxRvCvu93ZeGoWT0V8nv3WrpiiGfd yu2ZLfIr0v7g4YHbPb0zvVBMM/8/yKb5J/p9MaeHP1epRAAdIfaXpER1529KL7MKqRLx lSGg== 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 :dkim-signature; bh=VpWWa0boH3+/2WIj2IQtKJSjorRZele4YQzAu/aAdHk=; fh=+r/uGQT6Qu8jEOdJUkQPSq32Q/1EBqt0R+wzVvB6gTk=; b=PC/iSAMT/xxF8WZPfkhGm5hz4FlFkoExJZlnGUCp5ZNM03WIK6nRQDMH+aGjAlJ7YA 5UPLzfxuyX9WcrOhM5dFGoTB85OkWWEPFSAZnW6kj9bW4ZubVNGDEZ/q9rvRDGHAV0HY Jvt+qV3pvtIVWz0VMKYQ1aQFlbj39pb1U6kspbyMUxLcJCZXpU1xg35kEdEY0iQv2mPq 2+LVj0Z67b74D15cWzL0nVvFI1eruZAz2hfJ53DfhRaftwtmH0N+RJBmhXd5eu8IJEyr BWWQD+ZmHvWVbIWxFj1K1INUdvvoE/ole+hQ8bVdCSkfIe8w9QO5hjVNdu8Y/gRIKEZe 4VUw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b="MUVkg/r/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id n11-20020a63f80b000000b005ca409a5fefsi793932pgh.643.2023.12.12.11.27.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Dec 2023 11:27:30 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) client-ip=23.128.96.31; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b="MUVkg/r/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 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 morse.vger.email (Postfix) with ESMTP id C258C807CB56; Tue, 12 Dec 2023 11:27:16 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232713AbjLLT1D (ORCPT + 99 others); Tue, 12 Dec 2023 14:27:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34074 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229975AbjLLT1C (ORCPT ); Tue, 12 Dec 2023 14:27:02 -0500 Received: from mail-wm1-x32d.google.com (mail-wm1-x32d.google.com [IPv6:2a00:1450:4864:20::32d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9189DBD for ; Tue, 12 Dec 2023 11:27:07 -0800 (PST) Received: by mail-wm1-x32d.google.com with SMTP id 5b1f17b1804b1-40c38e520e2so12075e9.0 for ; Tue, 12 Dec 2023 11:27:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1702409226; x=1703014026; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=VpWWa0boH3+/2WIj2IQtKJSjorRZele4YQzAu/aAdHk=; b=MUVkg/r/g/XEGrT2LDlpt89VQAB0gdxF3Wgi6cR2QeG5X2iDakpIey8MV9b3cBcngJ BEXEeEkGZBovaZwYZ7ZSAwgXLhpH3FvvW9H17bOVjAtzcXJZ4kCp8fyQt5qZ6D+6xH7h MH5Z1ou3fVyrhT2Gp9CwTjrxVnWMMNlUQLF6HhUA41gBkKfIcOnDW/oZs+5PUSVyVxXK if2+c1dGQJ95gWpFSaXvmGsBoIdcXcUFYyyqg8uNZmtIm/p/QJFFumWZfzT1r7SpRzdl ugFwWgugHW2wULCei3I1QZVo6E4C8QAg6oAREaD6b4L6xRpH5tZb6ePhH36uc7erplHR s2Rg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702409226; x=1703014026; 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=VpWWa0boH3+/2WIj2IQtKJSjorRZele4YQzAu/aAdHk=; b=VZvG77P+3peNhbKlk8HT55H41do/954lWpgnlFOytiEk7HdF+gtRU1xIv9Egnh5Lso IXht8B5wEVdGz9m7uDDwccWtTpmLUC2OUx3F+i3TaBCDECRtIGhLdnzivftMQ9QTopmT Znx65IM9V/jL8JxRRYLqGRldYA6aWz5lsp96LIhxk+BFRzjMnGDzYgi+9jceCYTw704m pAXi15nDtmYKmQx+0EBMGKypYG7B8SNe8K/aZmevx23WnneAFk6bZtVjNytqqMuJYzcY Jim96IKOC9FrIWQs72bqXzgosILR5gaxf/a1hv+hDlHpCn72i4Z/LSB2Z85pe+J+5NMV LDnw== X-Gm-Message-State: AOJu0YxnDxl+h3BS3MdIEa5tZuAvkjHRQl/ViDTA5QpUzEulFryX9Eql SsDsE7R4XcFYR9ECkqMzgMTBIcJj3WlhYTGKXKwx2g== X-Received: by 2002:a05:600c:3491:b0:40b:33aa:a2b9 with SMTP id a17-20020a05600c349100b0040b33aaa2b9mr364639wmq.4.1702409225824; Tue, 12 Dec 2023 11:27:05 -0800 (PST) MIME-Version: 1.0 References: <20231208210855.407580-1-kan.liang@linux.intel.com> <07677ab2-c29b-499b-b473-f7535fb27a8c@linux.intel.com> In-Reply-To: From: Ian Rogers Date: Tue, 12 Dec 2023 11:26:54 -0800 Message-ID: Subject: Re: [PATCH] perf top: Use evsel's cpus to replace user_requested_cpus To: Namhyung Kim Cc: Mark Rutland , "Liang, Kan" , Arnaldo Carvalho de Melo , maz@kernel.org, marcan@marcan.st, linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 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 morse.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 (morse.vger.email [0.0.0.0]); Tue, 12 Dec 2023 11:27:16 -0800 (PST) On Tue, Dec 12, 2023 at 10:49=E2=80=AFAM Namhyung Kim = wrote: > > On Tue, Dec 12, 2023 at 10:31=E2=80=AFAM Mark Rutland wrote: > > > > On Tue, Dec 12, 2023 at 10:00:16AM -0800, Ian Rogers wrote: > > > On Tue, Dec 12, 2023 at 9:23=E2=80=AFAM Namhyung Kim wrote: > > > > > > > > On Tue, Dec 12, 2023 at 7:56=E2=80=AFAM Liang, Kan wrote: > > > > > > > > > > > > > > > > > > > > On 2023-12-11 4:13 p.m., Arnaldo Carvalho de Melo wrote: > > > > > > Em Fri, Dec 08, 2023 at 01:08:55PM -0800, kan.liang@linux.intel= .com escreveu: > > > > > >> From: Kan Liang > > > > > >> > > > > > >> perf top errors out on a hybrid machine > > > > > >> $perf top > > > > > >> > > > > > >> Error: > > > > > >> The cycles:P event is not supported. > > > > > >> > > > > > >> The user_requested_cpus may contain CPUs that are invalid for = a hybrid > > > > > >> PMU. It causes perf_event_open to fail. > > > > > > > > > > > > ? > > > > > > > > > > > > All perf top expects is that the "cycles", the most basic one, = be > > > > > > collected, on all CPUs in the system. > > > > > > > > > > > > > > > > Yes, but for hybrid there is no single "cycles" event which can c= over > > > > > all CPUs. > > > > > > > > Does that mean the kernel would reject the legacy "cycles" event > > > > on hybrid CPUs? > > > > > > I believe not. When the extended type isn't set on legacy cycles we > > > often have the CPU and from that can determine the PMU. The issue is > > > with the -1 any CPU perf_event_open option. As I was told, the PMU th= e > > > event is opened on in this case is the first one registered in the > > > kernel, on Intel hybrid this could be cpu_core or cpu_atom.. but IIRC > > > it'll probably be cpu_core. On ARM =C2=AF\_(=E3=83=84)_/=C2=AF. > > > > On ARM it'll be essentially the same as on x86: if you open an event wi= th > > type=3D=3DPERF_EVENT_TYPE_HARDWARE (without the extended HW type pointi= ng to a > > specific PMU), and with cpu=3D=3D-1, it'll go to an arbitrary CPU PMU, = whichever > > happens to be found by perf_init_event() when iterating over the 'pmus'= list. > > > > If you open an event with type=3D=3DPERF_EVENT_TYPE_HARDWARE and cpu!= =3D-1, the event > > will opened on the appropriate CPU PMU, by virtue of being rejected by = others > > when perf_init_event() iterates over the 'pmus' list. > > Ok, that means "cycles" with cpu =3D=3D -1 would not work well. > > I'm curious if it's possible to do some basic work at the event_init() > like to preserve (common) resource and to do some other work at > sched to config PMU on the current CPU. So that users can simply > use "cycles" or "instructions" for their processes. It should be possible to make things better, especially for standard events for cycles or instructions, for software that isn't aware of multiple core PMUs and the extended type field. There are legacy events like dTLB-speculative-read that may be supported by 1 PMU and not the other, so what should happen with thread scheduling there? On RISC-V there was discussion of the legacy to pmu/config mapping that happens in the driver being something that is handled in the tool. A lot of the legacy events end up being "" which is a pretty bad user experience, like this on AMD: ``` # perf stat -d -a sleep 1 Performance counter stats for 'system wide': 259,256.21 msec cpu-clock # 257.445 CPUs utilized 11,931 context-switches # 46.020 /sec 264 cpu-migrations # 1.018 /sec 419 page-faults # 1.616 /sec 5,892,812,250 cycles # 0.023 GHz (62.43%) 1,159,909,806 stalled-cycles-frontend # 19.68% frontend cycles idle (62.48%) 831,668,644 stalled-cycles-backend # 14.11% backend cycles idle (62.52%) 2,825,351,898 instructions # 0.48 insn per cycle # 0.41 stalled cycles per insn (62.54%) 520,403,374 branches # 2.007 M/sec (62.57%) 12,050,970 branch-misses # 2.32% of all branches (62.55%) 1,117,382,209 L1-dcache-loads # 4.310 M/sec (62.48%) 61,060,457 L1-dcache-load-misses # 5.46% of all L1-dcache accesses (62.43%) LLC-loads LLC-load-misses 1.007033432 seconds time elapsed ``` So I think the move should be away from legacy events but that doesn't necessarily mean we can't make them better. Thanks, Ian > Thanks, > Namhyung