From mboxrd@z Thu Jan 1 00:00:00 1970 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 BBD58C433EF for ; Sat, 11 Dec 2021 19:26:39 +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:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=nXABbQiYK60XEQUJscJW3qbLECHloV2UMvh+CnHYu3U=; b=xhTcE7gyGmk61D vnc3Pk9P38GfrAeCSmqubx/YrP3yKASLlZybv5CE+187Y5xVqQdyhIGsA6Tvi8n4ekjy7h6HsRFRZ fBSC3s+X2X/khbpVOHL/M03QuLAM2/FT8phyQ2+lrnXbwZyHfOWZ+8cVBarylrAGMgP/dOFZvPkww GCqT0Vwe5nmOKDS7abIgzLGFquT24/CghvBDYoyV96mKWiKlgsWpFllBezDVLc+8fcHAt+LyeJ2IU Qjetxrd5y5+ItyVwFF10FX2PPwwYN3+kblwSIxDoKy3IbjZUWOECoRIjv6fGHUkHxPmab3175sZrI Q+ZJHyYlMdwq6XGXzmlw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mw7zO-005RKR-10; Sat, 11 Dec 2021 19:24:58 +0000 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mw7zK-005RJ8-Ly for linux-arm-kernel@lists.infradead.org; Sat, 11 Dec 2021 19:24:56 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1639250691; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=QGYIOmJ2zjGn+fUhHgq4NRxWkx6+azyaRHTbsJwZhRY=; b=e1n6TqrPhhd5eM+qv5UykqoDBRtvvjbSEO3I8kuabvGDv2uItlymlqRP9NSWxbDWNgNVWs Twt34lmQJ060BPKvwVaWt7OdZT2Td29YoGgNv+d4ZrWwjdHjajQ+MLf18m1m1ubNOWzDHo UWy23b3dkbDi7vQOP723s2Ff9FSeTyQ= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-330-7jgIWgy2MmOZpENCLuJspg-1; Sat, 11 Dec 2021 14:24:50 -0500 X-MC-Unique: 7jgIWgy2MmOZpENCLuJspg-1 Received: by mail-wm1-f70.google.com with SMTP id 144-20020a1c0496000000b003305ac0e03aso8862946wme.8 for ; Sat, 11 Dec 2021 11:24:50 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=QGYIOmJ2zjGn+fUhHgq4NRxWkx6+azyaRHTbsJwZhRY=; b=QC3MoofQYgfVzgGPBEVVpx96f3j6Tprh1F75q/oRH/kXVbA6WEJUZGSzid1xXsMB2d 12q9+Mh9gQKmaeMJE0L8+AW42ilFn4k1IoZqMKoaz8pJ5K19HAXZ4R7V1WAI06IuVsbC hgS7JFORL1DooRGjOliV4QhT5bzrwTT0oo5ZOvt8sS44YSi1VzG5R93ZVbWIIPP6hnIj 7IlsaoLQnY/mEvaESm6F5XghxrM6MRTdAUaczg26/gbP/qAKRLUHMKzBPpMHDXSpkRjE k5szdwmxrMXss/ivqnavtmBHtIKySX2je7pvAVpQYOUpt58EHbVxyLIbUSC5sxuPmCZm fsuA== X-Gm-Message-State: AOAM533176uDCxkRHMxJU/bmLFJLGyVAFFDiZzfpfRVkhLHxIsPMCAru 6nxhpBMGxjrlbAdSqVlob9dzNcX6GEbblVgVudDHIDCF3jprx3ICJqlKolpZkfzwgI/RWL4JEnc IA9Ymcop/GHyjgjXvDAkXjf2VjKQaPmAutM8= X-Received: by 2002:a05:600c:3788:: with SMTP id o8mr25186226wmr.82.1639250689045; Sat, 11 Dec 2021 11:24:49 -0800 (PST) X-Google-Smtp-Source: ABdhPJwa/3BISCKTvKxuMjkiQQIWAJRL5ggw9TxlZ7vsysO2Hk3jaZV+Ycso4fQpJ7VM8oYT4MJC0g== X-Received: by 2002:a05:600c:3788:: with SMTP id o8mr25186186wmr.82.1639250688821; Sat, 11 Dec 2021 11:24:48 -0800 (PST) Received: from krava (nat-pool-brq-u.redhat.com. [213.175.37.12]) by smtp.gmail.com with ESMTPSA id h18sm6196422wre.46.2021.12.11.11.24.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 11 Dec 2021 11:24:48 -0800 (PST) Date: Sat, 11 Dec 2021 20:24:46 +0100 From: Jiri Olsa To: Ian Rogers Cc: Andi Kleen , 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, eranian@google.com Subject: Re: [PATCH 21/22] perf cpumap: Trim the cpu_aggr_map Message-ID: References: <20211208024607.1784932-1-irogers@google.com> <20211208024607.1784932-22-irogers@google.com> MIME-Version: 1.0 In-Reply-To: <20211208024607.1784932-22-irogers@google.com> Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jolsa@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211211_112454_836610_D972AB84 X-CRM114-Status: GOOD ( 19.09 ) 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: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Tue, Dec 07, 2021 at 06:46:06PM -0800, Ian Rogers wrote: > 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; > + } curious.. we should do this, but did you detect some big waste in here? thanks, jirka > /* ensure we process id in increasing order */ > qsort(c->map, c->nr, sizeof(struct aggr_cpu_id), aggr_cpu_id__cmp); > > -- > 2.34.1.400.ga245620fadb-goog > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel