Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp3428001rdh; Mon, 27 Nov 2023 14:11:24 -0800 (PST) X-Google-Smtp-Source: AGHT+IGINoPhGV0es9TW8IAuSfybtZnpV8BTYyTNscbrv5Vr/grMaLHocbl4OP1NMqfLd/hmzDAo X-Received: by 2002:a05:6a20:12ce:b0:18c:92f0:69c2 with SMTP id v14-20020a056a2012ce00b0018c92f069c2mr4866990pzg.39.1701123084260; Mon, 27 Nov 2023 14:11:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701123084; cv=none; d=google.com; s=arc-20160816; b=BQzZUVIuPw2Mv19zq5kXOzcLZ/Q9XNi0YEDdjUGPFMFqun7/dMjCRi4xi4FuL+BWye Sw0c/HNzDRWHnJfYWKZkTiAA4kLcTCJ3Vm8cCbjEDbU82mrT2mCE/F/pvHIlCVilojKH 5G39761pNh/DX9ZYIgfmwI47WSsRG3gPGXaQVP2zHsM8Ls9EJjuwWVRMCEK1h4LWjuYq M50zSVOJRzX/P1//BYeMDNq3aktHb/rskwcv2SQDBzq05kDLG4wW/4mq1z5gw1DrDTJB ckqfNV3VegRBD5jbGT+QauxAqO3CtLRD3ocDY903iixXGc62p7K34fRBdLzrl5JToO3N kv5Q== 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=uAs9xJJ0NlEB/osgBnOQ+CItqjWbP34nP1iWUwmaFSk=; fh=Io7x3OacpefNRRNKoYAzVE0aWTDwD7FRzyCdD1e3AN4=; b=Javl27+SFlrAp7FmRpwWOtGvRyRgvAAj1LRr3DOnVVIMuKzKSTQ2Tnr/bNnGhjLR2D xrc5hR+JQ5EitzQr0YhaT5DF0D/kZ3gZN6wA5S9KwGVyIFu/W3nzDxFaafJv9wvZRTQv 4DqmSk5uCD+nbO+ualTtKp2xP27AnO6N3U3A97cs3y9JnE+emggEP5pYbjpL9T4iDu7i 1o67Q5EdLHhUsjEzG3uSvYauVS+kvEauXDA1gMv5YybJFwdwKw7ldrCIECR5chodacgJ +naau4dUOjB7bJLg7NaHQyYxCwqvpS2wnpRJBqcXaq9PoAmurrpqbhd19i6Hjn2U45qc U1Kg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=Ou5kncoO; 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 k2-20020a17090a910200b00280072b397csi10986080pjo.30.2023.11.27.14.11.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Nov 2023 14:11:24 -0800 (PST) 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=Ou5kncoO; 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 BF4668107567; Mon, 27 Nov 2023 14:11:21 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234180AbjK0WLC (ORCPT + 99 others); Mon, 27 Nov 2023 17:11:02 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39240 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233855AbjK0WKc (ORCPT ); Mon, 27 Nov 2023 17:10:32 -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 A6C922103 for ; Mon, 27 Nov 2023 14:10:08 -0800 (PST) Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-5cef61289fdso38427937b3.1 for ; Mon, 27 Nov 2023 14:10:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1701123008; x=1701727808; 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=uAs9xJJ0NlEB/osgBnOQ+CItqjWbP34nP1iWUwmaFSk=; b=Ou5kncoOrxfYfVuvym4yMip8yo+PgBMeoms+79MdyYq6I6GUngQSVDEBECX97ZHBMQ wwRakzunprC5rB914GbqG7eDAK9q4rHR9iWScZEVoOzbI2FoGEA96OuJd3NGb7aIbixI lsBoN/H17MSLdJ7SHnivj5uNn8I8r7ecDRslQKoh2P56d1zrCDw3WQ26usbn+ng3P3U8 hhI3+V/c9hT+a2pTgq+8TGvoN+4lDJQ5bVLTP82Fq+PTLpFPbyV2JDfyjJL/KFpcSXVt LwIlOnXP/oKWiZzp2G0Dc3mShtZQiUOoSP4eiAIZiLGYfQ7CoNkcj6kORIws6vy1lZ9R qG6g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701123008; x=1701727808; 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=uAs9xJJ0NlEB/osgBnOQ+CItqjWbP34nP1iWUwmaFSk=; b=NcZUi0wghBwKGy3wE7FizNWioBB4cg3/7O5y7JUdQdKAydrvF3/bx+md7jtJXTQSi4 U5mN1ITW8prlSyT1WBKQCYHSUZeE1VFFEJXFvUTiwYj1pk7CuPpUW+T8qmNogHkA1uu+ ozchSw42ZgUe+FMb8JHu1D0P8KyTHddNzvGSK3Rj6WufeoJN6H833nSpJjdAxbNU40TO vANtKtubdDlLAUKnO/2nGVKy7Tknv4ZDabD1p1mtwbHjJduto21iz1jYGQ/zvO5zRQus b4z8sn8rjHZI3ajDe66SK00ZQiTCwL2BJB9TlwohXbYYZAhQXY1DuB73F3TGjXw38KkE /hLA== X-Gm-Message-State: AOJu0YyOXWV8ZOEU+V7AQK9I4v5LbkfoAdAmSccTegywG/eyFPV4mrsH 4Jm1nwDP1lDmhZ/bP07QnxcTuc8fuvfu X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:829:6e77:9093:f39b]) (user=irogers job=sendgmr) by 2002:a05:690c:811:b0:5ca:f8cb:181d with SMTP id bx17-20020a05690c081100b005caf8cb181dmr425161ywb.3.1701123007777; Mon, 27 Nov 2023 14:10:07 -0800 (PST) Date: Mon, 27 Nov 2023 14:08:31 -0800 In-Reply-To: <20231127220902.1315692-1-irogers@google.com> Message-Id: <20231127220902.1315692-20-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 19/50] 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=-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 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]); Mon, 27 Nov 2023 14:11:22 -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 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.43.0.rc1.413.gea7ed67945-goog