Received: by 2002:ab2:3b09:0:b0:1ed:14ea:9113 with SMTP id b9csp174745lqc; Thu, 29 Feb 2024 13:53:49 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCV3i0p5TqAjyagjGIRB20dw2yOh8/IoW+g5XW0+KZ/XckPIUXiqxn27CoT2KdQNTf9QaAS8bgAHD+YoJHgIemE6pQ7+iSvX65aNRnVuQw== X-Google-Smtp-Source: AGHT+IFkt09O/Ty8eMEL0ISK4jApxCIsNcdBqfOw9FS9QMY/T+RHTdP9HdmweK1ItKfcF0jM65oA X-Received: by 2002:a05:6a00:3cd1:b0:6e5:a96:6286 with SMTP id ln17-20020a056a003cd100b006e50a966286mr371413pfb.31.1709243629336; Thu, 29 Feb 2024 13:53:49 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709243629; cv=pass; d=google.com; s=arc-20160816; b=iWR/IhsQoIxNACbw4KAy8Rkwt9N04U81LnRQl2tumG8emIlaXKFytm54MGmod04hOC mdPCfuAJYGvbCCwNvGxKMIZWWEt3U/fU3wP3bzNt9uGscaHGxl4jppznCJ475YwvBsre CMbZ/nzKTzYGScXSIHDqjmcFxe9pMKIa6+CHR3qH+LPpi3TFxBVhlikGFKg4/SHmGd1R B+NKg3bRbWeuWTICAFXMy5umz0r8/bRJrvYZ6VY4UMK8jt/qR2h2/NleeX/7uXHv4fVs BNqd53QW7aTBVa1p3eSSEUBjYcL3R9I3ouuHXzu2tpeMUZE7iXN9s2Yw/yIYET/NwTfj Lzvg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence; bh=haUJa+5TdcS6m1vT9CvX3WylWRv8eifDwIPUXf2O2d4=; fh=bmz00j+NgFBiVPKDxaYtFmHxi+cZO9OS7vodCqNQzBg=; b=Kk0TriN3ecl1/AFtDBlXa8631NjzBSG/GfK+5T7TjkiRKNnZSn+SmfFF92jl1NZLk6 iTpxvUw1YRHVKMJd73EO2yCMEm+rtpt9yESHiN5HMfCJhYuFmrKjJRaS74cL3eKJVPRV kIRD16JQSDOmUbWshofrvD6UUsJAOEj0Fs4c9ibSeSnasS8ki5stc6lo1X0M4J/8nPUO smSdC4F8J9/5c6ot7zPvb0PvyKFtOGsQkSM2uZ0lQhMyntwelAEiHaTlXYLRjLpzyGYo dUT/xBjmlz+EGY515IvaOzKFaiKhXk5o5Gh7zgZrubHlumq5MIdycCVciiJKnSvU+r0J q2+w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-87604-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-87604-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id a17-20020aa78e91000000b006e5736fa38asi2096912pfr.260.2024.02.29.13.53.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Feb 2024 13:53:49 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-87604-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-87604-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-87604-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id B09ABB20D33 for ; Thu, 29 Feb 2024 21:53:46 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3F5066D532; Thu, 29 Feb 2024 21:53:35 +0000 (UTC) Received: from mail-pg1-f179.google.com (mail-pg1-f179.google.com [209.85.215.179]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 520EF16FF46; Thu, 29 Feb 2024 21:53:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.179 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709243614; cv=none; b=VbhZuKQjLdQLpj1lTUplml4yLYb7N9z7wxSXYBrMW1XFs2ijQLMk6rz4j5Akl6sbQP0U6YTiMTYQDj0zhHFBweVZR1jeGmM+D8HrMIOQ9ly//8UG6tY7REyfDXElRQl7jzQ0E3TO+Z1ffae5R4gN6OGagwhu7urhm/ZNRSykX/I= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709243614; c=relaxed/simple; bh=POqv0h1t39Wybcz3NApqo2vEL4LbOvoTJUL75VTqPzc=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=ZkRZLRrxRMbf8pBUB57CTlU0UdlWP4ye6YODUbu1XpwkIqopzOB+B4YwbksL/w2nwTTkmBVyMr45KWjHWxda3ug0AMF5bXeHJT/oOzujldLCtM2J2KV77uv7ZUPNRh1Yyt2e9xtBkIX94H6QfvyB02F4P2kmMrSIrd7IC3uLjGM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org; spf=pass smtp.mailfrom=gmail.com; arc=none smtp.client-ip=209.85.215.179 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pg1-f179.google.com with SMTP id 41be03b00d2f7-5d8b519e438so1278691a12.1; Thu, 29 Feb 2024 13:53:33 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709243612; x=1709848412; 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=haUJa+5TdcS6m1vT9CvX3WylWRv8eifDwIPUXf2O2d4=; b=Do1ObdRP8QG+kkhUk6dkmaevdkREhUKq2DqKlKm+XYu1P8MxdNoF5GJWrgLYgaV5c/ Et1rU50JVnU7WT/dz2gYTsp+NYXIqWnUOtlXWEu9pe1trWEM5Z5b6Mo6aAt9lB2yBz3z PaF7RnvOFUSWBo4PEIE/5Uxh4mzkorqTDFZpfcivto/y3IZxNsoewhZ5FOXVhv1fWx7b tTnP1exq6BAmEzNjVP1HQ0jOe6axJIBM4OK8rVIDeo1aGVXlX2v6OXULAgmp9NjMMldz wRMJV+R8bU3XTrgfrP/ZNINbxcrxkr3yFunDM4WTIX0QkZeYssc7tRFPYIU0GBuseb8Z Ss1A== X-Forwarded-Encrypted: i=1; AJvYcCXhGNq8JE5E4wjdLrmyLleWnpGNeVLF0XWB5SJ5QWQfADvVnJFced4I9DaVZTw2zVJTLuI+FsG/eUdvMWnh32Z58TPnysg/weSIBdrZJT5bHPWNIu/xTyHLZ9FFoUKlBKoevO8uw3ccXKfTfGq6ELpj4rDbZ/20bT2v2Rpmkn43wAyl7Q== X-Gm-Message-State: AOJu0YxpSYA9Ml7qGYhnsc0VNyBRtqCc5ZHgcH/PC+b07Zs/wCqZ+vY5 vJLMKMCL2vf78JlH2tPsPkzBJt02S7tDuwkQZI2kWZn5c8auVTqHgrt4sdjQsqQGlne4kTG1ASP cChquKwRFwl/kzW2AsM/yavUojuaWuzvZ X-Received: by 2002:a17:902:a70c:b0:1dc:a844:a38b with SMTP id w12-20020a170902a70c00b001dca844a38bmr3162774plq.67.1709243612496; Thu, 29 Feb 2024 13:53:32 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240228053335.312776-1-namhyung@kernel.org> In-Reply-To: From: Namhyung Kim Date: Thu, 29 Feb 2024 13:53:21 -0800 Message-ID: Subject: Re: [PATCH v2] perf lock contention: Account contending locks too To: Arnaldo Carvalho de Melo Cc: Ian Rogers , Jiri Olsa , Adrian Hunter , Peter Zijlstra , Ingo Molnar , LKML , linux-perf-users@vger.kernel.org, Song Liu , bpf@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Thu, Feb 29, 2024 at 9:23=E2=80=AFAM Arnaldo Carvalho de Melo wrote: > > On Wed, Feb 28, 2024 at 01:19:12PM -0800, Namhyung Kim wrote: > > On Wed, Feb 28, 2024 at 12:16=E2=80=AFPM 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=E2=80=AFAM 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 timest= amps in > > > > > > lock:contention_begin and lock:contention_end tracepoints. But= it means > > > > > > the lock should see the both events during the monitoring perio= d. > > > > > > > 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 ignor= es. So > > > > > > I think we should ignore the case 2. > > > > > > Perhaps have a separate output listing locks that were found to b= e 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=C2=B4t 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: ++++ > ... Summary could work. But I'm not sure about the histogram since different locks would have different behavior - spinlock vs. mutex/semaphore. Maybe it's more meaningful when you have filters or separate histograms for each lock. > > > 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. It doesn't collect user callstacks yet since it requires recording memory address space information of every process - basically FORK and MMAP. Maybe we can use callstacks with build-ID and offsets but it also requires mapping from build-ID to binary somewhere. Anyway, it's good to add more features to it. Let me process this patch first and think about more later. :) Thanks, Namhyung