Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp1362295rdb; Wed, 6 Dec 2023 17:19:14 -0800 (PST) X-Google-Smtp-Source: AGHT+IHSU4RHIPvdqF9nIvuvuOqYAtZfLgrSXe+WR+c+L0qB0TSsliGGqwrvgAYVhm+cemh1zDpH X-Received: by 2002:a05:6358:3a24:b0:170:6ed7:2e60 with SMTP id g36-20020a0563583a2400b001706ed72e60mr1130686rwe.17.1701911953876; Wed, 06 Dec 2023 17:19:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701911953; cv=none; d=google.com; s=arc-20160816; b=eSozgyHZ0ppJtVsdebFlubnInPE9y6wEEuRu2xmjZE9iKP6JhGPs3rL714PW3K2Npc IwBQh/tgFswFgwJTwH2umwPtrjgUnEzgzhWu1xtdDj2dKNvgfgoYTCF7MFu8I123sSDb xqF7dDKxya9H3jElH1mH827Nb/66JEM6iQeH+McoVvQtc0YWapqAeuj/PldLXULb488P OZWokEcqaib/Rr7JTnIWDjMTMGNIjRGMoNmAOd4OZM4qBuItQiAKKLlvv+rb80N1qqPP vUUKDdzut6nABt/JP4GdEDwGnlPSN5s95P7SqbiWar5nEbgn/ekmZ2DlTLxbdWXymp/h dHlA== 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=CK1SDxoKrbTxUwYVJxj/UubKl5I4LgaZQKa+Urxbs0A=; fh=Io7x3OacpefNRRNKoYAzVE0aWTDwD7FRzyCdD1e3AN4=; b=Iw4xYkFfPxCwgsmQM81c1ggiPRIHXWzan1gNzt97CNyUqb9WIZr09JziYgyrMu+nLV F+GOIa0EnMWw6EOi4mO0W1FuSi3XiGm7toZolb9CZ2X4any2vyRt4c4Bmg6KtPgHyaDg reHBJnBP4OrxTQ4MC7mx8HybDX4C+mfKVvrIRUCOyZJU/FIr7LcIITRrSIJ+nP1Hz5an cNLB6IADqttjSG92jIALK2g0lsf11d+zho3Db4uCJGDtPDtXJLULU0HVMV04KbYBG94e XijGnXHLqboT7+h0vmAnlBa16qIYavq1Te1EJZ8uVI5lxO6lImvhXlf94m8QLFZfw0AV mZnA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=oRoCCzJT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id i15-20020a17090a4b8f00b00286ce76ff01si135483pjh.146.2023.12.06.17.19.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Dec 2023 17:19:13 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=oRoCCzJT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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 971B080D7E50; Wed, 6 Dec 2023 17:19:12 -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 S1441996AbjLGBTC (ORCPT + 99 others); Wed, 6 Dec 2023 20:19:02 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45686 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1442968AbjLGBSg (ORCPT ); Wed, 6 Dec 2023 20:18:36 -0500 Received: from mail-yw1-x114a.google.com (mail-yw1-x114a.google.com [IPv6:2607:f8b0:4864:20::114a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DD75D10F0 for ; Wed, 6 Dec 2023 17:18:07 -0800 (PST) Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-5d8f69da4c8so1799267b3.2 for ; Wed, 06 Dec 2023 17:18:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1701911886; x=1702516686; 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=CK1SDxoKrbTxUwYVJxj/UubKl5I4LgaZQKa+Urxbs0A=; b=oRoCCzJT1o28+nq2r2Lqht6Oe9EQs5zUvGBF54W55qj1R4xZgBd1OsOCNXgghVoL8O 5egOT4k3+iCnNnMmyzBkg/ds1c8f4ORRjcIR29zX2YbGdQFdC+461v74CW4O1/5lzKaT 8TjNnzd+plrdW9XciHFTN8yLRVVwatbdXDaWPr3thYp3u7t5kBKcrVwytxo/1oN3DHTO j/HOdRlxsPoq/P0MBvYN1G2fsga0PbkuPi0TG9pPf5ogI5u0wXUj++OtBDpndqC2ktnS zadG/ESXzsB4mUr/lzRMOTFEF3i1IWZN6Dc9Z64Kf/WtdePDTurzEjeheJjiELSjBLqs cRMw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701911886; x=1702516686; 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=CK1SDxoKrbTxUwYVJxj/UubKl5I4LgaZQKa+Urxbs0A=; b=rImI+u92HaetVdwZlC+Ib/cTna7mBaoYqrd1T6+Fr+0RJClR7Gex722DCqvPonM5X1 rUXVUDYq0Et5B3lzCs+K/00Ic2ZsA8+Ma8jq8TXYWjMX6UkP8QSJd7RjlqpcuDWc0nEb DBJL5CvbshM6Gj5hPETeRVnMy6HPhO/um5wS9m8qVfyU6Auqq6J/L4kYQVrBKDkArYX+ gvB1LsCXlss2pQE1Xp5nCWTnN+JpvyfGlvJaxq8UvvCXBR4ekDHWaAq0gqHUhyfm/hPE W+uYXILEA2iGLM1uhJTGXN38xkw+DA7u0d5gB9T+w3HTnJoWgPrZ9gpezZwXMAOFYMyX 714w== X-Gm-Message-State: AOJu0Yy6bSqgjM5W7+G3OaBdHzfZI/X+3xNDa9OFTswVxNpLAmqgPoRO Kxwxf26zcbI8IimZJGTIMAOeZotRaYa4 X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:35bf:293e:7696:34e9]) (user=irogers job=sendgmr) by 2002:a05:690c:250b:b0:5d3:9222:a83e with SMTP id dt11-20020a05690c250b00b005d39222a83emr31356ywb.10.1701911886660; Wed, 06 Dec 2023 17:18:06 -0800 (PST) Date: Wed, 6 Dec 2023 17:16:51 -0800 In-Reply-To: <20231207011722.1220634-1-irogers@google.com> Message-Id: <20231207011722.1220634-18-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 17/47] perf maps: Do simple merge if given map doesn't overlap 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=unavailable 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:13 -0800 (PST) Simplify merge in for the simple case of a non-overlapping map. Signed-off-by: Ian Rogers --- tools/perf/util/maps.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tools/perf/util/maps.c b/tools/perf/util/maps.c index 94a97923527d..f305a4834cf0 100644 --- a/tools/perf/util/maps.c +++ b/tools/perf/util/maps.c @@ -697,9 +697,20 @@ void maps__fixup_end(struct maps *maps) int maps__merge_in(struct maps *kmaps, struct map *new_map) { struct map_rb_node *rb_node; + struct rb_node *first; + bool overlaps; LIST_HEAD(merged); int err = 0; + down_read(maps__lock(kmaps)); + first = first_ending_after(kmaps, new_map); + rb_node = first ? rb_entry(first, struct map_rb_node, rb_node) : NULL; + overlaps = rb_node && map__start(rb_node->map) < map__end(new_map); + up_read(maps__lock(kmaps)); + + if (!overlaps) + return maps__insert(kmaps, new_map); + maps__for_each_entry(kmaps, rb_node) { struct map *old_map = rb_node->map; -- 2.43.0.rc2.451.g8631bc7472-goog