Received: by 2002:ab2:3b09:0:b0:1ed:14ea:9113 with SMTP id b9csp28060lqc; Thu, 29 Feb 2024 09:23:43 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXjmZcIY90KV3jjYR7DULSob2HUODz0mwem+XTuNCVMjNK2U4V8mhcK6M+EGSWHqrRePngxa8tXW8Uj+jhi1DXkemUQYjTxOO9e5oXl4A== X-Google-Smtp-Source: AGHT+IG2l6xPQ0TbS01z9wK04oxJTPlzfJJtAkmMPxVE0nUshPl4NdwnLs6tr2JYdZjBBRYuAPLA X-Received: by 2002:a17:902:cf12:b0:1dc:722a:1e0a with SMTP id i18-20020a170902cf1200b001dc722a1e0amr3220392plg.41.1709227423450; Thu, 29 Feb 2024 09:23:43 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709227423; cv=pass; d=google.com; s=arc-20160816; b=emEn62a1NzKx2pUdzg41aSu06lShJUqSi186jwNsw7+Q3VR9okolPLSLCIEAeymt48 LNKzN0m/cXZ5PQXT39lk7cYRLHH2GeEkpxXjhzzZykYRMC/tsixJGVUM+lkp9ig4782c W2HxyML14TjGQk3THlqPcwPfSbbdWwmZHYMXPYIVk6tBcnk0cTyw4WrUrVlXCHVvOUYR y0FiIk6rRBFQkqn8NKijxDQkZ25OQBlMCQxKpkkbSSa5pU4wr5rxM+REfblfDOGaI1FH qTMmBcfM5uVIm+xgNp6JFwTnVnMM/Zon9SyNojf/4ae5vaUderPSx6wKTDSJXlqVqo3S 8WVw== 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=loDZfN6Xf1ojspp9Uq3vJvIpsHQAp5rpenio7emJIxk=; fh=78mGW6yVv48dZiorvT2E5xvL4+dg4FH356b04VUYzkA=; b=k/G63NIHs7FOqsmo8NiZXsfVp1SSeQnRhSGWozKdlRSeHluDGqMAcArYnCkAlBvKB8 PayeFCefxtjFnDLsuRKQQlQdhb2f1c+WFRPojTz491b+pjUrZ1IcwRE6FL7s5iaMvodB 6W3otPTF625Ry6YypSu71v06L4P2V0iPDjXu16yBCuORGyKOacfbmaaplZQoq6rQpyyv WqPUFdA3iTWXe/sXS3C0f8LNfgk9p1JgrG4brp+ADhG6/yvqe7V8H+UB/qi7MJ/VsvfW kM/Of4UHZapaw7O4wPHz0xg+jDz6cT6zxcqt+ApF7bxxt5Tq6QL/EqrUuO+H4HspKUnx MDxg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=athSDJtJ; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-87163-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-87163-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 h5-20020a170902f54500b001dc6d21ef03si1801358plf.185.2024.02.29.09.23.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Feb 2024 09:23:43 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-87163-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=athSDJtJ; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-87163-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-87163-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 23151286834 for ; Thu, 29 Feb 2024 17:23:43 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 10FA270ACE; Thu, 29 Feb 2024 17:23:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="athSDJtJ" 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 1E2346CBE3; Thu, 29 Feb 2024 17:23:33 +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=1709227414; cv=none; b=iNuRKnT3UMwr+ok7g2Eohd9MdoOBurkC8BPpJlP4KiWbhZC8qQ912x5QgjEk0doZk+2UrpRYlJsFlKNGFBfJiQKd/vHq4JkBTcUKR9+pVyjPwHhwyfQTeJyMNOOL52eDxH9a2hy9EUD7VQm0vAxQC7AHtmk0hfnrleUqPQYRRHM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709227414; c=relaxed/simple; bh=Oa4oT6c0wAHeOFyXLWOIs7ozD28bcI/Oq64bMT9EcJs=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=TG5cYO5CM3NG3YBdGKwn10eay458B6+92wDCoATpbC1W4iCdM01YKKPNZLq9yU3utJ3vlPf/1NaVMg06r5Bs3iW0h6sGz+76UXuYyig1oQ00o0n5eE0rtZbZaPx+31UNbUE8HGjQ1TWqaRInfTAsNd4RfSuiIDyRLHJ5Sb3zP+Y= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=athSDJtJ; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4454EC433F1; Thu, 29 Feb 2024 17:23:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1709227413; bh=Oa4oT6c0wAHeOFyXLWOIs7ozD28bcI/Oq64bMT9EcJs=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=athSDJtJ8RuUu8fWSuuZtAHY+/s0ZdAujGSirhTSKDm+/GWp0C+aiudrumr6R8IRH tJN50ftZC/WUuPg26zLc3h6Pc+G6RYFagSlXWAK3lAzeZJD+qagCSAXYkMyz+q9Vvj Uqga1oiRlU9mhAsyCUVN9P5l8tuDd3u8fEKwYzO3OiM2bNStw1X+dW2lHQUPmRL3SR FkshneKh+/a1QToNkyGGsMo1Lsnr3hwR9zo2Top0LbKDRo8WMPow+45nOIJa5vdcLE 4JKLfW96OOZpjYISfpxvrs7evO4dizAdNswCQiWnSRpOAAu20olEl7tIWDXWkgYJFw baswQ2+HSwgZQ== Date: Thu, 29 Feb 2024 14:23:30 -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 01:19:12PM -0800, Namhyung Kim wrote: > On Wed, Feb 28, 2024 at 12:16 PM Arnaldo Carvalho de Melo wrote: > > 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. > > Ah, ok. But there should be too many events in case 2 and > I don't think users want to see them all. And they don't have So maybe a summary, something like: N locks that were locked before this session started have been released, no further info besides this histogram of in-session durations: 0-N units of time: ++ N+1-M units of time: ++++ ... > flags. But maybe we can update the flag when it sees exactly > the same callstack later. The callstack, if going all the way to userspace may have the workload targeted in the command line ( some pid, tid, CPU, etc) and thus would point for things the user probably is interested than some other lock that may affect it but indirectly. - Arnaldo