From nobody Tue Sep 16 16:07:33 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id BBFBEC3DA7A for ; Mon, 2 Jan 2023 10:19:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232039AbjABKTV (ORCPT ); Mon, 2 Jan 2023 05:19:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40506 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232032AbjABKTR (ORCPT ); Mon, 2 Jan 2023 05:19:17 -0500 Received: from zju.edu.cn (spam.zju.edu.cn [61.164.42.155]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id CE458FE0 for ; Mon, 2 Jan 2023 02:19:15 -0800 (PST) Received: from localhost.localdomain (unknown [10.12.77.33]) by mail-app2 (Coremail) with SMTP id by_KCgD3_fWfr7Jj3v2PCQ--.15715S4; Mon, 02 Jan 2023 18:19:11 +0800 (CST) From: Lin Ma To: jan.kiszka@siemens.com, kbingham@kernel.org, linux-kernel@vger.kernel.org Cc: Lin Ma Subject: [PATCH v3] scripts/gdb: fix 'lx-timerlist' on newer kernel Date: Mon, 2 Jan 2023 18:19:11 +0800 Message-Id: <20230102101911.12765-1-linma@zju.edu.cn> X-Mailer: git-send-email 2.17.1 X-CM-TRANSID: by_KCgD3_fWfr7Jj3v2PCQ--.15715S4 X-Coremail-Antispam: 1UD129KBjvJXoW7ZFW5JFW3KF48XF4rur4rKrg_yoW5JrW7pr W5CFWakFs7tr4Fg39Fq3WIgr13Ga1vyrWfXFWDKFs8Ar9rG3y8Way2kFy5tFy7uFnIv39x G39Yvwn8JF4UArJanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUkI1xkIjI8I6I8E6xAIw20EY4v20xvaj40_Wr0E3s1l1IIY67AE w4v_Jr0_Jr4l8cAvFVAK0II2c7xJM28CjxkF64kEwVA0rcxSw2x7M28EF7xvwVC0I7IYx2 IY67AKxVWDJVCq3wA2z4x0Y4vE2Ix0cI8IcVCY1x0267AKxVWxJVW8Jr1l84ACjcxK6I8E 87Iv67AKxVW0oVCq3wA2z4x0Y4vEx4A2jsIEc7CjxVAFwI0_GcCE3s1le2I262IYc4CY6c 8Ij28IcVAaY2xG8wAqx4xG64xvF2IEw4CE5I8CrVC2j2WlYx0E2Ix0cI8IcVAFwI0_Jr0_ Jr4lYx0Ex4A2jsIE14v26r1j6r4UMcvjeVCFs4IE7xkEbVWUJVW8JwACjcxG0xvY0x0EwI xGrwACjI8F5VA0II8E6IAqYI8I648v4I1l42xK82IYc2Ij64vIr41l42xK82IY6x8ErcxF aVAv8VW8uw4UJr1UMxC20s026xCaFVCjc4AY6r1j6r4UMI8I3I0E5I8CrVAFwI0_Jr0_Jr 4lx2IqxVCjr7xvwVAFwI0_JrI_JrWlx4CE17CEb7AF67AKxVWUAVWUtwCIc40Y0x0EwIxG rwCI42IY6xIIjxv20xvE14v26r1j6r1xMIIF0xvE2Ix0cI8IcVCY1x0267AKxVWUJVW8Jw CI42IY6xAIw20EY4v20xvaj40_Jr0_JF4lIxAIcVC2z280aVAFwI0_Jr0_Gr1lIxAIcVC2 z280aVCY1x0267AKxVW8JVW8JrUvcSsGvfC2KfnxnUUI43ZEXa7VUbXdbUUUUUU== X-CM-SenderInfo: qtrwiiyqvtljo62m3hxhgxhubq/ Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" After commit 511885d7061e ("lib/timerqueue: Rely on rbtree semantics for next timer"), the struct timerqueue_head changes the internal field hence causes the old lx-timerlist command keeps reporting errors. This fix adds a simple version comparison and necessary code for traversing timerqueue on a newer kernel. Moreover, it fixes some python 3.X compatibility bugs. Test with python 2.7 and python 3.6 Test with gdb 10.2 Signed-off-by: Lin Ma --- V1->V2: remove the support of old versions, fix typo and adjust the commit message V2->V3: remove redundant re package scripts/gdb/linux/timerlist.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/scripts/gdb/linux/timerlist.py b/scripts/gdb/linux/timerlist.py index 071d0dd5a634..85072be2a196 100644 --- a/scripts/gdb/linux/timerlist.py +++ b/scripts/gdb/linux/timerlist.py @@ -43,8 +43,10 @@ def print_timer(rb_node, idx): =20 =20 def print_active_timers(base): - curr =3D base['active']['next']['node'] - curr =3D curr.address.cast(rbtree.rb_node_type.get_type().pointer()) + # 511885d7061e ("lib/timerqueue: Rely on rbtree semantics for next tim= er") + leftmost =3D base['active']['rb_root']['rb_leftmost'] + curr =3D leftmost.cast(rbtree.rb_node_type.get_type().pointer()) + idx =3D 0 while curr: yield print_timer(curr, idx) @@ -73,10 +75,9 @@ def print_cpu(hrtimer_bases, cpu, max_clock_bases): ts =3D cpus.per_cpu(tick_sched_ptr, cpu) =20 text =3D "cpu: {}\n".format(cpu) - for i in xrange(max_clock_bases): + for i in range(max_clock_bases): text +=3D " clock {}:\n".format(i) text +=3D print_base(cpu_base['clock_base'][i]) - if constants.LX_CONFIG_HIGH_RES_TIMERS: fmts =3D [(" .{} : {} nsecs", 'expires_next'), (" .{} : {}", 'hres_active'), @@ -165,7 +166,7 @@ def pr_cpumask(mask): i -=3D 1 start =3D i * 2 end =3D start + 2 - chunks.append(buf[start:end]) + chunks.append(str(buf[start:end])) if i !=3D 0 and i % 4 =3D=3D 0: chunks.append(',') =20 @@ -184,7 +185,7 @@ class LxTimerList(gdb.Command): =20 def invoke(self, arg, from_tty): hrtimer_bases =3D gdb.parse_and_eval("&hrtimer_bases") - max_clock_bases =3D gdb.parse_and_eval("HRTIMER_MAX_CLOCK_BASES") + max_clock_bases =3D gdb.parse_and_eval("(int)HRTIMER_MAX_CLOCK_BAS= ES") =20 text =3D "Timer List Version: gdb scripts\n" text +=3D "HRTIMER_MAX_CLOCK_BASES: {}\n".format(max_clock_bases) --=20 2.17.1