Received: by 2002:ab2:60d1:0:b0:1f7:5705:b850 with SMTP id i17csp1371988lqm; Thu, 2 May 2024 12:39:35 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCX5DH1fYvFDesOAOfCTn5PhDRp6aMnC60QTYHnvZsPgH0l+sXcdbiB9MQCLLZwpFtYu3ejhpN79KxOwhjacsM6+CA9BgveuGiKEaQ2Y7w== X-Google-Smtp-Source: AGHT+IG9KLtAicKRhsQyS0u1JERaSc5/UdOzNS03VrskkfA/WGPm+gU3HMQOHy0SFo2W0nh3N95N X-Received: by 2002:a17:90b:918:b0:2af:8fb6:348a with SMTP id bo24-20020a17090b091800b002af8fb6348amr792197pjb.3.1714678775423; Thu, 02 May 2024 12:39:35 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714678775; cv=pass; d=google.com; s=arc-20160816; b=WRxBAgvnR+VpJRo+O8vpHqeHfjG1T45QxCNWY/eO1m21fq8DSWIPbOuFWGmbN/JjoD GbCVrqe7qZ/4HwFgrSnw9/0wn2geJpbSp26s6peoq6DbidovpVYfHOMGgsFrhobZ2IAp zQXbkNJ47g7vHt+HFbPUwk5r8yHTb/ZyuTlRYZqD2gxMx/JSEKgmFmgEC5wkDXJMf+vk Em5/uE6igvKN1RV+Y4bTkZpjf79trnxsIN+JGrxeboh0tQrl2DU2L2uUTGzbUFW2sv5P xSHh8/jnX+56mcA07dqNCC5TICx/8g9Z3wUP93fs4nlFbqZ5hl7YWXF7Wcokmp8wDX1b LDig== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:message-id:subject:cc:to:from:date:dkim-signature; bh=wdCf7EqI58jg0ailqQBf7HhgFcQd3zXDUczRwb1wB+Y=; fh=QPHjG65RNQ4P0Lo50ADGdMc5jntiupTtyaImif19M7E=; b=vZppg2QQSTzsQoARrp7UsETloc+XGB/Sr8TYq0pMkQzfUs8zpydoKG0bTenGxPDojS TSuaeCqirBRA6sbJultWzVSh+1OoCJVTVAPxyJ8YRwUALneZLr6z65gA9IRwpL1mDu6R xoitghs746+p7Bd4ejkHoSDLa0LW+Eqsap7DeVmYUtqTMAIOg7GfG7KPiY5DERyg3NyT Vv2L471/C64MReOAKCefJOHdvU/ZORw+1i6U+9IVuZ3WeJrL+YA+A60e8f8ozEi4AVfZ se2v8cJ+6RgMF2hrLHhHLMS+lbM1/vqAiwTMusjFIg3lY7oSEThtKKIITcC1uvZWCbU7 KD8A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=rNTV1uS8; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-166869-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-166869-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id x18-20020a17090a531200b0029c762ab90asi1588968pjh.98.2024.05.02.12.39.35 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 May 2024 12:39:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-166869-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; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=rNTV1uS8; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-166869-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-166869-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org 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 BDDBD281823 for ; Thu, 2 May 2024 19:39:34 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5428817BB21; Thu, 2 May 2024 19:39:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="rNTV1uS8" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7429117BA0; Thu, 2 May 2024 19:39:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714678767; cv=none; b=RdJy7geOuqFaGO+ysPJLoVqCkRMQ1bzfkGn4mjm2dq9PAXEExzU9MMLBzs68WXPOktzXBJTBdsRPmEh1Kko9jts5dVR/g/2jrcoPeNCnsjl37jc8AFk7fvnNvsSbCZvKwo2ya0gOn+AOujpNZ5+PXIZ/56t78pSn4c4tparqjRo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714678767; c=relaxed/simple; bh=JsVdQSR88vIGJ/32DmR5jle3XfAotEofYnypCmvfJrA=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=W1DTNOcW6BDmte9yQdukVfe7fnwiFDDoSZpRieIyF6HndlF/2MNdXQPI5bkoUX0z8WGtHa4pvFGuNKrFXeUeVhmenE6crfO9xYArtMzndqGhwMPj+tghrBNxzRsLNpMDItDqabdTCYgAHt/Q2Bqyt39N1ALWVQ/8f1Pzwa0y+e8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=rNTV1uS8; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 89595C113CC; Thu, 2 May 2024 19:39:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1714678766; bh=JsVdQSR88vIGJ/32DmR5jle3XfAotEofYnypCmvfJrA=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=rNTV1uS8YgYJtg3/KHDnznPQGzshJLpPohlxoZ1nkZmtzhgmtgwQUZwr7wzpHcXJZ 5i3KGoA7GWjC958p8J0QgFz51QuUQ8pvYKrhmJNaLPDDT3EVSOK/gjSRCXmxAAJWJA BND8ZMVtXlX8bkLOE4l0RFfBC+30AWL6PAkPfpWYoH5MpaOKCTG3m5W5p17zznnFPb TLEZdgHrrZfjd1VyhJxKyUuysvFcW4LNHRHE1Fn8eL5x1AB1dz9JYv89A9gvowx/Ev s/QQT8yaTUcpr987qQD7OV7+nFk4aGgT0MmT/jLs8hp4w1rRGPYvffOr+YRXPWs464 og/7malu7HnqA== Date: Thu, 2 May 2024 16:38:14 -0300 From: Arnaldo Carvalho de Melo To: Ian Rogers Cc: Namhyung Kim , Kan Liang , Jiri Olsa , Adrian Hunter , Peter Zijlstra , Ingo Molnar , LKML , linux-perf-users@vger.kernel.org Subject: Re: [PATCH] perf maps: Remove check_invariants() from maps__lock() Message-ID: References: <20240429225738.1491791-1-namhyung@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: On Mon, Apr 29, 2024 at 07:09:54PM -0700, Ian Rogers wrote: > On Mon, Apr 29, 2024 at 3:57 PM Namhyung Kim wrote: > > > > I found that the debug build was a lot slowed down by the maps lock code > > since it checks the invariants whenever it gets the pointer to the lock. > > This means it checks twice the invariants before and after the access. > > > > Instead, let's move the checking code within the lock area but after any > > modification and remove it from the read paths. This would remove (more > > than) the half of the maps lock overhead. > > > > The time for perf report with a huge data file (200k+ of MMAP2 events). > > > > Non-debug Before After > > --------- -------- -------- > > 2m 43s 6m 45s 4m 21s Yeah, I had a debug build to check the size of 'struct hist_entry' with pahole and noticed that invariant checking in 'perf top'. > Thanks Namhyung, I think the change makes sense. There is an issue > that a user of a map may mutate it in a way that breaks the maps > sorting, symbol code would be a likely culprit of such a thing. A fix > for such a breakage would be to just set the unsorted flag on maps. > We'd be less likely to spot such an issue after this change, but it is > simple enough to add the function call when needed. Another option > would be to add another make flag like PARSER_DEBUG for these kind of, > "be paranoid," type things. Anyway, let's try to fix those problems > when they exist. > > Reviewed-by: Ian Rogers Thanks, applied to perf-tools-next, - Arnaldo