Re: [RFC PATCH 1/7] x86/resctrl: Add register/unregister functions for driver to hook into resctrl

From: Reinette Chatre
Date: Fri May 05 2023 - 19:18:06 EST


Hi Tony,

On 4/20/2023 3:06 PM, Tony Luck wrote:
> diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/resctrl/rdtgroup.c
> index 6ad33f355861..3e6778bde427 100644
> --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c
> +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c
> @@ -51,6 +51,9 @@ static struct kernfs_node *kn_mongrp;
> /* Kernel fs node for "mon_data" directory under root */
> static struct kernfs_node *kn_mondata;
>
> +static LIST_HEAD(drivers);
> +static bool resctrl_is_mounted;
> +

fyi ...
https://lore.kernel.org/lkml/20230320172620.18254-13-james.morse@xxxxxxx/

> +int resctrl_register_driver(struct resctrl_driver *d)
> +{
> + mutex_lock(&rdtgroup_mutex);
> + list_add(&d->list, &drivers);
> +
> + if (resctrl_is_mounted)
> + driver_up(d);
> + mutex_unlock(&rdtgroup_mutex);
> +
> + return 0;
> +}

Do you expect that the drivers may at any time
need to call into resctrl as opposed to relying entirely
on callbacks from resctrl? I am wondering about any potential
lock ordering issues between rdtgroup_mutex and locks
used internally by the drivers.

Reinette