From patchwork Wed Dec 8 02:46:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 12695238 Return-Path: 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 3D82FC433EF for ; Wed, 8 Dec 2021 03:05:23 +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=eyFMQyomEnVS8sNCj4sN263crbvMdjpkPYz4krXIHxA=; b=kIMfJlI7Z3MlVh+rvpVeGl9A/L SXFKDLA4Pb5P2cZcFJ4s9q1D0lIYCd8lJIRAdxT7MK4jn1s5k32u9RUDbyXdWbotRXfu0ZCvbedRi TI4AIUR4roj6fxkoGwa178gQO1JvCTjA+fQMQ+gQup2rpat4+obOKTiE7YIsZFfURCsG/FXf+X21H /CLK0T9aiTbvVtewU2vsoGl2bWdVrXPFpzoOtbVF53TUcI/qq9wL7/G4N98ULePMwyFRqxrI29rxT hkiovqAbU2dIvKWPXcmvuXGJDWLZ+znB3hpDcaxS++1j0Tq6yiCvLWZcPZWR3vMJZ9/DEA+1WVxj5 neKdXELQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1munEc-00Apy7-JU; Wed, 08 Dec 2021 03:03:10 +0000 Received: from mail-yb1-xb4a.google.com ([2607:f8b0:4864:20::b4a]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mumz2-00AjZO-In for linux-arm-kernel@lists.infradead.org; Wed, 08 Dec 2021 02:47:05 +0000 Received: by mail-yb1-xb4a.google.com with SMTP id d27-20020a25addb000000b005c2355d9052so2152846ybe.3 for ; Tue, 07 Dec 2021 18:47:03 -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=46qIhN6ZqruQ98+Z98KkhW+wGjl47Soa5Hi+10XVymU=; b=UNBl+7JloiQCD/xY168iKERSuflr+R4yFQza5Bf06jEFOezLH1Yrf6a5cQ8eVt73jG Zr5SQOyUhZdZBKa2ZFqGRZTtVBoNAV4QDUTanqFNh3X7wBOBclG/gnrUEVwwX2VEYFP3 Sl2s25eThz+5A5ev8rAsrR4XsgDk3bSnUwmEtk1D28E7j6o6ikNWoHdi5cWok0R45k60 tuqpQk3CoAKDwCL1Usb+kCsVapTKGSEgDz2WRVT0UBRPfnjCGSST/+w77S6+pF9qu8U8 x77ik5TZlYimrHbwsfk8s6I+14JFm//MC/nFcFZODfQ6UGTe+vcfbCRX8btUNC3SdwIo 557Q== 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=46qIhN6ZqruQ98+Z98KkhW+wGjl47Soa5Hi+10XVymU=; b=Z4dLNZCq9Gbwn29MOFK2YMO/D+17t+4ye5KZ+nW32YCl7tAieGXM3tZd2j0EfJmLl3 cbTFzPyhujlUwg+H8UQVvW9s1DuG4BLyhIuC099LmXAw18/QiMI7C0BOjyhZ8ekYQ7Cf nKUABl+kn2J97CENu6k9p5z5M+BrfIU3FPenZkWBansFUYJodfQXsi0Yo9MRdR1QGl0P ydHRN/A8BdLLVr4GAsR+von11WSX/FLNuQHB40DPouwRIAnZD++UF3xWWd3DgNFEhLk/ 1JgGrTRZk+57oJxDhZjVGF6hps4khgbKnWulXUOQU019Jv9YOQ0jskuoDdxBUNAqt8Yv 40Aw== X-Gm-Message-State: AOAM533gJEcuDe0DiXxwJvrZ9C8/q/evdwwA5C4okSoU4icJJD3DKplX WcplI97Yx2S/gAY3/MHHox+zcH3zGGgw X-Google-Smtp-Source: ABdhPJw+iR3JlVEnsW7c3j3ZLWwqusNogstWlTTEa9OX98HSXE9uZ96oIOZqJLqAA7iSwdxoAzljOXPBwwGG X-Received: from irogers.svl.corp.google.com ([2620:15c:2cd:202:57e:1dbb:34b4:8257]) (user=irogers job=sendgmr) by 2002:a25:d003:: with SMTP id h3mr55705481ybg.184.1638931623022; Tue, 07 Dec 2021 18:47:03 -0800 (PST) Date: Tue, 7 Dec 2021 18:46:06 -0800 In-Reply-To: <20211208024607.1784932-1-irogers@google.com> Message-Id: <20211208024607.1784932-22-irogers@google.com> Mime-Version: 1.0 References: <20211208024607.1784932-1-irogers@google.com> X-Mailer: git-send-email 2.34.1.400.ga245620fadb-goog Subject: [PATCH 21/22] perf cpumap: Trim the cpu_aggr_map From: Ian Rogers To: Andi Kleen , Jiri Olsa , Namhyung Kim , John Garry , Kajol Jain , "Paul A . Clarke" , Arnaldo Carvalho de Melo , Riccardo Mancini , Kan Liang , Peter Zijlstra , Ingo Molnar , Mark Rutland , Alexander Shishkin , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, Vineet Singh , James Clark , Mathieu Poirier , Suzuki K Poulose , Mike Leach , Leo Yan , coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org Cc: eranian@google.com, Ian Rogers X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211207_184704_665480_385607E6 X-CRM114-Status: GOOD ( 12.43 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org cpu_aggr_map__new removes duplicates, when this happens shrink the array. Signed-off-by: Ian Rogers --- tools/perf/util/cpumap.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tools/perf/util/cpumap.c b/tools/perf/util/cpumap.c index 8a72ee996722..985c87f1f1ca 100644 --- a/tools/perf/util/cpumap.c +++ b/tools/perf/util/cpumap.c @@ -185,7 +185,12 @@ struct cpu_aggr_map *cpu_aggr_map__new(const struct perf_cpu_map *cpus, c->nr++; } } - + /* Trim. */ + if (c->nr != cpus->nr) { + c = realloc(c, sizeof(struct cpu_aggr_map) + sizeof(struct aggr_cpu_id) * c->nr); + if (!c) + return NULL; + } /* ensure we process id in increasing order */ qsort(c->map, c->nr, sizeof(struct aggr_cpu_id), aggr_cpu_id__cmp);