Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp1362387rdb; Wed, 6 Dec 2023 17:19:26 -0800 (PST) X-Google-Smtp-Source: AGHT+IHbTgGOWGDzWEPtjKqVdfPHu63P+n59WqZYPuHE36cJRCTWUVcT6jv84pvWyk4hmXFSEtw7 X-Received: by 2002:a05:6a21:a5a9:b0:18f:97c:976f with SMTP id gd41-20020a056a21a5a900b0018f097c976fmr2189921pzc.87.1701911966555; Wed, 06 Dec 2023 17:19:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701911966; cv=none; d=google.com; s=arc-20160816; b=UUX9xqYA2e2ZWwnbmcWvFZMZjaCW/nx6uC6C2D0TfsE0pXrwLCP+LA91MeEu6o4aIK eysGGEf4X/XnIenEVh3rEsQV3WYyf2V7d6T2xPl5quEtENRA+QibPm9JmPSPdDV+N0jR RtEmkftSLJ15+wHN2PZXHyFTLVip10LKnzCG6553uqx99sxL8CYzdVDgx/vXDmxT5jg8 BqakRzSQJia7+WIiXOV4VGZwMEj2BvxhSoUlhBIkkP0pEnj51sY7D6IsQz/A2rTiI/tr XwuzYU+M3lf+9qCZfjhp/YlZHmHyH/6aiPS36I/iVIw+yRR7uoxKbKyhKRfOK59GQVrj 9t2g== 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=uJG3uwAA/nSL7IkSfLWDFQ2uIzS+c6TzT8pbE94oS2I=; fh=Io7x3OacpefNRRNKoYAzVE0aWTDwD7FRzyCdD1e3AN4=; b=Knr7om+loLzLboHkWiS4vGi3HW9FHeC4Hd75sOWoSgbHZ0qLyQkdC1LG9tZRe02U2D uuiqWuMH5Awr1VwtThVt8qc63H+974fVFgF2m+SGF8TzXvsjQs46JyeL7g7BDDraRmSs F8VoWdemB7cY7TJXe/m+HkaARwF7HOaCl0hxrUDjk9CO2C0rn3HVCZDniGK10kqTNwbe 0xyx/FHSoBkopRBQd7xULYY6Bczui/4quIlK2Bzzon1hwAhKRHepFp0GzSiP6sVIbcPh AUTSzvuYRqUTqWLE3BZqT3R1+8SPOPl6baKYixGelHRsaea3WDVzrIhzu16otmbPfCER 7qgA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=QUYPU1ne; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id b32-20020a631b60000000b005c67dd98b13si203364pgm.314.2023.12.06.17.19.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Dec 2023 17:19:26 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=QUYPU1ne; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 snail.vger.email (Postfix) with ESMTP id 8DD6F80DEA40; Wed, 6 Dec 2023 17:19:25 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1443104AbjLGBTL (ORCPT + 99 others); Wed, 6 Dec 2023 20:19:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44722 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1442987AbjLGBSl (ORCPT ); Wed, 6 Dec 2023 20:18:41 -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 8578D1FD8 for ; Wed, 6 Dec 2023 17:18:15 -0800 (PST) Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-5d351694be7so1636547b3.3 for ; Wed, 06 Dec 2023 17:18:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1701911894; x=1702516694; 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=uJG3uwAA/nSL7IkSfLWDFQ2uIzS+c6TzT8pbE94oS2I=; b=QUYPU1nepX6XgvTp3WSz/qAjTWrBjE+forNlVwRJe6yf5bdp4bpOpWjl3KjH4L6geD sRE9u/F7kMxf66tIIErTZU/PEwXki2BpAzzJQRohbqj82BMETZkHFn4jZ7hp9pFNMrHX fqSNiv77QyXMmfOBz1AQKP/tc1q2L2eSjjjJD9L9PRlEcD2XXFaamNGHScFhghvPeA/e PqiFJkvZF1zEpjAtP9V5LsQpEHz8JwJ3VmLcJZMQCQjpuWJDf4rCdt5lDwApwtjWz3VJ jvdFMSw5z190boZWCO5O8hCBYqLE60DWvNcPKvVM7SNsJtwC4f0nt7d1zG1sUfHjF+qr UenA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701911894; x=1702516694; 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=uJG3uwAA/nSL7IkSfLWDFQ2uIzS+c6TzT8pbE94oS2I=; b=ZCkEGwKw/uuxd4HZ1wZwmqSyv+9pO7hOlToSlB7a7dosE2V7kPh7GbrnM30xqCfjdv iSyYe+OHh4ItGNzj29cNUv+aQzGq8XuCxqnIs7IKBMdOIJDSAY/hEYhRFt5PmPHD6M3a GlL9IWTCRiZckIci0SKQe4nBrnyJfwfantdot0TR9HLCU91c59ay3Nt9V/kk7dTchmjv GLLdDNR+mfO0K7BRXWwSuzmeMfeCJRPfVybCuVdQ+vNLmMWJJv1rMm0zPp99gO+o+0PL UxY9nk0G98rUQmvsKovCvrfSk2P4RTFrW3BbG5yetyhBFi9/gKTEGVjZZKfJzMOlhzSr pyew== X-Gm-Message-State: AOJu0Yxjm1QD+LGorhDIjSfZyvqGMNo2gnjj2eZRbjXJRGR9fvqzLUvy 1Dv4E6gfkK8sbn7ja91ULX0ppLY03Btz X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:35bf:293e:7696:34e9]) (user=irogers job=sendgmr) by 2002:a05:690c:3244:b0:5ca:5fcd:7063 with SMTP id fg4-20020a05690c324400b005ca5fcd7063mr32175ywb.3.1701911893941; Wed, 06 Dec 2023 17:18:13 -0800 (PST) Date: Wed, 6 Dec 2023 17:16:54 -0800 In-Reply-To: <20231207011722.1220634-1-irogers@google.com> Message-Id: <20231207011722.1220634-21-irogers@google.com> Mime-Version: 1.0 References: <20231207011722.1220634-1-irogers@google.com> X-Mailer: git-send-email 2.43.0.rc2.451.g8631bc7472-goog Subject: [PATCH v6 20/47] 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=-9.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE, USER_IN_DEF_DKIM_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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 (snail.vger.email [0.0.0.0]); Wed, 06 Dec 2023 17:19:25 -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 38bf7108821d..b397a769006f 100644 --- a/tools/perf/util/machine.c +++ b/tools/perf/util/machine.c @@ -1762,12 +1762,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 024a6c9f72c4..5b898a0e97b2 100644 --- a/tools/perf/util/maps.c +++ b/tools/perf/util/maps.c @@ -663,6 +663,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.rc2.451.g8631bc7472-goog