Received: by 2002:ab2:6309:0:b0:1fb:d597:ff75 with SMTP id s9csp291590lqt; Thu, 6 Jun 2024 03:57:32 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUBGiq8RMc2U+BHzBuI73q9WCnfPKZfa8GBlMe11UJYov3K0zki5+5Qw3JBvLPognKCZmI4HGs7ZgmF+VWKbMcsGvAix8XdYs0sbLSXbg== X-Google-Smtp-Source: AGHT+IE+1hYKPlYv/aEFR0Ga4f3Xx/S1NEXMweoLYSHYPujsEkXrcg274KTUY+oFBwer+OY3otRX X-Received: by 2002:a17:90a:7105:b0:2c2:4129:a2d3 with SMTP id 98e67ed59e1d1-2c27db5b4a6mr5803420a91.36.1717671452586; Thu, 06 Jun 2024 03:57:32 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717671452; cv=pass; d=google.com; s=arc-20160816; b=AUT+UF7lj6w7ZCBX7pvX2s8GP7ZAf+iWix340mRMhfM7m4TjaPoicwu92QCwd/G3Q6 QOUyDOE7Gj+YT9Pl+OMFNNCTdwxGVw1+UxfcTm0cYD8hhPqypxe6RouraIpguyPcklbn myoUCVCaJp7PtYgJm2gJHrXXOaqg8OYtcWQhrZF9KTQZ/+vJ3eKtwZx3wTUUlagUVnrd IwqgTFDG1xFtXyGJcY2tpPT262xZNJixAKBf+hqgXTCKtXtbASCioiRg3b7upgIy5n/3 kSzpH8v84nNRdcrpr9ebKAALOTUVmjwsHlSAG+DF+frDsC+1xlIZeIs/Sf+DP8YwMO2G KbXQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:cc:content-language :references:to:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id; bh=KSCPffAVzTH1r8e1ZqCYRc98ysdOkInpk0DDn1x8Be4=; fh=CiXPhr3Osp5TieVpDP7W5oUNmyXbtcJett9BEmKR/wc=; b=EsAAKup5lUpBaTm6QLJsF1wP9nESaq2DvyiuB4cIGYq+dw4oeIDZJiJIb6HRyb2+T0 jwd2DLcBEZjWb+C9erHFitpQYVhuHq8ZyNVZlBWr5YbqJBNysExTpH026bJfMQw6eGsa ZhPEtoTw6kZsNJZt0RsYnVMVgQ287mnYcpg/ENBo8wlEO6uQgXgubKCPnyVS7ydRJJgQ xs0/gUbUXe5TzKkT57cI6Glq+AXPhNcppuQQIzpioj2Nf02oLsR1EgnkWhua+dIxsclK Rt3DFpoy+QbZzIuYEGAnFXbWdEpKSfmMUAM+mDFISMewRoOenGFsQjzJH8gWFi1cAaBn 6rMQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-204148-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-204148-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id 98e67ed59e1d1-2c2806bcf6dsi637429a91.125.2024.06.06.03.57.32 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Jun 2024 03:57:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-204148-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-204148-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-204148-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 791BD285B59 for ; Thu, 6 Jun 2024 10:57:00 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 533E1195395; Thu, 6 Jun 2024 10:56:54 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 59D839450; Thu, 6 Jun 2024 10:56:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717671413; cv=none; b=oUnIGlVnIdzFVH+0g2Fw/unbS7ai0m4HDhF81wRnHFPO5Hbl+vjEukF607VR4t6KW0sofDkKk7AAKJiC6HNcLU9SXX6Lgqh6kle+gjQG6tUQ/nRjYupsdf780n/I7wGYO96kHanblqv13jLoy9ywtYwvzRDn9yRCw3rbKDF3omM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717671413; c=relaxed/simple; bh=/vkBos92LXJ32FjgGFlGb6tlMPdz4UD7Ft2JSbxto3w=; h=Message-ID:Date:MIME-Version:Subject:To:References:Cc:From: In-Reply-To:Content-Type; b=hZApwFlL6nqn/a+3k3x7Ct/dqCdJF3NJkdwrBCGhcDVn2eDYv3t7kOgiBTPhIuwthele6wTFqS198nsuUQmD3OZrSIOFzri3tAnbMBfRJZDhGkSLl5/25cagqRCDfz+5W6DS+SJ6frqfWGSGD0r7E3EHTrpKhXN8S40RXYpq0V4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 15BED2F4; Thu, 6 Jun 2024 03:57:15 -0700 (PDT) Received: from [192.168.1.100] (usa-sjc-mx-foss1.foss.arm.com [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 8D20B3F762; Thu, 6 Jun 2024 03:56:48 -0700 (PDT) Message-ID: Date: Thu, 6 Jun 2024 11:56:46 +0100 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v1 0/3] Fix and improve __maps__fixup_overlap_and_insert To: Ian Rogers References: <20240521165109.708593-1-irogers@google.com> Content-Language: en-US Cc: "Steinar H . Gunderson" , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Adrian Hunter , Kan Liang , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org From: James Clark In-Reply-To: <20240521165109.708593-1-irogers@google.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 21/05/2024 17:51, Ian Rogers wrote: > Fix latent unlikely bugs in __maps__fixup_overlap_and_insert. > > Improve __maps__fixup_overlap_and_insert's performance 21x in the case > of overlapping mmaps. sesse@google.com reported slowness opening > perf.data files from chromium where the files contained a large number > of overlapping mappings. Improve this case primarily by avoiding > unnecessary sorting. > > Unscientific timing data processing a perf.data file with overlapping > mmap events from chromium: > > Before: > real 0m9.856s > user 0m9.637s > sys 0m0.204s > > After: > real 0m0.675s > user 0m0.454s > sys 0m0.196s > > Tested with address/leak sanitizer, invariant checks and validating > the before and after output are identical. > > Ian Rogers (3): > perf maps: Fix use after free in __maps__fixup_overlap_and_insert > perf maps: Reduce sorting for overlapping mappings > perf maps: Add/use a sorted insert for fixup overlap and insert > > tools/perf/util/maps.c | 113 +++++++++++++++++++++++++++++++++-------- > 1 file changed, 92 insertions(+), 21 deletions(-) > Reviewed-by: James Clark I'm wondering if there is any point in the non sorted insert any more? Maps could be always either sorted by name or sorted by address and insert() is always a sorted/fixup-overlaps insert depending on the sort style of the list.