From: Andrew Lunn <andrew@lunn.ch>
To: Thorsten Blum <thorsten.blum@linux.dev>
Cc: "FUJITA Tomonori" <fujita.tomonori@gmail.com>,
"Trevor Gross" <tmgross@umich.edu>,
"Heiner Kallweit" <hkallweit1@gmail.com>,
"Russell King" <linux@armlinux.org.uk>,
"David S. Miller" <davem@davemloft.net>,
"Eric Dumazet" <edumazet@google.com>,
"Jakub Kicinski" <kuba@kernel.org>,
"Paolo Abeni" <pabeni@redhat.com>,
"Miguel Ojeda" <ojeda@kernel.org>,
"Alex Gaynor" <alex.gaynor@gmail.com>,
"Boqun Feng" <boqun.feng@gmail.com>,
"Gary Guo" <gary@garyguo.net>,
"Björn Roy Baron" <bjorn3_gh@protonmail.com>,
"Benno Lossin" <lossin@kernel.org>,
"Andreas Hindborg" <a.hindborg@kernel.org>,
"Alice Ryhl" <aliceryhl@google.com>,
"Danilo Krummrich" <dakr@kernel.org>,
netdev@vger.kernel.org, rust-for-linux@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH net-next] rust: net::phy inline if expressions to improve read_status
Date: Fri, 19 Sep 2025 14:54:40 +0200 [thread overview]
Message-ID: <d1fe6fa4-da50-4899-8e2c-0721851c4e0d@lunn.ch> (raw)
In-Reply-To: <20250919112007.940061-2-thorsten.blum@linux.dev>
On Fri, Sep 19, 2025 at 01:20:08PM +0200, Thorsten Blum wrote:
> Inline the if expressions for dev.set_speed() and dev.set_duplex() to
> improve read_status(). This ensures dev.set_speed() is called only once
What is the issue of calling it twice, or 42 times??
> and allows us to remove the local variable 'duplex'.
And what is wrong with local variables?
And did you disassemble the code? What is the compiler actually doing?
Does it actually have a stack variable, or is it just a register? Does
the optimiser end up with just a single call to set_speed()?
This is slow path code. It gets called at most once per
second. Performance does not matter. Which means readability has much
higher preference. And i find the older version much easier to read.
Andrew
next prev parent reply other threads:[~2025-09-19 12:54 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-19 11:20 Thorsten Blum
2025-09-19 12:54 ` Andrew Lunn [this message]
2025-09-19 13:30 ` Thorsten Blum
2025-09-19 15:16 ` Andrew Lunn
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=d1fe6fa4-da50-4899-8e2c-0721851c4e0d@lunn.ch \
--to=andrew@lunn.ch \
--cc=a.hindborg@kernel.org \
--cc=alex.gaynor@gmail.com \
--cc=aliceryhl@google.com \
--cc=bjorn3_gh@protonmail.com \
--cc=boqun.feng@gmail.com \
--cc=dakr@kernel.org \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=fujita.tomonori@gmail.com \
--cc=gary@garyguo.net \
--cc=hkallweit1@gmail.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=lossin@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=ojeda@kernel.org \
--cc=pabeni@redhat.com \
--cc=rust-for-linux@vger.kernel.org \
--cc=thorsten.blum@linux.dev \
--cc=tmgross@umich.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®