Received: by 2002:a05:7412:b795:b0:e2:908c:2ebd with SMTP id iv21csp554123rdb; Thu, 2 Nov 2023 11:00:15 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGB/DPG67+3J+oTH+yhqSPgJ53i+KUX0PY3k4emWqvtmRDLZmSVyd2BFuad5OA/BH6CQz9u X-Received: by 2002:a05:6358:713:b0:168:f58d:7bff with SMTP id e19-20020a056358071300b00168f58d7bffmr22099623rwj.30.1698948014611; Thu, 02 Nov 2023 11:00:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698948014; cv=none; d=google.com; s=arc-20160816; b=eo827S3pA6aFGJwbesco21fveOmZAsf4ABjaKsUQVfvwxangoUyI4Z/zTC33OloMzF Np/Piomi/QFnQ9mNXcxTuheFNvs2evwkV3KAoLlvzpfWRfGWNfAvs5JPisgbnShZK1cW m22/gxMiw0n6RtUXg9z951rQcvDgtrJe23iL6SENkaB+P/zQQlsAYGAfvFSUYjp6/pxq G2rg1BrJgCfB1VjjMz1mKXqdY0kj4SZXdCw7xMpNlrREGgd68LlFhmgQ13XqEb8gCBTA G2BANzSrVHfyojJ9tyJlJf9SRnJkGbM26Q+kjH/QkOdGUpffKjompBaQEsFiqgvFFfKe Qxgg== 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=D/N4ckVg6cjKSIfadSgQO70fx2qt1gK+WL2vtB+jVqs=; fh=z1KcSqUpYQ9oC4uLSeIkhAYTnJ2bvP0QbNW2xqV5NqA=; b=pbv4PO43ivY8QjPPZdb51ShCY3FZ7d7cdo7kMHOzPWXpGbUwm/9vJKRqSbGiBGV3kh /ZZ//8Uo898UXtatVqUXt832ReKuifweBmiGZo3K31YlOPvy9LlhQI1d4pH8sg7NiQR6 odwqSYE+a3ZA9W5kr6i6cWGJVicdzpb0x8Yi2Ax3wH5rLof0SyuUjYjoCzuOJQUeonZa h7xPDiJ3w2qRGiyX8XC+r4fhoJzeLZPbtyA+S48bakfjTOyqmZ3QJFfvk3V7mV+hhJ7z 8xYssbVlGF+A8J1CSLr2x7ow6OormjTdjMkHvd8vou+BD2fDaZNMCa4fWYpq2yvU96cc FQ+w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=2zxmkJ4j; 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 b25-20020a656699000000b005859a7d38f9si54552pgw.703.2023.11.02.11.00.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Nov 2023 11:00:14 -0700 (PDT) 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=2zxmkJ4j; 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 47F0382BB54F; Thu, 2 Nov 2023 11:00:13 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1376349AbjKBSAE (ORCPT + 99 others); Thu, 2 Nov 2023 14:00:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53658 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346149AbjKBR7M (ORCPT ); Thu, 2 Nov 2023 13:59:12 -0400 Received: from mail-yb1-xb49.google.com (mail-yb1-xb49.google.com [IPv6:2607:f8b0:4864:20::b49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C4A711984 for ; Thu, 2 Nov 2023 10:58:47 -0700 (PDT) Received: by mail-yb1-xb49.google.com with SMTP id 3f1490d57ef6-da31ec03186so1062562276.1 for ; Thu, 02 Nov 2023 10:58:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1698947926; x=1699552726; 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=D/N4ckVg6cjKSIfadSgQO70fx2qt1gK+WL2vtB+jVqs=; b=2zxmkJ4jWXDGt9kklD3qp4T+SUeQYNWxrQTUc6IrAfmTuK1p97pdhKXlOBQRXHvLLZ S9KsnhwyfxyOznTCcMHEnL9BRUoqqPK6UlyxU1/EBhf3dIqIrD68C25WS1V286+DvYCH 3yBzVy+jEm22RkrJW4xhi9h4MuNQkAdn/5K4N76H7Sxl1t4hRLOEFsc5Bhg7U7aRxTqK qLQW/GNIdGG1ViEPwtgWPOd3s76QSoc+jPJUYDUt8lgkw/9FIh1RYUMHlNZvMxXZu5LX pAnHiFF85jiRpf+D1KZLjccaDSTSRbTJNeEw4wwmEEqQbNjO/PiAyz5Yjl3NuXfpKTNx 1H1Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698947926; x=1699552726; 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=D/N4ckVg6cjKSIfadSgQO70fx2qt1gK+WL2vtB+jVqs=; b=ijr3RwaJlmRRY8as/4zOlZPr5n/ol+IFeYI7etqTTRgAVfKpmnmN1Kd1uovYvdo5D6 cXmKOrYLm3UPR3+LnQHa9FUfSa+6AIKMvwE8IKGPJgzI6j59sOWGQkPK3Fa8tUyCxhFt 1g3bdKLuvNseJW0SbphUt56NNzeNzd6GTs6c/081sO5OuC5hzxMuL3Gjib7vQTzdRNwR ffaQp+af81L55wysEilLexTzH+ZDBCfFoskuIVWspARbjlwWbiQ7QlpgKvCGnDzTL7Q4 m4m+WF6us6J0XiDlf1fPDYqUm7mrnMjcpL7jqHAcCFsUWM2vHgibcg8f8EQqu11cyUHn +SMw== X-Gm-Message-State: AOJu0Yye1MJ6AJ9ieEwnqZ04NQ8WoLHBWVZrsj1539gEkLd9iBn6GFgn JUHyLVIzmWtVveaGqbq+A05IqltKZIfL X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:bb34:df9c:836c:afca]) (user=irogers job=sendgmr) by 2002:a05:6902:45:b0:d9b:59c3:6eef with SMTP id m5-20020a056902004500b00d9b59c36eefmr5140ybh.0.1698947926695; Thu, 02 Nov 2023 10:58:46 -0700 (PDT) Date: Thu, 2 Nov 2023 10:57:04 -0700 In-Reply-To: <20231102175735.2272696-1-irogers@google.com> Message-Id: <20231102175735.2272696-23-irogers@google.com> Mime-Version: 1.0 References: <20231102175735.2272696-1-irogers@google.com> X-Mailer: git-send-email 2.42.0.869.gea05f2083d-goog Subject: [PATCH v4 22/53] 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 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_NONE, 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]); Thu, 02 Nov 2023 11:00:13 -0700 (PDT) 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 40df08dd9bf3..14e1a169433d 100644 --- a/tools/perf/util/maps.c +++ b/tools/perf/util/maps.c @@ -696,9 +696,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); + overlaps = first && + map__start(rb_entry(first, struct map_rb_node, 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.42.0.869.gea05f2083d-goog