Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp3109609pxm; Mon, 28 Feb 2022 12:12:13 -0800 (PST) X-Google-Smtp-Source: ABdhPJwZ1miXOjiqqJRstzrHxDC3U0EkwZfR1WBWuN4ZoxX+xG3KRY4I/T2ruPe3LUNA90Wl9UaP X-Received: by 2002:a17:90a:e60d:b0:1bc:ff52:639e with SMTP id j13-20020a17090ae60d00b001bcff52639emr16645303pjy.145.1646079132994; Mon, 28 Feb 2022 12:12:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646079132; cv=none; d=google.com; s=arc-20160816; b=x22FiT7UcMga9jNcQ/ZMKguyU0Ly8WHP4mHtq6m2ZT36Rm69taOXFjeZmN2XzflRfU AuKQyyudulyEO1RRpaDOwWJJ5fuhVWfD/TmRL97BdKK7Yi2Ttm1q6KE8MabvrgY2zGaz xCvQy9WLtZHcyNCz6msVKP6lQX6ykKcVdRIbelT81BDObOayTIr6pZgkwdES+RcBHd9x 5TTjWRVyrRCWs5C6PmAW/xAdIG8UlAvYMXIfYdHejcN3OD4mnwNCJO51Q33mFQINHGgX MLv3XAVc4Rpxpgx0/HdJBh1jfc35yU5AtpTKrTIwJlK9AIFKDCU22urRt8ZS/GXiymFb cKHw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=hP2zTK8h5Mg1N1GB0wChNwJvwug/yKF/qXit723C/4w=; b=nH+A9lI/wWN+3AwafwUFSsjilCJfw24Z0i1KdwdCVvzdxugRLkILTrSWxNgtVp9kYE fxMLwc/nUc6ca0/kDXOQsPycwnihqYdotJ4QVU1JmE328dbZMsBG39kbx4EC4M5zLd7j V5wxb5wdY7KUsHoGM9SfLNWszMWpCO/Mak0cQo0SQIUDyWduDl2R9n18TgCb76xC3CE3 GlEsy2y2dN/3vPlX+n5mX2VH12otZTOo4E7WheA6/vnESRuolQoI6KpzoDZxzLi5TdgK /PaAZo6rvI7ClZywuwetMIbHp9qisRgb41cBFT5jobCCI++Y7Iew0VnfRGE5CaIp0H0a WShw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=HQ38uZIt; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id v21-20020a1709028d9500b0014fc36dde2fsi10173166plo.318.2022.02.28.12.12.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Feb 2022 12:12:12 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=HQ38uZIt; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 2A6CB157230; Mon, 28 Feb 2022 11:35:25 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239058AbiB1Rvj (ORCPT + 99 others); Mon, 28 Feb 2022 12:51:39 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57314 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240031AbiB1RpA (ORCPT ); Mon, 28 Feb 2022 12:45:00 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6B3812DAB9; Mon, 28 Feb 2022 09:37:34 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id F1AD86135F; Mon, 28 Feb 2022 17:37:33 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DF5C9C340E7; Mon, 28 Feb 2022 17:37:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646069853; bh=pRsXDIZaX6/B6+4vcBJG6GbnQNuzWJ76G+Fce0QPDKA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HQ38uZItqMpFXogzBnV/deiDMadG8itTQGiHx3APW3LF15eLoJzDfKOYng8SGCPC5 eoJXV3KWmP7b4jWafbYFiZuK+sAt1+sS1Z2OA+1aoZQJ7ER+aPSTkhiFDYWuE+gS+r 4dB5CLKeMS88pzDlQlvulGEP8cuHrlS1qxSuWkSk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Kan Liang , Zhengjun Xing , Adrian Hunter , alexander.shishkin@intel.com, Andi Kleen , Ian Rogers , Jin Yao , Jiri Olsa , Peter Zijlstra , Arnaldo Carvalho de Melo Subject: [PATCH 5.15 035/139] perf evlist: Fix failed to use cpu list for uncore events Date: Mon, 28 Feb 2022 18:23:29 +0100 Message-Id: <20220228172351.462238127@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220228172347.614588246@linuxfoundation.org> References: <20220228172347.614588246@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,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 lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Zhengjun Xing commit 8a3d2ee0de3828e0d01f9682d35ee53704659bd0 upstream. The 'perf record' and 'perf stat' commands have supported the option '-C/--cpus' to count or collect only on the list of CPUs provided. Commit 1d3351e631fc34d7 ("perf tools: Enable on a list of CPUs for hybrid") add it to be supported for hybrid. For hybrid support, it checks the cpu list are available on hybrid PMU. But when we test only uncore events(or events not in cpu_core and cpu_atom), there is a bug: Before: # perf stat -C0 -e uncore_clock/clockticks/ sleep 1 failed to use cpu list 0 In this case, for uncore event, its pmu_name is not cpu_core or cpu_atom, so in evlist__fix_hybrid_cpus, perf_pmu__find_hybrid_pmu should return NULL,both events_nr and unmatched_count should be 0 ,then the cpu list check function evlist__fix_hybrid_cpus return -1 and the error "failed to use cpu list 0" will happen. Bypass "events_nr=0" case then the issue is fixed. After: # perf stat -C0 -e uncore_clock/clockticks/ sleep 1 Performance counter stats for 'CPU(s) 0': 195,476,873 uncore_clock/clockticks/ 1.004518677 seconds time elapsed When testing with at least one core event and uncore events, it has no issue. # perf stat -C0 -e cpu_core/cpu-cycles/,uncore_clock/clockticks/ sleep 1 Performance counter stats for 'CPU(s) 0': 5,993,774 cpu_core/cpu-cycles/ 301,025,912 uncore_clock/clockticks/ 1.003964934 seconds time elapsed Fixes: 1d3351e631fc34d7 ("perf tools: Enable on a list of CPUs for hybrid") Reviewed-by: Kan Liang Signed-off-by: Zhengjun Xing Cc: Adrian Hunter Cc: alexander.shishkin@intel.com Cc: Andi Kleen Cc: Ian Rogers Cc: Jin Yao Cc: Jiri Olsa Cc: Peter Zijlstra Link: http://lore.kernel.org/lkml/20220218093127.1844241-1-zhengjun.xing@linux.intel.com Signed-off-by: Arnaldo Carvalho de Melo Signed-off-by: Greg Kroah-Hartman --- tools/perf/util/evlist-hybrid.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) --- a/tools/perf/util/evlist-hybrid.c +++ b/tools/perf/util/evlist-hybrid.c @@ -153,8 +153,8 @@ int evlist__fix_hybrid_cpus(struct evlis perf_cpu_map__put(matched_cpus); perf_cpu_map__put(unmatched_cpus); } - - ret = (unmatched_count == events_nr) ? -1 : 0; + if (events_nr) + ret = (unmatched_count == events_nr) ? -1 : 0; out: perf_cpu_map__put(cpus); return ret;