From: Greg KH <gregkh@linuxfoundation.org>
To: Viresh Kumar <viresh.kumar@linaro.org>
Cc: "Rafael J. Wysocki" <rafael@kernel.org>,
"Miguel Ojeda" <miguel.ojeda.sandonis@gmail.com>,
"Danilo Krummrich" <dakr@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" <benno.lossin@proton.me>,
"Andreas Hindborg" <a.hindborg@kernel.org>,
"Alice Ryhl" <aliceryhl@google.com>,
"Trevor Gross" <tmgross@umich.edu>,
linux-pm@vger.kernel.org,
"Vincent Guittot" <vincent.guittot@linaro.org>,
"Stephen Boyd" <sboyd@kernel.org>, "Nishanth Menon" <nm@ti.com>,
rust-for-linux@vger.kernel.org,
"Manos Pitsidianakis" <manos.pitsidianakis@linaro.org>,
"Erik Schilling" <erik.schilling@linaro.org>,
"Alex Bennée" <alex.bennee@linaro.org>,
"Joakim Bech" <joakim.bech@linaro.org>,
"Rob Herring" <robh@kernel.org>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH V6 02/15] cpufreq: Add cpufreq_table_len()
Date: Mon, 13 Jan 2025 08:53:28 +0100 [thread overview]
Message-ID: <2025011327-cubbyhole-idealness-d4cc@gregkh> (raw)
In-Reply-To: <20250113073040.rvtc27zcgpvcycrr@vireshk-i7>
On Mon, Jan 13, 2025 at 01:00:40PM +0530, Viresh Kumar wrote:
> On 09-01-25, 08:35, Greg KH wrote:
> > Then why not make the C code use this function as well, to keep all
> > cpufreq drivers from having to manually walk the list and that way both
> > C and Rust drivers all do the same thing? That makes more sense to me,
> > there's no reason you can't change C code today first to make things
> > more unified, in fact, that's usually a better idea overall anyway.
>
> I investigated a bit on this..
>
> - The cpufreq core normally gets (from cpufreq governor's for example)
> a frequency value to be matched against in the freq-table, and the
> loop which run over the freq-table is already optimized enough (it
> checks for CPUFREQ_TABLE_END) for this. Using length in this loop
> won't improve it anymore.
>
> - The cpufreq core then calls cpufreq driver's callbacks and passes an
> index to the freq-table, which the drivers don't need to verify
> against table length, since the index came from the core itself.
>
> - The same happens on the Rust side, where the cpufreq core calls the
> target_index() callback of the driver. While writing the Rust code,
> I thought maybe I should validate that the index is within limits
> (before I do pointer manipulation in Rust code). And so required
> this extra function (which C code never uses).
>
> - Now I can either keep doing this verification in the Rust code (and
> so keep the new API, only used by Rust code). Or I can just remove
> the verification and trust that the index passed by the
> cpufreq-drivers is correct (since they have received them from the
> cpufreq C code).
>
> What should I do ?
I would trust the C code, keeping the apis the same between the two
types of drivers. If in the future you want to fix up the api, then fix
both drivers. Don't try to have unique apis for only Rust drivers if
you can help it at all, that is just going to drive us all crazy over
time.
And really, you might want to fix up the api, that too sounds crazy :)
thanks,
greg k-h
next prev parent reply other threads:[~2025-01-13 7:53 UTC|newest]
Thread overview: 48+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-07 11:21 [PATCH V6 00/15] Rust bindings for cpufreq and OPP core + sample driver Viresh Kumar
2025-01-07 11:21 ` [PATCH V6 01/15] PM / OPP: Expose refcounting helpers for the Rust implementation Viresh Kumar
2025-01-07 11:58 ` Greg KH
2025-01-08 9:11 ` Viresh Kumar
2025-01-08 11:53 ` Greg KH
2025-01-07 11:21 ` [PATCH V6 02/15] cpufreq: Add cpufreq_table_len() Viresh Kumar
2025-01-07 11:59 ` Greg KH
2025-01-08 11:12 ` Viresh Kumar
2025-01-08 11:50 ` Greg KH
2025-01-09 4:41 ` Viresh Kumar
2025-01-09 7:35 ` Greg KH
2025-01-13 7:30 ` Viresh Kumar
2025-01-13 7:53 ` Greg KH [this message]
2025-01-07 11:21 ` [PATCH V6 03/15] cpufreq: Rust implementation doesn't parse BIT() macro Viresh Kumar
2025-01-07 12:00 ` Greg KH
2025-01-07 13:29 ` Daniel Almeida
2025-01-08 6:53 ` Viresh Kumar
2025-01-08 9:01 ` Alice Ryhl
2025-01-08 9:27 ` Viresh Kumar
2025-01-08 5:37 ` Viresh Kumar
2025-01-08 14:47 ` Miguel Ojeda
2025-01-07 11:21 ` [PATCH V6 04/15] rust: device: Add few helpers Viresh Kumar
2025-01-07 11:56 ` Greg Kroah-Hartman
2025-01-08 11:02 ` Viresh Kumar
2025-01-08 11:52 ` Greg Kroah-Hartman
2025-01-08 11:55 ` Alice Ryhl
2025-01-08 12:14 ` Greg Kroah-Hartman
2025-01-08 13:42 ` Danilo Krummrich
2025-01-09 6:36 ` Viresh Kumar
2025-01-09 5:14 ` Viresh Kumar
2025-01-07 11:56 ` Danilo Krummrich
2025-01-07 11:21 ` [PATCH V6 05/15] rust: Add bindings for cpumask Viresh Kumar
2025-01-07 12:01 ` Greg KH
2025-01-07 11:21 ` [PATCH V6 06/15] rust: Add bare minimal bindings for clk framework Viresh Kumar
2025-01-07 11:21 ` [PATCH V6 07/15] rust: Add initial bindings for OPP framework Viresh Kumar
2025-01-07 11:21 ` [PATCH V6 08/15] rust: Extend OPP bindings for the OPP table Viresh Kumar
2025-01-07 11:21 ` [PATCH V6 09/15] rust: Extend OPP bindings for the configuration options Viresh Kumar
2025-01-07 11:21 ` [PATCH V6 10/15] rust: Add initial bindings for cpufreq framework Viresh Kumar
2025-01-07 11:21 ` [PATCH V6 11/15] rust: Extend cpufreq bindings for policy and driver ops Viresh Kumar
2025-01-07 11:21 ` [PATCH V6 12/15] rust: Extend cpufreq bindings for driver registration Viresh Kumar
2025-01-07 11:21 ` [PATCH V6 13/15] rust: Extend OPP bindings with CPU frequency table Viresh Kumar
2025-01-07 11:21 ` [PATCH V6 14/15] cpufreq: Add Rust based cpufreq-dt driver Viresh Kumar
2025-01-07 12:04 ` Greg KH
2025-01-07 11:21 ` [PATCH V6 15/15] DO-NOT_MERGE: cpufreq: Rename cpufreq-dt platdev Viresh Kumar
2025-01-07 11:47 ` [PATCH V6 00/15] Rust bindings for cpufreq and OPP core + sample driver Danilo Krummrich
2025-01-08 5:20 ` Viresh Kumar
2025-01-08 15:03 ` Miguel Ojeda
2025-01-09 3:50 ` Viresh Kumar
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=2025011327-cubbyhole-idealness-d4cc@gregkh \
--to=gregkh@linuxfoundation.org \
--cc=a.hindborg@kernel.org \
--cc=alex.bennee@linaro.org \
--cc=alex.gaynor@gmail.com \
--cc=aliceryhl@google.com \
--cc=benno.lossin@proton.me \
--cc=bjorn3_gh@protonmail.com \
--cc=boqun.feng@gmail.com \
--cc=dakr@redhat.com \
--cc=erik.schilling@linaro.org \
--cc=gary@garyguo.net \
--cc=joakim.bech@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=manos.pitsidianakis@linaro.org \
--cc=miguel.ojeda.sandonis@gmail.com \
--cc=nm@ti.com \
--cc=ojeda@kernel.org \
--cc=rafael@kernel.org \
--cc=robh@kernel.org \
--cc=rust-for-linux@vger.kernel.org \
--cc=sboyd@kernel.org \
--cc=tmgross@umich.edu \
--cc=vincent.guittot@linaro.org \
--cc=viresh.kumar@linaro.org \
/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;
as well as URLs for NNTP newsgroup(s).