From: Reinette Chatre <reinette.chatre@intel.com>
To: Babu Moger <babu.moger@amd.com>, <tony.luck@intel.com>,
<tglx@linutronix.de>, <mingo@redhat.com>, <bp@alien8.de>,
<dave.hansen@linux.intel.com>
Cc: <corbet@lwn.net>, <Dave.Martin@arm.com>, <james.morse@arm.com>,
<x86@kernel.org>, <hpa@zytor.com>, <akpm@linux-foundation.org>,
<paulmck@kernel.org>, <rdunlap@infradead.org>, <pmladek@suse.com>,
<kees@kernel.org>, <arnd@arndb.de>, <fvdl@google.com>,
<seanjc@google.com>, <pawan.kumar.gupta@linux.intel.com>,
<xin@zytor.com>, <thomas.lendacky@amd.com>,
<sohil.mehta@intel.com>, <jarkko@kernel.org>,
<chang.seok.bae@intel.com>, <ebiggers@google.com>,
<elena.reshetova@intel.com>, <ak@linux.intel.com>,
<mario.limonciello@amd.com>, <perry.yuan@amd.com>,
<linux-doc@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
<peternewman@google.com>
Subject: Re: [PATCH v10 06/10] fs/resctrl: Add user interface to enable/disable io_alloc feature
Date: Fri, 24 Oct 2025 16:43:20 -0700 [thread overview]
Message-ID: <b28ed9df-03cf-412e-b300-2b8499c30fc8@intel.com> (raw)
In-Reply-To: <dd444497162c38f81858ba3b3f95c29058d38232.1761090860.git.babu.moger@amd.com>
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
...
> +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.
> +
> +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?
Reinette
next prev parent reply other threads:[~2025-10-24 23:43 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-21 23:54 [PATCH v10 00/10] x86,fs/resctrl: Support L3 Smart Data Cache Injection Allocation Enforcement (SDCIAE) Babu Moger
2025-10-21 23:54 ` [PATCH v10 01/10] x86/cpufeatures: Add support for L3 Smart Data Cache Injection Allocation Enforcement Babu Moger
2025-10-21 23:54 ` [PATCH v10 02/10] x86/resctrl: Add SDCIAE feature in the command line options Babu Moger
2025-10-21 23:54 ` [PATCH v10 03/10] x86,fs/resctrl: Detect io_alloc feature Babu Moger
2025-10-21 23:54 ` [PATCH v10 04/10] x86,fs/resctrl: Implement "io_alloc" enable/disable handlers Babu Moger
2025-10-24 23:39 ` Reinette Chatre
2025-10-21 23:54 ` [PATCH v10 05/10] fs/resctrl: Introduce interface to display "io_alloc" support Babu Moger
2025-10-24 23:40 ` Reinette Chatre
2025-10-21 23:54 ` [PATCH v10 06/10] fs/resctrl: Add user interface to enable/disable io_alloc feature Babu Moger
2025-10-24 23:43 ` Reinette Chatre [this message]
2025-10-27 18:32 ` Babu Moger
2025-10-21 23:54 ` [PATCH v10 07/10] fs/resctrl: Introduce interface to display io_alloc CBMs Babu Moger
2025-10-24 23:43 ` Reinette Chatre
2025-10-21 23:54 ` [PATCH v10 08/10] fs/resctrl: Modify struct rdt_parse_data to pass mode and CLOSID Babu Moger
2025-10-21 23:54 ` [PATCH v10 09/10] fs/resctrl: Introduce interface to modify io_alloc capacity bitmasks Babu Moger
2025-10-24 23:43 ` Reinette Chatre
2025-10-21 23:54 ` [PATCH v10 10/10] fs/resctrl: Update bit_usage to reflect io_alloc Babu Moger
2025-10-24 23:44 ` Reinette Chatre
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=b28ed9df-03cf-412e-b300-2b8499c30fc8@intel.com \
--to=reinette.chatre@intel.com \
--cc=Dave.Martin@arm.com \
--cc=ak@linux.intel.com \
--cc=akpm@linux-foundation.org \
--cc=arnd@arndb.de \
--cc=babu.moger@amd.com \
--cc=bp@alien8.de \
--cc=chang.seok.bae@intel.com \
--cc=corbet@lwn.net \
--cc=dave.hansen@linux.intel.com \
--cc=ebiggers@google.com \
--cc=elena.reshetova@intel.com \
--cc=fvdl@google.com \
--cc=hpa@zytor.com \
--cc=james.morse@arm.com \
--cc=jarkko@kernel.org \
--cc=kees@kernel.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mario.limonciello@amd.com \
--cc=mingo@redhat.com \
--cc=paulmck@kernel.org \
--cc=pawan.kumar.gupta@linux.intel.com \
--cc=perry.yuan@amd.com \
--cc=peternewman@google.com \
--cc=pmladek@suse.com \
--cc=rdunlap@infradead.org \
--cc=seanjc@google.com \
--cc=sohil.mehta@intel.com \
--cc=tglx@linutronix.de \
--cc=thomas.lendacky@amd.com \
--cc=tony.luck@intel.com \
--cc=x86@kernel.org \
--cc=xin@zytor.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox