lkml.org 
[lkml]   [2021]   [Jul]   [28]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
SubjectRe: [PATCH v6 01/24] x86/resctrl: Split struct rdt_resource
From
Date
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

\
 
 \ /
  Last update: 2021-07-28 18:18    [W:0.154 / U:2.792 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site