From nobody Sun Feb 8 05:29:39 2026 Received: from mail-wr1-f48.google.com (mail-wr1-f48.google.com [209.85.221.48]) (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 5063E1DF75A for ; Sun, 25 Jan 2026 20:08:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769371733; cv=none; b=at/SKEYAj5c/YjQwK5QGg9FL4S3nKrXWGx1tvilvo/KBuIwmFNZWXUeSjAjo6fYtS/rFMs2AQKfq8B9eH3bn5iUCF4wG9MA/XmBZ9RB1bmHFbgJpsNVYq4UQgvFF05OAOE5bac3697jogsUNZB2fOjt4OvE7EGL5fpNXFCXMCvw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769371733; c=relaxed/simple; bh=LbX1bJCVXzsmZIhljuGwQkBMgP+AErEY5RawD55Offc=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=pIoSGkDDcrJNr2A4dh8CNo8OHbcD3+kI1KVhbWVmN98uqUojxnpkcC5D6u4bZ7VO5Ynd28viA8hFWniRiNYVeDDykrrFJt1Mkwx8iELVBp1WWxnAJoqc4hE0DAKBKDnYjv4pfkkTqswyIH/ZtdGByTe9JR5klJOL357VgMSrOUE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=OGW2WHPq; arc=none smtp.client-ip=209.85.221.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="OGW2WHPq" Received: by mail-wr1-f48.google.com with SMTP id ffacd0b85a97d-4327555464cso2545740f8f.1 for ; Sun, 25 Jan 2026 12:08:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1769371730; x=1769976530; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=L8e4SJevGIwtqo4T1xXLLi2W63QvJLEESxStogimHtY=; b=OGW2WHPqZm5OfQDizmYbMZBEZj6DoB8j+ZLroj7yGZCCKuo4qvgverO52TTzgockDC w/Djz9b8BOv7d6RXbQQZh4t54J5tWW/YQzZYkhUkdADTKJZyhKqP2he3YZDVZTiRNlmD wETjjPluqET7SuxzVtnxV2Cny6wAoMwJrzDvCRb+xoL920gZ9L/8DNYyCRM2D18CjL0h i9UASKeuPkBKIKzLviXja63Vuad97Zyi3/u4x9IpvR+A9sSZDlMjKhB0qrFoyY4TTjI4 0BC4CZcm6EZrgpNhWjdGSGA7nQmf/R7swyA8e1+b598kWFTH5LDppBmGWiGyciGQefsQ dLFw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1769371730; x=1769976530; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=L8e4SJevGIwtqo4T1xXLLi2W63QvJLEESxStogimHtY=; b=XnD3AW644eNUy1lx7PLyJ2RXudVX/6fpB6gA8O5dl4JAapChoGkHNK0c86XMhUiMDf 4Gww5DEotHmNep6kK7LT8Y18MX1WfP4sWA09ysPOgsRyvIP76fCsLT8VX38ZvBwqcEsI V3GZFMPkc8WOYhm5B0xECassV4trZxddy5PV2y/Dh3VWrXxTdCH170d9RullLEhdMW+H 6Da0IKPfcKhXAG/WkC9x3pzEvnriBA5gl2OYbQCv0YPw3otQqjuRtw8c+vbeyxg5Fh5L VO2mtO0EnKdC8yevrH6Jk0s1hEbR9sTc5Fu4d6WGPMVRfFjm5pMi3/Aa3vmdE/ExPde7 sfug== X-Forwarded-Encrypted: i=1; AJvYcCU9xBJxi0Cjf4gUTj+a01H9y5i0EsQQbtoQJ0eOTcjge7E4+r433tZnu5/sCEnY/AkTL7kv/PqIJ11HSd4=@vger.kernel.org X-Gm-Message-State: AOJu0Yy/grNXdgdLdXZ9XgI1IOKV2eLwfMihnNgluo5JeVPFMGjMciJG 9vGtoApOMjPpsW0M9CihQoUcAXJbfvgLpj9XuqEuQQyClL1pwtCJ3xQQ X-Gm-Gg: AZuq6aJdBuXuDE9HfBh+zf8OyJjNyIHu0uGT/oR9a0BNwGDOAywVQctt7VIq/timL3y RiqVjHFnw0vgatQgPcpk/TNhgwrjmf/tAGvMzROCBU2hYjiJW8ePR0fBDqxeTOpiDv/TByVi9Pn CP1LKb2IQ+INr+fAxajrP9043os26UAhIVrbBTT+vJ4TQUQpOYQE9QTWCV7YTb/c2tW7SX6XGh4 6+cybTWMjI0CmomMexkVYwlq5kyChhHPo0NtkEkYtLPMrh+uJudlPQA0f6/tISDqy3E0ymPKhdL xS2RwdQ3/sQbbGtF/UNaHXV8VZzkcTg/REvaKf3nSB+k+Y0yBYG+vQgmv9zEUdQYOsZnuloVESf O/8XRgvnFY5CeI8Y5V7+lW5EUXLv13lB/WsrXt2quWBsHwxwSkwVjICzNsOqMWL+NFWR+AG6DTp EMqUy+Jb4CZr5RPbyqjLS394dOLpSXjdKx1B3APPUbPJk= X-Received: by 2002:a05:6000:2312:b0:435:af2d:2e05 with SMTP id ffacd0b85a97d-435ca39bd12mr4165832f8f.51.1769371729397; Sun, 25 Jan 2026 12:08:49 -0800 (PST) Received: from optiplex (p548853b2.dip0.t-ipconnect.de. [84.136.83.178]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-435b1f7b4d8sm23082976f8f.38.2026.01.25.12.08.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 25 Jan 2026 12:08:48 -0800 (PST) From: Hrishikesh Suresh To: Peter Zijlstra , Arnaldo Carvalho de Melo , Namhyung Kim Cc: Hrishikesh Suresh , Ingo Molnar , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , James Clark , Chun-Tse Shao , Blake Jones , Dmitry Vyukov , Leo Yan , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] perf session: print all machines in session dump Date: Sun, 25 Jan 2026 21:06:52 +0100 Message-ID: <20260125200759.57816-1-hrishikesh123s@gmail.com> X-Mailer: git-send-email 2.52.0 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" perf_session__fprintf() prints only host. This has been changed to print details of host and all guests, by traversing through the RB-Tree. These are visible when using high verbosity (-vvvv) in KVM environments, during perf report dumps. Testing - - Test 1: Record the local machine and guest VM using 'perf kvm record' and generate the report using 'perf kvm report -vvvv -D'. The dump should show the threads and other details related to local and guest machine. - 1 Ubuntu VM running on Fedora host - VM is running a noisy program =3D> $ dd if=3D/dev/urandom of=3D/dev/null - On host run =3D> $ sudo ./perf kvm --guestvmlinux=3D/tmp/shared/guest_vmlinux \ --guestkallsyms=3D/tmp/shared/guest_kallsyms \ --guestmodules=3D/tmp/shared/guest_modules \ record -a -g -o perf.data.guest and exit after a few seconds. [ perf record: Woken up 9 times to write data ] [ perf record: Captured and wrote 3.150 MB perf.data.guest \ (29311 samples) ] - Generate dump =3D> $ sudo ./perf kvm --guestkallsyms /tmp/shared/guest_kallsyms \ report -vvvv -D -i perf.data.guest > output.txt - Check for threads associated with guest machine. $ grep "Thread 0" output.txt Thread 0 swapper Thread 0 [guest/0] PASS - Test 2: Record the local machine and guest VM using 'perf kvm record' and generate the report using 'perf kvm report'. The functions running on guest VM should be seen in the report. - Same setup as Test 1 but the test looks at the performance profile, to check if the function names are visible. - Peek into profile using =3D> $ sudo ./perf kvm --guestkallsyms /tmp/shared/guest_kallsyms \ report -i perf.data.guest - Samples: 29K of event 'cycles', Event count (approx.): 28711693142 Children Self Command Shared Object Symbol 35.69% 35.69% :5820 [guest.kernel.kallsyms] [g] chacha_permute 11.56% 11.56% :5820 [guest.kernel.kallsyms] [g] entry_SYSRETQ_unsXXX 11.12% 11.12% :5820 [guest.kernel.kallsyms] [g] syscall_return_viXXX 7.36% 7.36% :5820 [guest.kernel.kallsyms] [g] entry_SYSCALL_64_XXX 6.07% 6.07% :5820 [guest.kernel.kallsyms] [g] chacha_block_generic 5.40% 5.40% :5820 [guest.kernel.kallsyms] [g] _copy_to_iter .... PASS - Test 3: Record the local and 2 guest VMs using 'perf kvm record' and generate the report using 'perf kvm report -vvvv -D'. The dump should show the threads and other details related to local and guest machines. - 1 Ubuntu and 1 Alpine VMs running on Fedora host. - Find PIDs of qemu instances and use them during record and report $ pgrep qemu 5816 25098 - Record the activity =3D> $ sudo ./perf kvm record -p 5816,25098 -a -g -o perf.data.guests Warning: PID/TID switch overriding SYSTEM [ perf record: Woken up 325927 times to write data ] [ perf record: Captured and wrote 3.692 MB perf.data.guests \ (57389 samples) ] - Generate dump =3D> $ sudo ./perf kvm report -vvvv -D -i perf.data.guests > output.txt - Check if the threads related to the local machine and guest VMs are present =3D> $ grep "Thread 0" output.txt Thread 0 swapper Thread 0 [guest/0] NOTE: Threads from Ubuntu and Alpine VMs are bundled together and appear as one guest machine. Looking into output.txt =3D> Threads: 6 Thread 0 [guest/0] Thread 5816 :5816 Thread 25098 :25098 Thread 5819 :5819 Thread 5820 :5820 Thread 25103 :25103 To conclude, information is collected for both VMs and not listed as two different guest machines. PASS - Test 4: Check if any guest-related information is printed in perf annotate. This test is included because the command calls perf_session__fprintf() in its code path when using -vvvv option. This could be explained by inability / lack of options for 'perf annotate' to look into guest VM from host machine, due to no option to specify the guest's kallsyms or modules. A similar explanation for 'perf mem' could be used, as perf_session__fprintf() is also present in its code path. - Run annotate =3D> $ sudo ./perf annotate -i perf.data.guest -vvvv > output.txt - Check for threads from local machine or guest VM =3D> $ grep "Thread 0" output.txt Thread 0 swapper Threads from local machine are found while threads from guest VM are not found. It is possibly because of a lack of a guest kallsyms option for DSO matching in perf annotate. PASS - Test 5: Run kvm test available on perf path - $ sudo ./perf test kvm 89: perf kvm tests : Ok PASS Signed-off-by: Hrishikesh Suresh --- tools/perf/util/session.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c index 4236503c8f6c..6c6dfeb4eb33 100644 --- a/tools/perf/util/session.c +++ b/tools/perf/util/session.c @@ -2674,11 +2674,15 @@ size_t perf_session__fprintf_nr_events(struct perf_= session *session, FILE *fp) =20 size_t perf_session__fprintf(struct perf_session *session, FILE *fp) { - /* - * FIXME: Here we have to actually print all the machines in this - * session, not just the host... - */ - return machine__fprintf(&session->machines.host, fp); + struct rb_node *nd; + struct machine *pos; + size_t ret =3D machine__fprintf(&session->machines.host, fp); + + for (nd =3D rb_first_cached(&session->machines.guests); nd; nd =3D rb_nex= t(nd)) { + pos =3D rb_entry(nd, struct machine, rb_node); + ret +=3D machine__fprintf(pos, fp); + } + return ret; } =20 void perf_session__dump_kmaps(struct perf_session *session) --=20 2.52.0