Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp1519262iog; Tue, 14 Jun 2022 07:39:41 -0700 (PDT) X-Google-Smtp-Source: AGRyM1txOokBncm10qBvfuT6UfNZp6z+LJ2PdghBOnn84iZvhAKqXZ3YF6L86smvZxqPvWAOMDZO X-Received: by 2002:a17:903:2c2:b0:168:e323:d471 with SMTP id s2-20020a17090302c200b00168e323d471mr4645148plk.147.1655217581113; Tue, 14 Jun 2022 07:39:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655217581; cv=none; d=google.com; s=arc-20160816; b=mvunmKUc9u9KEUqg5g9AYf3/mFqfiPzRC4L6lQJIUq4ZZCztX1r0B+K6UKN1yHt0j2 th3cMC8kXrpji+DTNktq3rY1f93flC3ojX3mrPl0etOFQ7yn0vzFBBPAzvDv2BJxrMvj yaCim6uQQOZhl3DlexaCLOJNrAN0j5aUvSPTM4MkbvQgAA3mmjmUKAoAogMSmfz5o+oq pfQBGQ0ywPI8AU8hAjx9eV2tyXKm81MCkUl3X4gGLNc3QJKGTd6dhFJPJmmRXwtP0fTo SDSpbOKyE9KrbQ7a33s4YtysTSQOUCDB1DeplynbztemDoK0JsE5JSUDsauBD0hLdWL3 Urkw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:references:mime-version :message-id:in-reply-to:date:dkim-signature; bh=jlLUXMLBK64yscSUpLZfKbiaF8vfOQAkVnrzfyvEsEQ=; b=ZBxg6dn1K+MeOBcU1ADbvwduF9ocjYBSzCkzeEEOHCQ/pXaJBhxXlrVcKmQasYDvCZ i+WfWV1tG0RG5GFq373M2KOo6IKqYC8YPtGQZFkcLZyuSmV7Ico7GlROS4Fh47W+GwIY wEc9ggiLDIqPqSUzWPx0UJujYy5yDfAAcQTkzc/z1feIrsURWBWrZekBZw6r2oNRGmSO UYEvFjfYiWccvOlqF6AEwxqTqxE7viCNSZxMoi41UmtvqwF1y8uvMN/1SmYEv6GZZrSh fKjiF92Pu+qV/wXud1zJ86QOgK2KoWS5wf3Q1899zGBz0Ux6nzO6r8XixnQI7wimFO09 i2XQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b="Rq2LH/kH"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q14-20020a170902eb8e00b0015866d0a301si10480214plg.399.2022.06.14.07.39.26; Tue, 14 Jun 2022 07:39:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b="Rq2LH/kH"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245375AbiFNOf3 (ORCPT + 99 others); Tue, 14 Jun 2022 10:35:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55466 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1355419AbiFNOeJ (ORCPT ); Tue, 14 Jun 2022 10:34:09 -0400 Received: from mail-yb1-xb4a.google.com (mail-yb1-xb4a.google.com [IPv6:2607:f8b0:4864:20::b4a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7542136B60 for ; Tue, 14 Jun 2022 07:34:07 -0700 (PDT) Received: by mail-yb1-xb4a.google.com with SMTP id s23-20020a257717000000b00660719d9f2fso7746394ybc.23 for ; Tue, 14 Jun 2022 07:34:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=jlLUXMLBK64yscSUpLZfKbiaF8vfOQAkVnrzfyvEsEQ=; b=Rq2LH/kH8h16OGkoEDqaZztuc/ZNrRQpln9CWWY2rlmxP6xfWs+uX7GPgsLdw9hhbK iI/w0ywcMZ0+Jcuuu7SGFyOEUki/nvJsuSn+8WNytUMuCbFnMMvBIw+3T8hcj0/raMiP YV2/fFagV5ebYC8CoBSloDp60zD0BcYN03U6nZ9V8VbHO2TYxC4LMNTO6tjrCIWL2NPT l76f05GB8Kp+BKCIPnYqbGTTCEUSKU3VnJT+6nB+nQu8xkcaKfxi39W3k5psa2GNti7w lGxaB9Hw0jiBOFVV0tIL+ZqkV8ZRq6j6pcsVGYg7NOFJZskT+ramiaVCIy0bK5FfOc0v 90lQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=jlLUXMLBK64yscSUpLZfKbiaF8vfOQAkVnrzfyvEsEQ=; b=KYrzLLgIqskUJ4kmPZUnUsiVGEpV9HIThD3tle9+PMyQ1sAc3greDCznfO7EUkQQV3 SSNE2Avsl6iR6nAEgrpN5prEr4bj4aCyDkEXpDMTDW20RLYEivHUR+3bmw/qFFAnYHeW J5XVsdeh79NFSvWboOiu8QLW53N4vhf3F5caqklzq5Wz8qQiF/Al0Gyn3g+iHX8zfVv1 3UibtrRjouwX2mRkr4UhuF0DDLxVzmSvDDFXdbOWwWuRdyM2l4rqD3JqyOlj92JRTxyr O8oC8mPNrrdf9BhQGT+P7UhVz8kZYGeOZn7nBBKNcqYYvncoyqr0bUS0ZDMyNoyrP6eF hN8g== X-Gm-Message-State: AJIora+BAf28EU9n9Fj6p56sxbiE71dV9Hnfi+J0s4w8Umdtdap4oDMk 6jfhkjYTAw6MtWR3+ybnCHF+feFGsrN8 X-Received: from irogers.svl.corp.google.com ([2620:15c:2cd:202:b55a:aaa7:a:1b17]) (user=irogers job=sendgmr) by 2002:a25:b884:0:b0:664:7ce8:38f0 with SMTP id w4-20020a25b884000000b006647ce838f0mr5266397ybj.503.1655217246623; Tue, 14 Jun 2022 07:34:06 -0700 (PDT) Date: Tue, 14 Jun 2022 07:33:50 -0700 In-Reply-To: <20220614143353.1559597-1-irogers@google.com> Message-Id: <20220614143353.1559597-4-irogers@google.com> Mime-Version: 1.0 References: <20220614143353.1559597-1-irogers@google.com> X-Mailer: git-send-email 2.36.1.476.g0c4daa206d-goog Subject: [PATCH v2 3/6] perf cpumap: Compute mask size in constant time From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , James Clark , Kees Cook , "Gustavo A. R. Silva" , Adrian Hunter , Riccardo Mancini , German Gomez , Colin Ian King , Song Liu , Dave Marchevsky , Athira Rajeev , Alexey Bayduraev , Leo Yan , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Stephane Eranian , Ian Rogers Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL autolearn=ham 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 perf_cpu_map__max computes the cpumap's maximum value, no need to iterate over all values. Signed-off-by: Ian Rogers --- tools/perf/util/synthetic-events.c | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/tools/perf/util/synthetic-events.c b/tools/perf/util/synthetic-events.c index b8a42a096502..0d87df20ec44 100644 --- a/tools/perf/util/synthetic-events.c +++ b/tools/perf/util/synthetic-events.c @@ -1213,18 +1213,7 @@ static size_t cpus_size(const struct perf_cpu_map *map) static size_t mask_size(const struct perf_cpu_map *map, int *max) { - int i; - - *max = 0; - - for (i = 0; i < perf_cpu_map__nr(map); i++) { - /* bit position of the cpu is + 1 */ - int bit = perf_cpu_map__cpu(map, i).cpu + 1; - - if (bit > *max) - *max = bit; - } - + *max = perf_cpu_map__max(map).cpu; return sizeof(struct perf_record_record_cpu_map) + BITS_TO_LONGS(*max) * sizeof(long); } -- 2.36.1.476.g0c4daa206d-goog