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: <20250108111253.tg6ixurijf2dvptx@vireshk-i7>
Date: Wed, 8 Jan 2025 16:42:53 +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 07-01-25, 12:59, Greg KH wrote:
> On Tue, Jan 07, 2025 at 04:51:35PM +0530, Viresh Kumar wrote:
> > Add a function to calculate number of entries in the cpufreq table. This
> > will be used by the Rust implementation.
> 
> Again, why is Rust unique here?  Why wouldn't the C code also need this?

How about this:

    cpufreq: Add cpufreq_table_len()

    The last entry of a cpufreq table is marked by setting the frequency
    field to a special value: CPUFREQ_TABLE_END. The C code manages to
    traverse the table by checking the frequency field, until it reaches
    CPUFREQ_TABLE_END.

    The Rust cpufreq bindings though will need to know the length of the
    cpufreq table in advance, for example to check against an invalid index
    value.

    Provide a helper to calculate number of entries in the cpufreq table.
    will be used by the Rust implementation.

> > Signed-off-by: Viresh Kumar <viresh.kumar@...aro.org>
> > ---
> >  include/linux/cpufreq.h | 11 +++++++++++
> >  1 file changed, 11 insertions(+)
> > 
> > diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h
> > index 7fe0981a7e46..6b882ff4dc24 100644
> > --- a/include/linux/cpufreq.h
> > +++ b/include/linux/cpufreq.h
> > @@ -783,6 +783,17 @@ bool cpufreq_boost_enabled(void);
> >  int cpufreq_enable_boost_support(void);
> >  bool policy_has_boost_freq(struct cpufreq_policy *policy);
> >  
> > +static inline unsigned int cpufreq_table_len(struct cpufreq_frequency_table *freq_table)
> > +{
> > +	struct cpufreq_frequency_table *pos;
> > +	unsigned int count = 0;
> > +
> > +	cpufreq_for_each_entry(pos, freq_table)
> > +		count++;
> 
> No locking is needed?

No, the cpufreq table is implemented as an array and is never altered once
created.

-- 
viresh

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ