Received: by 2002:ab2:3319:0:b0:1ef:7a0f:c32d with SMTP id i25csp503594lqc; Fri, 8 Mar 2024 04:13:42 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCW45IhRC64PPcJfqpMvgVmbD8qaMXiS1KFdpmHftK+cWzo0Ae8A+9d3BcufETNMySVKlI0HWmmqmcvZeH9EHWaTb1jfSvfezqVJcXg3xg== X-Google-Smtp-Source: AGHT+IEUjQdjztjQW8cO9TPzipByHuq/6A1C69xYBBJ6zy6APzZS1FO17SZSPdtOrF7yWEZTUN6M X-Received: by 2002:a0d:ea51:0:b0:609:c56d:ed37 with SMTP id t78-20020a0dea51000000b00609c56ded37mr11809897ywe.3.1709900022579; Fri, 08 Mar 2024 04:13:42 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709900022; cv=pass; d=google.com; s=arc-20160816; b=QRDQLCkJXC1MDS6lCTBJKrIi1P+PkyjAtDKAMfxrNsYWEadEeSYbGo3UG+8Q3ux4Dy TsfcNso4d0OaSdi/4g7JpCLgc07GIgklYrKC3qsRDxHeVqn/HbdXJlkU/Wreg/7mpAXV /RJ8OqPOks5E6E5QUSmQ2h5bCfbwxE0h3EJaUFK2/DX496KTdwVGdulqV+1E7VOQstmQ HKkNn+OWF6YA6ZLHzJfUWrUZKe4Q6kkOUsP5WWgclmvPgJN23rUnxsyzBE7sHpG0Hiq6 7DbtnN3reSi7uk1Ucqq0GsUL7P8V8dl1k8tQChA5T81Ha/49qlFbeQh+tdBaCKVMGPcT 0T1g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=vqxx9/7WcntcG0TXyzEcVqhiLRIa1BkAHKs3Or2wVmg=; fh=55zb+8Pnpe9tPOT9yFrIYrktNN9V1CqXca20SDoCA68=; b=k5AX+Az7YYLheXPuBC9gipbKgYuuBMHsxHZCdBbeajB+D+NcM9FpaCJ1c1EfBToPEG 0N0PYCzJCbJWGHBlmpk73/d6YpShGvNU64/fiAI2jWD8NidZ7VMt2M3swO/lEaPAO+UY O2fpvOjETTh0/wgySPqLIxyK3EPkQ0uEZLsTyruQVVos+/q7Shyw+64WSstU/9e+lpv2 aJjhtHdmTmwV27hXLkayPdTlpwkRAfOo/wlzWvk5CZTKpHvGTHcq7cNPYGK6ofb/uHLr oH28jlnUKtFZCJ5O+vOsew7sa/+guE93Yle4+xDe7XW1sFcRITTN5DIJSUvAzzdCaq0q 5k1w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@posteo.net header.s=2017 header.b="XW/ufEFY"; arc=pass (i=1 spf=pass spfdomain=posteo.net dkim=pass dkdomain=posteo.net dmarc=pass fromdomain=posteo.net); spf=pass (google.com: domain of linux-kernel+bounces-96986-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-96986-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=posteo.net Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id c22-20020ac87dd6000000b0042ef45158c5si5776045qte.809.2024.03.08.04.13.42 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Mar 2024 04:13:42 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-96986-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@posteo.net header.s=2017 header.b="XW/ufEFY"; arc=pass (i=1 spf=pass spfdomain=posteo.net dkim=pass dkdomain=posteo.net dmarc=pass fromdomain=posteo.net); spf=pass (google.com: domain of linux-kernel+bounces-96986-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-96986-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=posteo.net 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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 2B3091C215BE for ; Fri, 8 Mar 2024 12:13:42 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1C52156768; Fri, 8 Mar 2024 12:13:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=posteo.net header.i=@posteo.net header.b="XW/ufEFY" Received: from mout02.posteo.de (mout02.posteo.de [185.67.36.66]) (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 553E855E57 for ; Fri, 8 Mar 2024 12:13:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.67.36.66 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709900015; cv=none; b=NBFxoRl8WO7YeQiTRpAJqk+WitD12H+EB1EGNznGIA0mH5fkkgLfqgYmouofGOUnBeRtLGU74N+uRsgtMtd9Ekvk65BpebcPo6kzxVpR4Pi5NcW/ECtzjCaIZrtSLmCtKrslBmao+K6CzpEUrMsFUGZaVJNkQTj0i0WadW60Sb8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709900015; c=relaxed/simple; bh=o0MIa9u9Hqk3ZI02Q4Ut0uAnmSuanvs+Ylycd/Utd04=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=X1cJXgz7E7hOTgrwlpoQ08TwHWPI0nLWHr3+eK2BGISGy6KPMFGnQd/vC7Ch3JJt2YqAsuLIHBrYax7OwI++rVV7RlwxKc37AoKLwPZb2s1iJd9Nu2EpGDjPgGN4pe2Y7f9jPENw6W31e8ZoEqTmnZ2B+AliQq67b1QElXkMc4A= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=posteo.net; spf=pass smtp.mailfrom=posteo.net; dkim=pass (2048-bit key) header.d=posteo.net header.i=@posteo.net header.b=XW/ufEFY; arc=none smtp.client-ip=185.67.36.66 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=posteo.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=posteo.net Received: from submission (posteo.de [185.67.36.169]) by mout02.posteo.de (Postfix) with ESMTPS id C6D4D240103 for ; Fri, 8 Mar 2024 13:04:52 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1709899492; bh=o0MIa9u9Hqk3ZI02Q4Ut0uAnmSuanvs+Ylycd/Utd04=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version: Content-Transfer-Encoding:From; b=XW/ufEFYmNghRO9/dJpnthQiWG7F4dM+r84VMWzKXpuhutstXjOfZcZVwq8eD5q01 t4A8Ln8tyESKKT1F6ZDp2vvod4+GJ7xKCv/k3vNStrYVmHZGYm+8mPempnvYqOJvsy IO9XVYJdX5DGKgBSmWI1didokQ4Zwy6/Yw8gwX+WhVYHBIzKqvPi6WSiMymB3u5izt Yf8NnyPMgTePJtbcEKA4zif/FT+3mHfKD72jAPe46dZ/iqkTenldUYejPs87ZQKjMS l5nLQnXLx/7SfOCKQZl+LRa93RQa0mTE6wLfu1jmAoiwZ5HB6zR5xp54LSrOd1Qs5a PYDPrkir/LokA== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4TrlGQ6hCkz6tm4; Fri, 8 Mar 2024 13:04:46 +0100 (CET) From: Anne Macedo To: Arnaldo Carvalho de Melo , Namhyung Kim Cc: Anne Macedo , Peter Zijlstra , Ingo Molnar , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v0] perf lock contention: skip traceiter functions Date: Fri, 8 Mar 2024 12:03:31 +0000 Message-Id: <20240308120332.372810-1-retpolanne@posteo.net> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit The perf lock contention program currently shows the caller of the locks as __traceiter_contention_begin+0x??. This caller can be ignored, as it is from the traceiter itself. Instead, it should show the real callers for the locks. When fiddling with the --stack-skip parameter, the actual callers for the locks start to show up. However, just ignore the __traceiter_contention_begin and the __traceiter_contention_end symbols so the actual callers will show up. Before this patch is applied: sudo perf lock con -a -b -- sleep 3 contended total wait max wait avg wait type caller 8 2.33 s 2.28 s 291.18 ms rwlock:W __traceiter_contention_begin+0x44 4 2.33 s 2.28 s 582.35 ms rwlock:W __traceiter_contention_begin+0x44 7 140.30 ms 46.77 ms 20.04 ms rwlock:W __traceiter_contention_begin+0x44 2 63.35 ms 33.76 ms 31.68 ms mutex trace_contention_begin+0x84 2 46.74 ms 46.73 ms 23.37 ms rwlock:W __traceiter_contention_begin+0x44 1 13.54 us 13.54 us 13.54 us mutex trace_contention_begin+0x84 1 3.67 us 3.67 us 3.67 us rwsem:R __traceiter_contention_begin+0x44 Before this patch is applied - using --stack-skip 5 sudo perf lock con --stack-skip 5 -a -b -- sleep 3 contended total wait max wait avg wait type caller 2 2.24 s 2.24 s 1.12 s rwlock:W do_epoll_wait+0x5a0 4 1.65 s 824.21 ms 412.08 ms rwlock:W do_exit+0x338 2 824.35 ms 824.29 ms 412.17 ms spinlock get_signal+0x108 2 824.14 ms 824.14 ms 412.07 ms rwlock:W release_task+0x68 1 25.22 ms 25.22 ms 25.22 ms mutex cgroup_kn_lock_live+0x58 1 24.71 us 24.71 us 24.71 us spinlock do_exit+0x44 1 22.04 us 22.04 us 22.04 us rwsem:R lock_mm_and_find_vma+0xb0 After this patch is applied: sudo ./perf lock con -a -b -- sleep 3 contended total wait max wait avg wait type caller 6 5.27 s 1.76 s 878.55 ms rwlock:W release_task+0x68 2 2.99 s 2.99 s 1.50 s spinlock do_send_sig_info+0x3c 2 1.77 s 1.77 s 884.39 ms spinlock sigprocmask+0x98 2 1.76 s 1.76 s 878.56 ms rwlock:W do_exit+0x338 2 1.76 s 1.76 s 878.55 ms rwlock:W release_task+0x68 5 1.76 s 1.76 s 351.41 ms rwlock:W do_exit+0x338 1 48.10 ms 48.10 ms 48.10 ms mutex trace_contention_begin+0x84 4 257.80 us 119.34 us 64.45 us spinlock get_signal+0x108 1 9.33 us 9.33 us 9.33 us rwlock:W do_exit+0x338 Signed-off-by: Anne Macedo --- tools/perf/util/machine.c | 10 ++++++++++ tools/perf/util/machine.h | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c index 527517db3182..8e729167c1aa 100644 --- a/tools/perf/util/machine.c +++ b/tools/perf/util/machine.c @@ -3266,6 +3266,12 @@ bool machine__is_lock_function(struct machine *machine, u64 addr) sym = machine__find_kernel_symbol_by_name(machine, "__lock_text_end", &kmap); machine->lock.text_end = map__unmap_ip(kmap, sym->start); + + sym = machine__find_kernel_symbol_by_name(machine, "__traceiter_contention_begin", &kmap); + machine->traceiter.text_start = map__unmap_ip(kmap, sym->start); + + sym = machine__find_kernel_symbol_by_name(machine, "__traceiter_contention_end", &kmap); + machine->traceiter.text_end = map__unmap_ip(kmap, sym->start); } /* failed to get kernel symbols */ @@ -3280,5 +3286,9 @@ bool machine__is_lock_function(struct machine *machine, u64 addr) if (machine->lock.text_start <= addr && addr < machine->lock.text_end) return true; + /* traceiter functions are in traceiter text section */ + if (machine->traceiter.text_start <= addr && addr < machine->traceiter.text_end) + return true; + return false; } diff --git a/tools/perf/util/machine.h b/tools/perf/util/machine.h index e28c787616fe..ec51e9b080b9 100644 --- a/tools/perf/util/machine.h +++ b/tools/perf/util/machine.h @@ -49,7 +49,7 @@ struct machine { struct { u64 text_start; u64 text_end; - } sched, lock; + } sched, lock, traceiter; pid_t *current_tid; size_t current_tid_sz; union { /* Tool specific area */ -- 2.39.2