Message ID | 20231127220902.1315692-23-irogers@google.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:ce62:0:b0:403:3b70:6f57 with SMTP id o2csp3499548vqx; Mon, 27 Nov 2023 14:11:50 -0800 (PST) X-Google-Smtp-Source: AGHT+IHYWCtsMeP8sEXtvQpwAP3DdiBgeXAYeNXhVUNuQi5Jk5wiICrmly8rUoJRgDWwBBHuxdg4 X-Received: by 2002:a17:902:ec92:b0:1cf:bf7b:adf2 with SMTP id x18-20020a170902ec9200b001cfbf7badf2mr10379487plg.32.1701123110097; Mon, 27 Nov 2023 14:11:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701123110; cv=none; d=google.com; s=arc-20160816; b=QDtmUAIYAedHyRbc/kH+j11pQq9bTjuuicibNW0ccP85C4+flFSgDIRbCqrdt9EW6m s8EKm4S6lY5v5j1Y1ETlkM/jSDUxhRO/ezco01kx45Mt4ti0wiSoZ250RIuTjhnXk5Sh fpssBYn42Wbd8eBE+yixXTceO8G3/AWCpli39qlAFhpEGW9O6J5Y6qKCsODZSmSxTlXH oSEvhtfGyaXctt6KdUT17D1GVTOAKtLWQHxnvLPqGlTHhRC3G8tzkmNr9lcbIRatn2wS yPPpGmroal6CjfAc3SmT0jW1i0NykWC9rHy5jhMK7Fx5u30YTQLH7zdjcqzLxBiUmC44 0Stw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:from:subject:references:mime-version :message-id:in-reply-to:date:dkim-signature; bh=ibxQbrmoPrqwkvjL6HzRr4OKzYq/57jpsc4KyLgcIQ8=; fh=Io7x3OacpefNRRNKoYAzVE0aWTDwD7FRzyCdD1e3AN4=; b=mdp4EH/QezMYbniQ3woS7AgeXQE4Z8IcOXUNErU1Hno92KSwypT9/TBGuJfcDyj7ti UYMuQBfZH+09Cqweah1DWXOIHd+EIe2QrZfYyc7lTIV+CcGlmBsA4x0/hrX98v104m7A 4eZXXhgZ4lDhctFrfFGFoc6+chSyUd0RPQXqZBtBa8xe7zxtGeKfD90aPamDSTkmkUob 3SpL48SDbRDj9NP/oj8TTBsCVQB7DqG4c3o7nq8/98nR3wke8CRIoXY0d4sKncbDBrwu lPi7PIvTiMr7ZzLLtynCF1UBCVse+iSl0LqCADPMWtj/SJgsbGl0KXSe3LqK7Zcygruv 1frg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b="y/phPbzp"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id ja9-20020a170902efc900b001cfb6a814a0si5364971plb.288.2023.11.27.14.11.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Nov 2023 14:11:50 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b="y/phPbzp"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id 8496D8247753; Mon, 27 Nov 2023 14:11:43 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234260AbjK0WLd (ORCPT <rfc822;toshivichauhan@gmail.com> + 99 others); Mon, 27 Nov 2023 17:11:33 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42970 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234088AbjK0WKo (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Mon, 27 Nov 2023 17:10:44 -0500 Received: from mail-yw1-x1149.google.com (mail-yw1-x1149.google.com [IPv6:2607:f8b0:4864:20::1149]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A572CD63 for <linux-kernel@vger.kernel.org>; Mon, 27 Nov 2023 14:10:15 -0800 (PST) Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-5cd0a4fba39so57341957b3.1 for <linux-kernel@vger.kernel.org>; Mon, 27 Nov 2023 14:10:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1701123015; x=1701727815; darn=vger.kernel.org; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=ibxQbrmoPrqwkvjL6HzRr4OKzYq/57jpsc4KyLgcIQ8=; b=y/phPbzp6l0w8r3SUhuPNmyskKStD+EXNXGRuWsUxJMpIo+yW8HuZgZY9Adu6B5Qnu wHLcIoBF6XTRz5wP3kfWBDvJDbGS6mx3fGU5GMVCbcUN/22BzR0PMzFHMleZaXb6PK6F ovlgl8GfmdFGPiMwZdKzRCsM0kxgwkL8wWYqGU2Djz48oOJ7T92kMd5gIjqeoEI1O2hv a5bith3Gh4lV1boKHpoBvkrh2xVgTZ3nE/lViNx1Gjy/FUvovqkKOxzApwGkWGC/oPxf GpWlZQj7sWkIDGw9yRPzAjSJD+/fp3iYmnuIRbJXRnxUqQVOXADvdIW26w5/3JvqVA8P Whrw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701123015; x=1701727815; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=ibxQbrmoPrqwkvjL6HzRr4OKzYq/57jpsc4KyLgcIQ8=; b=px90UXSVMNirAoShLPQDXV1D6wpYa/MPyaiY4vmM5pVF/u7bVOMCUki9bPlT9yskVg iGtQ5Fu1gissrOY29057fcXbeGSQF9vYR7CVJhe0fGszfhIkl/APNhjmHll68KOna2/m EZYzsLsWnn+ReQjZPODBl1N6qmQkTS2JpgzqFzv0U4ddknkzK6793A8U2oN7Ly8wP+BM ZuyWaTRBISUxM6qJmH2hOgJSkn9xC9fge+ijrDJB/RLFwkVd2uG5LsJoXVake7bCl7eB GJflcuEybmCtbCSewzU/3zyBpJ0cpAULS1Xb5dWuoG+SHEttQRVlLpVrx5m8gmmirjha 2NJg== X-Gm-Message-State: AOJu0YyBKCi+Y2c9NkxR/TzYrS0h9Uf88xxbQU49GgTJOvjVYprpYtGI o9OOOlt/sk49iD6T4jzvARe/8OlfjcRI X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:829:6e77:9093:f39b]) (user=irogers job=sendgmr) by 2002:a0d:d40f:0:b0:59b:e684:3c7a with SMTP id w15-20020a0dd40f000000b0059be6843c7amr440723ywd.4.1701123014862; Mon, 27 Nov 2023 14:10:14 -0800 (PST) Date: Mon, 27 Nov 2023 14:08:34 -0800 In-Reply-To: <20231127220902.1315692-1-irogers@google.com> Message-Id: <20231127220902.1315692-23-irogers@google.com> Mime-Version: 1.0 References: <20231127220902.1315692-1-irogers@google.com> X-Mailer: git-send-email 2.43.0.rc1.413.gea7ed67945-goog Subject: [PATCH v5 22/50] perf maps: Add find next entry to give entry after the given map From: Ian Rogers <irogers@google.com> To: Peter Zijlstra <peterz@infradead.org>, Ingo Molnar <mingo@redhat.com>, Arnaldo Carvalho de Melo <acme@kernel.org>, Mark Rutland <mark.rutland@arm.com>, Alexander Shishkin <alexander.shishkin@linux.intel.com>, Jiri Olsa <jolsa@kernel.org>, Namhyung Kim <namhyung@kernel.org>, Ian Rogers <irogers@google.com>, Adrian Hunter <adrian.hunter@intel.com>, Nick Terrell <terrelln@fb.com>, Kan Liang <kan.liang@linux.intel.com>, Andi Kleen <ak@linux.intel.com>, Kajol Jain <kjain@linux.ibm.com>, Athira Rajeev <atrajeev@linux.vnet.ibm.com>, Huacai Chen <chenhuacai@kernel.org>, Masami Hiramatsu <mhiramat@kernel.org>, Vincent Whitchurch <vincent.whitchurch@axis.com>, "Steinar H. Gunderson" <sesse@google.com>, Liam Howlett <liam.howlett@oracle.com>, Miguel Ojeda <ojeda@kernel.org>, Colin Ian King <colin.i.king@gmail.com>, Dmitrii Dolgov <9erthalion6@gmail.com>, Yang Jihong <yangjihong1@huawei.com>, Ming Wang <wangming01@loongson.cn>, James Clark <james.clark@arm.com>, K Prateek Nayak <kprateek.nayak@amd.com>, Sean Christopherson <seanjc@google.com>, Leo Yan <leo.yan@linaro.org>, Ravi Bangoria <ravi.bangoria@amd.com>, German Gomez <german.gomez@arm.com>, Changbin Du <changbin.du@huawei.com>, Paolo Bonzini <pbonzini@redhat.com>, Li Dong <lidong@vivo.com>, Sandipan Das <sandipan.das@amd.com>, liuwenyu <liuwenyu7@huawei.com>, linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, Guilherme Amadio <amadio@gentoo.org> Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-8.4 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE, USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on howler.vger.email Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Mon, 27 Nov 2023 14:11:43 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1783756866217171918 X-GMAIL-MSGID: 1783756866217171918 |
Series |
Improvements to memory use
|
|
Commit Message
Ian Rogers
Nov. 27, 2023, 10:08 p.m. UTC
Use to remove map_rb_node use from machine.c.
Signed-off-by: Ian Rogers <irogers@google.com>
---
tools/perf/util/machine.c | 7 +++----
tools/perf/util/maps.c | 11 +++++++++++
tools/perf/util/maps.h | 2 ++
3 files changed, 16 insertions(+), 4 deletions(-)
diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c index 191e492539e5..ab345604f274 100644 --- a/tools/perf/util/machine.c +++ b/tools/perf/util/machine.c @@ -1759,12 +1759,11 @@ int machine__create_kernel_maps(struct machine *machine) if (end == ~0ULL) { /* update end address of the kernel map using adjacent module address */ - struct map_rb_node *rb_node = maps__find_node(machine__kernel_maps(machine), - machine__kernel_map(machine)); - struct map_rb_node *next = map_rb_node__next(rb_node); + struct map *next = maps__find_next_entry(machine__kernel_maps(machine), + machine__kernel_map(machine)); if (next) - machine__set_kernel_mmap(machine, start, map__start(next->map)); + machine__set_kernel_mmap(machine, start, map__start(next)); } out_put: diff --git a/tools/perf/util/maps.c b/tools/perf/util/maps.c index 9a84d26328a7..38d56709bd5e 100644 --- a/tools/perf/util/maps.c +++ b/tools/perf/util/maps.c @@ -662,6 +662,17 @@ struct map *maps__find_by_name(struct maps *maps, const char *name) return map; } +struct map *maps__find_next_entry(struct maps *maps, struct map *map) +{ + struct map_rb_node *rb_node = maps__find_node(maps, map); + struct map_rb_node *next = map_rb_node__next(rb_node); + + if (next) + return next->map; + + return NULL; +} + void maps__fixup_end(struct maps *maps) { struct map_rb_node *prev = NULL, *curr; diff --git a/tools/perf/util/maps.h b/tools/perf/util/maps.h index b7ab3ec61b7c..84b42c8456e8 100644 --- a/tools/perf/util/maps.h +++ b/tools/perf/util/maps.h @@ -136,6 +136,8 @@ int maps__fixup_overlap_and_insert(struct maps *maps, struct map *new); struct map *maps__find_by_name(struct maps *maps, const char *name); +struct map *maps__find_next_entry(struct maps *maps, struct map *map); + int maps__merge_in(struct maps *kmaps, struct map *new_map); void __maps__sort_by_name(struct maps *maps);