Received: by 2002:a05:7412:b10a:b0:f3:1519:9f41 with SMTP id az10csp3064509rdb; Mon, 4 Dec 2023 16:07:12 -0800 (PST) X-Google-Smtp-Source: AGHT+IHRZykmHjtZ9RfwiglBk5PDxKNBS5J/cCGJiRX3N5usZwszqsxIyhOpX9g1drNhf53vngCl X-Received: by 2002:a17:90a:d914:b0:286:6cc1:77f4 with SMTP id c20-20020a17090ad91400b002866cc177f4mr468948pjv.55.1701734832489; Mon, 04 Dec 2023 16:07:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701734832; cv=none; d=google.com; s=arc-20160816; b=W+grjApNa3XQmknXlDqCxO+dXUkSXwvG/8owMSJZuEShhHt7jLYhuoSK4XZDc/r8jS 8KM78XaIinomagmFnlMxCybp0Cw+foTSp+YLaWN13CQlVKOYIFaNYWLybaJ0XEG2xO8U QL6uDF6z7TYLY0OUyDEicADRst7OAZ9DzJY1gRk9xxY/UJ4LX3ALUZBxqDWpEFLBgXPk Kr3qCAZcZZcguLSwqhlp38KSqDGnB9DCP+OmdWao6my17RSxBLpefDJLLz1gUEGou2/j inhy9CH25kZShrCK/Jb9deuno5WGwCTWjUZNyEbH4BiqG1nmt5KtOA15BJegcsYAIZla aS3w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version; bh=tWDL91nLYv4r8WrkxXib5Plg50atjbld1uTtq8o9ukM=; fh=aWa9tyepd0GWyBFjkZa5ys7uNwpZ1AjfSj0Mu1iuQbE=; b=KO7g8yUxfyVoJ574mfip28UxIqA1Lg/BsYU4NUVAfj7NaUHR7iVpXwaZjrNxI5B2Gr UtXrMeYEPCL9T6NIft5eEXGfxRFiB0Vga/xBcC490dQ7pnJ7Z3fg17m/3z4GTzhzfKWt /zIf3zC0plWnMdJABtMuVSOGspkngI75+lTiG7nyM+QzohF4UpuoRr09KlDLXkFqvmnL YxS9hPUjwygbZ6jwsrlTgPOiHy5TluOa3lcL1V00f0g5qBZ4SNuxGoPjmY1c76V2q1Nm HCbzeJj9/XPEyJIlLRtM3SebXh/sKllR12iq1qkt0e/KuzN1VwH4tKhR+mvVsfnyHqLX 2geQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from morse.vger.email (morse.vger.email. [2620:137:e000::3:1]) by mx.google.com with ESMTPS id w22-20020a1709027b9600b001d0b24ebfc2si1743898pll.586.2023.12.04.16.07.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Dec 2023 16:07:12 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) client-ip=2620:137:e000::3:1; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id 1DD9D802244D; Mon, 4 Dec 2023 16:07:10 -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 S1343624AbjLEAGp convert rfc822-to-8bit (ORCPT + 99 others); Mon, 4 Dec 2023 19:06:45 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39064 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343594AbjLEAGj (ORCPT ); Mon, 4 Dec 2023 19:06:39 -0500 Received: from mail-pg1-f177.google.com (mail-pg1-f177.google.com [209.85.215.177]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 116C2119; Mon, 4 Dec 2023 16:06:46 -0800 (PST) Received: by mail-pg1-f177.google.com with SMTP id 41be03b00d2f7-5c2b7ec93bbso2766440a12.2; Mon, 04 Dec 2023 16:06:46 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701734805; x=1702339605; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=1JcpNF/47E6R5fVAJEjKqFUfdaQxK8rB5P+pDp4ewSo=; b=KNiwj4vAXfiP9hUaNz6SvCUELMKs/mMNyf40yv/xEE6LQJENVQ1+WtMW4I9EWYq3KD Yic71LwTXfWG7v+7PKwhuZxUZAxO9hIqN1ZlmyLrLA6+I6uq+1NaaerAkH7sTX/k4QSe +MyHjbnSdNfzxg2FD1vRLhG9LBwYCfhj5yQt1sG91+ofOZcO6OTAxiXvYvhvbo6sOkpA cqL7kjSikE3XPIkV2+MlUAVh8kC2SKGWO0E2TSadF2zLrZz7+iPwuEy0Ok50v8r6Pf1v 6QSVbhGf0bFTc4JBtQ/BjU6pzCCcZYRPl5SNQ7MoZNXKcyR4FCoe2irg7Z9iQ9pirW2h Iriw== X-Gm-Message-State: AOJu0YwWyG2i6Nxb+4tr2eyqHLVzP2ZdATrT3rUBKRGsRF2omiSufNEu 3bRQPQ+xfwYmDGNjhwrlgYkk5BsqcLzlp628HHA= X-Received: by 2002:a17:90b:180b:b0:286:d42d:e6a with SMTP id lw11-20020a17090b180b00b00286d42d0e6amr413358pjb.28.1701734805437; Mon, 04 Dec 2023 16:06:45 -0800 (PST) MIME-Version: 1.0 References: <20231127220902.1315692-1-irogers@google.com> <20231127220902.1315692-20-irogers@google.com> In-Reply-To: <20231127220902.1315692-20-irogers@google.com> From: Namhyung Kim Date: Mon, 4 Dec 2023 16:06:34 -0800 Message-ID: Subject: Re: [PATCH v5 19/50] perf maps: Do simple merge if given map doesn't overlap To: Ian Rogers Cc: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , 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" Content-Transfer-Encoding: 8BIT X-Spam-Status: No, score=-1.0 required=5.0 tests=MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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, 04 Dec 2023 16:07:10 -0800 (PST) On Mon, Nov 27, 2023 at 2:10 PM Ian Rogers wrote: > > Simplify merge in for the simple case of a non-overlapping map. > > Signed-off-by: Ian Rogers A nitpick below. > --- > 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); Can you please break this like below? rb_node = first ? rb_entry(first, struct map_rb_node, rb_node) : NULL; overlap = rb_node && map__start(rb_node->map) < map_end(new_map); Thanks, Namhyung > + 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 >