From nobody Fri Dec 19 15:35:38 2025 Received: from read.uberspace.de (read.uberspace.de [185.26.156.133]) (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 77A5214C58E for ; Thu, 25 Apr 2024 16:03:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.26.156.133 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714061019; cv=none; b=C/bKMWgnkQ8NllQFreGtquAb7k4nJEbCQxgUBm1mPZYDQFPLVr9jUrPCDR1GJWRZ7YWsF/mL22+B76S4GljqpnaWNRYpYsDYhBpuYJCcYWX9Fmid9xcyCTkPif0ighdUExEYHoqdVet0tasWh+DoWXJtU3JVJ/AzrZc48pGNX+E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714061019; c=relaxed/simple; bh=OqUDxo5jnbeq4E/p9TpxkO9IWm1pyo9rFs4m+YZepdY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=fm9NOTc42ckvFtBjbMoTUEJ87G7U48ZsQocL3j80lf4D+DJt+qVEvdW/pFCDF5fPQF0Cg2Bqzs1H7pDbXOW0IcDGy7Dz9W2ZbcUlLv7R2w/7olqIxDeAeOoWcaB09Et7wGECvK8wryp0V1GZWvN8wwezvAnRpBRCaso11hUJGfI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=florommel.de; spf=pass smtp.mailfrom=florommel.de; dkim=fail (0-bit key) header.d=florommel.de header.i=@florommel.de header.b=VL9/+SNG reason="key not found in DNS"; arc=none smtp.client-ip=185.26.156.133 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=florommel.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=florommel.de Authentication-Results: smtp.subspace.kernel.org; dkim=fail reason="key not found in DNS" (0-bit key) header.d=florommel.de header.i=@florommel.de header.b="VL9/+SNG" Received: (qmail 30623 invoked by uid 990); 25 Apr 2024 15:36:36 -0000 Authentication-Results: read.uberspace.de; auth=pass (plain) Received: from unknown (HELO unkown) (::1) by read.uberspace.de (Haraka/3.0.1) with ESMTPSA; Thu, 25 Apr 2024 17:36:36 +0200 From: Florian Rommel To: Jan Kiszka , Kieran Bingham Cc: Kuan-Ying Lee , Palmer Dabbelt , Deepak Gupta , Andrew Jones , Andrew Morton , linux-kernel@vger.kernel.org, Florian Rommel Subject: [PATCH 1/4] scripts/gdb: Fix failing KGDB detection during probe Date: Thu, 25 Apr 2024 17:34:58 +0200 Message-ID: <20240425153501.749966-2-mail@florommel.de> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240425153501.749966-1-mail@florommel.de> References: <20240425153501.749966-1-mail@florommel.de> 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 X-Rspamd-Bar: ----- X-Rspamd-Report: REPLY(-4) BAYES_HAM(-2.997039) MID_CONTAINS_FROM(1) MIME_GOOD(-0.1) R_MISSING_CHARSET(0.5) X-Rspamd-Score: -5.597039 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=florommel.de; s=uberspace; h=from:to:cc:subject:date; bh=OqUDxo5jnbeq4E/p9TpxkO9IWm1pyo9rFs4m+YZepdY=; b=VL9/+SNGECJcTKGmEy8Q4ijlUWL/nGHUqvTWAYMCmJqSj6vY7gxcN6eQePey715nZnVndT3nrY 0a+kZ5tNGX80BlgZh+p0Q6CRMBqU5FyHpCsSASpWfCWgbmo3jLrAbotJ8ZFjNf9e8jhQx0+8s9GG dRAvFwcEoERs0hGfNF3SRSjsz348BiurPeom1CNE/Pg3IsD15VK8ofQx4ZAGwVTLnspLAbVAN1BA 4LoqW0FhWk8PEucfwTbiwPeZOWsWaxL0Sl14ok4iQdjMr8ZFaIXh9wBrIVukrRfO0F8xLLzZdhLw gzElLkz5hBGeNcch4s5j1ODGC8d0z397SlpzMZ/Qeoa09wHdDBTD/O85gUBRyixK4Z8B7lr+MKw6 ydXz60+ndHfFhZzc19JJEa34Tgvv6Xw6BE4jsqYq/MxpxwaObaOiU4c/T7CiZxiJv04dp9xeaVSX Wu5Fnsu+/MueXMWcEUA5GPJBL86UXetQA13RdHiBl5QHSXGyN1UBNlvZ8sMX3dpzbui06MYDzxew ZaBRY93RmFVVyKttP7GEF9U+Y1O2peAesJyVBM6cx5wIaTyFUz8NvooIbrU/YQC3XcvBUrFdwJke 6Q+TwnjBTZbhCv8At96cUgDbuS4F/o2vD172zCdntm4RusVxsOaju97Wn3wcLlJT7MBVyILfclz5 A= Content-Type: text/plain; charset="utf-8" The KGDB probe function sometimes failed to detect KGDB for SMP machines as it assumed that task 2 (kthreadd) is running on CPU 0, which is not necessarily the case. Now, the detection is agnostic to kthreadd's CPU. Signed-off-by: Florian Rommel --- scripts/gdb/linux/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/gdb/linux/utils.py b/scripts/gdb/linux/utils.py index 7d5278d815fa..245ab297ea84 100644 --- a/scripts/gdb/linux/utils.py +++ b/scripts/gdb/linux/utils.py @@ -196,7 +196,7 @@ def get_gdbserver_type(): def probe_kgdb(): try: thread_info =3D gdb.execute("info thread 2", to_string=3DTrue) - return "shadowCPU0" in thread_info + return "shadowCPU" in thread_info except gdb.error: return False =20 --=20 2.44.0 From nobody Fri Dec 19 15:35:38 2025 Received: from read.uberspace.de (read.uberspace.de [185.26.156.133]) (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 E93AA12C466 for ; Thu, 25 Apr 2024 15:44:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.26.156.133 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714059851; cv=none; b=pJzuTviQ0KvYtFNSdy02Bp8O7sYkdO5EfpKbGny5uSfHKwSltG/8O4YqISt16HaTBoIlr6qZBClS/X4vbb6gphBQvJc+I4gOBDtirmI5fcl4MqX0nxKhCRLqTKetgX7cGm/gSlGNVrsiq2d+QhQ1F6gjr1tn0Ehsa3ZnFxcg4iY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714059851; c=relaxed/simple; bh=rKhcjnXo7EOIqnD76pPnNap0PU85LBwHgM50XLVgpJw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Ite8XJvVNUJ3obyePGGE4h2zkY8DCuU57gfQGGwxiqe7vOYJrHCaUenR1QsNLcFm1Knl3i5LTCxM9/UniW6+5zTQmXiICnNevB2Hn3JW7cAZZaD8lg78L3e8SihUYN1efj4R6WMZ2FMzg4c/1fPYuOFOIVeF0I+4wP8UKm3S23c= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=florommel.de; spf=pass smtp.mailfrom=florommel.de; dkim=fail (0-bit key) header.d=florommel.de header.i=@florommel.de header.b=s8o6289M reason="key not found in DNS"; arc=none smtp.client-ip=185.26.156.133 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=florommel.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=florommel.de Authentication-Results: smtp.subspace.kernel.org; dkim=fail reason="key not found in DNS" (0-bit key) header.d=florommel.de header.i=@florommel.de header.b="s8o6289M" Received: (qmail 30677 invoked by uid 990); 25 Apr 2024 15:36:37 -0000 Authentication-Results: read.uberspace.de; auth=pass (plain) Received: from unknown (HELO unkown) (::1) by read.uberspace.de (Haraka/3.0.1) with ESMTPSA; Thu, 25 Apr 2024 17:36:37 +0200 From: Florian Rommel To: Jan Kiszka , Kieran Bingham Cc: Kuan-Ying Lee , Palmer Dabbelt , Deepak Gupta , Andrew Jones , Andrew Morton , linux-kernel@vger.kernel.org, Florian Rommel Subject: [PATCH 2/4] scripts/gdb: Fix parameter handling in $lx_per_cpu Date: Thu, 25 Apr 2024 17:34:59 +0200 Message-ID: <20240425153501.749966-3-mail@florommel.de> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240425153501.749966-1-mail@florommel.de> References: <20240425153501.749966-1-mail@florommel.de> 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 X-Rspamd-Bar: ---- X-Rspamd-Report: REPLY(-4) BAYES_HAM(-2.999346) MID_CONTAINS_FROM(1) MIME_GOOD(-0.1) SUBJECT_HAS_CURRENCY(1) R_MISSING_CHARSET(0.5) X-Rspamd-Score: -4.599346 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=florommel.de; s=uberspace; h=from:to:cc:subject:date; bh=rKhcjnXo7EOIqnD76pPnNap0PU85LBwHgM50XLVgpJw=; b=s8o6289MZARO/X/Z0VB9amQLyMNS/bZtWfozd/ZPxw5DbaHlseMDtTsKmEpcwgCav6cUJchfu/ Xt60+GOWgYMi5rbp33stbGgmvADMzLo7hyBV3R+oHqxKQKzJyVvUtoPgy4BZae2XHIo+X1gyu2Kr vhI5fY7bm7+dOz4dftXM0lqdTjhBjR+qwS2XN15jdC45eSRSf1sn4+G0+Yl20FPnQPIWansL6l0r FI7gDjIbP22PUUO9ZDSO/w8o2K6LKGWQ0Hv9KdI29E/ZjY0K9SvNvhs/B+1J+vbEJDp1QFKqz7Gg YXlTF9uhowo9UCC4LmW/HcRqtL07jvT0kaiekINKMIEb+RddhkA69YSrYnLvcB4TGtZEsOlb+wwZ z5Iy00uRvr6Vj0t0IgRys0zv3HhD2imd6uGMCW+9+ix3dMCKba5SQyN338OEZPck8fu0xd0Q+SV7 IxXGpFu1evMeceEQTKI9o5Vd9bD8s8ZdoQxJbZ7RWx6CKmo614G8rCUxbjmBAuXc34aLgtiRwHvJ APcTHZQeK8fUidtGeQo0Co3UHro/LdoS9yiMW9EmxqmXJNRm9wYT3Rcd9nGz/x2rYenuVoQfHm6B SmqeEzMoMguT78ITakw4c9EMeDjshewNvJXSMiG9eV+0lVz5X+KxinDTV5xoZDAPyYAsUsdjINVJ s= Content-Type: text/plain; charset="utf-8" Before, the script tried to get the address by constructing a pointer to the parameter (by name). However, since GDB now passes the parameter as a GdbValue, we cannot get its name. Instead, we retrieve the address through GdbValue's address attribute. Before: >>> p $lx_per_cpu(cpu_info) Traceback (most recent call last): File "./scripts/gdb/linux/cpus.py", line 152, in invoke var_ptr =3D gdb.parse_and_eval("&" + var_name.string()) ^^^^^^^^^^^^^^^^^ gdb.error: Trying to read string with inappropriate type `struct cpuinfo_x8= 6'. Signed-off-by: Florian Rommel --- scripts/gdb/linux/cpus.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/scripts/gdb/linux/cpus.py b/scripts/gdb/linux/cpus.py index cba589e5b57d..2b51a3abd363 100644 --- a/scripts/gdb/linux/cpus.py +++ b/scripts/gdb/linux/cpus.py @@ -152,9 +152,8 @@ Note that VAR has to be quoted as string.""" def __init__(self): super(PerCpu, self).__init__("lx_per_cpu") =20 - def invoke(self, var_name, cpu=3D-1): - var_ptr =3D gdb.parse_and_eval("&" + var_name.string()) - return per_cpu(var_ptr, cpu) + def invoke(self, var, cpu=3D-1): + return per_cpu(var.address, cpu) =20 =20 PerCpu() --=20 2.44.0 From nobody Fri Dec 19 15:35:38 2025 Received: from read.uberspace.de (read.uberspace.de [185.26.156.133]) (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 8341614C587 for ; Thu, 25 Apr 2024 16:03:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.26.156.133 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714061014; cv=none; b=YM3aLrHjrt3pThw3nlAYwEUFBF5KB1jkXJnR6umlmx6P+WolmcrybLg41g0bY2Ftrl4p8ChtbswBQSstyzCO6oi8M4GbJqtZ76RrI/MnG/SJZGDO7lJ5nIN132ca6zUgexPJDTGp0aVIHGizVvFxwdSWGHWBkDPhcqLB7CU67No= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714061014; c=relaxed/simple; bh=xNNR/wUpIxuzrAufWGl/DeCwf0nh9qPTmwwaiUo3cnU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=nvvDW8VF4GGX3Sx2g7ULQgha/QRRLtDUo+mKYkRiIdZszC6x9T0tBm2tzVl/5rKylKZ7LltCdQBEeXNBfM8cZzjrXDrkOmawQvrKvo8Iz/footsRE2ZSedWk+Z073ut8rElqwqxHcnATG6O1e4LFMR8VuTW4//Vc27xw13wRjn0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=florommel.de; spf=pass smtp.mailfrom=florommel.de; dkim=fail (0-bit key) header.d=florommel.de header.i=@florommel.de header.b=if+UMpp3 reason="key not found in DNS"; arc=none smtp.client-ip=185.26.156.133 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=florommel.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=florommel.de Authentication-Results: smtp.subspace.kernel.org; dkim=fail reason="key not found in DNS" (0-bit key) header.d=florommel.de header.i=@florommel.de header.b="if+UMpp3" Received: (qmail 30710 invoked by uid 990); 25 Apr 2024 15:36:38 -0000 Authentication-Results: read.uberspace.de; auth=pass (plain) Received: from unknown (HELO unkown) (::1) by read.uberspace.de (Haraka/3.0.1) with ESMTPSA; Thu, 25 Apr 2024 17:36:37 +0200 From: Florian Rommel To: Jan Kiszka , Kieran Bingham Cc: Kuan-Ying Lee , Palmer Dabbelt , Deepak Gupta , Andrew Jones , Andrew Morton , linux-kernel@vger.kernel.org, Florian Rommel Subject: [PATCH 3/4] scripts/gdb: Make get_thread_info accept pointers Date: Thu, 25 Apr 2024 17:35:00 +0200 Message-ID: <20240425153501.749966-4-mail@florommel.de> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240425153501.749966-1-mail@florommel.de> References: <20240425153501.749966-1-mail@florommel.de> 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 X-Rspamd-Bar: ----- X-Rspamd-Report: REPLY(-4) BAYES_HAM(-2.99722) MID_CONTAINS_FROM(1) MIME_GOOD(-0.1) R_MISSING_CHARSET(0.5) X-Rspamd-Score: -5.59722 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=florommel.de; s=uberspace; h=from:to:cc:subject:date; bh=xNNR/wUpIxuzrAufWGl/DeCwf0nh9qPTmwwaiUo3cnU=; b=if+UMpp33eD8jvzlf3x4MCEysYOpDE0DI8Z+EW1cVgQr2KvtIWi2UvgA57uWFuqro/7Um6CIY2 kMRu2eCLEjid0StnfLgZWxavb90h9YQPoLGFZ9dcuca87OPuHIgw6jpIQamARhebgbVWan8A9Zg2 nqYR+cYkN3zcfkUKpOxTN1YyXSd2EpDr/dlNxv0Xk77FyiS0cAj9IqzB/vJBqYqzZmUeaKgoyqTG V5msunxNXu5KCg0CgOc/r0hcoafQn521Gw2ewSZ3PwmcskH+YDrrshvSXGtRzfwFSTMKlHjzoecv AZauQ+P8ovMwJohbLFgKzN/Chdx6aogFzUzoaPCmciDDJq4nRNCxR4Ig3KucMqgW66Jf/4Zr6Aip CANAA9RBBk5955H3N3cEcvYT8SErWkKuUXjVlFmycNenkOFgw6TtjHDMXiBSyGTAuGJ28yUn/c7K 81IMFfYZxPEb4O1+Od3dJpaJyLul7Cd9FH4z5i1hjHI22kjiyo28M78MNXWVtk7GNv5TZF609ZHT QhkDYcBnseHMQGfTgacRZcLhwuRDxIFQml+rtF0xdVQdlaWYC48NqIMLRpjDouJ8/b5eMfrJUPMy w1SC2DBagPMCmH3XZI+LBImT/hlGvYzisD34OgiQl3RbOsrMP3Xub1MkErlU7Lm1/rRdgnSDuRHk Y= Content-Type: text/plain; charset="utf-8" get_thread_info ($lx_thread_info) only accepted a dereferenced task parameter. Passing a pointer to a task_struct (like $lx_per_cpu does with KGDB) threw an exception. With this patch, both (dereferenced values and pointers) are accepted. Before (on x86, KGDB): >>> p $lx_per_cpu(cpu_info) Traceback (most recent call last): File "./scripts/gdb/linux/cpus.py", line 158, in invoke return per_cpu(var_ptr, cpu) ^^^^^^^^^^^^^^^^^^^^^ File "./scripts/gdb/linux/cpus.py", line 42, in per_cpu cpu =3D get_current_cpu() ^^^^^^^^^^^^^^^^^ File "./scripts/gdb/linux/cpus.py", line 33, in get_current_cpu return tasks.get_thread_info(tasks.get_task_by_pid(tid))['cpu'] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "./scripts/gdb/linux/tasks.py", line 88, in get_thread_info if task.type.fields()[0].type =3D=3D thread_info_type.get_type(): ~~~~~~~~~~~~~~~~~~^^^ IndexError: list index out of range Signed-off-by: Florian Rommel --- scripts/gdb/linux/tasks.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/gdb/linux/tasks.py b/scripts/gdb/linux/tasks.py index 6793d6e86e77..62348397c1f5 100644 --- a/scripts/gdb/linux/tasks.py +++ b/scripts/gdb/linux/tasks.py @@ -85,7 +85,7 @@ thread_info_type =3D utils.CachedType("struct thread_info= ") =20 def get_thread_info(task): thread_info_ptr_type =3D thread_info_type.get_type().pointer() - if task.type.fields()[0].type =3D=3D thread_info_type.get_type(): + if task_type.get_type().fields()[0].type =3D=3D thread_info_type.get_t= ype(): return task['thread_info'] thread_info =3D task['stack'].cast(thread_info_ptr_type) return thread_info.dereference() --=20 2.44.0 From nobody Fri Dec 19 15:35:38 2025 Received: from read.uberspace.de (read.uberspace.de [185.26.156.133]) (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 A89E514B086 for ; Thu, 25 Apr 2024 15:43:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.26.156.133 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714059821; cv=none; b=jgSkcb6vO7ZyJW/coPmahV0SDAhBTOyphCeGsPMg6e4nQLT+AAGIqjeaOoTePkgasmV/RDwOvj1yzMxWQx7j0QOF14uo2ugohof9NJrqFCdQ7zG89Hk6N5KOUKxw72Y7FTYq4f6bOczYhVnUqRmPoa1TdsB9XkoUb+APYzMMt0o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714059821; c=relaxed/simple; bh=PFSo08OuHGBuBBReLB/w3zYNHRv/sFj6evMDpx6HkYE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=c26Ww1O26L4Z9s+cM6bCTsqNWPvGerZpBVwf9KZA4Wxpoit0VmYoMSoWQ2/wtqtIwJt+/UbKGmfbDfNn0T1chQlKXqixPeckvQ+e8fznldEcnddXWdIvodQUq+33kHW8k56x5LuWIDWa654v02ZCEExS22m5Qf2NqY3QatWoQHU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=florommel.de; spf=pass smtp.mailfrom=florommel.de; dkim=fail (0-bit key) header.d=florommel.de header.i=@florommel.de header.b=Zp4TGPi7 reason="key not found in DNS"; arc=none smtp.client-ip=185.26.156.133 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=florommel.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=florommel.de Authentication-Results: smtp.subspace.kernel.org; dkim=fail reason="key not found in DNS" (0-bit key) header.d=florommel.de header.i=@florommel.de header.b="Zp4TGPi7" Received: (qmail 30745 invoked by uid 990); 25 Apr 2024 15:36:38 -0000 Authentication-Results: read.uberspace.de; auth=pass (plain) Received: from unknown (HELO unkown) (::1) by read.uberspace.de (Haraka/3.0.1) with ESMTPSA; Thu, 25 Apr 2024 17:36:38 +0200 From: Florian Rommel To: Jan Kiszka , Kieran Bingham Cc: Kuan-Ying Lee , Palmer Dabbelt , Deepak Gupta , Andrew Jones , Andrew Morton , linux-kernel@vger.kernel.org, Florian Rommel Subject: [PATCH 4/4] scripts/gdb: Fix detection of current CPU in KGDB Date: Thu, 25 Apr 2024 17:35:01 +0200 Message-ID: <20240425153501.749966-5-mail@florommel.de> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240425153501.749966-1-mail@florommel.de> References: <20240425153501.749966-1-mail@florommel.de> 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 X-Rspamd-Bar: ---- X-Rspamd-Report: REPLY(-4) BAYES_HAM(-2.030286) MID_CONTAINS_FROM(1) MIME_GOOD(-0.1) R_MISSING_CHARSET(0.5) X-Rspamd-Score: -4.630286 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=florommel.de; s=uberspace; h=from:to:cc:subject:date; bh=PFSo08OuHGBuBBReLB/w3zYNHRv/sFj6evMDpx6HkYE=; b=Zp4TGPi7xeJSc9YTX8EtU6Bx65jEzXjlS2pZzWZw+oRi6lIqFGL7CNR+h/AV9q6h+DGepffBht VB/3wG9PGeQ6+i3jnkWHoP9JBTB2EqFJ4X2qo5V5w1Ula/HBbDxSRTZKq0HZx1EfmR0pILMPbkGZ aL0DZikfMFCDaYo2iU53Ev48kB5QzYzj+8qdr+rLpsOZchEinkGKJ6TAg3fwJ6zGPNjaZ36WArR8 iSs9Yq2ryvClBlKIiRtJLHQmIcmjd1ogUevu49EjI+x3eOeCAiv4gh8YGxvsN0bVUzlGNbppiVfh fuRjGGAaVbYpnC0XTOVLTIOhjLH1ed7vrCVphm8Ahl2kWFNuw2+694U11gP2nFFNgxGHWTNO1xkD ijX2N5mJ/wYIez/oYb+ONmutitIXFhsfUhOgeD0yxgCjuLYZ3rboiMoykqOSHY4FfdWHJvSOcMLu IFGdDM7K9Mktv+6CZYmCm2VaHeaHl2HB+iSF5ovrV6MGPXPQs4zmYisDDfwWSjfzRLtc+KOmahyk XEDQ8GsiZDVEQ7wuPkvxr4OyUlIBMJxPHz7U+DUG2IF7zcIrY4eAZVE13ZHrmVLjcdOn3IKuftbN nQT+OZRirC3vYkkh4UePpSjKS4V4eY0+0MsACCXmRGqj7XFihNW27LcPiEMJ9KEIP4TH+qhrOp2D 8= Content-Type: text/plain; charset="utf-8" Directly read the current CPU number from the kgdb_active variable. Before, the active CPU was obtained through the current task, which required searching the task list for the pid of GDB's selected thread. Obtaining the pid was buggy: GDB may use selected_thread().ptid[1] (LWPID) instead of .ptid[2] (TID) to store the threads pid; see https://sourceware.org/gdb/current/onlinedocs/gdb.html/Threads-In-Python.ht= ml As a result, the detection could return the wrong CPU number, leading to incorrect results for $lx_per_cpu and $lx_current. As a side effect, the patch significantly speeds up $lx_per_cpu and $lx_current in KGDB by avoiding the task-list iteration. Signed-off-by: Florian Rommel --- scripts/gdb/linux/cpus.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/scripts/gdb/linux/cpus.py b/scripts/gdb/linux/cpus.py index 2b51a3abd363..2f11c4f9c345 100644 --- a/scripts/gdb/linux/cpus.py +++ b/scripts/gdb/linux/cpus.py @@ -26,11 +26,7 @@ def get_current_cpu(): if utils.get_gdbserver_type() =3D=3D utils.GDBSERVER_QEMU: return gdb.selected_thread().num - 1 elif utils.get_gdbserver_type() =3D=3D utils.GDBSERVER_KGDB: - tid =3D gdb.selected_thread().ptid[2] - if tid > (0x100000000 - MAX_CPUS - 2): - return 0x100000000 - tid - 2 - else: - return tasks.get_thread_info(tasks.get_task_by_pid(tid))['cpu'] + return gdb.parse_and_eval("kgdb_active.counter") else: raise gdb.GdbError("Sorry, obtaining the current CPU is not yet " "supported with this gdb server.") --=20 2.44.0