Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp4729354pxb; Tue, 31 Aug 2021 11:50:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxhFZYlNVdq+GWLeIa1BB7r1wC03IAjk4g+ioON8oasVQ18XHmIyizCMCjCShJztL/zASX5 X-Received: by 2002:a92:c5aa:: with SMTP id r10mr18905237ilt.274.1630435807030; Tue, 31 Aug 2021 11:50:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1630435807; cv=none; d=google.com; s=arc-20160816; b=l6017SZ62woP2+RKuwXBBO8eZPIChxf71ib05Bz8KhyEGWyGgxs71auegAqCBdZppN RwFE7jq/pHq+AuacfG9WzuRvIvMr5ENA5WacdVYVRcYkRROkB0n0S5DtABGWAEhuw4GK 7oro/+TYnMPMqICnrcM35B8peEIwBcZr8CqiEEXaX2RQVstcNwo/FQFb2/7idoRzgc0l K3O8Qs1ZLLvmmnqc+UTuNf8KLXLaOMxuo/UT8hdMZJ+v4rLfbWBQZzgtYJyKZsbO8OLS GLzJyae126AgnTkYj3D0RTN3eiY+P+YwzG8wD+S3quYUy1wsKQkMX808ON8FDrBDeD5D aUcA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=679GzT3AJpwV/ve49vQ29+GhS00RbhdgO3ucCiOFuG4=; b=N6UDLFTwBIzMZyu1nzYBroNXrly3whrg1FbOLEbHIqfABOMbd4rPkau1pYtiGrdqq1 2mCVj4/uGtpcYTXFaJLNTG5q/ohS61+NJxmKOzqnTVx5oxYWPNmGWMR2/RGRjl83mcRA qa7PDrGAA8gVy/uDH4aOr1sf1P3kFaagkE4U6AbwCVQ+j2DPr/zgEMhTebYYZXZWAYd/ Tds4YO4U1JDsW5G9+VFHSbB7Rh7xYpRpD+hlvuCsBfwXfOTxUp+w7M6kJfLZ1swxOBJC gG+qos2dn9j/7EXm+B0qoFIsV0d7G2xlhEhOOD1Z3oUH6wXbgK6dMs0OF8K4x8nrJnQo XIEQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=mktDBhAO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y12si18149833ilg.98.2021.08.31.11.49.55; Tue, 31 Aug 2021 11:50:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=mktDBhAO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229946AbhHaSsJ (ORCPT + 99 others); Tue, 31 Aug 2021 14:48:09 -0400 Received: from mail.kernel.org ([198.145.29.99]:56824 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239481AbhHaSsI (ORCPT ); Tue, 31 Aug 2021 14:48:08 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 37BF161008; Tue, 31 Aug 2021 18:47:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1630435633; bh=iT/iIdNBsTbGiFre6zz9wX0FMEwGiJRBo2nVuhGFLaE=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=mktDBhAO3/B5cmfypfEMomXqZX+lfO17FLVMw0r2aC6emyMFXQaxwJcErh4djdmsw upV+1TEuS+2cKvpyefH4tk8kN7iY06HKsUNayutcm/xrShONgV2qO3NXEHNFrqX0NO LAATfSaDO/cmqOQuXWTeJEXGOT9/rIKAX37a7Jw/tYhXGZB6SQJ0ZGL0QTaL+mIyZY AHt/Dy+Fnx+ppqA4V8+1c503hwM+Vj1DZQoUyZeNqj1E6FGYMeYIUhJ54RetrLYj78 8NH7FK8sC8xbL854MXORHmN3AOw5mgH0syLTWfHShflq4eCbuxRCz8wowf9ZtNghN+ 9RDfWfJrSt+8g== Received: by quaco.ghostprotocols.net (Postfix, from userid 1000) id BBE1C400FE; Tue, 31 Aug 2021 15:47:10 -0300 (-03) Date: Tue, 31 Aug 2021 15:47:10 -0300 From: Arnaldo Carvalho de Melo To: Riccardo Mancini Cc: Ian Rogers , Namhyung Kim , Peter Zijlstra , Ingo Molnar , Mark Rutland , Jiri Olsa , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org Subject: Re: [RFC PATCH v1 02/37] libperf cpumap: improve max function Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Url: http://acmel.wordpress.com Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Em Sat, Aug 21, 2021 at 11:19:08AM +0200, Riccardo Mancini escreveu: > >From commit 7074674e7338863e ("perf cpumap: Maintain cpumaps ordered and > without dups"), perf_cpu_map elements are sorted in ascending order. > > This patch improves the perf_cpu_map__max function by returning the last > element. > > Signed-off-by: Riccardo Mancini > --- > tools/lib/perf/cpumap.c | 12 ++++-------- > 1 file changed, 4 insertions(+), 8 deletions(-) > > diff --git a/tools/lib/perf/cpumap.c b/tools/lib/perf/cpumap.c > index fb633272be3aaed9..80e03b2f0c60cce7 100644 > --- a/tools/lib/perf/cpumap.c > +++ b/tools/lib/perf/cpumap.c > @@ -284,14 +284,10 @@ int perf_cpu_map__idx(struct perf_cpu_map *cpus, int cpu) > > int perf_cpu_map__max(struct perf_cpu_map *map) > { > - int i, max = -1; > - > - for (i = 0; i < map->nr; i++) { > - if (map->map[i] > max) > - max = map->map[i]; > - } > - > - return max; > + if (map->nr > 0) > + return map->map[map->nr-1]; > + else > + return -1; Applying, but adding spaces around the '-', Thanks. - Arnaldo