[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250113073040.rvtc27zcgpvcycrr@vireshk-i7>
Date: Mon, 13 Jan 2025 13:00:40 +0530
From: Viresh Kumar <viresh.kumar@...aro.org>
To: Greg KH <gregkh@...uxfoundation.org>
Cc: "Rafael J. Wysocki" <rafael@...nel.org>,
Miguel Ojeda <miguel.ojeda.sandonis@...il.com>,
Danilo Krummrich <dakr@...hat.com>, Miguel Ojeda <ojeda@...nel.org>,
Alex Gaynor <alex.gaynor@...il.com>,
Boqun Feng <boqun.feng@...il.com>, Gary Guo <gary@...yguo.net>,
Björn Roy Baron <bjorn3_gh@...tonmail.com>,
Benno Lossin <benno.lossin@...ton.me>,
Andreas Hindborg <a.hindborg@...nel.org>,
Alice Ryhl <aliceryhl@...gle.com>, Trevor Gross <tmgross@...ch.edu>,
linux-pm@...r.kernel.org,
Vincent Guittot <vincent.guittot@...aro.org>,
Stephen Boyd <sboyd@...nel.org>, Nishanth Menon <nm@...com>,
rust-for-linux@...r.kernel.org,
Manos Pitsidianakis <manos.pitsidianakis@...aro.org>,
Erik Schilling <erik.schilling@...aro.org>,
Alex Bennée <alex.bennee@...aro.org>,
Joakim Bech <joakim.bech@...aro.org>, Rob Herring <robh@...nel.org>,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH V6 02/15] cpufreq: Add cpufreq_table_len()
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 ?
--
viresh
Powered by blists - more mailing lists