Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp10390253rwl; Mon, 2 Jan 2023 01:32:04 -0800 (PST) X-Google-Smtp-Source: AMrXdXtbIjUGDyGUooqILKihnNxHSFS+MIkeHW4Br5lfbz8wuvUDXS7K7FO9bCHhBfF8v0qkH2OS X-Received: by 2002:a05:6402:4518:b0:46c:b2a7:1e03 with SMTP id ez24-20020a056402451800b0046cb2a71e03mr30802352edb.36.1672651924574; Mon, 02 Jan 2023 01:32:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672651924; cv=none; d=google.com; s=arc-20160816; b=m33g7YfvHoX2Xh865q5Q97euJnv7RCi7sDw/wsMI0eBKzAAf/HrbXalr/DPcTnwJUa YW2AFfJQzrOZFj8iETupYYeF0aSTVMm/KcKRAzxxyNnU4dLV2J0m4lMlyliYBeo1t7By rH4Yar80uWZpUPqIo3sqYTp/gzPnoer9wM/1HAjgqFDWAPiq2BtU76/DuZLFzQl6nau3 v5mXAjxfGMw7BAq+Eo1o227aou6770i3AxUiwV8H7meKL/fGVwRgVaI38MaMPYh/u7N+ 3Aem5VWRXNcw/6jtH+RcYD3Vea2KnuZGGrQZE4V53xFtzeJycaouixSgU/JfwdHf8j8d cjiw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:cc:to:from; bh=ZNmH2KCIyuKK0LXcsV0CyrCLerzxBp0RJK7SibaIoDE=; b=ha/CFJiSoTcKI8UnDUUZpAfMPRFQz5L1NBc/ke9hb7Q/v2tMMP/qu5kuPoHjUPETs0 QMFUjnjsoRFuI0a9sgCaypUPhMzZ9qxRRcCo085hd348qcxH+rnW/2NCEyARbHs4reiC zkWwWnPH5CvHKzHiZagAxc/6azz9fKaybSb4ysWNFk8t0bNDJ+gn3VGmvmxzEeTWC8b9 v1U6VhQwLYhor5Qz9iMkfOm3EIR1eMz6o3nN6OfckTq0ONVSqchC3Tpw4f7edIQPHDwT ndxlLqLfqwvxjl+SORVLvBM0rDLWVAFpFxABLnPffDOxn+lWwKM2miFDdTMYJz4BGBtq f37Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id dr17-20020a170907721100b007a31138203asi25182324ejc.669.2023.01.02.01.31.51; Mon, 02 Jan 2023 01:32:04 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229722AbjABJL4 (ORCPT + 58 others); Mon, 2 Jan 2023 04:11:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36818 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231736AbjABJLs (ORCPT ); Mon, 2 Jan 2023 04:11:48 -0500 Received: from zju.edu.cn (spam.zju.edu.cn [61.164.42.155]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id EFE451114 for ; Mon, 2 Jan 2023 01:11:46 -0800 (PST) Received: from localhost.localdomain (unknown [10.12.77.33]) by mail-app3 (Coremail) with SMTP id cC_KCgAHWLTNn7Jj6Bx6Cw--.23223S4; Mon, 02 Jan 2023 17:11:41 +0800 (CST) From: Lin Ma To: jan.kiszka@siemens.com, kbingham@kernel.org, linux-kernel@vger.kernel.org Cc: Lin Ma Subject: [PATCH v2] scripts/gdb: fix 'lx-timerlist' on newer kernel Date: Mon, 2 Jan 2023 17:11:37 +0800 Message-Id: <20230102091137.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0_Gr1UYxBIdaVFxhVjvjDU0xZFpf9x0JUdHUDUUUUU= X-CM-SenderInfo: qtrwiiyqvtljo62m3hxhgxhubq/ X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_PASS, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 scripts/gdb/linux/timerlist.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/scripts/gdb/linux/timerlist.py b/scripts/gdb/linux/timerlist.py index 071d0dd5a634..73534da92745 100644 --- a/scripts/gdb/linux/timerlist.py +++ b/scripts/gdb/linux/timerlist.py @@ -4,6 +4,7 @@ import binascii import gdb +import re from linux import constants from linux import cpus @@ -43,8 +44,10 @@ def print_timer(rb_node, idx): def print_active_timers(base): - curr = base['active']['next']['node'] - curr = curr.address.cast(rbtree.rb_node_type.get_type().pointer()) + # 511885d7061e ("lib/timerqueue: Rely on rbtree semantics for next timer") + leftmost = base['active']['rb_root']['rb_leftmost'] + curr = leftmost.cast(rbtree.rb_node_type.get_type().pointer()) + idx = 0 while curr: yield print_timer(curr, idx) @@ -73,10 +76,9 @@ def print_cpu(hrtimer_bases, cpu, max_clock_bases): ts = cpus.per_cpu(tick_sched_ptr, cpu) text = "cpu: {}\n".format(cpu) - for i in xrange(max_clock_bases): + for i in range(max_clock_bases): text += " clock {}:\n".format(i) text += print_base(cpu_base['clock_base'][i]) - if constants.LX_CONFIG_HIGH_RES_TIMERS: fmts = [(" .{} : {} nsecs", 'expires_next'), (" .{} : {}", 'hres_active'), @@ -165,7 +167,7 @@ def pr_cpumask(mask): i -= 1 start = i * 2 end = start + 2 - chunks.append(buf[start:end]) + chunks.append(str(buf[start:end])) if i != 0 and i % 4 == 0: chunks.append(',') @@ -184,7 +186,7 @@ class LxTimerList(gdb.Command): def invoke(self, arg, from_tty): hrtimer_bases = gdb.parse_and_eval("&hrtimer_bases") - max_clock_bases = gdb.parse_and_eval("HRTIMER_MAX_CLOCK_BASES") + max_clock_bases = gdb.parse_and_eval("(int)HRTIMER_MAX_CLOCK_BASES") text = "Timer List Version: gdb scripts\n" text += "HRTIMER_MAX_CLOCK_BASES: {}\n".format(max_clock_bases) -- 2.17.1