From patchwork Tue Jul 23 06:48:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kuan-Ying Lee X-Patchwork-Id: 13739587 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9C1FDC3DA64 for ; Tue, 23 Jul 2024 06:49:37 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2B4A96B00AC; Tue, 23 Jul 2024 02:49:37 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 264FF6B00BF; Tue, 23 Jul 2024 02:49:37 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0EA476B00C0; Tue, 23 Jul 2024 02:49:37 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id D92F26B00AC for ; Tue, 23 Jul 2024 02:49:36 -0400 (EDT) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 9B0251C424D for ; Tue, 23 Jul 2024 06:49:36 +0000 (UTC) X-FDA: 82370091552.28.78796A9 Received: from smtp-relay-internal-0.canonical.com (smtp-relay-internal-0.canonical.com [185.125.188.122]) by imf27.hostedemail.com (Postfix) with ESMTP id 80EE740028 for ; Tue, 23 Jul 2024 06:49:34 +0000 (UTC) Authentication-Results: imf27.hostedemail.com; dkim=pass header.d=canonical.com header.s=20210705 header.b=CampAaxH; spf=pass (imf27.hostedemail.com: domain of kuan-ying.lee@canonical.com designates 185.125.188.122 as permitted sender) smtp.mailfrom=kuan-ying.lee@canonical.com; dmarc=pass (policy=none) header.from=canonical.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1721717313; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=rC35uQ15eqvudJFKCmfhKueP5euBpEMwrUgBuRH1430=; b=fPqh1e/MPQaGuuIoiGSskUVt28Oc26oMSregW+kZRnuVG+sGebHi7u6jnkxx2AqdBn2rHp C9BxQlHekgBVMhJt4Z7qobpFu8eiakTfPwBuhw0P1dDGpOKFWsS6P6KIeHoCRE3TS9KyjA l4KoT29C76bZQ+I3YNYvM9lpQqtlRvg= ARC-Authentication-Results: i=1; imf27.hostedemail.com; dkim=pass header.d=canonical.com header.s=20210705 header.b=CampAaxH; spf=pass (imf27.hostedemail.com: domain of kuan-ying.lee@canonical.com designates 185.125.188.122 as permitted sender) smtp.mailfrom=kuan-ying.lee@canonical.com; dmarc=pass (policy=none) header.from=canonical.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1721717313; a=rsa-sha256; cv=none; b=4yUQ3/VvwoFJWiT4KYEm3ViUsJ1d1J6rV/0RN1fC5jPCCcRklQG9/FrxvXuYmtJoFzxyVF TvxJPZQUmMuHRwnafLifL3r4AMlYuTLeHeJmcSMnYYahTKckir69iJMcBgtO9pTaoIBMt/ hhDYvQAkZqebvYrn15JMsTNnjLg/O9Y= Received: from mail-pj1-f70.google.com (mail-pj1-f70.google.com [209.85.216.70]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-0.canonical.com (Postfix) with ESMTPS id 1A4493F1EE for ; Tue, 23 Jul 2024 06:49:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1721717373; bh=rC35uQ15eqvudJFKCmfhKueP5euBpEMwrUgBuRH1430=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=CampAaxH3Di0LFQkZ+08akaVRVHBHWp+eWMfWj9gs9u8K17cQxubn6+F+5aoKI/Dv lBQCosqAK73Q5UpqQ/21I4MSd1HAPtTNDfIXDeESzDhgRcdSKkMdBYsfFKqKCM+ro6 Et6UHyZM98LiZ08YYvRgPBDOIoed440VC6QnnpSbI9pI1i+xgfDWG8lB/zc4DDSf0o KmksX1/E9Dfpni8Xst5+7qMlZ6Mc8/4Q9wtIUzwbwD+plYVntXwQZrmz8RGGNShLAq m3tlb6ky82C1TU+eFKS4Kgu7dLEWZf4MSSrpQ7whcOsLWaVZoUuINBUN92EM2yQVEL nq0IZJu2QOJ8w== Received: by mail-pj1-f70.google.com with SMTP id 98e67ed59e1d1-2cb7364bac9so4766987a91.0 for ; Mon, 22 Jul 2024 23:49:33 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721717371; x=1722322171; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=rC35uQ15eqvudJFKCmfhKueP5euBpEMwrUgBuRH1430=; b=tN6GWJSllxjVzFuL5RikqLnZy0H9DYE1tatZUcDYD29p/gomuAtKmEEiyJNlNzN3P6 sWibANY9dFUW9l3D0xxGY5Jn7FIhLV033jbw1tYR6UnVEGmIUnF1btqKXCNU4Kk6wAZ+ YI2MEEdMxqn2bwp2/81Lx8x70mw/EuoDDFtbiNFMeKENkHKSK7sBM3Z96WrW7VyDRoa6 O8dERAdmaS+vBuXBNUUrOjS0qsfavzUfJAWSMU5BkFdiNOj/M6xO8YATCEULFJHhesCH fhbm7sYv1qRQ+erGp+00CxTtef37QAbrh4iM+cV5NgCaBsUpSkjD6WW0Cyq2g/qyKbJB XDuw== X-Gm-Message-State: AOJu0YzNUqVYHV/1J8xRUvYUsRvscc1Pu6Am0heZO2mOGHc+j19eqj6o +ibLMrBXxj/2fjFpN9BlbRI9bg1Y9syKYeihMCIYgan3DQtTaQ0hCOTOe/3emiGUmWdRl/+o/jB LMq0MNacZu/ebzSvyIQIs+pLTTlAJgfVKn3+sfRDLQgUnQ78terXdGeVp2VpjvEkA X-Received: by 2002:a17:90b:4c8a:b0:2c7:d24b:57f with SMTP id 98e67ed59e1d1-2cd8d11c9ccmr1897651a91.19.1721717371634; Mon, 22 Jul 2024 23:49:31 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGdcDBoDGFSCrA52BVnISHDjdXUedskgJ+Mos8j+PlbYjDf49OcjwGMpoau4hD8clEwbyyrBQ== X-Received: by 2002:a17:90b:4c8a:b0:2c7:d24b:57f with SMTP id 98e67ed59e1d1-2cd8d11c9ccmr1897632a91.19.1721717371242; Mon, 22 Jul 2024 23:49:31 -0700 (PDT) Received: from kylee-ThinkPad-E16-Gen-1.. ([122.147.171.160]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2ccf7c5391bsm8354749a91.24.2024.07.22.23.49.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Jul 2024 23:49:31 -0700 (PDT) From: Kuan-Ying Lee To: kuan-ying.lee@canonical.com, Andrew Morton , Jan Kiszka , Kieran Bingham , Thomas Gleixner , Frederic Weisbecker Cc: linux-mm@kvack.org, stable@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 1/5] scripts/gdb: fix timerlist parsing issue Date: Tue, 23 Jul 2024 14:48:57 +0800 Message-Id: <20240723064902.124154-2-kuan-ying.lee@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240723064902.124154-1-kuan-ying.lee@canonical.com> References: <20240723064902.124154-1-kuan-ying.lee@canonical.com> MIME-Version: 1.0 X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 80EE740028 X-Stat-Signature: eunw83q81dfz7cc4guh1kytb3fawombg X-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gtYYaGR1KhDvvhtoQzPcpb2Z74Yhbst3UGFN2LSBeri86fwg54pVBjoTLXM2CsMyBoJm5Wy96uKYwSdbcZ2eFLJlXN0muCLcYi1OVBeXOwBbJPKXNJSVltdTGSQio62qNOOcZEShoNPp0uzzYzTO3nNgw2RDGaxvoRCX/yiWPoVtwrQMQhKGtifPswIkP0/dNg5sGnt57lYPkzYfGiATHzoI+xoK1xCJRV2PPEsU6X0nigqHI1IGxJj1254MrEwSRv3SgL4FjzQL50L3qSW7onitrJoWf/ApbriI+wnqDVdZSVzMTScsAQsXuzWBhY3x/BW2VLuHxaME3ENxkoGZ X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Commit 7988e5ae2be7 ("tick: Split nohz and highres features from nohz_mode") and commit 7988e5ae2be7 ("tick: Split nohz and highres features from nohz_mode") move 'tick_stopped' and 'nohz_mode' to flags field which will break the gdb lx-mounts command: (gdb) lx-timerlist Python Exception : There is no member named nohz_mode. Error occurred in Python: There is no member named nohz_mode. (gdb) lx-timerlist Python Exception : There is no member named tick_stopped. Error occurred in Python: There is no member named tick_stopped. We move 'tick_stopped' and 'nohz_mode' to flags field instead. Fixes: a478ffb2ae23 ("tick: Move individual bit features to debuggable mask accesses") Fixes: 7988e5ae2be7 ("tick: Split nohz and highres features from nohz_mode") Cc: Signed-off-by: Kuan-Ying Lee --- scripts/gdb/linux/timerlist.py | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/scripts/gdb/linux/timerlist.py b/scripts/gdb/linux/timerlist.py index 64bc87191003..98445671fe83 100644 --- a/scripts/gdb/linux/timerlist.py +++ b/scripts/gdb/linux/timerlist.py @@ -87,21 +87,22 @@ def print_cpu(hrtimer_bases, cpu, max_clock_bases): text += "\n" if constants.LX_CONFIG_TICK_ONESHOT: - fmts = [(" .{} : {}", 'nohz_mode'), - (" .{} : {} nsecs", 'last_tick'), - (" .{} : {}", 'tick_stopped'), - (" .{} : {}", 'idle_jiffies'), - (" .{} : {}", 'idle_calls'), - (" .{} : {}", 'idle_sleeps'), - (" .{} : {} nsecs", 'idle_entrytime'), - (" .{} : {} nsecs", 'idle_waketime'), - (" .{} : {} nsecs", 'idle_exittime'), - (" .{} : {} nsecs", 'idle_sleeptime'), - (" .{}: {} nsecs", 'iowait_sleeptime'), - (" .{} : {}", 'last_jiffies'), - (" .{} : {}", 'next_timer'), - (" .{} : {} nsecs", 'idle_expires')] - text += "\n".join([s.format(f, ts[f]) for s, f in fmts]) + TS_FLAG_STOPPED = 1 << 1 + TS_FLAG_NOHZ = 1 << 4 + text += f" .{'nohz':15s}: {int(bool(ts['flags'] & TS_FLAG_NOHZ))}\n" + text += f" .{'last_tick':15s}: {ts['last_tick']}\n" + text += f" .{'tick_stopped':15s}: {int(bool(ts['flags'] & TS_FLAG_STOPPED))}\n" + text += f" .{'idle_jiffies':15s}: {ts['idle_jiffies']}\n" + text += f" .{'idle_calls':15s}: {ts['idle_calls']}\n" + text += f" .{'idle_sleeps':15s}: {ts['idle_sleeps']}\n" + text += f" .{'idle_entrytime':15s}: {ts['idle_entrytime']} nsecs\n" + text += f" .{'idle_waketime':15s}: {ts['idle_waketime']} nsecs\n" + text += f" .{'idle_exittime':15s}: {ts['idle_exittime']} nsecs\n" + text += f" .{'idle_sleeptime':15s}: {ts['idle_sleeptime']} nsecs\n" + text += f" .{'iowait_sleeptime':15s}: {ts['iowait_sleeptime']} nsecs\n" + text += f" .{'last_jiffies':15s}: {ts['last_jiffies']}\n" + text += f" .{'next_timer':15s}: {ts['next_timer']}\n" + text += f" .{'idle_expires':15s}: {ts['idle_expires']} nsecs\n" text += "\njiffies: {}\n".format(jiffies) text += "\n" From patchwork Tue Jul 23 06:48:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kuan-Ying Lee X-Patchwork-Id: 13739588 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5C015C3DA63 for ; Tue, 23 Jul 2024 06:49:40 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DD8296B00C1; Tue, 23 Jul 2024 02:49:39 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D886B6B00C2; Tue, 23 Jul 2024 02:49:39 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BB48A6B00C3; Tue, 23 Jul 2024 02:49:39 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 9B4C76B00C1 for ; Tue, 23 Jul 2024 02:49:39 -0400 (EDT) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 580C5A1C69 for ; Tue, 23 Jul 2024 06:49:39 +0000 (UTC) X-FDA: 82370091678.05.8F84E8F Received: from smtp-relay-internal-1.canonical.com (smtp-relay-internal-1.canonical.com [185.125.188.123]) by imf04.hostedemail.com (Postfix) with ESMTP id 4FFDB4000A for ; Tue, 23 Jul 2024 06:49:37 +0000 (UTC) Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=canonical.com header.s=20210705 header.b=j69J5RcG; spf=pass (imf04.hostedemail.com: domain of kuan-ying.lee@canonical.com designates 185.125.188.123 as permitted sender) smtp.mailfrom=kuan-ying.lee@canonical.com; dmarc=pass (policy=none) header.from=canonical.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1721717330; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=FZLjJAcXmHbLrd6SXPvE5R1r1QmGlvoXd3SP54bkBhg=; b=JXlIoxfsYOsErCbIJeZq4kmvJ1tJSPiH6/ROl0sF8KxmZn1LH3oqwVqDE5Ug6L3ZgiF6bR KyOb0cw7lsymcgs76DsCIY8WZmxtSttaHaJZM/hUjWG0tSsNij3e8zhefi0JlFnx5T67w4 o+FKlU+37jdbuqUkSNLorPVaqg9HsoI= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1721717330; a=rsa-sha256; cv=none; b=afgTwyCPXfRaosumSxAewmbVHa4I3f8W/3LWnW/QvcdIlBNVOyj9fXahOsbfGo9wy+l9Fu lKmrQYRAoOxYh5UoJhDeQmUctJnNADVEGaSDZuwMUAQM0g4em5+KcM6puJH5v37o1gtCH1 /knhKwsj/TgX09NAvJBb9nARbNvgy18= ARC-Authentication-Results: i=1; imf04.hostedemail.com; dkim=pass header.d=canonical.com header.s=20210705 header.b=j69J5RcG; spf=pass (imf04.hostedemail.com: domain of kuan-ying.lee@canonical.com designates 185.125.188.123 as permitted sender) smtp.mailfrom=kuan-ying.lee@canonical.com; dmarc=pass (policy=none) header.from=canonical.com Received: from mail-pj1-f72.google.com (mail-pj1-f72.google.com [209.85.216.72]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-1.canonical.com (Postfix) with ESMTPS id 1936A400E1 for ; Tue, 23 Jul 2024 06:49:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1721717376; bh=FZLjJAcXmHbLrd6SXPvE5R1r1QmGlvoXd3SP54bkBhg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=j69J5RcGCzLUn5UlZ/qkrBR1Ps94MbfOkcZ5rtUQ5gQWBH9Gr+fVIia2RB7KYjZsg bALczu06VN9yjkRlqhCNpx6DlX61YnDYeRz2UvO8xVl0CF5bd0aYG3oR4zCXIFlh+Z aL1mbnh//8Lr2/s9RZ9RU/5SOoft5TZam0TF05hxSsT+E6g9L6yiVCFbLv/I/PzzKf 7fgXigCqXefQX47ITElK9prElTe60AU2alN80mbvY/x/buN6zk2E+YbLcP0kFn42cY 8IGQGjFmn2YRCCPFc0naJ2m7/wtdBU2TqYjF/Im3C+v2WgG41osL89/r72eSIDHhnv QkfTrMEuqHbXQ== Received: by mail-pj1-f72.google.com with SMTP id 98e67ed59e1d1-2cd4e722d82so1917765a91.3 for ; Mon, 22 Jul 2024 23:49:36 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721717375; x=1722322175; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=FZLjJAcXmHbLrd6SXPvE5R1r1QmGlvoXd3SP54bkBhg=; b=wOIyfkDYXPhhGweZSq+JX98xK/OS7eYyom/paoQIGlyILl0a24UO/p+XDVX+gHZDcy 87919VuoLtoKyFrtMTODGFMyI5nvK5cEEpIM5ZnTh0uWVwRLrAy3jY8strBLTUoD2U0d 5J+sChzDVoPItFaOjSQ7Zm0uwhWUKSgnk8vTZuatOFdeqr6je6AZi6nRJ+v6e0GgkoGy Py31H368tmezuFHAiMwYVQCmT8IN4OeclojBkz87xe/XU59zNiK7GglJK3tNhJkj5uQM zmuDPOxkfqH66wXdPZyvRD5urCS6ttQUkAjEQmFEUPZncGYvxzYrULNTr8gwxKFC7UpJ mW8g== X-Gm-Message-State: AOJu0YzK4AJBWqc4ir8OqEmzcX1w86Z7OvGCYUThg4DKwheYSoX3L8RI qZ8VXUEmLgiwLyWShfCaBcQ+EphUcv/YBiiiCB9Kk+1QYnvu4nvbETCMoJ/SgAgbuX0VEckYePo tlGzhek0yyx1NfdUITx8qPti2dVrVzTMjEY5VG+/vNkM6CNWSujnr0t0bDEbEa4Tx X-Received: by 2002:a17:90b:1b01:b0:2c9:860c:7802 with SMTP id 98e67ed59e1d1-2cd274adcc9mr4794634a91.28.1721717374744; Mon, 22 Jul 2024 23:49:34 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEyHMUKv6gR8JgkHmVIVGpYTx4tb8B3QCJ9HWDbWwLfpovncTtZcuCPQHfoJdvHkml9CbbRnA== X-Received: by 2002:a17:90b:1b01:b0:2c9:860c:7802 with SMTP id 98e67ed59e1d1-2cd274adcc9mr4794620a91.28.1721717374355; Mon, 22 Jul 2024 23:49:34 -0700 (PDT) Received: from kylee-ThinkPad-E16-Gen-1.. ([122.147.171.160]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2ccf7c5391bsm8354749a91.24.2024.07.22.23.49.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Jul 2024 23:49:34 -0700 (PDT) From: Kuan-Ying Lee To: kuan-ying.lee@canonical.com, Andrew Morton , Jan Kiszka , Kieran Bingham , Miklos Szeredi , Christian Brauner , Ian Kent Cc: linux-mm@kvack.org, stable@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 2/5] scripts/gdb: add iteration function for rbtree Date: Tue, 23 Jul 2024 14:48:58 +0800 Message-Id: <20240723064902.124154-3-kuan-ying.lee@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240723064902.124154-1-kuan-ying.lee@canonical.com> References: <20240723064902.124154-1-kuan-ying.lee@canonical.com> MIME-Version: 1.0 X-Stat-Signature: tnmrss6bimxu7ah61uomfwnhmtaz1aap X-Rspamd-Queue-Id: 4FFDB4000A X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1721717377-85667 X-HE-Meta: U2FsdGVkX1+0yADuclpwYLGJdRTwfXaszbLHW1rmuN26Ue00NVhhE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LzHmfMN2aY2GfNZxjkntio5cjZqUSJokYxZqXn70Qb+hV69uaJDvb/B/WmIG0QntpVJWrvIK6Zwcs7YJvLSSh68ZowG2h9fVgziirQs28o+3pZEwaKbyOgixjqsuAYVBybWUPWA+5mlZB1cIC+t/T6TgXE775tqc8Vj9N0Mno324gj4CH3myusmZMTAC22FaAAZ31liyXbaoyjQXFlMQm0pFoq/OlQY9c9BoPq02BxfYZr2cnDEPhM X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Add inorder iteration function for rbtree usage. This is a preparation patch for the next patch to fix the gdb mounts issue. Fixes: 2eea9ce4310d ("mounts: keep list of mounts in an rbtree") Cc: Signed-off-by: Kuan-Ying Lee --- scripts/gdb/linux/rbtree.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/scripts/gdb/linux/rbtree.py b/scripts/gdb/linux/rbtree.py index fe462855eefd..fcbcc5f4153c 100644 --- a/scripts/gdb/linux/rbtree.py +++ b/scripts/gdb/linux/rbtree.py @@ -9,6 +9,18 @@ from linux import utils rb_root_type = utils.CachedType("struct rb_root") rb_node_type = utils.CachedType("struct rb_node") +def rb_inorder_for_each(root): + def inorder(node): + if node: + yield from inorder(node['rb_left']) + yield node + yield from inorder(node['rb_right']) + + yield from inorder(root['rb_node']) + +def rb_inorder_for_each_entry(root, gdbtype, member): + for node in rb_inorder_for_each(root): + yield utils.container_of(node, gdbtype, member) def rb_first(root): if root.type == rb_root_type.get_type(): From patchwork Tue Jul 23 06:48:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kuan-Ying Lee X-Patchwork-Id: 13739589 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 69EC5C3DA63 for ; Tue, 23 Jul 2024 06:49:44 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E27F36B00C3; Tue, 23 Jul 2024 02:49:43 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id DAFD36B00C4; Tue, 23 Jul 2024 02:49:43 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C2B966B00C5; Tue, 23 Jul 2024 02:49:43 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id A2B196B00C3 for ; Tue, 23 Jul 2024 02:49:43 -0400 (EDT) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 44A6C161D49 for ; Tue, 23 Jul 2024 06:49:43 +0000 (UTC) X-FDA: 82370091846.08.ED221F5 Received: from smtp-relay-internal-1.canonical.com (smtp-relay-internal-1.canonical.com [185.125.188.123]) by imf15.hostedemail.com (Postfix) with ESMTP id 1EF5EA001B for ; Tue, 23 Jul 2024 06:49:40 +0000 (UTC) Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=canonical.com header.s=20210705 header.b=QZmzfd7d; spf=pass (imf15.hostedemail.com: domain of kuan-ying.lee@canonical.com designates 185.125.188.123 as permitted sender) smtp.mailfrom=kuan-ying.lee@canonical.com; dmarc=pass (policy=none) header.from=canonical.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1721717319; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=SSby+veWhYFs/KPIxtuFQP9fWzklyucEzByPv4c+H1w=; b=xfCbEC0qI1F7WTRPnFy0Pu2giBiciRjBLZfQJqYeyiEWjrNSx8LJ/or4o1J3CsrtkY45WC 9DgUQ1uYVZ3+vS3Onr50cGiLYGi27M/OyTbSXS86PJotXLL35VWHbC938v+sZnY1/aGm3o 7uhADMK2NKDQ9xpbsYyTvSx3xnZIysU= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=pass header.d=canonical.com header.s=20210705 header.b=QZmzfd7d; spf=pass (imf15.hostedemail.com: domain of kuan-ying.lee@canonical.com designates 185.125.188.123 as permitted sender) smtp.mailfrom=kuan-ying.lee@canonical.com; dmarc=pass (policy=none) header.from=canonical.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1721717319; a=rsa-sha256; cv=none; b=Lzi6tF9iaIQSGWci38ehJ5+GqDdttHsG/uHjVhErGWIyFukmPG/P+7NTUqsexSqFN1sbgD TMaAwX/alNzP3Y1/DoCHd8vvFyjYkcn6Hc49aFRjxqWaM4gUliAbP++7dajGw8Atsu9MLq lKMCCFx9zqeT4br9YRFKyQdlpZTUlyE= Received: from mail-pg1-f198.google.com (mail-pg1-f198.google.com [209.85.215.198]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-1.canonical.com (Postfix) with ESMTPS id D90A0401AE for ; Tue, 23 Jul 2024 06:49:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1721717379; bh=SSby+veWhYFs/KPIxtuFQP9fWzklyucEzByPv4c+H1w=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=QZmzfd7dB0K8vSbyizDbW0rjiOZCmzKQDTD1DS/GKZn7AG4xAk4+d3g535VV4abbz ar3HW4NVPjvnOz/KGsXIgKxSammVFQ/gZvAe05PrQvJarHgI7lE31GkWK0QgL/9ZP+ I2T57fHCzxg+GP69ZOgA8sMLSdE+c5tm6ZpFxB9tS4AZA48/hi5sg7qBwIxkDkJzmE IEezJ0S+HDr+B8+aoXzEGt4obRJWKtEkyBSBlLpJigktps1XwOfO9cMDjD8QYbM3ZK SicFBUn+YyQtoglb5OsICfmePMbv2tICdaqTS39pdXpUt8kFAQxt8CrSS98A0dq8t4 hFdhb3jlihCJw== Received: by mail-pg1-f198.google.com with SMTP id 41be03b00d2f7-7a242496838so450016a12.3 for ; Mon, 22 Jul 2024 23:49:39 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721717378; x=1722322178; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=SSby+veWhYFs/KPIxtuFQP9fWzklyucEzByPv4c+H1w=; b=fm431D21XsOEz6AlfO0w3CYYL0v9WD4iDJGxm/wFhTu7T6US4/+RoF7srj6mBHpK9G xdoTU1g2CrBRBvpDJoHC1IbIgJ8LpRN0g5cJHY6cNG/YqFLpx2zPN7Hkl40WhPI4Edur YBdT2BIfgd6Fg7W//vE/KCcdrIC9TroVk4jfns53b7nweBDzZYOmSD9f33b1HRZz3dxh YZVOXXkUF8E51s08ZMkjbawTHn5uH07u4CkpzBg/pBMmlts2fLpE5AglzcM9hm7lE4tX iuqhVjVzZ019Eu4THuKz9s+JiMYG6AaOfKk1vOQN5+zm1AUHTZAi0rRyGylVhWMYhxPh l6Zw== X-Gm-Message-State: AOJu0YxyymkxQAZDs9nOgrwKtaL44ksGF4JTogngt8PGNoGFGArgW9GP VIINA4Dj3Ph9H+cAWsbuMAmm7hGu4hB99NWI3e9fQUb0uEePoeC7NJKC1/wuv2gPwOkBg/7IuY1 GqFJjxtS8ml5jaKDwdwlS7OzZf5K88jm41c6D/tflcQr+S882w2WoWEk4ZiD4KTde X-Received: by 2002:a05:6a20:6f04:b0:1c3:ff33:277e with SMTP id adf61e73a8af0-1c44f86c92cmr2110006637.32.1721717378103; Mon, 22 Jul 2024 23:49:38 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGDabqAEkCpkyaJ7TFPUAZCurxHz2+fpzUWqrGvdUCtX2upCViYYzhYgk3ASQ8CzhkJfiBe6w== X-Received: by 2002:a05:6a20:6f04:b0:1c3:ff33:277e with SMTP id adf61e73a8af0-1c44f86c92cmr2109987637.32.1721717377759; Mon, 22 Jul 2024 23:49:37 -0700 (PDT) Received: from kylee-ThinkPad-E16-Gen-1.. ([122.147.171.160]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2ccf7c5391bsm8354749a91.24.2024.07.22.23.49.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Jul 2024 23:49:37 -0700 (PDT) From: Kuan-Ying Lee To: kuan-ying.lee@canonical.com, Andrew Morton , Jan Kiszka , Kieran Bingham , Christian Brauner , Ian Kent , Miklos Szeredi Cc: linux-mm@kvack.org, stable@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 3/5] scripts/gdb: fix lx-mounts command error Date: Tue, 23 Jul 2024 14:48:59 +0800 Message-Id: <20240723064902.124154-4-kuan-ying.lee@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240723064902.124154-1-kuan-ying.lee@canonical.com> References: <20240723064902.124154-1-kuan-ying.lee@canonical.com> MIME-Version: 1.0 X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 1EF5EA001B X-Stat-Signature: ky8ugo75bmcc3aj56rtgzmc5hjeo468n X-Rspam-User: X-HE-Tag: 1721717380-964617 X-HE-Meta: U2FsdGVkX18Ga/6zX+2G6cukIXMJmUzguPR+S7ajeI9QPTZiMLkP1gXAkv4zkc4mJC1Gkjj43d5zYSxmSu2V8+qg5eAC/cXo7W6eTlFfveJ49hwOGJJGVkp0GyortQHhfYCRkcCVSBx6m+l/obErT90I0VVtWkUpLicLr8IQ/8OopJ/+T1CptEg0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F1b/HxhYHfmrbEz5JGtTLNmbdMs4cxMJKwSAJIKeNSfzuVOiNr9PtsSeSlc6EPygtD+1K7m92pYJV+t5rS8LOAE7kyt4sqx3ep77D4JwiqV+Jjst3GrmTo X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: (gdb) lx-mounts mount super_block devname pathname fstype options Python Exception : There is no member named list. Error occurred in Python: There is no member named list. We encoutner the above issue after commit 2eea9ce4310d ("mounts: keep list of mounts in an rbtree"). The commit move a mount from list into rbtree. So we can instead use rbtree to iterate all mounts information. Fixes: 2eea9ce4310d ("mounts: keep list of mounts in an rbtree") Cc: Signed-off-by: Kuan-Ying Lee --- scripts/gdb/linux/proc.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/gdb/linux/proc.py b/scripts/gdb/linux/proc.py index 43c687e7a69d..65dd1bd12964 100644 --- a/scripts/gdb/linux/proc.py +++ b/scripts/gdb/linux/proc.py @@ -18,6 +18,7 @@ from linux import utils from linux import tasks from linux import lists from linux import vfs +from linux import rbtree from struct import * @@ -172,8 +173,7 @@ values of that process namespace""" gdb.write("{:^18} {:^15} {:>9} {} {} options\n".format( "mount", "super_block", "devname", "pathname", "fstype")) - for mnt in lists.list_for_each_entry(namespace['list'], - mount_ptr_type, "mnt_list"): + for mnt in rbtree.rb_inorder_for_each_entry(namespace['mounts'], mount_ptr_type, "mnt_node"): devname = mnt['mnt_devname'].string() devname = devname if devname else "none" From patchwork Tue Jul 23 06:49:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kuan-Ying Lee X-Patchwork-Id: 13739590 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id BE003C3DA49 for ; Tue, 23 Jul 2024 06:49:46 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2DCCD6B00C6; Tue, 23 Jul 2024 02:49:46 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 28D1E6B00C7; Tue, 23 Jul 2024 02:49:46 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 01BA46B00C8; Tue, 23 Jul 2024 02:49:45 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id D64C06B00C6 for ; Tue, 23 Jul 2024 02:49:45 -0400 (EDT) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 7A88681D19 for ; Tue, 23 Jul 2024 06:49:45 +0000 (UTC) X-FDA: 82370091930.05.485BEBC Received: from smtp-relay-internal-0.canonical.com (smtp-relay-internal-0.canonical.com [185.125.188.122]) by imf15.hostedemail.com (Postfix) with ESMTP id 69AD9A000E for ; Tue, 23 Jul 2024 06:49:43 +0000 (UTC) Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=canonical.com header.s=20210705 header.b=sAaNEfTP; spf=pass (imf15.hostedemail.com: domain of kuan-ying.lee@canonical.com designates 185.125.188.122 as permitted sender) smtp.mailfrom=kuan-ying.lee@canonical.com; dmarc=pass (policy=none) header.from=canonical.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1721717322; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=p8WnU9klM9imNroT/ir5Cxun9HbZF+Zv15lDq/QcnHE=; b=pRMwOlLIinSe1CMu4HaIpJe39P2PAT+Q1hvyvtPKYe2dkDDfle5koXZ7C7YX7U78A+uh1w MfR1IO4ESfgYeb/EPHWchqCSY9SMOBIvAcFZ9GCZ9y8hfbpyrFIc1MCVX1Cq4/GJmT0TKi ol8F8RDEPAz1S2NLgEhGH5mv2KbOL/4= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=pass header.d=canonical.com header.s=20210705 header.b=sAaNEfTP; spf=pass (imf15.hostedemail.com: domain of kuan-ying.lee@canonical.com designates 185.125.188.122 as permitted sender) smtp.mailfrom=kuan-ying.lee@canonical.com; dmarc=pass (policy=none) header.from=canonical.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1721717322; a=rsa-sha256; cv=none; b=KMeXL1+hV3j1+KeztvEeW2ewPDUSdIPaI0qjbkPdiOUDEN9U8xFzFsRoyr8kzOK/S89HhR Y6OQmJF9rMOaZ1Qf533nMJh1e0n8vHR82lMO3usPwie8a5YR28PjWdNFawRui4alar92lE e8L7ty27hZSFvpRmKMpzEH27DmUWAqA= Received: from mail-pj1-f69.google.com (mail-pj1-f69.google.com [209.85.216.69]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-0.canonical.com (Postfix) with ESMTPS id E06B03F69B for ; Tue, 23 Jul 2024 06:49:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1721717381; bh=p8WnU9klM9imNroT/ir5Cxun9HbZF+Zv15lDq/QcnHE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=sAaNEfTPngXFMsXzwBKH8RlOqLk6C6WZjYnTf+8NdUhMJ2uQEiu/+ajmfmWDTu0u8 xAVBHrN3EMpsvLdJnwBYDKJBb7UQcCXkMPst+cIKbJHBOUNqfxxZziTTIYHdebCMqj kFgPWKNUFZr8kx5Uu2fJwb/kVQ+iDSK/RtGn8MFH8015UMsK0n7RE01p/tHmHUHVl7 r6Bsq8clz59+i5Q3AJ8xwVTNAlfPxK8ZOqgUS3JzHhrELNFX+Ny4133PUdtdIUnwuL a6BMvwE0LKFVxfeCi0buQxSXBJ0TFh2MLi6B723NEv2ACJZlREX9ctKl5MfkwTKTtW Wu4LotgoJ2Mvg== Received: by mail-pj1-f69.google.com with SMTP id 98e67ed59e1d1-2cb576921b6so4526479a91.1 for ; Mon, 22 Jul 2024 23:49:41 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721717380; x=1722322180; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=p8WnU9klM9imNroT/ir5Cxun9HbZF+Zv15lDq/QcnHE=; b=DkXJD/hH3oHRhPlVgs95Amr9MF6rkY2tvEvSunwGvdk+hMBncsv5mh0hpbaLQF0KSK sDQyiuH49bkHoXLWH677qmSgweNGBRrGEZjFoVwyEU9pCHqBqzXdHCX9zMIWGusos5j/ p8qgKhQCzZOyRNcFvyNQe+IlcIEm9X5yswjILN/6JfC8lNvKoLu9Sp64jKUtoKapnWSY 8g8ZsacK7YrhyvPzqoQk0OTnkKwzBjd2RF9at6n0OM7NP6lKUdVaKtRbYpoeqcM0t3WW pvlvGl1/K860Ti0TjpwtVw72gUv6z2BAobhwsaYolevXgqsV4thHPWTUArtjdU1rNjTy HDHw== X-Gm-Message-State: AOJu0YycKrIgeA+gx/4WzoqKMYsYsBpVdEgtbvHN+sZhvs01eS8irDzl 7kZscAyXzc/gGc0tsUPMSJxbImn2j1MV9CCIGHym4+KIgD7KWbQAQb2tLXR2qKQI1Ek5iIAJnNY TrlZ2Ki+69//dpcXy1+8f7yAzPQ7xFc6S5MWwsuwRVkytjOOt/2oK+kwwSOjFdZbk X-Received: by 2002:a17:90a:734b:b0:2c9:90f5:cfca with SMTP id 98e67ed59e1d1-2cd274dabb9mr4925273a91.42.1721717380519; Mon, 22 Jul 2024 23:49:40 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEAsMwdXkeKQBJPyfug9/lQ1wFoE87H0ZOyB6iwoKjmcAasHQ62oHoidxTUkiX05wTzPVeRCA== X-Received: by 2002:a17:90a:734b:b0:2c9:90f5:cfca with SMTP id 98e67ed59e1d1-2cd274dabb9mr4925257a91.42.1721717380184; Mon, 22 Jul 2024 23:49:40 -0700 (PDT) Received: from kylee-ThinkPad-E16-Gen-1.. ([122.147.171.160]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2ccf7c5391bsm8354749a91.24.2024.07.22.23.49.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Jul 2024 23:49:40 -0700 (PDT) From: Kuan-Ying Lee To: kuan-ying.lee@canonical.com, Andrew Morton , Jan Kiszka , Kieran Bingham Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 4/5] scripts/gdb: Add 'lx-stack_depot_lookup' command. Date: Tue, 23 Jul 2024 14:49:00 +0800 Message-Id: <20240723064902.124154-5-kuan-ying.lee@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240723064902.124154-1-kuan-ying.lee@canonical.com> References: <20240723064902.124154-1-kuan-ying.lee@canonical.com> MIME-Version: 1.0 X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 69AD9A000E X-Stat-Signature: o1e33t59q3gmy18wny75qn6t5kukdwdm X-Rspam-User: X-HE-Tag: 1721717383-657978 X-HE-Meta: U2FsdGVkX18L29uFP2omWjdDLkCQ/JPGBzqV3cRc+yR09v5Kl4vWcAMngPYOHQcLQmg3NWz/HLsWzfBBi4nXeHbUt5/JWHDSFP4cp5U03sHTGe7WJkT1JoICb+685qf/aPBNqle88FYfl5FCDD7egoQ5QSWZfFOfGYmwrGdatqdsrqphOv66W1ZRDH+Gbf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Gsn2L1NEz+n2v/lw6NW6SqxNlNu9KQD1/P3VOfCBHYgOuK4js3FTjxSTm7SPi15Jmh4uH7QqebEBArNzGHoXJT+6b3C/38ao8= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: This command allows users to quickly retrieve a stacktrace using a handle obtained from a memory coredump. Example output: (gdb) lx-stack_depot_lookup 0x00c80300 0xffff8000807965b4 : mov x20, x0 0xffff800081a077d8 : mov x1, x0 0xffff800081a079a0 : cbnz w0, 0xffff800081a07968 0xffff800082f4a3fc : ldr x19, [sp, #16] 0xffff800080a0fb34 : ldp x3, x4, [sp, #96] 0xffff800080a0a550 : ldp x19, x20, [sp, #16] 0xffff8000808e7b40 : mov w5, w0 0xffff800080a0b8ac : mov x23, x0 0xffff800080914a48 : mov x6, x0 0xffff8000809151c4 : ldr x21, [sp, #32] Signed-off-by: Kuan-Ying Lee --- scripts/gdb/linux/stackdepot.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/scripts/gdb/linux/stackdepot.py b/scripts/gdb/linux/stackdepot.py index bb3a0f843931..37313a5a51a0 100644 --- a/scripts/gdb/linux/stackdepot.py +++ b/scripts/gdb/linux/stackdepot.py @@ -13,6 +13,13 @@ if constants.LX_CONFIG_STACKDEPOT: stack_record_type = utils.CachedType('struct stack_record') DEPOT_STACK_ALIGN = 4 +def help(): + t = """Usage: lx-stack_depot_lookup [Hex handle value] + Example: + lx-stack_depot_lookup 0x00c80300\n""" + gdb.write("Unrecognized command\n") + raise gdb.GdbError(t) + def stack_depot_fetch(handle): global DEPOT_STACK_ALIGN global stack_record_type @@ -57,3 +64,23 @@ def stack_depot_print(handle): gdb.execute("x /i 0x%x" % (int(entries[i]))) except Exception as e: gdb.write("%s\n" % e) + +class StackDepotLookup(gdb.Command): + """Search backtrace by handle""" + + def __init__(self): + if constants.LX_CONFIG_STACKDEPOT: + super(StackDepotLookup, self).__init__("lx-stack_depot_lookup", gdb.COMMAND_SUPPORT) + + def invoke(self, args, from_tty): + if not constants.LX_CONFIG_STACKDEPOT: + raise gdb.GdbError('CONFIG_STACKDEPOT is not set') + + argv = gdb.string_to_argv(args) + if len(argv) == 1: + handle = int(argv[0], 16) + stack_depot_print(gdb.Value(handle).cast(utils.get_uint_type())) + else: + help() + +StackDepotLookup() From patchwork Tue Jul 23 06:49:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kuan-Ying Lee X-Patchwork-Id: 13739591 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5AE66C3DA63 for ; Tue, 23 Jul 2024 06:49:49 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8D4666B00C7; Tue, 23 Jul 2024 02:49:48 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 881EB6B00C8; Tue, 23 Jul 2024 02:49:48 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 684706B00C9; Tue, 23 Jul 2024 02:49:48 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 4697A6B00C7 for ; Tue, 23 Jul 2024 02:49:48 -0400 (EDT) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id F3BF0161D58 for ; Tue, 23 Jul 2024 06:49:47 +0000 (UTC) X-FDA: 82370092056.18.35B53AB Received: from smtp-relay-internal-1.canonical.com (smtp-relay-internal-1.canonical.com [185.125.188.123]) by imf16.hostedemail.com (Postfix) with ESMTP id DD7AD180004 for ; Tue, 23 Jul 2024 06:49:45 +0000 (UTC) Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=canonical.com header.s=20210705 header.b=FwKl7jyR; spf=pass (imf16.hostedemail.com: domain of kuan-ying.lee@canonical.com designates 185.125.188.123 as permitted sender) smtp.mailfrom=kuan-ying.lee@canonical.com; dmarc=pass (policy=none) header.from=canonical.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1721717350; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=wYKfkQhlmAQpjsnay3TVuvCtalPKMOXrFYtZFkyFmGI=; b=PA30tkdzvqygaqimLYGUz+q3NvoDcz5MHhXZ7XJJ+uK7BWo2fH3vuEcC95IQpWTDmeD7Ww 6r3ulzbHiKFPkUIHGtVuvaoPhYrce5xDfkPb/7pMtmticePukIpVH9EsoIUXK8s4r2WFxv OzbQhTa4DHPU0VpwBU1pUx06Ad2tdEI= ARC-Authentication-Results: i=1; imf16.hostedemail.com; dkim=pass header.d=canonical.com header.s=20210705 header.b=FwKl7jyR; spf=pass (imf16.hostedemail.com: domain of kuan-ying.lee@canonical.com designates 185.125.188.123 as permitted sender) smtp.mailfrom=kuan-ying.lee@canonical.com; dmarc=pass (policy=none) header.from=canonical.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1721717350; a=rsa-sha256; cv=none; b=5ulAO5afqENv/Ez5wxPlJFsiK9Jb5Y54szQmbMo5PK9UEOwVPF6ogUWxYAlD04WKVe1sSY Nlnddg8JcScIpn1+F2ynVK+5U9hn3xhETBLXHiFWwjOgGH2b1eDrMszWDD8N3uABvmUjyd ob5nipGX8uvDzeC2lPJOAro3SSNyruY= Received: from mail-pj1-f69.google.com (mail-pj1-f69.google.com [209.85.216.69]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-1.canonical.com (Postfix) with ESMTPS id 94D443F187 for ; Tue, 23 Jul 2024 06:49:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1721717384; bh=wYKfkQhlmAQpjsnay3TVuvCtalPKMOXrFYtZFkyFmGI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=FwKl7jyRzm7UKftIBxpkcHEbgYH80l0/JvuQYFQsn3Xw5nrvfTFaKEk1xz4vrZnUX CqhjnzQ4kXWzm+3KqyyuwASP9n0D24CdzLN2CmmyD8zSSijl4RkBo4rUocuOU9/VIs 6xuLLR1yV21JmO3ag6E6sBQZnCuwohzk9dcos16w55op6SD/7kT1Kye/omiU0GTuUC XDXco/Zn5W4hseK4hsOOfrUsRyR8GGW4vFFGQX5lcRHk1pXmWKtziUW4/Q24HhW8mi RraxdFzKSUZ5LiK0e8ZrYvREKa2io7CovGzA7YlDw2A2A610ZCc/gdn/giafiIpqjl vXxtssL2WiMCA== Received: by mail-pj1-f69.google.com with SMTP id 98e67ed59e1d1-2cb575938f1so4679472a91.2 for ; Mon, 22 Jul 2024 23:49:44 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721717383; x=1722322183; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=wYKfkQhlmAQpjsnay3TVuvCtalPKMOXrFYtZFkyFmGI=; b=J7UgJc24wv9v639ji9EEDTYiOa7YUfpA2lY0gpDLMlJkv5RYbUUXSMt845WAEURdMJ IL2yvLhRuX/IIOvavZ8/YzlHxwh0U3BfMoA5X2Rpn24hNgdCrGxLT4qVjmv0ALIxbXNZ 41mBlMWZgGU1G5B2bgCHwQ3ozsi/srBOB2u6i9u0+8NmGrCQmfcrFjdqs8MqBYUfS/2U 1xptXscitT/f68t9K7rkpvllb0upNZ/NOdGxtU/caNn/eb76qffl+UkcHkuQOFkxG1yh wK27oC116O21K/U+KQ4lctoJZSrkEP+LrIasIIXPudBBOoh6RfTpzi/KHU9RYdXaIHVH N8ZQ== X-Gm-Message-State: AOJu0Yx5u4FkCwZKX/vNXXv2OfTkyQMek7IjPkQVzlLC+oyJc8/wvdgb mUy5LrHR+dOrRIg80OHPYplp6T9v85Mj3UreUyvFsJmWeONrN7TUmrnwSmT1Kgd5OVe6ZORlRY9 hjIVV5GaZmpodYjv83vA2ELsiZTl+asrZ9x31WbbwXkWWGkiXG/VOp8sXjQQE6Xs/ X-Received: by 2002:a17:90a:e501:b0:2cd:1e60:9c31 with SMTP id 98e67ed59e1d1-2cd1e609c71mr5483420a91.30.1721717383186; Mon, 22 Jul 2024 23:49:43 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHFl31sX6VxPv7cHZhXyRmzKNIeGHs2Q9sPpSI1pZKYGAWsC+89F8KKIt8KWDuUcYG9dGvD/Q== X-Received: by 2002:a17:90a:e501:b0:2cd:1e60:9c31 with SMTP id 98e67ed59e1d1-2cd1e609c71mr5483405a91.30.1721717382832; Mon, 22 Jul 2024 23:49:42 -0700 (PDT) Received: from kylee-ThinkPad-E16-Gen-1.. ([122.147.171.160]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2ccf7c5391bsm8354749a91.24.2024.07.22.23.49.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Jul 2024 23:49:42 -0700 (PDT) From: Kuan-Ying Lee To: kuan-ying.lee@canonical.com, Andrew Morton , Jan Kiszka , Kieran Bingham Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 5/5] scripts/gdb: Add 'lx-kasan_mem_to_shadow' command Date: Tue, 23 Jul 2024 14:49:01 +0800 Message-Id: <20240723064902.124154-6-kuan-ying.lee@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240723064902.124154-1-kuan-ying.lee@canonical.com> References: <20240723064902.124154-1-kuan-ying.lee@canonical.com> MIME-Version: 1.0 X-Stat-Signature: r89aerux34et6eaehm8x5564m4ziipzy X-Rspam-User: X-Rspamd-Queue-Id: DD7AD180004 X-Rspamd-Server: rspam02 X-HE-Tag: 1721717385-318516 X-HE-Meta: U2FsdGVkX1+01M5X1k19NO6M79vaM50CRigvvradK2MkPkOAq+O0WLdgba3AwFtdQgpm50ucFVt0/e9AArFL0YrMx6+Dr71Z67j1xb/KknC3ub5KvRblMeoyr+aSqWxfb84eB8NslV6mXIfXO65wXRuzXmHzk1uIz0ijPPEbBxS5noj0ROKlIuI06s55iY4lDIyjt0xal6i+CRFUvKrdzphWbxLzjtT8cFwhmFlefyN7GcOA2U+vfxTQqG5og45GPXwkT6SzrZLAP8dBcKA7gbwWBCGQxI7BFhs7HPjsK5+8UYOcNMlMWvG/BXgR98EdGtsUZFqKINtK/Gnyg93DP7GBI0hXApxv0MUC5smGELfiiupcvzhuQTpj1CqYE9wVC4RTEtpswqBrMv4XXihfSYLAVe1M/8aAwjsq8QUtJx3r09VIuAKzhVMit/aTk2NWTNfoVMUqocDGu05dM8mDRehLfr+CQe80D7vVEe9N7csZ+PQuDqEBcMwZ+Yj79wHjJiT/Yx5yiwFtj8j6i/GXuvUcbonmfBtoiyWeKuF4Z8Gw9IrmT0jJ4Pqqq1u9HZ1vfugOT1lMJ39Jl1j+aKvC7F7d7N+x5kDekxh7pfQH/K+CPHCGrzTP2M2fUzUW9qO8BTz/udGXj8vhKIwdCXiKDCnyVzLgpboRpRZTKiIS3wOhNRv554vbZ3x6I9JXpq6qRrm9in6qboIR/Hpm8QLJrLPtNae91xYlTEHPRP+e5zAdg232FCxrXV+35TR7kIx/4xnzvqR6+XJGP4IF71mV5DGKY7iRpNwDAJwVTUFDB1DGW2f93jyTdpUv1fHGiYiiUM+0VrVRtab8ENNoA6kEZc2M/kjMO9HUk+KW1+J09xm24H+g4RBQ4w4uXHn4NTJ0n9Ni4sQybjIC6h1aHispJPR+ajxibdkuloFKAloQ0vueexjllaGK0d3tvMjrEaYnML+b3ZwH/tbdXBPzHkA Znd5D2zb LR0VtGaaznDQfJ6S9HMffgBnXHPhyfbQZ6ZQUlQv91Dy+0djW52RPAkM5ntbVex3r2on68NTgHN8qkyM73qEla9T8Mb0/+GaGgJc38P38luRQTwAMK3iOs0dxiOCu6bWBDumnF2Pr6txz2gUEEXAjvRqXwUtv/pjQ/PhuZVXrj2Oc7g/dyrcSZmQWj7n2u6k9v6eeyUqWlAVOegqQWTs0fBW1Uz8Un1kO0B/6Gn/fU8H+U0ugPrqcXGj23svx4CSccZWwcNvUsvUOvEI87ZDJcbW/SV/54cTIDN03zX+TtsnIyrPOZxL8QRjX61qCixZoLuEWOSV37Uys7ok4Am+gyN4zWUTGTxYuA5hKFraeNl65QM8= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: This command allows users to quickly translate memory address to the kasan shadow memory address. Example output: (gdb) lx-kasan_mem_to_shadow 0xffff000019acc008 shadow addr: 0xffff600003359801 Signed-off-by: Kuan-Ying Lee --- scripts/gdb/linux/kasan.py | 44 ++++++++++++++++++++++++++++++++++++++ scripts/gdb/vmlinux-gdb.py | 1 + 2 files changed, 45 insertions(+) create mode 100644 scripts/gdb/linux/kasan.py diff --git a/scripts/gdb/linux/kasan.py b/scripts/gdb/linux/kasan.py new file mode 100644 index 000000000000..56730b3fde0b --- /dev/null +++ b/scripts/gdb/linux/kasan.py @@ -0,0 +1,44 @@ +# SPDX-License-Identifier: GPL-2.0 +# +# Copyright 2024 Canonical Ltd. +# +# Authors: +# Kuan-Ying Lee +# + +import gdb +from linux import constants, mm + +def help(): + t = """Usage: lx-kasan_mem_to_shadow [Hex memory addr] + Example: + lx-kasan_mem_to_shadow 0xffff000008eca008\n""" + gdb.write("Unrecognized command\n") + raise gdb.GdbError(t) + +class KasanMemToShadow(gdb.Command): + """Translate memory address to kasan shadow address""" + + p_ops = None + + def __init__(self): + if constants.LX_CONFIG_KASAN_GENERIC or constants.LX_CONFIG_KASAN_SW_TAGS: + super(KasanMemToShadow, self).__init__("lx-kasan_mem_to_shadow", gdb.COMMAND_SUPPORT) + + def invoke(self, args, from_tty): + if not constants.LX_CONFIG_KASAN_GENERIC or constants.LX_CONFIG_KASAN_SW_TAGS: + raise gdb.GdbError('CONFIG_KASAN_GENERIC or CONFIG_KASAN_SW_TAGS is not set') + + argv = gdb.string_to_argv(args) + if len(argv) == 1: + if self.p_ops is None: + self.p_ops = mm.page_ops().ops + addr = int(argv[0], 16) + shadow_addr = self.kasan_mem_to_shadow(addr) + gdb.write('shadow addr: 0x%x\n' % shadow_addr) + else: + help() + def kasan_mem_to_shadow(self, addr): + return (addr >> self.p_ops.KASAN_SHADOW_SCALE_SHIFT) + self.p_ops.KASAN_SHADOW_OFFSET + +KasanMemToShadow() diff --git a/scripts/gdb/vmlinux-gdb.py b/scripts/gdb/vmlinux-gdb.py index fc53cdf286f1..d4eeed4506fd 100644 --- a/scripts/gdb/vmlinux-gdb.py +++ b/scripts/gdb/vmlinux-gdb.py @@ -49,3 +49,4 @@ else: import linux.page_owner import linux.slab import linux.vmalloc + import linux.kasan