From: Drew Fustini <fustini@kernel.org>
To: Reinette Chatre <reinette.chatre@intel.com>
Cc: "Paul Walmsley" <pjw@kernel.org>,
"Palmer Dabbelt" <palmer@dabbelt.com>,
"Albert Ou" <aou@eecs.berkeley.edu>,
"Alexandre Ghiti" <alex@ghiti.fr>,
"Radim Krčmář" <rkrcmar@ventanamicro.com>,
"Samuel Holland" <samuel.holland@sifive.com>,
"Adrien Ricciardi" <aricciardi@baylibre.com>,
"Nicolas Pitre" <npitre@baylibre.com>,
"Kornel Dulęba" <mindal@semihalf.com>,
"Atish Patra" <atish.patra@linux.dev>,
"Atish Kumar Patra" <atishp@rivosinc.com>,
"Vasudevan Srinivasan" <vasu@rivosinc.com>,
"Ved Shanbhogue" <ved@rivosinc.com>,
"Conor Dooley" <conor.dooley@microchip.com>,
"yunhui cui" <cuiyunhui@bytedance.com>,
"Chen Pei" <cp0613@linux.alibaba.com>,
"Liu Zhiwei" <zhiwei_liu@linux.alibaba.com>,
"Weiwei Li" <liwei1518@gmail.com>,
guo.wenjia23@zte.com.cn,
"Gong Shuai" <gong.shuai@sanechips.com.cn>,
"Gong Shuai" <gsh517@gmail.com>,
liu.qingtao2@zte.com.cn, "Tony Luck" <tony.luck@intel.com>,
"Babu Moger" <babu.moger@amd.com>,
"Peter Newman" <peternewman@google.com>,
"Fenghua Yu" <fenghua.yu@intel.com>,
"James Morse" <james.morse@arm.com>,
"Ben Horgan" <ben.horgan@arm.com>,
"Dave Martin" <Dave.Martin@arm.com>,
"Rob Herring" <robh@kernel.org>,
"Conor Dooley" <conor+dt@kernel.org>,
"Krzysztof Kozlowski" <krzk+dt@kernel.org>,
"Rafael J. Wysocki" <rafael@kernel.org>,
"Len Brown" <lenb@kernel.org>,
"Robert Moore" <robert.moore@intel.com>,
"Sunil V L" <sunilvl@ventanamicro.com>,
linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org,
x86@kernel.org, linux-acpi@vger.kernel.org,
acpica-devel@lists.linux.dev, devicetree@vger.kernel.org,
"Paul Walmsley" <paul.walmsley@sifive.com>
Subject: Re: [PATCH RFC v3 04/11] RISC-V: QoS: add CBQRI hardware interface
Date: Thu, 30 Apr 2026 21:45:21 -0700 [thread overview]
Message-ID: <afQv4dpMHUonDJcJ@x1> (raw)
In-Reply-To: <eeecb5df-64ee-46ef-b4a8-0f0cdc88f0ae@intel.com>
On Thu, Apr 30, 2026 at 04:15:05PM -0700, Reinette Chatre wrote:
> Hi Drew,
>
> On 4/14/26 6:53 PM, Drew Fustini wrote:
> > diff --git a/arch/riscv/kernel/qos/internal.h b/arch/riscv/kernel/qos/internal.h
> > new file mode 100644
> > index 000000000000..edbcbd9471b1
> > --- /dev/null
> > +++ b/arch/riscv/kernel/qos/internal.h
>
> ...
>
> > +
> > +struct cbqri_config {
> > + u64 cbm; /* capacity block mask */
> > + u64 rbwb; /* reserved bandwidth blocks */
> > +};
>
> Is this struct necessary? From what I can tell it is used to pass a parameter to
> cbqri_apply_cache_config() and cbqri_apply_bw_config() where each just picks the
> one member of interest. Could parameter of interest just be provided directly to
> cbqri_apply_cache_config() and cbqri_apply_bw_config() without bouncing it
> through this struct first?
Agreed, the struct is unnecessary indirection. The two callers each
write one field and read it back immediately. I will drop it and pass
cbm / rbwb directly.
> > +
> > +#endif /* _ASM_RISCV_QOS_INTERNAL_H */
> > diff --git a/arch/riscv/kernel/qos/qos_resctrl.c b/arch/riscv/kernel/qos/qos_resctrl.c
> > new file mode 100644
> > index 000000000000..6d294f2f2504
> > --- /dev/null
> > +++ b/arch/riscv/kernel/qos/qos_resctrl.c
> > @@ -0,0 +1,432 @@
> > +// SPDX-License-Identifier: GPL-2.0-only
> > +
> > +#define pr_fmt(fmt) "qos: resctrl: " fmt
> > +
> > +#include <linux/err.h>
> > +#include <linux/io.h>
> > +#include <linux/io-64-nonatomic-lo-hi.h>
> > +#include <linux/iopoll.h>
> > +#include <linux/ioport.h>
> > +#include <linux/resctrl.h>
> > +#include <linux/riscv_qos.h>
> > +#include <linux/slab.h>
> > +#include <linux/types.h>
> > +#include <asm/csr.h>
> > +#include <asm/qos.h>
> > +#include "internal.h"
> > +
> > +static struct cbqri_resctrl_res cbqri_resctrl_resources[RDT_NUM_RESOURCES];
> > +
> > +static bool exposed_alloc_capable;
> > +/* CDP (code data prioritization) on x86 is AT (access type) on RISC-V */
> > +static bool exposed_cdp_l2_capable;
> > +static bool exposed_cdp_l3_capable;
> > +static bool is_cdp_l2_enabled;
> > +static bool is_cdp_l3_enabled;
>
> These CDP values could also be handled as part of struct cbqri_resctrl_res, similar
> to how CDP is managed with struct rdt_hw_resource. There does seem to be a hidden
> assumption in this implementation that if *any* cache controller at particular level
> supports CDP (which will cause global exposed_cdp_l{2,3}_capable to be true) then all cache
> controllers at that level are assumed to support CDP even though this property is
> enumerated separately for every cache controller making it possible for this
> support to not be uniform.
>
> ...
Good point. This is fixed in v4 which I was about to send. The
controller-level cap is now stored on each controller as
cc.supports_alloc_at_code and cc.supports_alloc_at_data, and
cbqri_resctrl_pick_caches() rejects a heterogeneous-CDP set at the same
cache level. Therefore, resctrl never sees a global-capable bit that
some controllers cannot honour. I will take a look at folding this into
struct cbqri_resctrl_res to make it simpler.
> > +/* Perform capacity allocation control operation on capacity controller */
> > +static int cbqri_cc_alloc_op(struct cbqri_controller *ctrl, int operation, int rcid,
> > + enum resctrl_conf_type type)
> > +{
> > + int reg_offset = CBQRI_CC_ALLOC_CTL_OFF;
> > + int status;
> > + u64 reg;
> > +
> > + reg = ioread64(ctrl->base + reg_offset);
> > + reg &= ~CBQRI_CONTROL_REGISTERS_OP_MASK;
> > + reg |= FIELD_PREP(CBQRI_CONTROL_REGISTERS_OP_MASK, operation);
> > + reg &= ~CBQRI_CONTROL_REGISTERS_RCID_MASK;
> > + reg |= FIELD_PREP(CBQRI_CONTROL_REGISTERS_RCID_MASK, rcid);
> > +
> > + /* CBQRI capacity AT is only supported on L2 and L3 caches for now */
> > + if (ctrl->type == CBQRI_CONTROLLER_TYPE_CAPACITY &&
> > + ((ctrl->cache.cache_level == 2 && is_cdp_l2_enabled) ||
> > + (ctrl->cache.cache_level == 3 && is_cdp_l3_enabled))) {
> > + reg &= ~CBQRI_CONTROL_REGISTERS_AT_MASK;
> > + switch (type) {
> > + case CDP_CODE:
> > + reg |= FIELD_PREP(CBQRI_CONTROL_REGISTERS_AT_MASK,
> > + CBQRI_CONTROL_REGISTERS_AT_CODE);
> > + break;
> > + case CDP_DATA:
> > + default:
> > + reg |= FIELD_PREP(CBQRI_CONTROL_REGISTERS_AT_MASK,
> > + CBQRI_CONTROL_REGISTERS_AT_DATA);
> > + break;
> > + }
> > + }
>
> There does not seem to be any special enabling when resctrl enables CDP via
> resctrl_arch_set_cdp_enabled() so I assume CDP is always enabled? Does that mean
> that when CDP is disabled from resctrl perspective (thus, both is_cdp_l2_enabled
> and is_cdp_l3_enabled are false, but exposed_cdp_l2_capable and exposed_cdp_l3_capable
> are true) then the default behavior is that allocation applies to both code and data
> and it is not necessary to set both CBQRI_CONTROL_REGISTERS_AT_CODE and
> CBQRI_CONTROL_REGISTERS_AT_DATA?
Good question. I think this is a bug. resctrl_arch_set_cdp_enabled() is
implemented in v4 and toggles the is_cdp_l{2,3}_enabled flags. When CDP
is disabled, the AT field is left at 0 in cbqri_cc_alloc_op(). But BQRI
encodes AT=0 as data, so it only programs the data config and silently
leaves code config at whatever the hardware default is.
The fix would be to issue two CONFIG_LIMIT ops, AT=data and AT=code, for
the same cbm when supports_alloc_at_code is true and CDP is disabled.
Thanks for catching this.
[..]
> > + /*
> > + * max_rmid is used by resctrl_arch_system_num_rmid_idx()
> > + * Find the smallest mcid_count amongst all controllers.
> > + */
> > + max_rmid = min(max_rmid, ctrl->mcid_count);
>
> This computation appears to include all controllers, whether they support monitoring or not.
> What will ctrl->mcid_count be on a controller that does not support monitoring?
Good catch. I will gate the minimum on ctrl->mon_capable.
Thanks,
Drew
next prev parent reply other threads:[~2026-05-01 4:45 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-15 1:53 [PATCH RFC v3 00/11] RISC-V: QoS: add CBQRI resctrl interface Drew Fustini
2026-04-15 1:53 ` [PATCH RFC v3 01/11] dt-bindings: riscv: Add Ssqosid extension description Drew Fustini
2026-04-15 1:53 ` [PATCH RFC v3 02/11] RISC-V: Detect the Ssqosid extension Drew Fustini
2026-04-15 1:53 ` [PATCH RFC v3 03/11] RISC-V: Add support for srmcfg CSR from " Drew Fustini
2026-04-15 1:53 ` [PATCH RFC v3 04/11] RISC-V: QoS: add CBQRI hardware interface Drew Fustini
2026-04-30 23:15 ` Reinette Chatre
2026-05-01 4:45 ` Drew Fustini [this message]
2026-04-15 1:53 ` [PATCH RFC v3 05/11] RISC-V: QoS: add resctrl arch callbacks for CBQRI controllers Drew Fustini
2026-04-30 23:17 ` Reinette Chatre
2026-04-30 23:37 ` Drew Fustini
2026-04-30 23:52 ` Reinette Chatre
2026-04-15 1:54 ` [PATCH RFC v3 06/11] RISC-V: QoS: add resctrl setup and domain management Drew Fustini
2026-04-17 10:52 ` guo.wenjia23
2026-04-18 22:01 ` Drew Fustini
2026-04-30 23:20 ` Reinette Chatre
2026-05-01 22:56 ` Drew Fustini
2026-04-15 1:54 ` [PATCH RFC v3 07/11] RISC-V: QoS: enable resctrl support for Ssqosid Drew Fustini
2026-04-15 1:54 ` [PATCH RFC v3 08/11] ACPI: PPTT: Add acpi_pptt_get_cache_size_from_id helper Drew Fustini
2026-04-30 23:20 ` Reinette Chatre
2026-05-01 16:53 ` Drew Fustini
2026-04-15 1:54 ` [PATCH RFC v3 09/11] DO NOT MERGE: include: acpi: actbl2: Add structs for RQSC table Drew Fustini
2026-04-15 1:54 ` [PATCH RFC v3 10/11] ACPI: RISC-V: Parse RISC-V Quality of Service Controller (RQSC) table Drew Fustini
2026-04-15 1:54 ` [PATCH RFC v3 11/11] ACPI: RISC-V: Add support for RISC-V Quality of Service Controller (RQSC) Drew Fustini
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=afQv4dpMHUonDJcJ@x1 \
--to=fustini@kernel.org \
--cc=Dave.Martin@arm.com \
--cc=acpica-devel@lists.linux.dev \
--cc=alex@ghiti.fr \
--cc=aou@eecs.berkeley.edu \
--cc=aricciardi@baylibre.com \
--cc=atish.patra@linux.dev \
--cc=atishp@rivosinc.com \
--cc=babu.moger@amd.com \
--cc=ben.horgan@arm.com \
--cc=conor+dt@kernel.org \
--cc=conor.dooley@microchip.com \
--cc=cp0613@linux.alibaba.com \
--cc=cuiyunhui@bytedance.com \
--cc=devicetree@vger.kernel.org \
--cc=fenghua.yu@intel.com \
--cc=gong.shuai@sanechips.com.cn \
--cc=gsh517@gmail.com \
--cc=guo.wenjia23@zte.com.cn \
--cc=james.morse@arm.com \
--cc=krzk+dt@kernel.org \
--cc=lenb@kernel.org \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-riscv@lists.infradead.org \
--cc=liu.qingtao2@zte.com.cn \
--cc=liwei1518@gmail.com \
--cc=mindal@semihalf.com \
--cc=npitre@baylibre.com \
--cc=palmer@dabbelt.com \
--cc=paul.walmsley@sifive.com \
--cc=peternewman@google.com \
--cc=pjw@kernel.org \
--cc=rafael@kernel.org \
--cc=reinette.chatre@intel.com \
--cc=rkrcmar@ventanamicro.com \
--cc=robert.moore@intel.com \
--cc=robh@kernel.org \
--cc=samuel.holland@sifive.com \
--cc=sunilvl@ventanamicro.com \
--cc=tony.luck@intel.com \
--cc=vasu@rivosinc.com \
--cc=ved@rivosinc.com \
--cc=x86@kernel.org \
--cc=zhiwei_liu@linux.alibaba.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