lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250819114641.26223fb9@gandalf.local.home>
Date: Tue, 19 Aug 2025 12:09:25 -0400
From: Steven Rostedt <rostedt@...dmis.org>
To: Mohammad Gomaa <midomaxgomaa@...il.com>
Cc: Wolfram Sang <wsa+renesas@...g-engineering.com>, Masami Hiramatsu
 <mhiramat@...nel.org>, Mathieu Desnoyers <mathieu.desnoyers@...icios.com>,
 linux-i2c@...r.kernel.org, linux-kernel@...r.kernel.org,
 linux-trace-kernel@...r.kernel.org, kenalba@...gle.com,
 hbarnor@...omium.org, rayxu@...gle.com
Subject: Re: [PATCH WIP v2] i2c: add tracepoints to aid debugging in
 i2c-core-base

On Sun, 17 Aug 2025 10:55:14 +0300
Mohammad Gomaa <midomaxgomaa@...il.com> wrote:

> Hello,
> 
> This patch adds tracepoints to i2c-core-base to aid with debugging I2C probing failrues.
> 
> The motivation for this comes from my work in Google Summer of Code (GSoC) 2025:
> "ChromeOS Platform Input Device Quality Monitoring"
> https://summerofcode.withgoogle.com/programs/2025/projects/uCdIgK7K
> 
> This is my first submission to the Linux kernel, so any feedback is welcome.

Welcome Mohammad!

>  	driver = to_i2c_driver(dev->driver);
>  

I'll let those that own this code discuss the merits of this, and if
there's a better way to achieve this. But I'll comment only on the tracing
aspect of this change.

> +	has_id_table = driver->id_table;
> +	has_acpi_match = acpi_driver_match_device(dev, dev->driver);
> +	has_of_match = i2c_of_match_device(dev->driver->of_match_table, client);
> +
> +	if (!has_id_table)
> +		trace_i2c_device_probe_debug(dev, I2C_TRACE_REASON_NO_I2C_ID_TABLE);
> +	if (!has_acpi_match)
> +		trace_i2c_device_probe_debug(dev, I2C_TRACE_REASON_ACPI_ID_MISMATCH);
> +	if (!has_of_match)
> +		trace_i2c_device_probe_debug(dev, I2C_TRACE_REASON_OF_ID_MISMATCH);

The above adds if statements into the running code when tracing is disabled
and this causes pressure on the branch prediction and should be avoided. To
avoid this, you could use the trace_<tracepoint>_enabled() helper:

	if (trace_i2c_device_probe_debug_enabled()) {
		has_id_table = driver->id_table;
		has_acpi_match = acpi_driver_match_device(dev, dev->driver);
		has_of_match = i2c_of_match_device(dev->driver->of_match_table, client);

		if (!has_id_table)
			trace_i2c_device_probe_debug(dev, I2C_TRACE_REASON_NO_I2C_ID_TABLE);
		if (!has_acpi_match)
			trace_i2c_device_probe_debug(dev, I2C_TRACE_REASON_ACPI_ID_MISMATCH);
		if (!has_of_match)
			trace_i2c_device_probe_debug(dev, I2C_TRACE_REASON_OF_ID_MISMATCH);
	}

But I suspect there's a better way to record this information. I just
wanted to inform you on the trace_<tracepoint>_enabled() logic. What it
does is to add a static branch (jump label) where there's no "if"
statement. It's either a nop that skips this code altogether, or it's a jmp
to the code that will do the logic as well as the tracing and then jump
back to where it left off.

It's much more efficient to use this and it doesn't add anything to the
branch prediction cache.

-- Steve

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ