Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp3428374rdh; Mon, 27 Nov 2023 14:12:02 -0800 (PST) X-Google-Smtp-Source: AGHT+IF1p/8f7s1xUskrpQNFiDjhrL/qXXo2ERBUBqa+rohvsVxyWmpvIH4kWpAKUFFKwy9dD6Hj X-Received: by 2002:a05:6a20:158e:b0:18b:cdd5:10c1 with SMTP id h14-20020a056a20158e00b0018bcdd510c1mr19432880pzj.26.1701123122199; Mon, 27 Nov 2023 14:12:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701123122; cv=none; d=google.com; s=arc-20160816; b=QzQONUYZZ/aG1OZH3TQR2/w/SnDxzozCyuNNgRgVMX6gnGO/0GSX+UYKH23E8Pppat AHXNROBybOTAm1kgTZK40yOVeq6z7NUK8tnqtS+xsbEGuuZ3OVBO4w+1iGPvSX3x4uWK 2hUjFHyV2xIvXDm3l2al7/Tp8r3e94WM7UkTRZqemXjlQWuAgNTcwJ3/Xu5g/a9Z8MCO SMrY1aH7tcEMBmM0U+VUCPvlpmIoCJwQSSYALxZaSzrLqOUpXN1FEqkxi7kChPtObJ5c 0b4LqTK4OlEmzC78j6n2uYNawSDIEV/k+OSKrNs6z7hQHu+XVuIXMHkmdk0GO2TP9dNs /GXg== 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 Return-Path: Received: from howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id t17-20020a056a0021d100b006cb4ac19d40si10997595pfj.226.2023.11.27.14.12.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Nov 2023 14:12:02 -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 48F0E824774F; Mon, 27 Nov 2023 14:11:55 -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 + 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 ); 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 ; Mon, 27 Nov 2023 14:10:15 -0800 (PST) Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-5cd0a4fba39so57341957b3.1 for ; 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 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 , Kajol Jain , Athira Rajeev , Huacai Chen , Masami Hiramatsu , Vincent Whitchurch , "Steinar H. Gunderson" , Liam Howlett , Miguel Ojeda , Colin Ian King , Dmitrii Dolgov <9erthalion6@gmail.com>, Yang Jihong , Ming Wang , James Clark , K Prateek Nayak , Sean Christopherson , Leo Yan , Ravi Bangoria , German Gomez , Changbin Du , Paolo Bonzini , Li Dong , Sandipan Das , liuwenyu , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, Guilherme Amadio 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: 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:55 -0800 (PST) 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.43.0.rc1.413.gea7ed67945-goog