Message ID | 20211223074541.3318938-34-irogers@google.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show
Return-Path: <linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org> X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B41FCC433EF for <linux-arm-kernel@archiver.kernel.org>; Thu, 23 Dec 2021 08:14:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:From:Subject:References: Mime-Version:Message-Id:In-Reply-To:Date:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=n29hbiAamkgrw915fIkJhZ1spc5tHGiDU+7oXk6C3ug=; b=0Mq1m4QvmZLDBmv6kzGTgTjwbP oggc6gPzgyiF8zcnL1nu+ZYpHoIlL1IaSD5cBtO++lS+5zpWdRytq0ugvWCH1EcJUy+lVdw1hOO5x clpdfV3meeID0nkBfQZ7bda2exa1BMcS6xP2xBW9sVF8T70r7mT2qmZnx7oqxT0IBptVEdNNtXDtW uWkhGrC3JO4+ZdfMkeniSgWONjHeEl2LRiWOc5MUCMskJEygeXkOEmhSKPOs7tdfLmLLle4czpZ2N vWiOaHmcTLsrGyuQS6Bobgo85S6OIWXBw5Thfqkx/jLx4OTA5T/2L8NiiSwYsZubSwREB0d5w80Pe 46Y+e6zQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1n0JDR-00C9TO-Og; Thu, 23 Dec 2021 08:12:47 +0000 Received: from mail-yb1-xb49.google.com ([2607:f8b0:4864:20::b49]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1n0Ip3-00C01p-NZ for linux-arm-kernel@lists.infradead.org; Thu, 23 Dec 2021 07:47:35 +0000 Received: by mail-yb1-xb49.google.com with SMTP id r18-20020a25ac52000000b005c9047c420bso8731556ybd.4 for <linux-arm-kernel@lists.infradead.org>; Wed, 22 Dec 2021 23:47:32 -0800 (PST) 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=7KMW6WRtr7zGKUVYDJaGbIMwO/xb3TdjfWdejoRFxZk=; b=PD4AhddK0yCJrWHFUVFzF6fy/Hy7kE5hAz32UsxLOp2AWaiATpdPZNCESgd7gmZh+0 JD9szVEZUwVwVIovJ8uhUR86l/3obJU0BPy0vtKl5hh/RzQIxNRTRLuKGDvT5HhD/yOY 7CkPaB8T0BMkbm834BJKnDbYDjVJ6M72NJOIPfDmDT0/XJ8FQ0wSOKcrz1Wd3rBBrUbR Bqk8D0IIq5X+1wZ3FpVNLhVw7Qq54DrrbCECNH/qXk7Dl2u/AZHZkMRE6RED9In2ibgw C5Z3sPDQck0XHpCGjAL4/8F0gNSwBg3zIh80bnxvN8HFHtOSeMh62yc6uD8f8ZPBSSSd rtww== 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=7KMW6WRtr7zGKUVYDJaGbIMwO/xb3TdjfWdejoRFxZk=; b=kwkujxxBxVl4AFh7zso7K5raWCm4KpiN3Ct+wUH7z2WH/69l0PwP+aqprdASxeYs9j m34vL8PMQYfr6HJJ6ov1lgqggAuHlKo9uSf5UGeL5Tj8BGW6+uG6AA7XKIMtwETQroI9 pmMfJCwCm6e5scrt4b8XxI0g3We8U2VYtLYXJyjzo8va8Kvrhf/H8OVhQFxSN5AczkaB oMirVPYK36apBlVJvzs8Bk33ypr6Dpi5XNz+w/BCd4i7l9wZYQYYhYmS0E/mDSfVwjO/ FmSyCe+xJttztQZss6xxhW/S17rKRiF5Ia2jQbaYFXhq/7Mv9Hk3zNLZqt7RU6r6o21R z9OQ== X-Gm-Message-State: AOAM531bsMd0ADGXUH8HmyoRRJi5apYQIl2PDeMlAgoPspeVKEqxnZHF OrYsmtLyOh9KQwPPhAACgQg0/jNicaCm X-Google-Smtp-Source: ABdhPJy1JMKjOvk17SbJ4unY+bdUb6VxzdlzcVN9x0G1cd9E8XUWweez9IQ3dMvk09C8NWl/FjP22s3abygL X-Received: from irogers.svl.corp.google.com ([2620:15c:2cd:202:4fef:90ff:589d:24ca]) (user=irogers job=sendgmr) by 2002:a25:da06:: with SMTP id n6mr1734069ybf.763.1640245652081; Wed, 22 Dec 2021 23:47:32 -0800 (PST) Date: Wed, 22 Dec 2021 23:45:26 -0800 In-Reply-To: <20211223074541.3318938-1-irogers@google.com> Message-Id: <20211223074541.3318938-34-irogers@google.com> Mime-Version: 1.0 References: <20211223074541.3318938-1-irogers@google.com> X-Mailer: git-send-email 2.34.1.307.g9b7440fafd-goog Subject: [PATCH v2 33/48] libperf: Allow NULL in perf_cpu_map__idx From: Ian Rogers <irogers@google.com> To: Andi Kleen <ak@linux.intel.com>, Jiri Olsa <jolsa@redhat.com>, Namhyung Kim <namhyung@kernel.org>, John Garry <john.garry@huawei.com>, Kajol Jain <kjain@linux.ibm.com>, "Paul A . Clarke" <pc@us.ibm.com>, Arnaldo Carvalho de Melo <acme@kernel.org>, Riccardo Mancini <rickyman7@gmail.com>, Kan Liang <kan.liang@linux.intel.com>, Peter Zijlstra <peterz@infradead.org>, Ingo Molnar <mingo@redhat.com>, Mark Rutland <mark.rutland@arm.com>, Alexander Shishkin <alexander.shishkin@linux.intel.com>, linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, Vineet Singh <vineet.singh@intel.com>, James Clark <james.clark@arm.com>, Mathieu Poirier <mathieu.poirier@linaro.org>, Suzuki K Poulose <suzuki.poulose@arm.com>, Mike Leach <mike.leach@linaro.org>, Leo Yan <leo.yan@linaro.org>, coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org Cc: eranian@google.com, Ian Rogers <irogers@google.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211222_234733_804736_81ECE562 X-CRM114-Status: GOOD ( 11.90 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: <linux-arm-kernel.lists.infradead.org> List-Unsubscribe: <http://lists.infradead.org/mailman/options/linux-arm-kernel>, <mailto:linux-arm-kernel-request@lists.infradead.org?subject=unsubscribe> List-Archive: <http://lists.infradead.org/pipermail/linux-arm-kernel/> List-Post: <mailto:linux-arm-kernel@lists.infradead.org> List-Help: <mailto:linux-arm-kernel-request@lists.infradead.org?subject=help> List-Subscribe: <http://lists.infradead.org/mailman/listinfo/linux-arm-kernel>, <mailto:linux-arm-kernel-request@lists.infradead.org?subject=subscribe> Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" <linux-arm-kernel-bounces@lists.infradead.org> Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org |
Series |
Refactor perf cpumap
|
expand
|
diff --git a/tools/lib/perf/cpumap.c b/tools/lib/perf/cpumap.c index 3c36a06771af..eacea3ab965a 100644 --- a/tools/lib/perf/cpumap.c +++ b/tools/lib/perf/cpumap.c @@ -270,8 +270,13 @@ bool perf_cpu_map__empty(const struct perf_cpu_map *map) int perf_cpu_map__idx(const struct perf_cpu_map *cpus, int cpu) { - int low = 0, high = cpus->nr; + int low, high; + if (!cpus) + return -1; + + low = 0; + high = cpus->nr; while (low < high) { int idx = (low + high) / 2, cpu_at_idx = cpus->map[idx];
Return -1, not found, if NULL is passed. Signed-off-by: Ian Rogers <irogers@google.com> --- tools/lib/perf/cpumap.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)