From nobody Mon Sep 28 14:45:52 2026 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.21]) (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 E006D40F751; Fri, 21 Aug 2026 05:49:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.21 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787291364; cv=none; b=PNwpFzaWl9epGTmRgPJ8jsNxacPRcW5PR9ClqTFEgDvnFAJYeJwl2Kns94xewVZNwcD6e0/wQAPVdLFMec2Hp8N9dZIqMYUsEHn8enAFAJfHx5Uo027F9ksphg4SC55jHW0QYRDJhvsLbonHANqDzPZKX9YxTHR7BvI592IiPvk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787291364; c=relaxed/simple; bh=KGrk8Cjn8wCWCTB57J+A0VqQw6g3R7B+FtoTdYlsacg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=R+8P5F4Jz+vxGc7kURdZKM2kWW9fGTY1lEB0WQSRMhPmoZASStkr9h63Y5ijonJ+G8EcqzfhTiQpQwtWtKkhWyzxsgg73SSYQc8J2QwmcyIYHnR4Mf9cizbgrLXa5V57rIlaOCWAeuGuTpre5NgX4Agoust8f00vKZwYK0TyUMY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=UcKMCRot; arc=none smtp.client-ip=198.175.65.21 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="UcKMCRot" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1787291362; x=1818827362; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=KGrk8Cjn8wCWCTB57J+A0VqQw6g3R7B+FtoTdYlsacg=; b=UcKMCRot+rn4XJ2dbCrty7hHptLuqiWR9zb1kru/fKjsG/wuKsp/gMZ3 UGoWHD523QkuxE/wPWtSg3HK7TBbA50qRNDlTNk3vJYUopt8xnc8Nb3qQ hzXjEYVNIxt5IVxnoTRRX9LQHufmkLUwqeOuR/iA+bJBqMKhLarJKQPHT GQ5UPPNa5CSoFxoMOh91Bbx7U47KiPoF5P2+LFb3EvKmffn8jrEHZPhDe 2ddFDNqI4FuBX0BjK6DszOMrB823q3zwf4zDZpdcsBt2G5QNh3c1vGsQb N3QLTINY/p+7DMKwOzB1uPWhJFecsI3HAEfk3BQbBiqir+9a9ns2dNrZk g==; X-CSE-ConnectionGUID: SXc39gBPT4ildQaFKXdcAg== X-CSE-MsgGUID: BWK6iHE3TeWtZFHVWS/BiA== X-IronPort-AV: E=McAfee;i="6800,10657,11881"; a="87691954" X-IronPort-AV: E=Sophos;i="6.25,234,1779174000"; d="scan'208";a="87691954" Received: from orviesa005.jf.intel.com ([10.64.159.145]) by orvoesa113.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Aug 2026 22:49:22 -0700 X-CSE-ConnectionGUID: V6xjQL8IRY+/OPhQhqpn6Q== X-CSE-MsgGUID: xHzWl5xXQyepIupaEUIaPQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.25,234,1779174000"; d="scan'208";a="270476139" Received: from linux-pnp-gnr-1.sh.intel.com ([10.239.83.186]) by orviesa005.jf.intel.com with ESMTP; 20 Aug 2026 22:49:19 -0700 From: Jiebin Sun To: namhyung@kernel.org Cc: acme@kernel.org, mingo@redhat.com, peterz@infradead.org, adrian.hunter@intel.com, alexander.shishkin@linux.intel.com, irogers@google.com, james.clark@linaro.org, jolsa@kernel.org, mark.rutland@arm.com, dapeng1.mi@linux.intel.com, thomas.falcon@intel.com, tianyou.li@intel.com, wangyang.guo@intel.com, jiebin.sun@intel.com, linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/4] perf c2c: Fix documented default coalesce fields Date: Fri, 21 Aug 2026 13:56:08 +0800 Message-ID: X-Mailer: git-send-email 2.52.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The default coalesce fields dropped pid in favor of iaddr, but the man page still documents the old pid,iaddr default. Update it to match the command. Fixes: 423701a0c8d7 ("perf c2c: Change the default coalesce setup") Signed-off-by: Jiebin Sun Cc: Dapeng Mi Cc: Ian Rogers Cc: James Clark Cc: Namhyung Kim Cc: Thomas Falcon Reviewed-by: Tianyou Li Reviewed-by: Wangyang Guo Acked-by: Namhyung Kim --- tools/perf/Documentation/perf-c2c.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/perf/Documentation/perf-c2c.txt b/tools/perf/Documentati= on/perf-c2c.txt index 8775889bc0a3..9e58a51c55de 100644 --- a/tools/perf/Documentation/perf-c2c.txt +++ b/tools/perf/Documentation/perf-c2c.txt @@ -341,7 +341,7 @@ output fields set for cacheline offsets output: Code address, Code symbol, Shared Object, Source line dso - coalesced by shared object =20 -By default the coalescing is setup with 'pid,iaddr'. +By default, coalescing uses `iaddr`. =20 STDIO OUTPUT ------------ --=20 2.52.0 From nobody Mon Sep 28 14:45:52 2026 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.21]) (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 9C44440F73A; Fri, 21 Aug 2026 05:49:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.21 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787291367; cv=none; b=RKy+RBEZohXuGjhnPgO1LXUbC2GWDofknWu10FuKkgRbGtTMGlM5akkqgH4aQSSs7nVxF3Um/XHbfDuDWtLsehbYpGBv0OQVjb1qrHDWmAip2G21VghI2kbO+DQJJtR35Gnno9wX928vXGDOSlh1DqahXNdvV7gmQUKtdHCwCr8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787291367; c=relaxed/simple; bh=oX/8+86+vsLtFdyfjC5kn7Rey0KOuQDFmdEPdCWiYjk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=R8EC39aqZUOaE9rFqV+d5gqzrRZjoq+6nQrd1ThvPMn5uP3yihrGm7EA4ZNyAw/dHSlnnmX13SPKePwULs5Xsl6hlFC8eyASSyXRo8iOqIvN8uO0WtER20ZSLiSaohTHE9ng7ArfuP8xS5fCcElBvcnNB4/80zrIHRqwMYGep58= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=BH7kdtXI; arc=none smtp.client-ip=198.175.65.21 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="BH7kdtXI" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1787291366; x=1818827366; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=oX/8+86+vsLtFdyfjC5kn7Rey0KOuQDFmdEPdCWiYjk=; b=BH7kdtXIQm7cqmrjg2fQCblq2a7KCwFXszLFc+gvLxfmHQlb8VHJ2DNS eyV1okABDBQj8J1QjUR/FS7QR+PI4lqTsPjRonTn9J6EYtjg28SX/Gq5m HcQTiepaitrrIcfrdMHdUYLBAwRhnPfjsC1ERbWCR+vRsbcLrZu7ruWha BsJ2lDUMVk3zvxjm1+YnGLHsinqdrhgVnS7TRJEB1AJAv4bbKrQhnG8Zp JR7/+dqPOzTL9tuVpZqNfr/CNtmnBRrXHJwJv1tQVFJHheKQ7lMHR9gnt wtCAE2nne7YKkLI4X037RBQOJBoZecJ+IuuNfMjk3yg0cJhp18FzlbQ62 g==; X-CSE-ConnectionGUID: IJUsqfTKTtaGWS57Afqj5A== X-CSE-MsgGUID: STuzuPpYTwKOO+Qshq2szQ== X-IronPort-AV: E=McAfee;i="6800,10657,11881"; a="87691961" X-IronPort-AV: E=Sophos;i="6.25,234,1779174000"; d="scan'208";a="87691961" Received: from orviesa005.jf.intel.com ([10.64.159.145]) by orvoesa113.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Aug 2026 22:49:25 -0700 X-CSE-ConnectionGUID: RT87H+5QQfOzXEO6eQZpRw== X-CSE-MsgGUID: fFHl7zGzSoSyTkRDeOCSng== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.25,234,1779174000"; d="scan'208";a="270476164" Received: from linux-pnp-gnr-1.sh.intel.com ([10.239.83.186]) by orviesa005.jf.intel.com with ESMTP; 20 Aug 2026 22:49:22 -0700 From: Jiebin Sun To: namhyung@kernel.org Cc: acme@kernel.org, mingo@redhat.com, peterz@infradead.org, adrian.hunter@intel.com, alexander.shishkin@linux.intel.com, irogers@google.com, james.clark@linaro.org, jolsa@kernel.org, mark.rutland@arm.com, dapeng1.mi@linux.intel.com, thomas.falcon@intel.com, tianyou.li@intel.com, wangyang.guo@intel.com, jiebin.sun@intel.com, linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/4] perf tests c2c: Report skip when the workload fails Date: Fri, 21 Aug 2026 13:56:09 +0800 Message-ID: <7d472dc1b51dbdbf68254535d608c4fb24b75274.1787283281.git.jiebin.sun@intel.com> X-Mailer: git-send-email 2.52.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The workload path leaves err at 0 and returns, so the test exits 0 and is reported as a pass even though nothing was recorded and neither report invocation ran. The check_c2c_support() path above it already sets err=3D2. Set err=3D2 there as well so a failing workload is reported as a skip. Fixes: ac881007c4bf ("perf tests c2c: Add a basic c2c") Signed-off-by: Jiebin Sun Cc: Dapeng Mi Cc: Ian Rogers Cc: James Clark Cc: Namhyung Kim Cc: Thomas Falcon Reviewed-by: Tianyou Li Reviewed-by: Wangyang Guo Acked-by: Namhyung Kim --- tools/perf/tests/shell/c2c.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/perf/tests/shell/c2c.sh b/tools/perf/tests/shell/c2c.sh index 2471d44595c3..f5f223cbf9cc 100755 --- a/tools/perf/tests/shell/c2c.sh +++ b/tools/perf/tests/shell/c2c.sh @@ -39,6 +39,7 @@ test_c2c_record_report() { # Run a workload that does some memory operations. if ! perf c2c record -o "${perfdata}" -- perf test -w datasym 1 > /dev/nu= ll 2>&1 ; then echo "c2c record and report test [Skipped: perf c2c record failed during= workload]" + err=3D2 return fi =20 --=20 2.52.0 From nobody Mon Sep 28 14:45:52 2026 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.21]) (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 ACED53F6C4D; Fri, 21 Aug 2026 05:49:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.21 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787291373; cv=none; b=Avdepl0SL2MK3qjwbg1I6bAW7P/8RrK8i/LSv3MYpjWRzwEgli+dcizy+SXbNFKSN19Ay5/bkjQj01a4dpOBpQezV7/mXLeA6Ze3unAVN6tODNQ+I62cscBK7CjYK7qKTjiX7H9NLRcoktHk9Yio8YPbnFiJPMyF1/WRBrXK0gE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787291373; c=relaxed/simple; bh=eR8K3cLrav5I2zLr6N7Mw3trLHlhYTtRFUwRknOs4V8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=NKAEdvGQs26kOUh2JNsd+v48zGGJ0f3nWW8Plhje8QMF5/iv5H+xdqN/apG7LHlMlTzWYps5DM4XqVPsOY1/NZKujz7fE0dMAavpvDYjtboW/sIQ8AaGLyYougKVxXbwMHu5i4hlRkBFaDW3TPoW+Ng05GSv9eIOmZVlNrLXk8U= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=Jf3JP8fZ; arc=none smtp.client-ip=198.175.65.21 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="Jf3JP8fZ" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1787291372; x=1818827372; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=eR8K3cLrav5I2zLr6N7Mw3trLHlhYTtRFUwRknOs4V8=; b=Jf3JP8fZgZTclmGPK2HXRwAv2ntGsLc8vXlKTAG6/3YwlCwQr877yEdO mknBs+ruS7+ALz2w4kCQlbU5Ctd+CshZsyEQQ1HtRihCxKhrhoSY86qDK 23ud+Ta3EHXKcMcFepNXp7IpHgk9lc+d1IUt+8qYrvtygvvWZidqPPpn5 ZN11aQt8VEiGcNoWUpswlPUQsqFym53MHBSmCx5hA0ZrR+ac3FPYKegk/ KHi9yuT3Hw8x8JOJ4BC8ASnR78PlgS/0nYxXHhG09xbBFn+J2tpvA65ra FjXcaJ8R9xTklLN5XqV1j6IGdJ/D/VHih8tl6aL2AZNi5RBsiyWcVEmEd A==; X-CSE-ConnectionGUID: hC6XImPGSGaxIO7NBjiOYw== X-CSE-MsgGUID: /lDyP47AT4q7DiI0ROXJSQ== X-IronPort-AV: E=McAfee;i="6800,10657,11881"; a="87691973" X-IronPort-AV: E=Sophos;i="6.25,234,1779174000"; d="scan'208";a="87691973" Received: from orviesa005.jf.intel.com ([10.64.159.145]) by orvoesa113.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Aug 2026 22:49:32 -0700 X-CSE-ConnectionGUID: 5Y/0/p6mS+WC5ejXqdX17A== X-CSE-MsgGUID: m2I0i2lZSBKWP4IfbLb5UQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.25,234,1779174000"; d="scan'208";a="270476182" Received: from linux-pnp-gnr-1.sh.intel.com ([10.239.83.186]) by orviesa005.jf.intel.com with ESMTP; 20 Aug 2026 22:49:26 -0700 From: Jiebin Sun To: namhyung@kernel.org Cc: acme@kernel.org, mingo@redhat.com, peterz@infradead.org, adrian.hunter@intel.com, alexander.shishkin@linux.intel.com, irogers@google.com, james.clark@linaro.org, jolsa@kernel.org, mark.rutland@arm.com, dapeng1.mi@linux.intel.com, thomas.falcon@intel.com, tianyou.li@intel.com, wangyang.guo@intel.com, jiebin.sun@intel.com, linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 3/4] perf c2c: Add stdio support for the function view Date: Fri, 21 Aug 2026 13:56:10 +0800 Message-ID: X-Mailer: git-send-email 2.52.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The function view is currently TUI-only, so it cannot be used by builds without SLANG support, when output is piped, or from a script. Add a --function option that prints the fully expanded three-level hierarchy to stdout. Keep the stdio renderer in builtin-c2c.c and reuse the common function-view model introduced by the merged series. Export only the coalescing-field capability check from the model, preserving the util/UI boundary and leaving the TUI object in libperf-ui.a. Stop padding the final identity column in symbol_view_entry(). The generic formatter pads non-final columns but deliberately leaves the final column unpadded, avoiding trailing whitespace in function-view table rows. The TUI remains unchanged because its browser clears the rest of each rendered row. --function implies --stdio and is rejected together with --stats. Validate the iaddr requirement before processing events. Return function-view build failures from the report command, and preserve TUI browser errors when converting the display helpers to return a status. Signed-off-by: Jiebin Sun Cc: Dapeng Mi Cc: Ian Rogers Cc: James Clark Cc: Namhyung Kim Cc: Thomas Falcon Reviewed-by: Tianyou Li Reviewed-by: Wangyang Guo Acked-by: Namhyung Kim --- tools/perf/Documentation/perf-c2c.txt | 12 +++- tools/perf/builtin-c2c.c | 85 ++++++++++++++++++++++++--- tools/perf/util/c2c-function.c | 9 +-- tools/perf/util/c2c.h | 1 + 4 files changed, 90 insertions(+), 17 deletions(-) diff --git a/tools/perf/Documentation/perf-c2c.txt b/tools/perf/Documentati= on/perf-c2c.txt index 9e58a51c55de..7a0cf31be7ed 100644 --- a/tools/perf/Documentation/perf-c2c.txt +++ b/tools/perf/Documentation/perf-c2c.txt @@ -107,6 +107,10 @@ REPORT OPTIONS --stats:: Display only statistic tables and force stdio mode. =20 +--function:: + Display the function view and force stdio mode. This requires `iaddr` + in the cacheline coalescing fields and cannot be used with `--stats`. + --full-symbols:: Display full length of symbols. =20 @@ -360,6 +364,10 @@ Following tables are displayed: Shared Cache Line Distribution Pareto - list of all accessed offsets for each cacheline =20 +With `--function`, the cacheline and Pareto tables are replaced by a fully +expanded Shared Data Functions Table. Its three levels are the read-side +function, contending writer, and shared cacheline, as detailed below. + TUI OUTPUT ---------- The TUI output provides interactive interface to navigate @@ -374,8 +382,8 @@ Verbose mode also includes code addresses in function r= ows, and code addresses remain available in the per-cacheline detail view ('d'). =20 The function view requires `iaddr` in the cacheline coalescing fields. If -`--coalesce` omits it, TAB reports that the view is unavailable rather than -attributing already-coalesced samples to an arbitrary function. +`--coalesce` omits it, TAB or `--function` reports that the view is unavai= lable +rather than attributing already-coalesced samples to an arbitrary function. =20 Level 1: the read-side function, sorted by Cycles % (estimated load cycles: HITM, peer-snoop and other-load cycles) diff --git a/tools/perf/builtin-c2c.c b/tools/perf/builtin-c2c.c index 715b75d42f2a..cce76a1e2ff5 100644 --- a/tools/perf/builtin-c2c.c +++ b/tools/perf/builtin-c2c.c @@ -73,6 +73,7 @@ struct perf_c2c { bool show_all; bool use_stdio; bool stats_only; + bool function_view; bool symbol_full; bool stitch_lbr; =20 @@ -2530,7 +2531,48 @@ static void print_c2c_info(FILE *out, struct perf_se= ssion *session) fprintf(out, " Cacheline data grouping : %s\n", c2c.cl_sort); } =20 -static void perf_c2c__hists_fprintf(FILE *out, struct perf_session *sessio= n) +static void c2c_function__unfold_all(struct rb_root_cached *root) +{ + struct rb_node *nd; + + for (nd =3D rb_first_cached(root); nd; nd =3D rb_next(nd)) { + struct hist_entry *he =3D rb_entry(nd, struct hist_entry, rb_node); + + if (!he->has_children) + continue; + he->unfolded =3D true; + c2c_function__unfold_all(&he->hroot_out); + } +} + +static int perf_c2c__function_fprintf(FILE *out) +{ + bool saved_use_callchain =3D symbol_conf.use_callchain; + struct hists *hists; + int ret; + + /* Function-view entries aggregate samples and never display callchains. = */ + symbol_conf.use_callchain =3D false; + ret =3D c2c_function__build(&c2c.hists, c2c.cl_sort, c2c.symbol_full, + &hists); + if (ret) { + if (ret =3D=3D -EOPNOTSUPP) + pr_err("The function view requires iaddr in --coalesce.\n"); + else + pr_err("Failed to build function view hierarchy (ret=3D%d)\n", ret); + goto out; + } + + /* Match fold signs to hists__fprintf()'s forced child traversal. */ + c2c_function__unfold_all(&hists->entries); + hists__fprintf(hists, true, 0, 0, 0, out, true); + c2c_function__reset(); +out: + symbol_conf.use_callchain =3D saved_use_callchain; + return ret; +} + +static int perf_c2c__hists_fprintf(FILE *out, struct perf_session *session) { setup_pager(); =20 @@ -2541,7 +2583,17 @@ static void perf_c2c__hists_fprintf(FILE *out, struc= t perf_session *session) print_c2c_info(out, session); =20 if (c2c.stats_only) - return; + return 0; + + if (c2c.function_view) { + fprintf(out, "\n"); + fprintf(out, "=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D\n"); + fprintf(out, " Shared Data Functions Table\n"); + fprintf(out, "=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D\n"); + fprintf(out, "#\n"); + + return perf_c2c__function_fprintf(out); + } =20 fprintf(out, "\n"); fprintf(out, "=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D\n"); @@ -2558,6 +2610,7 @@ static void perf_c2c__hists_fprintf(FILE *out, struct= perf_session *session) fprintf(out, "#\n"); =20 print_pareto(out, perf_session__env(session)); + return 0; } =20 #ifdef HAVE_SLANG_SUPPORT @@ -2794,18 +2847,18 @@ static int perf_c2c__hists_browse(struct hists *his= ts) return 0; } =20 -static void perf_c2c_display(struct perf_session *session) +static int perf_c2c_display(struct perf_session *session) { if (use_browser =3D=3D 0) - perf_c2c__hists_fprintf(stdout, session); - else - perf_c2c__hists_browse(&c2c.hists.hists); + return perf_c2c__hists_fprintf(stdout, session); + + return perf_c2c__hists_browse(&c2c.hists.hists); } #else -static void perf_c2c_display(struct perf_session *session) +static int perf_c2c_display(struct perf_session *session) { use_browser =3D 0; - perf_c2c__hists_fprintf(stdout, session); + return perf_c2c__hists_fprintf(stdout, session); } #endif /* HAVE_SLANG_SUPPORT */ =20 @@ -3081,6 +3134,8 @@ static int perf_c2c__report(int argc, const char **ar= gv) OPT_BOOLEAN(0, "stdio", &c2c.use_stdio, "Use the stdio interface"), OPT_BOOLEAN(0, "stats", &c2c.stats_only, "Display only statistic tables (implies --stdio)"), + OPT_BOOLEAN(0, "function", &c2c.function_view, + "Display the function view (implies --stdio)"), OPT_BOOLEAN(0, "full-symbols", &c2c.symbol_full, "Display full length of symbols"), OPT_BOOLEAN(0, "no-source", &no_source, @@ -3119,6 +3174,11 @@ static int perf_c2c__report(int argc, const char **a= rgv) PARSE_OPT_STOP_AT_NON_OPTION); if (argc) usage_with_options(report_c2c_usage, options); + if (c2c.stats_only && c2c.function_view) { + pr_err("--stats and --function cannot be used together.\n"); + err =3D -EINVAL; + goto out; + } =20 #ifndef HAVE_SLANG_SUPPORT c2c.use_stdio =3D true; @@ -3126,6 +3186,8 @@ static int perf_c2c__report(int argc, const char **ar= gv) =20 if (c2c.stats_only) c2c.use_stdio =3D true; + if (c2c.function_view) + c2c.use_stdio =3D true; =20 /** * Annotation related options disassembler_style, objdump_path are set @@ -3199,6 +3261,11 @@ static int perf_c2c__report(int argc, const char **a= rgv) pr_debug("Failed to initialize hists\n"); goto out_session; } + if (c2c.function_view && !c2c_function__has_iaddr(c2c.cl_sort)) { + pr_err("The function view requires iaddr in --coalesce.\n"); + err =3D -EINVAL; + goto out_session; + } =20 err =3D c2c_hists__init(&c2c.hists, "dcacheline", 2, perf_session__env(se= ssion)); if (err) { @@ -3332,7 +3399,7 @@ static int perf_c2c__report(int argc, const char **ar= gv) goto out_mem2node; } =20 - perf_c2c_display(session); + err =3D perf_c2c_display(session); =20 out_mem2node: mem2node__exit(&c2c.mem2node); diff --git a/tools/perf/util/c2c-function.c b/tools/perf/util/c2c-function.c index 5b6a06a5a067..d410196d0429 100644 --- a/tools/perf/util/c2c-function.c +++ b/tools/perf/util/c2c-function.c @@ -305,8 +305,8 @@ symbol_view_entry(struct perf_hpp_fmt *fmt, struct perf= _hpp *hpp, char symbuf[32]; =20 scnprintf(symbuf, sizeof(symbuf), "0x%" PRIx64, addr); - ret +=3D scnprintf(hpp->buf + ret, hpp->size - ret, "%-*.*s", - text_width, text_width, symbuf); + ret +=3D scnprintf(hpp->buf + ret, hpp->size - ret, "%.*s", + text_width, symbuf); } else { /* Level 1 and level 2 are both functions. */ size_t cell_size; @@ -331,9 +331,6 @@ symbol_view_entry(struct perf_hpp_fmt *fmt, struct perf= _hpp *hpp, len =3D min_t(size_t, len, cell_size - 1); =20 ret +=3D len; - if (len < text_width) - ret +=3D scnprintf(hpp->buf + ret, hpp->size - ret, "%*s", - text_width - len, ""); } =20 return ret; @@ -1519,7 +1516,7 @@ void c2c_function__reset(void) symbol_conf.use_callchain =3D saved_use_callchain; } =20 -static bool c2c_function__has_iaddr(const char *cl_sort) +bool c2c_function__has_iaddr(const char *cl_sort) { const char *field =3D cl_sort; =20 diff --git a/tools/perf/util/c2c.h b/tools/perf/util/c2c.h index 53f024e25d99..198032ec7c87 100644 --- a/tools/perf/util/c2c.h +++ b/tools/perf/util/c2c.h @@ -107,6 +107,7 @@ bool c2c_fmt_equal(struct perf_hpp_fmt *a, struct perf_= hpp_fmt *b); int c2c_function__build(struct c2c_hists *cl_hists, const char *cl_sort, bool symbol_full, struct hists **hists); void c2c_function__reset(void); +bool c2c_function__has_iaddr(const char *cl_sort); /* Valid only between a successful build and c2c_function__reset(). */ struct hist_entry *c2c_function__find_cacheline(struct hist_entry *he); =20 --=20 2.52.0 From nobody Mon Sep 28 14:45:52 2026 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.21]) (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 2DA7B40F74A; Fri, 21 Aug 2026 05:49:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.21 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787291375; cv=none; b=lksKignZ7FzRYuz/QDG5dSMFgma3a1Lr1a13dKmdBwdqaxCmyDNXCfF+q7BT4q/Dy0osJ3Llkxnpxzg/4bC/Tjqf6LbsUjwVmPKKMsnwXCCSg2/KmCI90S9qwJuW1eRo+fHFbnLRpY15fEtoTWpr+a9122SE80pJs0tVlqoZ+6A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787291375; c=relaxed/simple; bh=HWxa1AZQIeHftwYIuZGqxXn+VypsNqsJaWLDzH4s4Iw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=uN+HYOJwi1BiDqJP2ab1kni0Qq5HfOVjcTsAuYPPlH/vFTU9Ho0ZzrqY74d1QldB/4hq+AFvtsklFcKACqu1Xc8mctgjOmaZoCszL9LGY96y3C1jlRu2/OPC7GypZkCrPWF7SOZ2NEQPJcaQ82Z6yiYkVQlLvE8dNJaTJBWtrYg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=VtoVuX9/; arc=none smtp.client-ip=198.175.65.21 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="VtoVuX9/" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1787291374; x=1818827374; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=HWxa1AZQIeHftwYIuZGqxXn+VypsNqsJaWLDzH4s4Iw=; b=VtoVuX9/TQpHIHc5DifeqmcDosOst6EDzGO2TuuyQikvdmtddUoOG8QL GBG3OxNi5uDlclQsNFP6GY8CBfjX27PNzgSwWPPXou+G0yCvw/IDuW6eS apEzBq3vEc2C1Wzms0HxQ3qJodkAD4D6tC5IZbvo3/Lh8u1ipIj/caCaq pVj8RrCz1D6Z2wxIPtziEKZfCJEkBadYEB+KUNzXtjjXxx5NMG9gbeols LkF0Zsg5b3z8b+kpgAp93pqLL00WP9LDjQCSgHQbp3lN2yE37h+9T7f8Q Im7g8tbJ2z1BNn7buhGmrkJA/KKEUGlh8H17Q0FGbBTyeBn0sJ6BgEK72 Q==; X-CSE-ConnectionGUID: mxCEJiofRIiDFQdzOsl6Tw== X-CSE-MsgGUID: iGKIZ1R1TUmG/KPQS4SGuQ== X-IronPort-AV: E=McAfee;i="6800,10657,11881"; a="87691991" X-IronPort-AV: E=Sophos;i="6.25,234,1779174000"; d="scan'208";a="87691991" Received: from orviesa005.jf.intel.com ([10.64.159.145]) by orvoesa113.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Aug 2026 22:49:33 -0700 X-CSE-ConnectionGUID: lZumh/SDQcOHm8fzt/yZkg== X-CSE-MsgGUID: MIiOmRIDRxu1Z49NJNarUQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.25,234,1779174000"; d="scan'208";a="270476192" Received: from linux-pnp-gnr-1.sh.intel.com ([10.239.83.186]) by orviesa005.jf.intel.com with ESMTP; 20 Aug 2026 22:49:29 -0700 From: Jiebin Sun To: namhyung@kernel.org Cc: acme@kernel.org, mingo@redhat.com, peterz@infradead.org, adrian.hunter@intel.com, alexander.shishkin@linux.intel.com, irogers@google.com, james.clark@linaro.org, jolsa@kernel.org, mark.rutland@arm.com, dapeng1.mi@linux.intel.com, thomas.falcon@intel.com, tianyou.li@intel.com, wangyang.guo@intel.com, jiebin.sun@intel.com, linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 4/4] perf tests c2c: Add function view stdio coverage Date: Fri, 21 Aug 2026 13:56:11 +0800 Message-ID: <9bd7a313c9c1d71058e857c320c6d5c30cf4cbfa.1787283281.git.jiebin.sun@intel.com> X-Mailer: git-send-email 2.52.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Exercise the function view without driving a terminal now that it has a stdio path. Keep the existing datasym record/report coverage and make a separate recording of the contended locks used by the futex hash benchmark. Always check the function table headers, table replacement, missing-iaddr diagnostic, and conflicting options. A machine can support c2c recording without capturing a contended sample, so report a skip when the hierarchy is empty rather than treating hardware sampling variance as a failure. When samples are available, check generic row shapes for all three hierarchy levels, their expanded fold signs, cacheline addresses, and the absence of trailing whitespace in the table body. Signed-off-by: Jiebin Sun Cc: Dapeng Mi Cc: Ian Rogers Cc: James Clark Cc: Namhyung Kim Cc: Thomas Falcon Reviewed-by: Tianyou Li Reviewed-by: Wangyang Guo Acked-by: Namhyung Kim --- tools/perf/tests/shell/c2c.sh | 113 ++++++++++++++++++++++++++++++++++ 1 file changed, 113 insertions(+) diff --git a/tools/perf/tests/shell/c2c.sh b/tools/perf/tests/shell/c2c.sh index f5f223cbf9cc..cf76359d19cc 100755 --- a/tools/perf/tests/shell/c2c.sh +++ b/tools/perf/tests/shell/c2c.sh @@ -6,10 +6,15 @@ set -e =20 err=3D0 perfdata=3D$(mktemp /tmp/__perf_c2c_test.perf.data.XXXXX) +funcdata=3D$(mktemp /tmp/__perf_c2c_function_test.perf.data.XXXXX) +perfout=3D$(mktemp /tmp/__perf_c2c_test.output.XXXXX) =20 cleanup() { rm -f "${perfdata}" rm -f "${perfdata}".old + rm -f "${funcdata}" + rm -f "${funcdata}".old + rm -f "${perfout}" trap - EXIT TERM INT } =20 @@ -58,6 +63,114 @@ test_c2c_record_report() { echo "c2c record and report test [Success]" } =20 +test_c2c_function_report() { + echo "c2c function stdio report test" + + if perf c2c report -i "${perfdata}" --function -c pid > "${perfout}" 2>&1= ; then + echo "c2c function stdio report test [Failed: report accepted missing ia= ddr]" + err=3D1 + return + fi + if ! grep -Fq "The function view requires iaddr in --coalesce." "${perfou= t}" ; then + echo "c2c function stdio report test [Failed: missing iaddr diagnostic]" + cat "${perfout}" + err=3D1 + return + fi + if grep -Fq "Shared Data Functions Table" "${perfout}" ; then + echo "c2c function stdio report test [Failed: partial report on missing = iaddr]" + cat "${perfout}" + err=3D1 + return + fi + + if perf c2c report -i "${perfdata}" --function --stats > "${perfout}" 2>&= 1 ; then + echo "c2c function stdio report test [Failed: accepted conflicting optio= ns]" + err=3D1 + return + fi + if ! grep -Fq -- "--stats and --function cannot be used together." "${per= fout}" ; then + echo "c2c function stdio report test [Failed: missing conflict diagnosti= c]" + cat "${perfout}" + err=3D1 + return + fi + + # Exercise contended futex hash-bucket locks so the function view can get + # reader, writer, and cacheline rows without changing the original test. + if ! perf c2c record -o "${funcdata}" -- \ + perf bench futex hash -t 4 -r 1 -s > /dev/null 2>&1 ; then + echo "c2c function stdio report test [Skipped: recording failed]" + err=3D2 + return + fi + + if ! perf c2c report -i "${funcdata}" --function > "${perfout}" 2>&1 ; th= en + echo "c2c function stdio report test [Failed: report failed]" + cat "${perfout}" + err=3D1 + return + fi + + for expected in "Shared Data Functions Table" \ + "# Cycles Store" \ + "# % count Function / Contending function / Cacheline" \ + "# ......... ......." ; do + if ! grep -Fq "${expected}" "${perfout}" ; then + echo "c2c function stdio report test [Failed: missing '${expected}']" + cat "${perfout}" + err=3D1 + return + fi + done + for unexpected in "Shared Data Cache Line Table" \ + "Shared Cache Line Distribution Pareto" ; do + if grep -Fq "${unexpected}" "${perfout}" ; then + echo "c2c function stdio report test [Failed: found '${unexpected}']" + cat "${perfout}" + err=3D1 + return + fi + done + + if ! awk '/^# \.+/ { body =3D 1; next } + body && !/^#/ && NF { found =3D 1 } + END { exit !found }' "${perfout}" ; then + echo "c2c function stdio report test [Skipped: no contended samples]" + err=3D2 + return + fi + + # The spaces intentionally verify per-level indentation and expanded + # fold-sign placement without depending on symbol names. + for expected in \ + '^ - +[0-9]+\.[0-9]+% +[0-9]+ - ' \ + '^ +[0-9]+ - ' \ + '^ +[0-9]+ 0x[[:xdigit:]]+$' ; do + if ! grep -Eq "${expected}" "${perfout}" ; then + echo "c2c function stdio report test [Failed: missing hierarchy row]" + echo " ${expected}" + cat "${perfout}" + err=3D1 + return + fi + done + + if awk '/^# \.+/ { body =3D 1; next } + body && /[[:blank:]]$/ { found =3D 1 } + END { exit !found }' "${perfout}" ; then + echo "c2c function stdio report test [Failed: trailing whitespace in tab= le body]" + cat "${perfout}" + err=3D1 + return + fi + + echo "c2c function stdio report test [Success]" +} + test_c2c_record_report +if [ "${err}" -eq 0 ]; then + test_c2c_function_report +fi cleanup exit $err --=20 2.52.0