From nobody Sat Jun 13 17:06:31 2026 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (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 EACD636EAA7; Wed, 6 May 2026 07:11:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778051501; cv=none; b=p1aH2ELexWZMykAHVfeXZXhg7glII305nLKg45/Xoq8b63wUeibtPEN7vxWYdkKe9lOGNzsXMG8PPZbvjD97gQPxjtMBOH7iKaScfcLmUabXf6fD4z746uyLjsinWt5jXY3wsB4570ePONrKB90UU7pIT5RKssldqxsC785l07w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778051501; c=relaxed/simple; bh=yY9wFU42FvKCrRWOxRc5EbET7rHsLh/1RIM33FR6rlE=; h=Date:From:To:Subject:Cc:In-Reply-To:References:MIME-Version: Message-ID:Content-Type; b=gwHq7Yj3TnSFyhaJNAxqn9aPCBovvbgxjHOiWph9Krc5u4gfvNofc/y05GExpg0FUJ3veMH670eL4b+tDpjCwFid0m1WP5JlvVlEUbd0MiJNOd5FOrt+qexKiyinklbhrfNJvjFh1lNAgxw9gqOUqT/XppJQfhdUUTFB/wc9mes= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=M24ZaE5J; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=7ormXOX/; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="M24ZaE5J"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="7ormXOX/" Date: Wed, 06 May 2026 07:11:37 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1778051498; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=26RL7a24hRaAuqkip82pikK26rsgUimQy8HoKEks6as=; b=M24ZaE5JsqyqE4+DvBZ7G9GqNgWm6v8Xhj3hNZNC0+2zgJa2v2W1vgfGg3RJk+VVEoqydt 4JYTXwHZJhopa/QAnmsLWTAtlqMqsAWbgmOlKcHiH/nRz3nWkGUZWtMudxK1YwJSR23GUh mH3CVUGU2aE5d+TuXir2CyA+9UdGuhsA6BrUowrDpVCjbuH6seOd59VfLthE8efp5X+Y25 OfwiO7KMgBAULDIQncA3lnolJxjxzjyr46Njx2edq1co7iMF5CekUNSjF5u2PfQpDybRlc npAr5Ias6ncI7gMTOQXIxQ07n8ggK4js235pW0KoXBieZV8Oy6r20tlvj4ygzQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1778051498; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=26RL7a24hRaAuqkip82pikK26rsgUimQy8HoKEks6as=; b=7ormXOX/xKf2bysJ+5aSgMRvRp8z8rxWu7DTVP2KSpyvS0XfFO5pj3G+iA1jvg+ICa2nb2 cNcxF1iyQV6hngCw== From: "tip-bot2 for Frederic Weisbecker" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: timers/core] scripts/timers: Add timer_migration_tree.py Cc: Frederic Weisbecker , Thomas Gleixner , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20260423165354.95152-7-frederic@kernel.org> References: <20260423165354.95152-7-frederic@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <177805149709.424702.14748972019534399416.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Precedence: bulk Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable The following commit has been merged into the timers/core branch of tip: Commit-ID: cab0cd0130eb6c884982ede3f70aca0392a7fc57 Gitweb: https://git.kernel.org/tip/cab0cd0130eb6c884982ede3f70aca039= 2a7fc57 Author: Frederic Weisbecker AuthorDate: Thu, 23 Apr 2026 18:53:54 +02:00 Committer: Thomas Gleixner CommitterDate: Wed, 06 May 2026 08:33:07 +02:00 scripts/timers: Add timer_migration_tree.py Introduce a script that provides a simple ascii representation of the timer migration tree on top of boot trace events. First boot with: trace_event=3D=3Dtmigr_connect_cpu_parent,tmigr_connect_child_parent Then parse the result with: scripts/timer_migration_tree.py < /sys/kernel/tracing/trace On a system with 8 CPUs, this produces the following output: Tree for capacity 1024 /-0, node 0, lvl:-1 | |--1, node 0, lvl:-1 | |--2, node 0, lvl:-1 | |--3, node 0, lvl:-1 -- /00000000dcebac8b, node 0, lvl:0 |--4, node 0, lvl:-1 | |--5, node 0, lvl:-1 | |--6, node 0, lvl:-1 | \-7, node 0, lvl:-1 Signed-off-by: Frederic Weisbecker Signed-off-by: Thomas Gleixner Link: https://patch.msgid.link/20260423165354.95152-7-frederic@kernel.org --- scripts/timer_migration_tree.py | 122 +++++++++++++++++++++++++++++++- 1 file changed, 122 insertions(+) create mode 100755 scripts/timer_migration_tree.py diff --git a/scripts/timer_migration_tree.py b/scripts/timer_migration_tree= .py new file mode 100755 index 0000000..faac9de --- /dev/null +++ b/scripts/timer_migration_tree.py @@ -0,0 +1,122 @@ +#!/usr/bin/env python3 +# SPDX-License-Identifier: GPL-2.0 + +""" +Draw the timer migration tree. + +1) Boot with trace_event=3D=3Dtmigr_connect_cpu_parent,tmigr_connect_child= _parent +2) ./timer_migration_tree.py < /sys/kernel/tracing/trace +""" + +import re, sys +from ete3 import Tree + +class Node: + def __init__(self, group): + self.group =3D group + self.children =3D [] + self.parent =3D None + self.num_children =3D 0 + self.groupmask =3D 0 + self.lvl =3D -1 + + def set_groupmask(self, groupmask): + self.groupmask =3D groupmask + + def set_parent(self, parent): + self.parent =3D parent + + def add_child(self, child): + self.children.append(child) + + def set_lvl(self, lvl): + self.lvl =3D lvl + + def set_numa(self, numa): + self.numa =3D numa + + def set_num_children(self, num_children): + self.num_children =3D num_children + + def __repr__(self): + if self.parent: + parent_grp =3D self.parent.group + else: + parent_grp =3D "-" + return "Group: %s mask: %s parent: %s lvl: %d numa: %d num_children: %d"= % (self.group, self.groupmask, parent_grp, self.lvl, self.numa, self.num_c= hildren) + +hierarchies =3D { } + +def get_hierarchy(capacity): + if capacity not in hierarchies: + hierarchies[capacity] =3D {} + return hierarchies[capacity] + +def get_node(capacity, group): + hier =3D get_hierarchy(capacity) + if group in hier: + return hier[group] + else: + n =3D Node(group) + hier[group] =3D n + return n + +def tmigr_connect_cpu_parent(ts, line): + s =3D re.search("tmigr_connect_cpu_parent: cpu=3D([0-9]+) groupmask=3D([0= -9a-zA-Z]+) parent=3D([0-9a-zA-Z]+) lvl=3D([0-9]+) numa=3D([-]?[0-9]+) capa= city=3D([-]?[0-9]+) num_children=3D([0-9]+)", line) + if s is None: + return False + (cpu, groupmask, parent, lvl, numa, capacity, num_children) =3D (int(s.gr= oup(1)), s.group(2), s.group(3), int(s.group(4)), int(s.group(5)), int(s.gr= oup(6)), int(s.group(7))) + n =3D get_node(capacity, cpu) + p =3D get_node(capacity, parent) + n.set_parent(p) + n.set_groupmask(groupmask) + n.set_lvl(-1) + p.set_lvl(lvl) + p.set_numa(numa) + n.set_numa(numa) + p.set_num_children(num_children) + p.add_child(n) + +def tmigr_connect_child_parent(ts, line): + s =3D re.search("tmigr_connect_child_parent: group=3D([0-9a-zA-Z]+) group= mask=3D([0-9a-zA-Z]+) parent=3D([0-9a-zA-Z]+) lvl=3D([0-9]+) numa=3D([-]?[0= -9]+) capacity=3D([-]?[0-9]+) num_children=3D([0-9]+)", line) + if s is None: + return False + (group, groupmask, parent, lvl, numa, capacity, num_children) =3D (s.grou= p(1), s.group(2), s.group(3), int(s.group(4)), int(s.group(5)), int(s.group= (6)), int(s.group(7))) + n =3D get_node(capacity, group) + p =3D get_node(capacity, parent) + n.set_parent(p) + n.set_groupmask(groupmask) + p.set_lvl(lvl) + p.set_numa(numa) + p.set_num_children(num_children) + p.add_child(n) + +def populate(enode, node): + enode =3D enode.add_child(name =3D node.group) + enode.add_feature("groupmask", "m:%s" % node.groupmask) + enode.add_feature("lvl", "lvl:%d" % node.lvl) + enode.add_feature("numa", "node %d" % node.numa) + enode.add_feature("num_children", "c=3D%d" % node.num_children) + for child in node.children: + populate(enode, child) + +if __name__ =3D=3D "__main__": + for line in sys.stdin: + s =3D re.search("([0-9]+[.][0-9]{6}): (.+?)$", line, re.S) + if s is not None: + if tmigr_connect_cpu_parent(float(s.group(1)), s.group(2)): + continue + if tmigr_connect_child_parent(float(s.group(1)), s.group(2)): + continue + + for cap in hierarchies: + h =3D hierarchies[cap] + print("Tree for capacity %d" % cap) + for k in h: + n =3D h[k] + while n.parent !=3D None: + n =3D n.parent + root =3D Tree() + populate(root, n) + print(root.get_ascii(show_internal=3DTrue, attributes=3D["name", "numa"= , "lvl"])) + break