[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <89afdfc8-9c78-4128-ab73-d569f6ac0c06@amd.com>
Date: Mon, 27 Oct 2025 13:32:31 -0500
From: Babu Moger <bmoger@....com>
To: Reinette Chatre <reinette.chatre@...el.com>,
Babu Moger <babu.moger@....com>, tony.luck@...el.com, tglx@...utronix.de,
mingo@...hat.com, bp@...en8.de, dave.hansen@...ux.intel.com
Cc: corbet@....net, Dave.Martin@....com, james.morse@....com, x86@...nel.org,
hpa@...or.com, akpm@...ux-foundation.org, paulmck@...nel.org,
rdunlap@...radead.org, pmladek@...e.com, kees@...nel.org, arnd@...db.de,
fvdl@...gle.com, seanjc@...gle.com, pawan.kumar.gupta@...ux.intel.com,
xin@...or.com, thomas.lendacky@....com, sohil.mehta@...el.com,
jarkko@...nel.org, chang.seok.bae@...el.com, ebiggers@...gle.com,
elena.reshetova@...el.com, ak@...ux.intel.com, mario.limonciello@....com,
perry.yuan@....com, linux-doc@...r.kernel.org, linux-kernel@...r.kernel.org,
peternewman@...gle.com
Subject: Re: [PATCH v10 06/10] fs/resctrl: Add user interface to
enable/disable io_alloc feature
Hi Reinette,
Thanks for the review.
On 10/24/25 18:43, Reinette Chatre wrote:
> Hi Babu,
>
> On 10/21/25 4:54 PM, Babu Moger wrote:
>
> ...
>
>> When resctrl is mounted with "-o cdp" to enable code/data prioritization,
>> there are two L3 resources that can support I/O allocation: L3CODE and
>> L3DATA. From resctrl fs perspective the two resources share a CLOSID and
>> the architecture's available CLOSID are halved to support this. The
>> architecture's underlying CLOSID used by SDCIAE when CDP is enabled is the
>> CLOSID associated with the CDP_CODE resource, but from resctrl's perspective
>> there is only one CLOSID for both CDP_CODE and CDP_DATA. CDP_DATA is thus
>> not usable for general (CPU) cache allocation nor I/O allocation. Keep the
>> CDP_CODE and CDP_DATA I/O alloc status in sync to avoid any confusion to
>> user space. That is, enabling io_alloc on CDP_CODE does so on CDP_DATA and
>> vice-versa, and keep the I/O allocation CBMs of CDP_CODE and CDP_3DATA in
>> sync.
> CDP_3DATA -> CDP_DATA
Sure.
>
> ...
>
>> +ssize_t resctrl_io_alloc_write(struct kernfs_open_file *of, char *buf,
>> + size_t nbytes, loff_t off)
>> +{
>> + struct resctrl_schema *s = rdt_kn_parent_priv(of->kn);
>> + struct rdt_resource *r = s->res;
>> + char const *grp_name;
>> + u32 io_alloc_closid;
>> + bool enable;
>> + int ret;
>> +
>> + ret = kstrtobool(buf, &enable);
>> + if (ret)
>> + return ret;
>> +
>> + cpus_read_lock();
>> + mutex_lock(&rdtgroup_mutex);
>> +
>> + rdt_last_cmd_clear();
>> +
>> + if (!r->cache.io_alloc_capable) {
>> + rdt_last_cmd_printf("io_alloc is not supported on %s\n", s->name);
>> + ret = -ENODEV;
>> + goto out_unlock;
>> + }
>> +
>> + /* If the feature is already up to date, no action is needed. */
>> + if (resctrl_arch_get_io_alloc_enabled(r) == enable)
>> + goto out_unlock;
>> +
>> + io_alloc_closid = resctrl_io_alloc_closid(r);
>> + if (!resctrl_io_alloc_closid_supported(io_alloc_closid)) {
>> + rdt_last_cmd_printf("io_alloc CLOSID (ctrl_hw_id) %u is not available\n",
>> + io_alloc_closid);
>> + ret = -EINVAL;
>> + goto out_unlock;
>> + }
>> +
>> + if (enable) {
>> + if (!closid_alloc_fixed(io_alloc_closid)) {
>> + grp_name = rdtgroup_name_by_closid(io_alloc_closid);
>> + WARN_ON_ONCE(!grp_name);
>> + rdt_last_cmd_printf("CLOSID (ctrl_hw_id) %u for io_alloc is used by %s group\n",
>> + io_alloc_closid, grp_name ? grp_name : "another");
>> + ret = -ENOSPC;
>> + goto out_unlock;
>> + }
>> +
>> + ret = resctrl_io_alloc_init_cbm(s, io_alloc_closid);
>> + if (ret) {
>> + rdt_last_cmd_puts("Failed to initialize io_alloc allocations\n");
>> + closid_free(io_alloc_closid);
>> + goto out_unlock;
>> + }
>> + } else {
>> + closid_free(io_alloc_closid);
>> + }
>> +
>> + ret = resctrl_arch_io_alloc_enable(r, enable);
> I missed this earlier ... if enable == true then a CLOSID would have been allocated
> at this point but resctrl_arch_io_alloc_enable() is not expected to change the arch's
> state when it fails. io_alloc arch state would thus remain "disabled" while the io_alloc
> CLOSID is allocated. io_alloc CLOSID should free'd on failure of
> resctrl_arch_io_alloc_enable() to address this scenario.
Sure. Will add the check:
ret = resctrl_arch_io_alloc_enable(r, enable);
if (enable && ret) {
rdt_last_cmd_puts("Failed to enable io_alloc feature\n");
closid_free(io_alloc_closid);
}
>
>> +
>> +out_unlock:
>> + mutex_unlock(&rdtgroup_mutex);
>> + cpus_read_unlock();
>> +
>> + return ret ?: nbytes;
>> +}
>> diff --git a/fs/resctrl/internal.h b/fs/resctrl/internal.h
>> index a18ed8889396..26ab8f9b30d8 100644
>> --- a/fs/resctrl/internal.h
>> +++ b/fs/resctrl/internal.h
>> @@ -390,6 +390,8 @@ void rdt_staged_configs_clear(void);
>>
>> bool closid_allocated(unsigned int closid);
>>
>> +bool closid_alloc_fixed(u32 closid);
>> +
>> int resctrl_find_cleanest_closid(void);
>>
>> void *rdt_kn_parent_priv(struct kernfs_node *kn);
>> @@ -428,6 +430,15 @@ ssize_t mbm_L3_assignments_write(struct kernfs_open_file *of, char *buf, size_t
>> loff_t off);
>> int resctrl_io_alloc_show(struct kernfs_open_file *of, struct seq_file *seq, void *v);
>>
>> +int rdtgroup_init_cat(struct resctrl_schema *s, u32 closid);
>> +
>> +enum resctrl_conf_type resctrl_peer_type(enum resctrl_conf_type my_type);
>> +
>> +ssize_t resctrl_io_alloc_write(struct kernfs_open_file *of, char *buf,
>> + size_t nbytes, loff_t off);
>> +
>> +const char *rdtgroup_name_by_closid(int closid);
> Could this please keep the closid type consistent as u32?
Sure. Will do.
Thanks
Babu
Powered by blists - more mailing lists