[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20251112130812.51532c2e@pumpkin>
Date: Wed, 12 Nov 2025 13:08:12 +0000
From: David Laight <david.laight.linux@...il.com>
To: Tony Luck <tony.luck@...el.com>
Cc: Fenghua Yu <fenghuay@...dia.com>, Reinette Chatre
<reinette.chatre@...el.com>, Maciej Wieczor-Retman
<maciej.wieczor-retman@...el.com>, Peter Newman <peternewman@...gle.com>,
James Morse <james.morse@....com>, Babu Moger <babu.moger@....com>, Drew
Fustini <dfustini@...libre.com>, Dave Martin <Dave.Martin@....com>, Chen Yu
<yu.c.chen@...el.com>, x86@...nel.org, linux-kernel@...r.kernel.org,
patches@...ts.linux.dev
Subject: Re: [PATCH v13 12/32] x86,fs/resctrl: Support binary fixed point
event counters
On Wed, 29 Oct 2025 09:20:55 -0700
Tony Luck <tony.luck@...el.com> wrote:
> resctrl assumes that all monitor events can be displayed as unsigned
> decimal integers.
>
> Hardware architecture counters may provide some telemetry events with
> greater precision where the event is not a simple count, but is a
> measurement of some sort (e.g. Joules for energy consumed).
>
> Add a new argument to resctrl_enable_mon_event() for architecture code
> to inform the file system that the value for a counter is a fixed-point
> value with a specific number of binary places.
> Only allow architecture to use floating point format on events that the
> file system has marked with mon_evt::is_floating_point.
>
> Display fixed point values with values rounded to an appropriate number
> of decimal places for the precision of the number of binary places
> provided. Add one extra decimal place for every three additional binary
> places, except for low precision binary values where exact representation
> is possible:
>
> 1 binary place is 0.0 or 0.5 => 1 decimal place
> 2 binary places is 0.0, 0.25, 0.5, 0.75 => 2 decimal places
> 3 binary places is 0.0, 0.125, etc. => 3 decimal places
>
> Signed-off-by: Tony Luck <tony.luck@...el.com>
> Reviewed-by: Reinette Chatre <reinette.chatre@...el.com>
> ---
> include/linux/resctrl.h | 3 +-
> fs/resctrl/internal.h | 8 +++
> arch/x86/kernel/cpu/resctrl/core.c | 6 +--
> fs/resctrl/ctrlmondata.c | 84 ++++++++++++++++++++++++++++++
> fs/resctrl/monitor.c | 10 +++-
> 5 files changed, 105 insertions(+), 6 deletions(-)
>
> diff --git a/include/linux/resctrl.h b/include/linux/resctrl.h
> index 702205505dc9..a7e5a546152d 100644
> --- a/include/linux/resctrl.h
> +++ b/include/linux/resctrl.h
> @@ -409,7 +409,8 @@ u32 resctrl_arch_get_num_closid(struct rdt_resource *r);
> u32 resctrl_arch_system_num_rmid_idx(void);
> int resctrl_arch_update_domains(struct rdt_resource *r, u32 closid);
>
> -void resctrl_enable_mon_event(enum resctrl_event_id eventid, bool any_cpu);
> +void resctrl_enable_mon_event(enum resctrl_event_id eventid, bool any_cpu,
> + unsigned int binary_bits);
>
> bool resctrl_is_mon_event_enabled(enum resctrl_event_id eventid);
>
> diff --git a/fs/resctrl/internal.h b/fs/resctrl/internal.h
> index 40b76eaa33d0..f5189b6771a0 100644
> --- a/fs/resctrl/internal.h
> +++ b/fs/resctrl/internal.h
> @@ -62,6 +62,9 @@ static inline struct rdt_fs_context *rdt_fc2context(struct fs_context *fc)
> * Only valid if @evtid is an MBM event.
> * @configurable: true if the event is configurable
> * @any_cpu: true if the event can be read from any CPU
> + * @is_floating_point: event values are displayed in floating point format
> + * @binary_bits: number of fixed-point binary bits from architecture,
> + * only valid if @is_floating_point is true
> * @enabled: true if the event is enabled
> */
> struct mon_evt {
> @@ -71,6 +74,8 @@ struct mon_evt {
> u32 evt_cfg;
> bool configurable;
> bool any_cpu;
> + bool is_floating_point;
> + unsigned int binary_bits;
> bool enabled;
> };
Nit: You've added 4 bytes of padding.
David
Powered by blists - more mailing lists