Received: by 2002:a05:7412:bbc7:b0:fc:a2b0:25d7 with SMTP id kh7csp2587990rdb; Mon, 5 Feb 2024 11:01:48 -0800 (PST) X-Google-Smtp-Source: AGHT+IHLRIUQes5dUq/klZes3pz10VPIAtdC53Ymemv9YJBtK3wMAegB71Btd6e+qFLACwEhtgnl X-Received: by 2002:a17:902:ecc5:b0:1d9:bf28:8bd1 with SMTP id a5-20020a170902ecc500b001d9bf288bd1mr333626plh.53.1707159708155; Mon, 05 Feb 2024 11:01:48 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707159708; cv=pass; d=google.com; s=arc-20160816; b=uGhXI4UKxc26Iul6Pg1UkSIeHFnpAfrs1e8wc/eNSQawPxhFVNwiA8GULk03ybU56c L92khKZbyyeUKzGm1bwxE8EodMubOxTPITx2CCuFocmm3woXadsF7Pdwz4WxwdbUW86T Av1XX8nZaiR1GyVODU3FjVe4hJ1a9qoci0oLQu1eZ+7sm4NYAREqt1MbPtg+7rE6uMFl Zu0VsNCxotMimQchuSkxkbwP8E66OvV1esiUO1vKX1tvKsXJXeMFCTxACctcRfj/H8Db 7O1JpMZj1mIsVllVjYqoiAZFfxi5rN7HSiYGPuv46g9Nal/lkqIdqxRjmGaiqLbEV9jH 0C1g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=7H9BBJTcpBtJeA4RTeXkmbirc5R+koNLnHkIMn9x2ZQ=; fh=knlE13VUyzH5OPAjhBHoNSfZM2agluZ87+MSOfrDsFA=; b=VRnyPIAY+uXSSOhgZtKKexKRCaKjYjd3lnvvhcPD/OCAQKwnig3d3ZcPO5rdXjviR/ P1ku9FAWWTAffosrdSj5NGKDNELU7meu4vDkYar9UrPMmV8bY0z2YZl3hib5CvpYEIxt ALdaKrB59TpYVtuRtE0f7ULvI3tBdlTZY2NO9iyYEo6rUaqPKLO4fLQZz2S/wdfSAYHR tyg9y4Ko1RlIXbgf6JfMulDVGtVkhWh/vfVsJAWAwWxZikRiuThCWvY2LJIX/Gsa3yos rW8fXg0ucWBDOuVosO8WrBNA9/D2KEZ8OHohCc/IU+AU1mnPvPHHcwJNVqqX/flNyd2i CY0g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Mh2Pe9fY; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-53270-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-53270-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Forwarded-Encrypted: i=1; AJvYcCXob7csBtNlM2Nai0xPhxGztsGR0aQTQPKvryvoiBeM5CZMKqzZKZUX7vUinrSZc19vlxIeEM8QULIb0f/q330rGWmUgnOTJM5BOo7kRg== Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id d10-20020a170903230a00b001d6e9ff365esi242901plh.580.2024.02.05.11.01.47 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Feb 2024 11:01:48 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-53270-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Mh2Pe9fY; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-53270-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-53270-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 7330628B748 for ; Mon, 5 Feb 2024 19:01:07 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D825D4878A; Mon, 5 Feb 2024 18:59:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Mh2Pe9fY" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E64982E3FD; Mon, 5 Feb 2024 18:59:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707159598; cv=none; b=OSKFGDUiGs7ixZ/J3wV23XGoSDFSILoEMK2Rs6wm2WEL+n7L6FbbxBpkTiMtbfUOLy9KrxX+7fE1UeAjw4iJnzgS/HudtK1McV/dPrBKg7ccHtbDz1mwiYeEfGItbh29ia2/zLfHZX6TepU5FAUPjAU6tc0v0K+nV0mXve9HzaE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707159598; c=relaxed/simple; bh=24FU41oSYj4xFt0JsE0eIhXDNfjo9usWgVMXWyc9vzA=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=JV3BITW+RDFuEpgovbsDiqeCheSRiSV0dLzLqBa+0PG4JV0Z9u/XKhaGJpWgC/Ntj0k6ZCnISrkBp4np+1FOE8V2a/fKyfHhFsAqfv1kH5rZpkJDN6SSjlv6Owdd38a7dd6i9Sk4ATYi6s1xpYrNH2EbN3LtwWCEZccEwzAyS0Y= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Mh2Pe9fY; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id B6A85C43390; Mon, 5 Feb 2024 18:59:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1707159597; bh=24FU41oSYj4xFt0JsE0eIhXDNfjo9usWgVMXWyc9vzA=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Mh2Pe9fYchh9i5SGvsYyXPPRAGJdbb4COKD/CZDghDcgfj60stOk+7wnZofU2Hnh2 aqXTgp/+sH3/SUSGMAPSQfWj/8trfZ0CUlc+AX0KPKRJUabYkMbq222DuhotCdfled uybJhGMlsL+5mhIcYJ5d8tQ7xcpQJKinoh4GV4T6vhS5DdN8wUIggXj8aGMdihPzI5 ZXhulqsd9K/EwXPS5HILLqWiGycF/I8+fVuTpRxQ8WmOLsnaMbFJ0lzU3oNUKf9zVa MRNcxOgb51R1LExf+lTNgquBQhWyF7kJMor4vDKmHH5F/wRp63x2zybhbBYSL/Ihpy aEOj3hwk0t19Q== Date: Mon, 5 Feb 2024 15:59:53 -0300 From: Arnaldo Carvalho de Melo To: Yang Jihong Cc: peterz@infradead.org, mingo@redhat.com, namhyung@kernel.org, mark.rutland@arm.com, alexander.shishkin@linux.intel.com, jolsa@kernel.org, irogers@google.com, adrian.hunter@intel.com, linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 3/5] perf sched: Move curr_thread initialization to perf_sched__map() Message-ID: References: <20240205104616.132417-1-yangjihong1@huawei.com> <20240205104616.132417-4-yangjihong1@huawei.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240205104616.132417-4-yangjihong1@huawei.com> On Mon, Feb 05, 2024 at 10:46:14AM +0000, Yang Jihong wrote: > The curr_thread is used only for the 'perf sched map'. Put initialization > in perf_sched__map() to reduce unnecessary actions in other commands. > > Simple functional testing: > > # perf sched record perf bench sched messaging > # Running 'sched/messaging' benchmark: > # 20 sender and receiver processes per group > # 10 groups == 400 processes run > > Total time: 0.197 [sec] > [ perf record: Woken up 1 times to write data ] > [ perf record: Captured and wrote 15.526 MB perf.data (140095 samples) ] > > # perf sched map > *A0 451264.532445 secs A0 => migration/0:15 > *. 451264.532468 secs . => swapper:0 > . *B0 451264.532537 secs B0 => migration/1:21 > . *. 451264.532560 secs > . . *C0 451264.532644 secs C0 => migration/2:27 > . . *. 451264.532668 secs > . . . *D0 451264.532753 secs D0 => migration/3:33 > . . . *. 451264.532778 secs > . . . . *E0 451264.532861 secs E0 => migration/4:39 > . . . . *. 451264.532886 secs > . . . . . *F0 451264.532973 secs F0 => migration/5:45 > > A7 A7 A7 A7 A7 *A7 . . . . . . . . . . 451264.790785 secs > A7 A7 A7 A7 A7 A7 *A7 . . . . . . . . . 451264.790858 secs > A7 A7 A7 A7 A7 A7 A7 *A7 . . . . . . . . 451264.790934 secs > A7 A7 A7 A7 A7 A7 A7 A7 *A7 . . . . . . . 451264.791004 secs > A7 A7 A7 A7 A7 A7 A7 A7 A7 *A7 . . . . . . 451264.791075 secs > A7 A7 A7 A7 A7 A7 A7 A7 A7 A7 *A7 . . . . . 451264.791143 secs > A7 A7 A7 A7 A7 A7 A7 A7 A7 A7 A7 *A7 . . . . 451264.791232 secs > A7 A7 A7 A7 A7 A7 A7 A7 A7 A7 A7 A7 *A7 . . . 451264.791336 secs > A7 A7 A7 A7 A7 A7 A7 A7 A7 A7 A7 A7 A7 *A7 . . 451264.791407 secs > A7 A7 A7 A7 A7 A7 A7 A7 A7 A7 A7 A7 A7 A7 *A7 . 451264.791484 secs > A7 A7 A7 A7 A7 A7 A7 A7 A7 A7 A7 A7 A7 A7 A7 *A7 451264.791553 secs > # echo $? > 0 > > Signed-off-by: Yang Jihong > --- > tools/perf/builtin-sched.c | 15 ++++++++------- > 1 file changed, 8 insertions(+), 7 deletions(-) > > diff --git a/tools/perf/builtin-sched.c b/tools/perf/builtin-sched.c > index 26dbfa4aab61..54d79e560617 100644 > --- a/tools/perf/builtin-sched.c > +++ b/tools/perf/builtin-sched.c > @@ -3266,9 +3266,13 @@ static int perf_sched__map(struct perf_sched *sched) > { > int rc = -1; > > - if (setup_map_cpus(sched)) > + sched->curr_thread = calloc(MAX_CPUS, sizeof(*(sched->curr_thread))); > + if (!sched->curr_thread) > return rc; > > + if (setup_map_cpus(sched)) > + goto out_free_curr_thread; > + > if (setup_color_pids(sched)) > goto out_free_map_cpus; > > @@ -3291,6 +3295,9 @@ static int perf_sched__map(struct perf_sched *sched) > out_free_map_cpus: > free(sched->map.comp_cpus); > perf_cpu_map__put(sched->map.cpus); > + > +out_free_curr_thread: > + free(sched->curr_thread); zfree(&sched->curr_thread); > return rc; > } > > @@ -3576,11 +3583,6 @@ int cmd_sched(int argc, const char **argv) > unsigned int i; > int ret = 0; > > - sched.curr_thread = calloc(MAX_CPUS, sizeof(*sched.curr_thread)); > - if (!sched.curr_thread) { > - ret = -ENOMEM; > - goto out; > - } > sched.cpu_last_switched = calloc(MAX_CPUS, sizeof(*sched.cpu_last_switched)); > if (!sched.cpu_last_switched) { > ret = -ENOMEM; > @@ -3662,7 +3664,6 @@ int cmd_sched(int argc, const char **argv) > out: > free(sched.curr_pid); > free(sched.cpu_last_switched); > - free(sched.curr_thread); > > return ret; > } > -- > 2.34.1