Linux Power Management development
 help / color / mirror / Atom feed
From: Lukasz Luba <lukasz.luba@arm.com>
To: Changwoo Min <changwoo@igalia.com>
Cc: christian.loehle@arm.com, tj@kernel.org, rafael@kernel.org,
	pavel@kernel.org, kernel-dev@igalia.com,
	linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org,
	len.brown@intel.com
Subject: Re: [PATCH v2] PM: EM: Add inotify support when the energy model is updated.
Date: Fri, 9 May 2025 11:55:50 +0100	[thread overview]
Message-ID: <a82423bc-8c38-4d57-93da-c4f20011cc92@arm.com> (raw)
In-Reply-To: <20250507014728.6094-1-changwoo@igalia.com>

Hi Changwoo,

On 5/7/25 02:47, Changwoo Min wrote:
> The sched_ext schedulers [1] currently access the energy model through the
> debugfs to make energy-aware scheduling decisions [2]. The userspace part
> of a sched_ext scheduler feeds the necessary (post-processed) energy-model
> information to the BPF part of the scheduler.
> 
> However, there is a limitation in the current debugfs support of the energy
> model. When the energy model is updated (em_dev_update_perf_domain), there
> is no way for the userspace part to know such changes (besides polling the
> debugfs files).
> 
> Therefore, add inotify support (IN_MODIFY) when the energy model is updated.
> With this inotify support, the directory of an updated performance domain
> (e.g., /sys/kernel/debug/energy_model/cpu0) and its parent directory (e.g.,
> /sys/kernel/debug/energy_model) are inotified. Therefore, a sched_ext
> scheduler (or any userspace application) monitors the energy model change
> in userspace using the regular inotify interface.
> 
> Note that accessing the energy model information from userspace has many
> advantages over other alternatives, especially adding new BPF kfuncs. The
> userspace has much more freedom than the BPF code (e.g., using external
> libraries and floating point arithmetics), which may be infeasible (if not
> impossible) in the BPF/kernel code.
> 
> [1] https://lwn.net/Articles/922405/
> [2] https://github.com/sched-ext/scx/pull/1624
> 
> Signed-off-by: Changwoo Min <changwoo@igalia.com>
> ---
> 
> ChangeLog v1 -> v2:
>    - Change em_debug_update() to only inotify the directory of an updated
>      performance domain (and its parent directory).
>    - Move the em_debug_update() call outside of the mutex lock.
>    - Update the commit message to clarify its motivation and what will be
>      inotified when updated.
> 
>   kernel/power/energy_model.c | 12 ++++++++++++
>   1 file changed, 12 insertions(+)
> 

I have discussed that with Rafael and we have similar view.
The EM debugfs is not the right interface for this purpose.

A better design and mechanism for your purpose would be the netlink
notification. It is present in the kernel in thermal framework
and e.g. is used by Intel HFI
- drivers/thermal/intel/intel_hfi.c
- drivers/thermal/thermal_netlink.c
It's able to send to the user space the information from FW about
the CPUs' efficiency changes, which is similar to this EM modification.

Would you be interested in writing similar mechanism in the EM fwk?

Regards,
Lukasz


  parent reply	other threads:[~2025-05-09 10:55 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-05-07  1:47 [PATCH v2] PM: EM: Add inotify support when the energy model is updated Changwoo Min
2025-05-07 17:04 ` Tejun Heo
2025-05-08  6:03   ` Changwoo Min
2025-05-09 10:55 ` Lukasz Luba [this message]
2025-05-09 16:41   ` Rafael J. Wysocki
2025-05-10  5:07     ` Changwoo Min
2025-05-10 11:34       ` Rafael J. Wysocki
2025-05-22  8:19         ` Lukasz Luba
2025-05-22  8:35           ` Changwoo Min
2025-05-22  8:43             ` Lukasz Luba
2025-05-10  4:40   ` Changwoo Min

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=a82423bc-8c38-4d57-93da-c4f20011cc92@arm.com \
    --to=lukasz.luba@arm.com \
    --cc=changwoo@igalia.com \
    --cc=christian.loehle@arm.com \
    --cc=kernel-dev@igalia.com \
    --cc=len.brown@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=pavel@kernel.org \
    --cc=rafael@kernel.org \
    --cc=tj@kernel.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