Received: by 2002:a05:7412:251c:b0:e2:908c:2ebd with SMTP id w28csp2186526rda; Tue, 24 Oct 2023 15:28:45 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEmkIbpFeTWE8rDcm04A1OXySs1Joos63bcKw0UXsWOb7H0eWi61VfV0AGYv40aC5j78Du9 X-Received: by 2002:a05:6a00:14c6:b0:68f:c7c5:a73a with SMTP id w6-20020a056a0014c600b0068fc7c5a73amr16417286pfu.16.1698186524389; Tue, 24 Oct 2023 15:28:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698186524; cv=none; d=google.com; s=arc-20160816; b=IJfMeYqy+lW7UYTZxcEihiitv+0M4q/oQmm7Qk8RvKH3hhZzrb+XppAGW3AmbeMhOA bLukp3rddDyMwq2Jrzkw2fHdaaDh9CQ/smHC2EanA2Natqpn1gX7xPtRZwZP5+y4ik9S 5b+iNQjdZVF8zBQa/nSpsO5D48pGoYFvXEZYYbK034XOt805akFvxlvB3gHbCyiuIqfX yXUXFLL1+goPLwM9GF7BOb8bJ1ccu34G3Yml+cFAcV8c20CH9fSxAKIY6aPZI4jeScEr ij9I9Jzda57t5PgmaQIOD2kqAEbKjgxuvNr4/vgePGRhbSulxz9dCgFVx0KkPjKGIcwB DRSg== 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=MiRI18wPFPsoj3esFQh9IhgomcBelp5JaqZwyCYVfWY=; fh=NAro5oTsDEB2Or99ABwb774QJkwQSkr6EoLVqn/Yde0=; b=gwYIyFNy3QgjnNcNEV04Mx2UjELGk+3iYRUFB80Dieuu8nMvxyKXFA+H/4c/OtQ8KD rsrMibIYL4tXcu1kpWrM8xtPiiOSsKsi1aSpdDGYD0h/v85ReGTv1fqkSDHfupiZ9XcD R5ZxHuCIxl0428r2R+CfXLiHzB4wp/gMRPGz9ps7EeaHgFyEwgInPMWk9qnjxf911oiq tD32G98GiHdTURbp+b2ica/JFGO3Va4afo8wKjvJ3EMPvTnj3hcSPSZg4K7zEpBi+xBu VRg7TUyrbcsoauEWBzYGK1Rqq4R3g20OTi7yktfr03rckvzP7jTMNsmzhMIzmcs7eMlV PV+A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=zSTUS5jd; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id n10-20020aa7984a000000b006b7e321c0aesi8877577pfq.40.2023.10.24.15.28.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Oct 2023 15:28:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) client-ip=23.128.96.31; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=zSTUS5jd; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 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 morse.vger.email (Postfix) with ESMTP id 058A78021B36; Tue, 24 Oct 2023 15:28:40 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344646AbjJXW2X (ORCPT + 99 others); Tue, 24 Oct 2023 18:28:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42882 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344644AbjJXW17 (ORCPT ); Tue, 24 Oct 2023 18:27:59 -0400 Received: from mail-yb1-xb4a.google.com (mail-yb1-xb4a.google.com [IPv6:2607:f8b0:4864:20::b4a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A517A1700 for ; Tue, 24 Oct 2023 15:25:33 -0700 (PDT) Received: by mail-yb1-xb4a.google.com with SMTP id 3f1490d57ef6-d9cb3a59a19so2859931276.2 for ; Tue, 24 Oct 2023 15:25:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1698186332; x=1698791132; 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=MiRI18wPFPsoj3esFQh9IhgomcBelp5JaqZwyCYVfWY=; b=zSTUS5jdV7rKsOD7wncjVXcyqL1sOPHzXG2/a9kSRAwf3/XvbAHBV5zrQ8WsLWkVCk efbjbuAfjgH0FNr5pR251us6BjWcJHX8KZHGzNjnXM9N8F5NSklkreiQEKXnOUyNxP3x eq6QeDZ289YikNgPMqhf3xSLXd0fCmYu/+t9g8n1Zat1fJM0f52DAuEHuKdkgNTvtkSS n7kaGgZXC+gNxiwEcvEXbEs7GtKxegcL9JXCfVHjB2KInCWV3sqH+s+0qymhutcxAooN jVlDCUZXEcHqVf5uA817QVZWRlYKJPmgK1+MwEAUnj8P3EXu8KkLT/5C+lOqK37g/oEm 6gfA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698186332; x=1698791132; 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=MiRI18wPFPsoj3esFQh9IhgomcBelp5JaqZwyCYVfWY=; b=p6KQRxU9mgzaXnPvzvwXTuqRN1sZ1D55s6TIUUHuMMvov2jYvqiUQ7oYM3y3RkWlXy bTa0pQpds1up2Bm6o49vr3W8qEWglgnP73T26HVK33BI2USAp1nBvsAEBdFjkvWr9cWR X/MtAe4LJ0hdWZwZPhDyTjQUa0h42aDKAe6qF6GQyavnFpgLykC+tqhLD4AO2kE3Ha2Y t0IRxhgY0Xi0xkwB6+CntVZAiTFACNxla5B8BHdGsTjiRZTmsOpR5HXOLkXyHE/vPTrk NvrtcIz3dDCbrwFEofRKcVRG+MGaGTZxka5uSsBQ95YJWfRQcvmjrvdvRwW40I7BzcA3 75aw== X-Gm-Message-State: AOJu0YydrdDxFBz4/iOekgFfmkhKIOeVmAPXcgNzIPaEbyrgfg6NBqQs pHoI50P2eUOPu47Hvk9O1Hxx/477GyQw X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:93d2:18cc:4d63:45ba]) (user=irogers job=sendgmr) by 2002:a05:6902:1743:b0:d9a:50d2:a8be with SMTP id bz3-20020a056902174300b00d9a50d2a8bemr262421ybb.1.1698186331901; Tue, 24 Oct 2023 15:25:31 -0700 (PDT) Date: Tue, 24 Oct 2023 15:23:38 -0700 In-Reply-To: <20231024222353.3024098-1-irogers@google.com> Message-Id: <20231024222353.3024098-36-irogers@google.com> Mime-Version: 1.0 References: <20231024222353.3024098-1-irogers@google.com> X-Mailer: git-send-email 2.42.0.758.gaed0368e0e-goog Subject: [PATCH v3 35/50] perf maps: Add find next entry to give entry after the given map From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Ian Rogers , Adrian Hunter , Nick Terrell , Kan Liang , Andi Kleen , Leo Yan , Song Liu , Sandipan Das , James Clark , Anshuman Khandual , Miguel Ojeda , Liam Howlett , Yang Jihong , Athira Rajeev , Kajol Jain , K Prateek Nayak , Sean Christopherson , Yanteng Si , Ravi Bangoria , German Gomez , Changbin Du , Paolo Bonzini , Masami Hiramatsu , liuwenyu , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.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,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 morse.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Tue, 24 Oct 2023 15:28:40 -0700 (PDT) Use to remove map_rb_node use from machine.c. Signed-off-by: Ian Rogers --- 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); -- 2.42.0.758.gaed0368e0e-goog