Received: by 2002:ab2:620c:0:b0:1ef:ffd0:ce49 with SMTP id o12csp1126441lqt; Tue, 19 Mar 2024 13:33:53 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXgqWV6VaylB/ZwEUrJAJ4lF3W5fzXUiDhW/jMfvFU7mTSErHPSxEAUnTjd1iheWOSs7QZuLK9IpH3Xzjrkaww0kTeKQpv6BBnBUGraEA== X-Google-Smtp-Source: AGHT+IGyFJK0gOQErWL5XetxZV1idXFYAAjQVQd1JLEFea7dZ13FagAfKF1BI89WFh9rgfunUbjW X-Received: by 2002:a05:6358:7f96:b0:17e:8f64:1e92 with SMTP id c22-20020a0563587f9600b0017e8f641e92mr15069428rwo.13.1710880433216; Tue, 19 Mar 2024 13:33:53 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710880433; cv=pass; d=google.com; s=arc-20160816; b=Qk+Dwhr40THmMuIvOe3C/81ngKL3xdOGd5L9BD3Zp0pn7VoQfNPYH2dicErMUvavoi T+ULLEBkpWDJKZ0zGB44I6aHAcAomgZvGa27mfjjAtTMmkc5N414LxkLIItQU5D+phbv EZUAYj1b9GaOzejXL/k4KqGyjcD+bHrTh69kcMhlgfc8+1Rt0AxO49BvaiKJRPhPg/tD OvhKvgpM+NwGzmk+o/nr5QLf+KqFcNRL8xa2l90xeRaazGqLt86LinwookKGJQYCqmTx BwA17LwbEA/sLhBV2NOIqDhF+l9R+i/6cgwT2Zd6aJbfy+X56svrgCPJV54ZMDTSzb0/ jXaQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=f7PpDNpShgz+B/PDR36qmkNusndcc30e4ilE7bZHSuo=; fh=2Re34C0SDrmOs8nW2rMmKYpZZLGitjqHafjlpRoERxc=; b=ww9u8NYMU4zCEKpS8F1/T1aGNwNwcUdKm2MVge0Y5Hsoucb0bi4fgRdG3SFznTSBJV qH93CUQuawsS55WExAWPT1aiMH3NtAbG2AJ+hqGlofXGZwotQxhcEGHS6YUuMPSJwMeu cBpUbeM11s8IyYDTO6qw/UZ1/1rnTzdhMAvba/zMwIxNZYRJJcJb3j5f3bGLRj32GH39 swbarfSBjRBPo9zc1K78FnYUadcKZ4MmFq0lPi+T7mWOvAcvbTiYODvg8W+BewdKUjCG qbNeVgFsY6Xf+75O+xJSZKPi1hcoG+vb7ltx054R4SbnsStNL8qkFB5/07Z9VKq+nB0s mzxQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=RQVtpJzh; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-108110-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-108110-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id w7-20020a634907000000b005dc7e971180si10866849pga.543.2024.03.19.13.33.52 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Mar 2024 13:33:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-108110-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=RQVtpJzh; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-108110-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-108110-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 59623B21FF4 for ; Tue, 19 Mar 2024 20:33:50 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3E8083BBD9; Tue, 19 Mar 2024 20:33:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="RQVtpJzh" Received: from mail-il1-f182.google.com (mail-il1-f182.google.com [209.85.166.182]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BC38F38FA8 for ; Tue, 19 Mar 2024 20:33:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.182 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710880421; cv=none; b=dsxdMPvcD2VGGWRop8RXMOAG8cIZryPZzDPWbRHLmvEGXD8AuQ5fRYrp/LHpVrwm0w7EruqCTcbKCzRKP2oXW3C1xVF+XbxR2m/1pmwQ/wYEoQkb1daqmpm7A42XDVKR8KC1Scd1i5p5633/HEzj+BAAQ6r3coJMOyPaXHBam1M= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710880421; c=relaxed/simple; bh=Eok2DGTMs9IQ05hXDYxc0HToH4eXhUzDfxur7FtwE/U=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=uJzEBFeFZ90lCB1KkaMIFgFNvOOmbnaIBmeBNakZZERL6iJ4bErZu+UfFa1wbcYcRTq3xLEa0SuxAT43hOvJ0H4HftDV9v+9943pDKOxGejm+ILJHGp+mjlSohnt03Fj0NxGCbphMAk7bVgTtGIYuieaASH77058/GHwxXH+R6A= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=RQVtpJzh; arc=none smtp.client-ip=209.85.166.182 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=google.com Received: by mail-il1-f182.google.com with SMTP id e9e14a558f8ab-366abfd7b09so33025ab.0 for ; Tue, 19 Mar 2024 13:33:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1710880419; x=1711485219; 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=f7PpDNpShgz+B/PDR36qmkNusndcc30e4ilE7bZHSuo=; b=RQVtpJzhd0g7iDyp2STlM2a+1mir7pn6WJlOV8tKr5IreGlXdYDRlLLVcR1KwOZ3NJ oMdmXuLCdJKMdU3eUIvybNaiIwGdfysBWjhcFOpNtL1SJ6uwzGXOBucnYymsJ5H5x74Z 8rp1rQo/6rsJtsWvaKwGTY4T5kHxJ8bvDJqSMsEtaH7KG1n3LcSdQQQHFiFrx3MwT9yf +aHj6p6P81F428UX1PdeZkGEZP5BpR+ZcmeZsHCWmr24iUxb5vIb6AKXpA5K98dezg4o DevZrZm2C7Z7I+5yf+8DtBSb8hRtz046IAtzv39tfVqD7TTmyjXxK0gB6Hmcyp+K33FR BD/w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710880419; x=1711485219; 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=f7PpDNpShgz+B/PDR36qmkNusndcc30e4ilE7bZHSuo=; b=QOw/P9ntljlfwcjlLMNj+UwpaLl7ogSwmEKQlXSQC95tjVuL8XHewcuZYdrnHkCiJs laO2ogFxGG/7tRcc+AUEerbIJHE50JBW2ZvNFrr8xTqn0OwQx/jnQqCKxaFWyUu5uApD SfysioH52sYYd/vUvI4msO/1K/hVm/OY3nm4jRNfbHvnGbeZeOzJV7lc1thER3POdjlx /5dM7dCMk5uSGjVmG3PsqBQr4vH9Md+PEVHQ01ckx6HDEwjTWjBUmVcQgznEpZjVlcEr /AZ3ae1OVzSK5uLkznMfUfCLwba3qT3uh4CYln56cqVkwVgPmcJbTxY0KWLz+1F2Fpss M62w== X-Forwarded-Encrypted: i=1; AJvYcCVkWKxUp89v1cFbPSnGraDk/rSBwPGYT1njPZOpJXKkttdoLYA6hP7FJ+qQ3qj2D2NuyA4/KRyZnAWhEbsgGdK78o4ak9d2oc8BoI7X X-Gm-Message-State: AOJu0YxCjsPxarmXo+Bv9AtaTxr8oBxlUx8LpTINiiTq1noF36u7X4wF GbWHRF/EkI2yRoEbFlDZxHby+PMsXhoobQ0FPcl+++O2Eye+zyFgpc6ocoxI9DdT19kqZN6RoNU szuxPeQlEGfP586UfFEmD+U3pGD01hCG6wu6h X-Received: by 2002:a05:6e02:219b:b0:363:c7a9:c5a2 with SMTP id j27-20020a056e02219b00b00363c7a9c5a2mr71438ila.28.1710880418724; Tue, 19 Mar 2024 13:33:38 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240319091429.2056555-1-spring.cxz@gmail.com> In-Reply-To: <20240319091429.2056555-1-spring.cxz@gmail.com> From: Ian Rogers Date: Tue, 19 Mar 2024 13:33:24 -0700 Message-ID: Subject: Re: [PATCH v2] perf evlist: Fix 'perf record -C xx' failed issue To: Chunxin Zang Cc: peterz@infradead.org, mingo@redhat.com, acme@kernel.org, namhyung@kernel.org, mark.rutland@arm.com, alexander.shishkin@linux.intel.com, jolsa@kernel.org, adrian.hunter@intel.com, yangchen11@lixiang.com, zhouchunhua@lixiang.com, linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, zangchunxin@lixiang.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Tue, Mar 19, 2024 at 2:14=E2=80=AFAM Chunxin Zang = wrote: > > The cpu has 8 performance-cores and 8 efficient-cores on my pc. > 0-15 are performance-cores > 16-23 are 8 efficient-cores > > When I run "perf record -C xxx", the command fails if xxx all belong to > performance cores or efficient cores > > The results are as follows > > # perf record -C 12 > WARNING: A requested CPU in '12' is not supported by PMU 'cpu_atom' (CP= Us 16-23) for event 'cycles:P' > Error: > The sys_perf_event_open() syscall returned with 22 (Invalid argument) f= or event (cpu_atom/cycles:P/). > /bin/dmesg | grep -i perf may provide additional information. > > # perf record -C 14-17 > WARNING: A requested CPU in '14-17' is not supported by PMU 'cpu_atom' = (CPUs 16-23) for event 'cycles:P' > WARNING: A requested CPU in '14-17' is not supported by PMU 'cpu_core' = (CPUs 0-15) for event 'cycles:P' > ^C[ perf record: Woken up 1 times to write data ] > > The reason is that the cpu_map of 'cpu_atom'-evsel is empty, causing > the sys_perf_event_open() result to fail. > > Changes in v2: > - fix memory leak about 'intersect' > > Signed-off-by: Chunxin Zang > Reviewed-by: Chen Yang > --- > tools/perf/util/evlist.c | 24 +++++++++++++++++------- > 1 file changed, 17 insertions(+), 7 deletions(-) > > diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c > index 55a300a0977b..babbde29341f 100644 > --- a/tools/perf/util/evlist.c > +++ b/tools/perf/util/evlist.c > @@ -2499,7 +2499,7 @@ void evlist__check_mem_load_aux(struct evlist *evli= st) > void evlist__warn_user_requested_cpus(struct evlist *evlist, const char = *cpu_list) > { > struct perf_cpu_map *user_requested_cpus; > - struct evsel *pos; > + struct evsel *pos, *tmp; > > if (!cpu_list) > return; > @@ -2508,18 +2508,28 @@ void evlist__warn_user_requested_cpus(struct evli= st *evlist, const char *cpu_lis > if (!user_requested_cpus) > return; > > - evlist__for_each_entry(evlist, pos) { > + evlist__for_each_entry_safe(evlist, tmp, pos) { > struct perf_cpu_map *intersect, *to_test; > const struct perf_pmu *pmu =3D evsel__find_pmu(pos); > > to_test =3D pmu && pmu->is_core ? pmu->cpus : cpu_map__on= line(); Perhaps this would be clearer if we just made sure requested uncore CPUs were online. Uncore cpu maps are weird, they say the default CPU but other CPUs are valid. It'd be worth testing the impact of this change on uncore events. > intersect =3D perf_cpu_map__intersect(to_test, user_reque= sted_cpus); > - if (!perf_cpu_map__equal(intersect, user_requested_cpus))= { > - char buf[128]; > + if (!intersect) { > + evlist__remove(evlist, pos); > + evsel__delete(pos); > + perf_cpu_map__put(intersect); evlist__warn_user_requested_cpus seems like a wrong function name if evsels are being removed. Perhaps something like evlist__remove_empty_cpu_map_evsels. It seems this change will remove warnings in cases like: $ perf record cpu_atom/cycles/ -C 0 ... I wonder that we need a flag in the evsel to say when an event comes from wildcard expansion so we only don't warn/remove in that case. Wrt memory leaks, try compiling with EXTRA_CFLAGS=3D"-fsanitize=3Daddress" which also incorporates leak sanitizer. Thanks, Ian > + continue; > + } > + > + if (!perf_cpu_map__is_subset(user_requested_cpus, interse= ct)) { > + char buf_test[128]; > + char buf_intersect[128]; > > - cpu_map__snprint(to_test, buf, sizeof(buf)); > - pr_warning("WARNING: A requested CPU in '%s' is n= ot supported by PMU '%s' (CPUs %s) for event '%s'\n", > - cpu_list, pmu ? pmu->name : "cpu", buf, e= vsel__name(pos)); > + cpu_map__snprint(to_test, buf_test, sizeof(buf_te= st)); > + cpu_map__snprint(intersect, buf_intersect, sizeof= (buf_intersect)); > + pr_warning("WARNING: A requested CPU '%s' in '%s'= is not supported by " > + "PMU '%s' (CPUs %s) for event '%s'\n",= buf_intersect, cpu_list, > + pmu ? pmu->name : "cpu", buf_test, evs= el__name(pos)); > } > perf_cpu_map__put(intersect); > } > -- > 2.34.1 >