From patchwork Thu Feb 1 04:22:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 195155 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:693c:2685:b0:106:209c:c626 with SMTP id mn5csp204999dyc; Wed, 31 Jan 2024 20:35:18 -0800 (PST) X-Google-Smtp-Source: AGHT+IG/fHjvvtxulU2DFuFwJ36IY8CkMQtw4biuJRCkiZcOlx0HCewor+DIKP2Uwqsw2gsVlIjr X-Received: by 2002:aa7:9911:0:b0:6dd:e5c8:82fb with SMTP id z17-20020aa79911000000b006dde5c882fbmr3895596pff.32.1706762118686; Wed, 31 Jan 2024 20:35:18 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706762118; cv=pass; d=google.com; s=arc-20160816; b=oeHkAXKk5l90tKCj29U5QH82/lpVLQOihgAIEJr5lAej6Qykh9XP63PAzSV5KTcwRs M0zR/z4rJkuLOG78SNedGPV+Yjr+hp32IfR/UoT+nkFLJUFv77ULRLtTRxPLlaDV0+rb 6+w0BV2nl61sMTwjQiTP6x2s99vNpiLU/e0owkQO1Dvy6K3yh0u+pZ+GxzE9zSe7jvkX k/0GG5SH5/j74D1SuGsfx6hljGA4HScIr5RShWBZtIOLBKNTdzcqAIfX+FllmQ4HNShW sdUzVeQqFc5x4yzrezOWTGiAdAdU4Mzyy3VmWTS4e6iqWsJvaA89XMxx2hBQ0apMj+bd RTCw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=to:from:subject:references:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:in-reply-to:date :dkim-signature; bh=ZaackeHVB/qKw2MvrD7oP7QYNMjIwSaxho/+246ePe0=; fh=16knQUam+zknXF5hs1Vg1Ps0jMXecrolbLDdLXydqO4=; b=0Hv7IWoeWPue8Ha6pcv32lCPN/7JO1Mrao1GFuRXad2lEcKO+CWo1DIdwLL8zmSBS8 d9Ca5qzgNd/5qUChkEOp9IJiSwhbae1Ok5tNdSZjVc0xmsem4rd+UqezpvXp5lL05xvH 5ikrrn/C/jMtfbg/1bVVyYUpzwhtlJNdE3gUtcGCv7hP4ZtE0lpvq/DlNaPfvbFefp8W K2D7bdJjvjr/B2u4EBd/eCDfZRh6/Z/uQx+xpdg2rfx0ntxfgFt604zbnXjX2Thsf5OC Ec3cN6ljVwnDjSHIK2gsh2eyT46oSkcZrl1OuVC1RmUq6BjLV8Zehq265mC6eapuGscx xUUg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=4JhR1+W1; arc=pass (i=1 spf=pass spfdomain=flex--irogers.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-47612-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-47612-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com X-Forwarded-Encrypted: i=1; AJvYcCWIZxSN2UK1orCN9nELyiq9FL6+xjmbRNJupmFaJuEZiJ5kKa2s7FJ129m0BRDid9xRkIIXVgYqEAnhaZHbIDt7DZFxjQ== Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id x6-20020aa784c6000000b006dbcb54e91asi11178596pfn.227.2024.01.31.20.35.18 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Jan 2024 20:35:18 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-47612-ouuuleilei=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=4JhR1+W1; arc=pass (i=1 spf=pass spfdomain=flex--irogers.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-47612-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-47612-ouuuleilei=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 E607FB226DD for ; Thu, 1 Feb 2024 04:24:46 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 782AC3C08E; Thu, 1 Feb 2024 04:23:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="4JhR1+W1" Received: from mail-yb1-f202.google.com (mail-yb1-f202.google.com [209.85.219.202]) (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 1E1BB3FB01 for ; Thu, 1 Feb 2024 04:23:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706761383; cv=none; b=BJuO2lqCYPJyh1Hto6B048iICGnn89FnkxP6blAnfV3unDOWj8U32AX2E1RtV/YypHKDelQJbaygXv6Yk7/1/oGYuootcp2SII5K2JVhJ5he7aVIzl3azTAiQj0fF2z7OzborZir1QfR5PeL5/+jrJ4/XbynN4YMjin/r1ncXX4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706761383; c=relaxed/simple; bh=rcLKh3+Pos68LmxJ9Hm/6wnfZr3ChIf03nmHam1edtQ=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=nIKfEMkYkbLr8Q0xA7N/4cgzN9+g+oLFBXnMH21eSaEopvSoDvChr+RU+f0sSk0KBssElgLhZ/wo1ZnpP87RXMKRjeZXdlYqeqOmIWIAD5TBvshmTdlf7POA1diNTkHB90kmZjt/UPlaTGs84B/ZCiBmdjB+JGz9uNKdEUCy27c= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=4JhR1+W1; arc=none smtp.client-ip=209.85.219.202 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=flex--irogers.bounces.google.com Received: by mail-yb1-f202.google.com with SMTP id 3f1490d57ef6-dc6b26ce0bbso1018029276.1 for ; Wed, 31 Jan 2024 20:23:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1706761381; x=1707366181; darn=vger.kernel.org; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=ZaackeHVB/qKw2MvrD7oP7QYNMjIwSaxho/+246ePe0=; b=4JhR1+W1YmqUbpXA7T4AygMApo80I6G3b1PQq9FzIZ/dej7f0oIpEFE3A/GrQPkfVw YxRgxcPboW8nY3qGZ7/5RgUgvvhHT+fKN36BUmuyyvWfEWPEtqBJYzIcq1Qy3A2Lobfh Vm5C96+GBSJ+ckbmkn7KZ62DxY4vc3zP+qVtD5Y3cVfOQUZbXXOtQEtu6MHZKxXTLKyA qwQwe/M1RG+aC/PYGH9oZUjGIjsujZ/7QCp0Iku6J+AkBs/1WNBuxLp9YijQON9+0ZMZ aNMuukIwV3J/SV+rBhF7QPmKQOzpiXqsafSF//aHPq2Xz+dPYdG+MlgNmsnqeDjMBP5h e7Qw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706761381; x=1707366181; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=ZaackeHVB/qKw2MvrD7oP7QYNMjIwSaxho/+246ePe0=; b=XWIUKAE5ORF6v8wfYiciXJ8UciGMkp91GTduktuBgbwAgldHo4hqAIEY5MPvsSKQJX J3Vd/NTskrFHisMvHiMTq+qaCOg/J7nPBwkUGmDAfK/Om70btvIBZEdApYLVoT8yZd/k MSgpbIOMyXjP/iAkmISn6YWGXSDCyR2Vh/fDprz1VRKqoKYGnTSFxsuKl2rMEXXox/9c ZCQWyAc3HkDc0Muy0tiSJx80+C/k4xXRGvizqsBpIwLz3K1vPFIQTU+wh3Un184/5kN9 yCT/UiQv+UVOI911AUWZ3wbI1NSH4QxEnPkt422G19zOOzPeh1hWl3+9s8amOdFY6JC7 /B5A== X-Gm-Message-State: AOJu0YwSkHtab6h1WIeWkShT9A0cOkznJI4WaMhS3aFYGfxPJXvO0r7t vtYXVL+gWmirUK7nzVRMwdHxePWi/IOi3oEk3d9mKdqxCd+joCok5qpoKfCpP57frkUzUkbVXD/ b2o2kGw== X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:16c5:1feb:bf99:a5d1]) (user=irogers job=sendgmr) by 2002:a05:6902:2082:b0:dc2:50cd:bee6 with SMTP id di2-20020a056902208200b00dc250cdbee6mr1003483ybb.9.1706761381204; Wed, 31 Jan 2024 20:23:01 -0800 (PST) Date: Wed, 31 Jan 2024 20:22:33 -0800 In-Reply-To: <20240201042236.1538928-1-irogers@google.com> Message-Id: <20240201042236.1538928-6-irogers@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240201042236.1538928-1-irogers@google.com> X-Mailer: git-send-email 2.43.0.429.g432eaa2c6b-goog Subject: [PATCH v2 5/8] perf cpumap: Clean up use of perf_cpu_map__has_any_cpu_or_is_empty From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Ian Rogers , Adrian Hunter , Suzuki K Poulose , Mike Leach , James Clark , Leo Yan , John Garry , Will Deacon , Thomas Gleixner , Darren Hart , Davidlohr Bueso , " =?utf-8?q?Andr=C3=A9_Almeida?= " , Kan Liang , K Prateek Nayak , Sean Christopherson , Paolo Bonzini , Kajol Jain , Athira Rajeev , Andrew Jones , Alexandre Ghiti , Atish Patra , "Steinar H. Gunderson" , Yang Jihong , Yang Li , Changbin Du , Sandipan Das , Ravi Bangoria , Paran Lee , Nick Desaulniers , Huacai Chen , Yanteng Si , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org, bpf@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789669795629689317 X-GMAIL-MSGID: 1789669795629689317 Most uses of what was perf_cpu_map__empty but is now perf_cpu_map__has_any_cpu_or_is_empty want to do something with the CPU map if it contains CPUs. Replace uses of perf_cpu_map__has_any_cpu_or_is_empty with other helpers so that CPUs within the map can be handled. Signed-off-by: Ian Rogers Reviewed-by: James Clark --- tools/perf/builtin-c2c.c | 6 +----- tools/perf/builtin-stat.c | 9 ++++----- tools/perf/util/auxtrace.c | 4 ++-- tools/perf/util/record.c | 2 +- tools/perf/util/stat.c | 2 +- 5 files changed, 9 insertions(+), 14 deletions(-) diff --git a/tools/perf/builtin-c2c.c b/tools/perf/builtin-c2c.c index 16b40f5d43db..24107062c43e 100644 --- a/tools/perf/builtin-c2c.c +++ b/tools/perf/builtin-c2c.c @@ -2319,11 +2319,7 @@ static int setup_nodes(struct perf_session *session) nodes[node] = set; - /* empty node, skip */ - if (perf_cpu_map__has_any_cpu_or_is_empty(map)) - continue; - - perf_cpu_map__for_each_cpu(cpu, idx, map) { + perf_cpu_map__for_each_cpu_skip_any(cpu, idx, map) { __set_bit(cpu.cpu, set); if (WARN_ONCE(cpu2node[cpu.cpu] != -1, "node/cpu topology bug")) diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c index 5fe9abc6a524..280eb0c99d2b 100644 --- a/tools/perf/builtin-stat.c +++ b/tools/perf/builtin-stat.c @@ -1317,10 +1317,9 @@ static int cpu__get_cache_id_from_map(struct perf_cpu cpu, char *map) * be the first online CPU in the cache domain else use the * first online CPU of the cache domain as the ID. */ - if (perf_cpu_map__has_any_cpu_or_is_empty(cpu_map)) + id = perf_cpu_map__min(cpu_map).cpu; + if (id == -1) id = cpu.cpu; - else - id = perf_cpu_map__cpu(cpu_map, 0).cpu; /* Free the perf_cpu_map used to find the cache ID */ perf_cpu_map__put(cpu_map); @@ -1623,7 +1622,7 @@ static int perf_stat_init_aggr_mode(void) * taking the highest cpu number to be the size of * the aggregation translate cpumap. */ - if (!perf_cpu_map__has_any_cpu_or_is_empty(evsel_list->core.user_requested_cpus)) + if (!perf_cpu_map__is_any_cpu_or_is_empty(evsel_list->core.user_requested_cpus)) nr = perf_cpu_map__max(evsel_list->core.user_requested_cpus).cpu; else nr = 0; @@ -2290,7 +2289,7 @@ int process_stat_config_event(struct perf_session *session, perf_event__read_stat_config(&stat_config, &event->stat_config); - if (perf_cpu_map__has_any_cpu_or_is_empty(st->cpus)) { + if (perf_cpu_map__is_empty(st->cpus)) { if (st->aggr_mode != AGGR_UNSET) pr_warning("warning: processing task data, aggregation mode not set\n"); } else if (st->aggr_mode != AGGR_UNSET) { diff --git a/tools/perf/util/auxtrace.c b/tools/perf/util/auxtrace.c index 3684e6009b63..6b1d4bafad59 100644 --- a/tools/perf/util/auxtrace.c +++ b/tools/perf/util/auxtrace.c @@ -174,7 +174,7 @@ void auxtrace_mmap_params__set_idx(struct auxtrace_mmap_params *mp, struct evlist *evlist, struct evsel *evsel, int idx) { - bool per_cpu = !perf_cpu_map__has_any_cpu_or_is_empty(evlist->core.user_requested_cpus); + bool per_cpu = !perf_cpu_map__has_any_cpu(evlist->core.user_requested_cpus); mp->mmap_needed = evsel->needs_auxtrace_mmap; @@ -648,7 +648,7 @@ int auxtrace_parse_snapshot_options(struct auxtrace_record *itr, static int evlist__enable_event_idx(struct evlist *evlist, struct evsel *evsel, int idx) { - bool per_cpu_mmaps = !perf_cpu_map__has_any_cpu_or_is_empty(evlist->core.user_requested_cpus); + bool per_cpu_mmaps = !perf_cpu_map__has_any_cpu(evlist->core.user_requested_cpus); if (per_cpu_mmaps) { struct perf_cpu evlist_cpu = perf_cpu_map__cpu(evlist->core.all_cpus, idx); diff --git a/tools/perf/util/record.c b/tools/perf/util/record.c index 87e817b3cf7e..e867de8ddaaa 100644 --- a/tools/perf/util/record.c +++ b/tools/perf/util/record.c @@ -237,7 +237,7 @@ bool evlist__can_select_event(struct evlist *evlist, const char *str) evsel = evlist__last(temp_evlist); - if (!evlist || perf_cpu_map__has_any_cpu_or_is_empty(evlist->core.user_requested_cpus)) { + if (!evlist || perf_cpu_map__is_any_cpu_or_is_empty(evlist->core.user_requested_cpus)) { struct perf_cpu_map *cpus = perf_cpu_map__new_online_cpus(); if (cpus) diff --git a/tools/perf/util/stat.c b/tools/perf/util/stat.c index b0bcf92f0f9c..0bd5467389e4 100644 --- a/tools/perf/util/stat.c +++ b/tools/perf/util/stat.c @@ -315,7 +315,7 @@ static int check_per_pkg(struct evsel *counter, struct perf_counts_values *vals, if (!counter->per_pkg) return 0; - if (perf_cpu_map__has_any_cpu_or_is_empty(cpus)) + if (perf_cpu_map__is_any_cpu_or_is_empty(cpus)) return 0; if (!mask) {