[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <76911cf6-799e-c8ae-b5c9-51d260d87402@arm.com>
Date: Wed, 28 Jul 2021 17:17:03 +0100
From: James Morse <james.morse@....com>
To: x86@...nel.org, linux-kernel@...r.kernel.org
Cc: Fenghua Yu <fenghua.yu@...el.com>,
Reinette Chatre <reinette.chatre@...el.com>,
Thomas Gleixner <tglx@...utronix.de>,
Ingo Molnar <mingo@...hat.com>, Borislav Petkov <bp@...en8.de>,
H Peter Anvin <hpa@...or.com>,
Babu Moger <Babu.Moger@....com>,
shameerali.kolothum.thodi@...wei.com,
Jamie Iles <jamie@...iainc.com>,
D Scott Phillips OS <scott@...amperecomputing.com>,
lcherian@...vell.com, bobo.shaobowang@...wei.com
Subject: Re: [PATCH v6 01/24] x86/resctrl: Split struct rdt_resource
Hello,
On 15/07/2021 18:30, James Morse wrote:
> resctrl is the defacto Linux ABI for SoC resource partitioning features.
>
> To support it on another architecture, it needs to be abstracted from
> the features provided by Intel RDT and AMD PQoS, and moved to /fs/.
> struct rdt_resource contains a mix of architecture private details
> and properties of the filesystem interface user-space uses.
>
> Start by splitting struct rdt_resource, into an architecture private
> 'hw' struct, which contains the common resctrl structure that would be
> used by any architecture.
> The foreach helpers are most commonly used by
> the filesystem code, and should return the common resctrl structure.
> for_each_rdt_resource() is changed to walk the common structure in its
> parent arch private structure.
[...]
> diff --git a/arch/x86/kernel/cpu/resctrl/internal.h b/arch/x86/kernel/cpu/resctrl/internal.h
> index 6a5f60a37219..88d71c889328 100644
> --- a/arch/x86/kernel/cpu/resctrl/internal.h
> +++ b/arch/x86/kernel/cpu/resctrl/internal.h
> @@ -524,33 +439,42 @@ enum {
> RDT_NUM_RESOURCES,
> };
>
> +static inline struct rdt_resource *resctrl_inc(struct rdt_resource *res)
> +{
> + struct rdt_hw_resource *hw_res = resctrl_to_arch_res(res);
> +
> + hw_res++;
> + return &hw_res->r_resctrl;
> +}
> +
> +/*
> + * To return the common struct rdt_resource, which is contained in struct
> + * rdt_hw_resource, walk the resctrl member of struct rdt_hw_resource.
> + * This makes the limit the resctrl member past the end of the array.
> + */
> #define for_each_rdt_resource(r) \
> - for (r = rdt_resources_all; r < rdt_resources_all + RDT_NUM_RESOURCES;\
> - r++)
> + for (r = &rdt_resources_all[0].r_resctrl; \
> + r < &rdt_resources_all[RDT_NUM_RESOURCES].r_resctrl; \
> + r = resctrl_inc(r))
Kbuild robot reports UBSAN doesn't like this, presumably the dastardly compiler has gone
and generated some accesses. Easily fixed, (but now looks less like the original)
v6's branch gets a patch on top, I'll squash this into v7:
----%<----
@@ -441,11 +441,10 @@ int resctrl_arch_set_cdp_enabled(enum resctrl_res_level l, bool enable);
/*
* To return the common struct rdt_resource, which is contained in struct
* rdt_hw_resource, walk the resctrl member of struct rdt_hw_resource.
- * This makes the limit the resctrl member past the end of the array.
*/
#define for_each_rdt_resource(r) \
for (r = &rdt_resources_all[0].r_resctrl; \
- r < &rdt_resources_all[RDT_NUM_RESOURCES].r_resctrl; \
+ r <= &rdt_resources_all[RDT_NUM_RESOURCES - 1].r_resctrl; \
r = resctrl_inc(r))
#define for_each_capable_rdt_resource(r) \
----%<----
Thanks,
James
Powered by blists - more mailing lists