Received: by 2002:a05:7208:13ce:b0:7f:395a:35b6 with SMTP id r14csp66522rbe; Wed, 28 Feb 2024 12:16:50 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXPKc+tbvbEUcbLPhAvrwQjsYzibVQ2e0ncHHj/frhCV6/xQkjYN+XmqIZ2iWapKLHJKfcp6BYMDLGeCVAErl2eWWYYtJw1Mlj2oFXJ/Q== X-Google-Smtp-Source: AGHT+IFUiXL2N59c0n/JPnX08CJBQxAI+YixNK3m75bXXjoINUT5AcaBO8mPoYwFMQJXOtAglf3q X-Received: by 2002:a05:6a00:178f:b0:6e5:5425:e285 with SMTP id s15-20020a056a00178f00b006e55425e285mr660082pfg.13.1709151410365; Wed, 28 Feb 2024 12:16:50 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709151410; cv=pass; d=google.com; s=arc-20160816; b=JicsJhLyomNDZGWGCDtt6f+KbOI3MgqfClVLiEumOWKTac5ALQdhdkAD5oCYiaVyg5 XXpZjTLk+WCIkBmEG8ES/EGFBTHTSgPEl9uTiDwE+rGfL/rcpIcU/PMp/OYhCZ2komG5 WbGDv/0UXxIlN5XUuaR49JZUX1YI4OUnnlwe4fZ0ZrCZt3nCrok/Ss/xcheBQlMqPGq2 MSzLNijYMoUoX7NJTb+0i1IVi+amN6YASb7oQOnV/IyBoDXRe8ZqhX/LobM7yHk5BZTu JVk7aFCwpA3mwWdaFXRrdxtvYEi3MP82W3fuZZOixc0GS8DCwYWPp3bbufa0k/DSiu5W +a0w== 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=4QUVe5SWGYamMRLMAtoIcxzf9OimVGCSSNcDqUk/jkk=; fh=78mGW6yVv48dZiorvT2E5xvL4+dg4FH356b04VUYzkA=; b=wWBfVjzb7IfJxB8VTlb75fGxLLrTdyDeSA0UAmVaAAM10u148iTuBSJu9Qor55mok9 ZlFMuQti7UGWlrw9xx73daAOvNKlb5B/OmVoFDiyzPpt0KkPcdxMZddccfLxtvXmra/l FVobr6vWImn/rvPephPcZj93uCBY6f6M/xZB7wYDGtU9PlDRhCc/9IVf+i6burYErOru 1TY+QXc41X7HxcV2MWEUr1d3Y4k0vu/9NYXPgyHJJc/82c+IcTff/5F/JR148+t+zYW5 ii+NenVzjazpaKn7LJ3Vt+R0nLAn+VT0SN+d98/MtIAFUDjcUX6QwThzq3b6CqJfRR98 j38g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="Fb5/3KZu"; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-85666-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-85666-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. [139.178.88.99]) by mx.google.com with ESMTPS id a10-20020a056a001d0a00b006e566b3c834si170535pfx.3.2024.02.28.12.16.50 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Feb 2024 12:16:50 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-85666-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="Fb5/3KZu"; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-85666-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-85666-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 98874287A89 for ; Wed, 28 Feb 2024 20:16:38 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0C28F74431; Wed, 28 Feb 2024 20:16:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Fb5/3KZu" 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 26C4A5E06C; Wed, 28 Feb 2024 20:16:28 +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=1709151389; cv=none; b=sPX2WwFFXvxq/jBjn4CAyZf1e3t+Ir4H8EeAW4XLq17gRYiXmD2dxJ6Qg1GxL8V9ZK3TPGRXOKb2Bn0/kiBzjKThW5+wJUJFJGyZBVycborwHVN21lCyLU30p4Gryv1HUzZvUceR3dh7EC2hYOn8hgJBsDhwuno0wH5Dy1nqTVE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709151389; c=relaxed/simple; bh=8Objle7v/jEBe99Hj6SMEzxAZiF4Xti3vQEyGIpNDYU=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=MhCdrCE7QU2vtIymfp3UaFv1y7VHPBJJalpUXc2UhqIX4UZL1lXWE37GLr6CPkcKjstdmspT3yC7D5ijZKKvSdZN3at2WSsJ+/Nx+aEmMMkz0WDodDl1p286Oow6iIrQ/9BML/fm6PxYklGD+KtHaB2j7P2iITr5G1kQBxmWmWA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Fb5/3KZu; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 67C54C433F1; Wed, 28 Feb 2024 20:16:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1709151388; bh=8Objle7v/jEBe99Hj6SMEzxAZiF4Xti3vQEyGIpNDYU=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Fb5/3KZuVt+nHUzPvWhMwkgdRq0PrU53jDcwftN897mxW60kP/uQnaVPmg5K9U8X4 KVaXGbwhwsxY0oKpJ5RhCetxS4KK7d+sDazk9Lm0fPS7yNYziqLT9lx08khNTZIzrn vninn5ZJZ66xpXF0VjnqhlBe+p2FoUC8M6i8zVFDgsH06v5NjkoInffaQv56rAlMQy r7PMDYDpwbYKfSmhnNS1Rl9/ndAONZrQQoUKD2S6ZpEaiSgkP8Pz2E8Vn0U7EFL9ao Aiq8Kz8Rnjl8zNRT+IuTSDunOZrt8HoRZCseHoGpfTb2Sf2ZQ3bmAaW4rcU7fvx7lF actdX0u1KrWSA== Date: Wed, 28 Feb 2024 17:16:25 -0300 From: Arnaldo Carvalho de Melo To: Namhyung Kim Cc: Ian Rogers , Jiri Olsa , Adrian Hunter , Peter Zijlstra , Ingo Molnar , LKML , linux-perf-users@vger.kernel.org, Song Liu , bpf@vger.kernel.org Subject: Re: [PATCH v2] perf lock contention: Account contending locks too Message-ID: References: <20240228053335.312776-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 Wed, Feb 28, 2024 at 12:01:55PM -0800, Namhyung Kim wrote: > On Wed, Feb 28, 2024 at 4:22 AM Arnaldo Carvalho de Melo > wrote: > > > > On Tue, Feb 27, 2024 at 09:33:35PM -0800, Namhyung Kim wrote: > > > Currently it accounts the contention using delta between timestamps in > > > lock:contention_begin and lock:contention_end tracepoints. But it means > > > the lock should see the both events during the monitoring period. > > > > > > Actually there are 4 cases that happen with the monitoring: > > > > > > monitoring period > > > / \ > > > | | > > > 1: B------+-----------------------+--------E > > > 2: B----+-------------E | > > > 3: | B-----------+----E > > > 4: | B-------------E | > > > | | > > > t0 t1 > > > > > > where B and E mean contention BEGIN and END, respectively. So it only > > > accounts the case 4 for now. It seems there's no way to handle the case > > > 1. The case 2 might be handled if it saved the timestamp (t0), but it > > > lacks the information from the B notably the flags which shows the lock > > > types. Also it could be a nested lock which it currently ignores. So > > > I think we should ignore the case 2. > > > > Perhaps have a separate output listing locks that were found to be with > > at least tE - t0 time, with perhaps a backtrace at that END time? > > Do you mean long contentions in case 3? I'm not sure what do > you mean by tE, but they started after t0 so cannot be greater case 2 monitoring period / \ | | 2: B----+-------------E | | | | t0 tE t1 We get a notification for event E, right? We don´t have one for B, because it happened before we were monitoring. > than or equal to the monitoring period. Maybe we can try with > say, 90% of period but we can still miss something. > > And collecting backtrace of other task would be racy as the it > may not contend anymore. > > > With that we wouldn't miss that info, however incomplete it is and the > > user would try running again, perhaps for a longer time, or start > > monitoring before the observed workload starts, etc. > > Yeah, it can be useful. Let me think about it more. > > > > > Anyway: > > > > Reviwed-by: Arnaldo Carvalho de Melo > > Thanks for your review! > Namhyung >