From: K Prateek Nayak <kprateek.nayak@amd.com>
To: Viresh Kumar <viresh.kumar@linaro.org>
Cc: Huang Rui <ray.huang@amd.com>,
"Gautham R. Shenoy" <gautham.shenoy@amd.com>,
Mario Limonciello <mario.limonciello@amd.com>,
"Rafael J. Wysocki" <rafael@kernel.org>,
Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>,
Len Brown <lenb@kernel.org>,
Sebastian Andrzej Siewior <bigeasy@linutronix.de>,
Clark Williams <clrkwllms@kernel.org>,
Bert Karwatzki <spasswolf@web.de>, <linux-pm@vger.kernel.org>,
<linux-kernel@vger.kernel.org>, <linux-rt-devel@lists.linux.dev>,
Perry Yuan <perry.yuan@amd.com>
Subject: Re: [PATCH v2 2/2] cpufreq: Pass the policy to cpufreq_driver->adjust_perf()
Date: Fri, 16 Jan 2026 10:20:32 +0530 [thread overview]
Message-ID: <549095b9-c12e-4415-999a-f2589451f5e0@amd.com> (raw)
In-Reply-To: <rs4z34vntq4inwbl6nhzwsmefcgud33a4jpec44ff5ylrxtnur@rczzlmhgejky>
Hello Viresh,
On 1/16/2026 10:14 AM, Viresh Kumar wrote:
> On 16-01-26, 10:08, K Prateek Nayak wrote:
>> Guilty of not having CONFIG_RUST enabled! I've arrived at the
>> following after tasking a look at cpufreq.rs (specifically the
>> fast_switch_callback implementation):
>>
>> (Only build tested currently)
>>
>> diff --git a/rust/kernel/cpufreq.rs b/rust/kernel/cpufreq.rs
>> index f968fbd22890..bea109f8ff78 100644
>> --- a/rust/kernel/cpufreq.rs
>> +++ b/rust/kernel/cpufreq.rs
>> @@ -1255,18 +1255,17 @@ impl<T: Driver> Registration<T> {
>> /// # Safety
>> ///
>> /// - This function may only be called from the cpufreq C infrastructure.
>> + /// - The pointer arguments must be valid pointers.
>> unsafe extern "C" fn adjust_perf_callback(
>> - cpu: c_uint,
>> + ptr: *mut bindings::cpufreq_policy,
>> min_perf: c_ulong,
>> target_perf: c_ulong,
>> capacity: c_ulong,
>> ) {
>> - // SAFETY: The C API guarantees that `cpu` refers to a valid CPU number.
>> - let cpu_id = unsafe { CpuId::from_u32_unchecked(cpu) };
>> -
>> - if let Ok(mut policy) = PolicyCpu::from_cpu(cpu_id) {
>> - T::adjust_perf(&mut policy, min_perf, target_perf, capacity);
>> - }
>> + // SAFETY: The `ptr` is guaranteed to be valid by the contract with the C code for the
>> + // lifetime of `policy`.
>> + let policy = unsafe { Policy::from_raw_mut(ptr) };
>> + T::adjust_perf(policy, min_perf, target_perf, capacity);
>> }
>>
>> /// Driver's `get_intermediate` callback.
>> ---
>>
>> Let me know what you think. If you think this is alright, I'll fold it
>> into this same patch in the next version to preserve bisectiblity with
>> CONFIG_RUST (or should I keep it separate?).
>>
>> Since this is my first time dealing with the rust bindings, comments are
>> highly appreciated.
>
> Yeah looks fine. Just make sure it builds fine.
Ack! Let me give it a spin before sending out the v3. Thank you again
for taking a look.
--
Thanks and Regards,
Prateek
prev parent reply other threads:[~2026-01-16 4:50 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-14 8:51 [PATCH v2 0/2] cpufreq/amd-pstate: Prevent scheduling when atomic on PREEMPT_RT K Prateek Nayak
2026-01-14 8:51 ` [PATCH v2 1/2] cpufreq/amd-pstate: Pass the policy to amd_pstate_update() K Prateek Nayak
2026-01-14 8:51 ` [PATCH v2 2/2] cpufreq: Pass the policy to cpufreq_driver->adjust_perf() K Prateek Nayak
2026-01-14 16:24 ` kernel test robot
2026-01-15 4:14 ` Viresh Kumar
2026-01-16 4:38 ` K Prateek Nayak
2026-01-16 4:44 ` Viresh Kumar
2026-01-16 4:50 ` K Prateek Nayak [this message]
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=549095b9-c12e-4415-999a-f2589451f5e0@amd.com \
--to=kprateek.nayak@amd.com \
--cc=bigeasy@linutronix.de \
--cc=clrkwllms@kernel.org \
--cc=gautham.shenoy@amd.com \
--cc=lenb@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=linux-rt-devel@lists.linux.dev \
--cc=mario.limonciello@amd.com \
--cc=perry.yuan@amd.com \
--cc=rafael@kernel.org \
--cc=ray.huang@amd.com \
--cc=spasswolf@web.de \
--cc=srinivas.pandruvada@linux.intel.com \
--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
all inboxes | Powered by JetHome®