[PW_SID:1100121] riscv: add Ssqosid and CBQRI resctrl support#2004
[PW_SID:1100121] riscv: add Ssqosid and CBQRI resctrl support#2004linux-riscv-bot wants to merge 18 commits into
Conversation
Document the ratified Supervisor-mode Quality of Service ID (Ssqosid) extension v1.0. Link: https://github.com/riscv/riscv-ssqosid/releases/tag/v1.0 Acked-by: Conor Dooley <conor.dooley@microchip.com> Signed-off-by: Drew Fustini <fustini@kernel.org> Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
Ssqosid is the RISC-V Quality-of-Service (QoS) Identifiers specification which defines the Supervisor Resource Management Configuration (srmcfg) register. Link: https://github.com/riscv/riscv-ssqosid/releases/tag/v1.0 Co-developed-by: Kornel Dulęba <mindal@semihalf.com> Signed-off-by: Kornel Dulęba <mindal@semihalf.com> Signed-off-by: Drew Fustini <fustini@kernel.org> Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
Add support for the srmcfg CSR defined in the Ssqosid ISA extension. The CSR contains two fields: - Resource Control ID (RCID) for resource allocation - Monitoring Counter ID (MCID) for tracking resource usage Requests from a hart to shared resources are tagged with these IDs, allowing resource usage to be associated with the running task. Add a srmcfg field to thread_struct with the same format as the CSR so the scheduler can set the RCID and MCID for each task on context switch. A per-cpu cpu_srmcfg variable mirrors the CSR state to avoid redundant writes. L1D-hot memory access is faster than a CSR read and avoids traps under virtualization. A per-cpu cpu_srmcfg_default holds the default srmcfg for each CPU as set by resctrl CPU group assignment. On context switch, RCID and MCID inherit from the CPU default independently: a task whose thread RCID field is zero takes the CPU default's RCID, and likewise for MCID. Link: https://github.com/riscv/riscv-ssqosid/releases/tag/v1.0 Assisted-by: Claude:claude-opus-4-7 Co-developed-by: Kornel Dulęba <mindal@semihalf.com> Signed-off-by: Kornel Dulęba <mindal@semihalf.com> Signed-off-by: Drew Fustini <fustini@kernel.org> Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
Four sites in fs/resctrl distinguish bandwidth resources (MBA, SMBA) from cache resources by explicit rid match: fs/resctrl/ctrlmondata.c parse_line() fs/resctrl/rdtgroup.c rdtgroup_mode_test_exclusive() fs/resctrl/rdtgroup.c rdtgroup_size_show() fs/resctrl/rdtgroup.c rdtgroup_init_alloc() Replace the open-coded MBA/SMBA tests with a single resctrl_is_membw() helper keyed on schema_fmt (RESCTRL_SCHEMA_RANGE). No functional change: every existing RESCTRL_SCHEMA_RANGE resource is MBA or SMBA today. This isolates fs/resctrl from the addition of further bandwidth resource types so the four call sites do not have to be updated for each new rid. Assisted-by: Claude:claude-opus-4-7 Signed-off-by: Drew Fustini <fustini@kernel.org> Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
Introduce bandwidth controls which are semantically different from the throttle-based MB resource: - RDT_RESOURCE_MB_MIN: minimum reserved bandwidth - RDT_RESOURCE_MB_WGHT: weighted share of unreserved bandwidth Assisted-by: Claude:claude-opus-4-7 Signed-off-by: Drew Fustini <fustini@kernel.org> Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
Bandwidth resources reset to max_bw on group creation today, which is the right default for MBA and SMBA. However, it is the wrong default for hardware whose registers form a sum-constrained reservation: defaulting every new group to max_bw would immediately violate the sum on the first mkdir. When default_to_min is set, resctrl_get_default_ctrl() returns min_bw for the resource. The existing MBA and SMBA behavior is not changed. Assisted-by: Claude:claude-opus-4-7 Signed-off-by: Drew Fustini <fustini@kernel.org> Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
Add support for the RISC-V CBQRI capacity controller (CC). The firmware discovery layer (ACPI or DT) is responsible for passing the cbqri_controller_info descriptor to riscv_cbqri_register_controller(). The driver resolves the cpumask so callers do not need the cacheinfo topology. AT-capable controllers with CDP off mirror the cbm into both DATA and CODE halves so the spec's reserved-zero AT field cannot diverge. Assisted-by: Claude:claude-opus-4-7 Co-developed-by: Adrien Ricciardi <aricciardi@baylibre.com> Signed-off-by: Adrien Ricciardi <aricciardi@baylibre.com> Signed-off-by: Drew Fustini <fustini@kernel.org> Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
Add capacity monitoring operations. cbqri_init_mon_counters() pre-arms every MCID with the Occupancy event so a subsequent READ_COUNTER just snapshots the live counter without re-configuring the slot. cbqri_probe_cc() leaves ctrl->mon_capable false when cacheinfo has not given a non-zero cache_size, since the byte conversion would be meaningless. cbqri_mon_op() takes a reg_offset and serves both capacity and bandwidth mon_ctl registers as they share an identical layout. Assisted-by: Claude:claude-opus-4-7 Co-developed-by: Adrien Ricciardi <aricciardi@baylibre.com> Signed-off-by: Adrien Ricciardi <aricciardi@baylibre.com> Signed-off-by: Drew Fustini <fustini@kernel.org> Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
Add support for CBQRI bandwidth controller (BC) discovery and the two BC allocation control knobs. Rbwb is the number of reserved bandwidth blocks per RCID. Mweight is the weighted share per RCID of the remaining unreserved bandwidth. Both fields share the bc_bw_alloc register, so cbqri_apply_bc_field() seeds both halves from per-RCID software caches (rbwb_cache and mweight_cache) on every CONFIG_LIMIT. The caches are the authoritative source of the unmodified field, which sidesteps a silent READ_LIMIT no-op leaking stale data from a prior RCID. After CONFIG_LIMIT, the caller writes a sentinel to the target field and reads back via READ_LIMIT to verify hardware accepted the write. The cache is updated only after verify succeeds. mweight_cache is seeded to FIELD_MAX at probe so the first MB_MIN domain init does not commit Mweight=0 (per CBQRI 4.5, a hard cap that disallows opportunistic bandwidth) before the subsequent MB_WGHT init catches up. cbqri_apply_rbwb() enforces the spec-mandated sum(Rbwb) <= MRBWB invariant from rbwb_cache rather than per-RCID READ_LIMIT round-trips, which would cost up to 1 ms each while holding the mutex. cbqri_apply_mweight_config() rejects values that would truncate against the 8-bit MWEIGHT_MASK at entry. Assisted-by: Claude:claude-opus-4-7 Co-developed-by: Adrien Ricciardi <aricciardi@baylibre.com> Signed-off-by: Adrien Ricciardi <aricciardi@baylibre.com> Signed-off-by: Drew Fustini <fustini@kernel.org> Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
Add the BC monitoring primitives. cbqri_init_bc_mon_counters() pre-arms each MCID with the TOTAL_READ_WRITE event and allocates the per-MCID software accumulator (struct cbqri_bc_mon_state) so subsequent reads can extend the 62-bit hardware counter to the 64-bit byte total resctrl expects. cbqri_bc_mon_overflow() recovers a single-wrap delta. The OVF bit signals multi-wrap and is the caller's concern. cbqri_find_only_mon_bc() returns NULL when zero or more than one mon-capable BC is present. A BC's counter can only accurately back L3 mbm_total_bytes when every memory request flows through that BC. Assisted-by: Claude:claude-opus-4-7 Co-developed-by: Adrien Ricciardi <aricciardi@baylibre.com> Signed-off-by: Adrien Ricciardi <aricciardi@baylibre.com> Signed-off-by: Drew Fustini <fustini@kernel.org> Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
Wire CBQRI capacity controllers into resctrl as RDT_RESOURCE_L2 and RDT_RESOURCE_L3 schemata. Mismatched CC caps at the same cache level are treated as a fatal configuration error since fs/resctrl exposes a single per-rid cap set. Domains are created lazily in the cpuhp online callback so cpu_mask reflects only currently online CPUs. Assisted-by: Claude:claude-opus-4-7 Co-developed-by: Adrien Ricciardi <aricciardi@baylibre.com> Signed-off-by: Adrien Ricciardi <aricciardi@baylibre.com> Signed-off-by: Drew Fustini <fustini@kernel.org> Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
Expose QOS_L3_OCCUP_EVENT_ID so userspace can read per-MCID llc_occupancy. The result is converted from capacity blocks to bytes using cache_size and ncblks. resctrl_arch_reset_rmid() re-arms CONFIG_EVENT with EVT_ID=Occupancy. CONFIG_EVENT both resets the counter to 0 and selects the event, so re-arming with the same event keeps the MCID counting after reset rather than relying on sticky-last-event semantics that the CBQRI register definition does not guarantee. The L3 mon_domain is created lazily on the first CPU of a cache_id and linked to the paired ctrl_domain. Assisted-by: Claude:claude-opus-4-7 Co-developed-by: Adrien Ricciardi <aricciardi@baylibre.com> Signed-off-by: Adrien Ricciardi <aricciardi@baylibre.com> Signed-off-by: Drew Fustini <fustini@kernel.org> Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
Add bandwidth allocation through Rbwb (reserved bandwidth blocks) exposed as the MB_MIN resource. Rbwb's sum constraint does not fit MBA's percentage cap, so MB_MIN lands as a new RDT_RESOURCE_* rather than masquerading as MBA. The sum(Rbwb) <= MRBWB (max resv bw blocks) invariant from the CBQRI spec is enforced at schemata-write time using a per-RCID software cache under ctrl->lock. -EINVAL on overflow, matching the existing schemata-write rejection convention. Reset gives RCID 0 the remaining MRBWB budget after reserving 1 block per other RCID. default_to_min=true on MB_MIN so mkdir cannot overflow the sum constraint. Assisted-by: Claude:claude-opus-4-7 Co-developed-by: Adrien Ricciardi <aricciardi@baylibre.com> Signed-off-by: Adrien Ricciardi <aricciardi@baylibre.com> Signed-off-by: Drew Fustini <fustini@kernel.org> Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
Add bandwidth allocation through Mweight (shared weight for unreserved bandwidth) exposed as the MB_WGHT resource. Mweight has no MBA equivalent, so it lands as a new RDT_RESOURCE_*. Mweight is an integer in [0, 255]. A value of 0 disables work- conserving sharing for the group, capping its bandwidth at the MB_MIN reservation. Values 1..255 compete for the leftover pool in proportion to the weight. The same BC backs both MB_MIN and MB_WGHT and bc_bw_alloc packs Rbwb and Mweight in one register. cbqri_attach_cpu_to_bw_ctrl() attaches both rids to the picked BC. Reset gives every RCID the new-group default (max_bw = 255) for equal opportunistic shares. Assisted-by: Claude:claude-opus-4-7 Co-developed-by: Adrien Ricciardi <aricciardi@baylibre.com> Signed-off-by: Adrien Ricciardi <aricciardi@baylibre.com> Signed-off-by: Drew Fustini <fustini@kernel.org> Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
Expose CBQRI bandwidth controller's combined read+write counter as the L3 mbm_total_bytes event. A software accumulator keeps the 64-bit byte total monotonic across the 62-bit hardware counter wrap. mbm_local_bytes is not supported because the CBQRI spec has no way to distinguish total versus local. mbm_total_bytes is enabled only when the platform exposes exactly one mon-capable bandwidth controller and exactly one L3 domain. Pairing a single BC with multiple L3 domains would let standard userspace tools overcount system bandwidth by summing the same counter across domains. Assisted-by: Claude:claude-opus-4-7 Co-developed-by: Adrien Ricciardi <aricciardi@baylibre.com> Signed-off-by: Adrien Ricciardi <aricciardi@baylibre.com> Signed-off-by: Drew Fustini <fustini@kernel.org> Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
Add a parser for the ACPI RQSC table, which describes the CBQRI controllers in a system. For each table entry, populate a cbqri_controller_info descriptor and hand it to the CBQRI driver via riscv_cbqri_register_controller(). The driver owns all subsequent state, including cpumask resolution at cbqri_resctrl_setup() time. Link: https://github.com/riscv-non-isa/riscv-rqsc/blob/main/src/ Link: https://github.com/riscv-non-isa/riscv-cbqri/releases/tag/v1.0 Assisted-by: Claude:claude-opus-4-7 Signed-off-by: Drew Fustini <fustini@kernel.org> Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
…QSC) Call acpi_parse_rqsc() from acpi_arch_init() to discover CBQRI controllers when an RQSC table is present. Gate on CONFIG_RISCV_CBQRI_DRIVER rather than CONFIG_RISCV_ISA_SSQOSID so a kernel built with the ISA extension but without the driver (e.g. RESCTRL_FS=n) does not walk the table and print a misleading "found 0 CBQRI controllers" line on every boot. Link: https://github.com/riscv-non-isa/riscv-cbqri/releases/tag/v1.0 Link: https://github.com/riscv-non-isa/riscv-rqsc/blob/main/src/ Assisted-by: Claude:claude-opus-4-7 Signed-off-by: Drew Fustini <fustini@kernel.org> Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
RISCV_ISA_SSQOSID selects RISCV_CBQRI_DRIVER unconditionally. The resctrl filesystem integration is gated separately by RISCV_CBQRI_RESCTRL_FS, a silent option that defaults to y when both RISCV_CBQRI_DRIVER and RESCTRL_FS are enabled. Enabling the resctrl filesystem itself stays a user choice via the standard fs/Kconfig MISC_FILESYSTEMS menu. Signed-off-by: Drew Fustini <fustini@kernel.org> Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
|
Patch 1: "[RFC,v5,01/18] dt-bindings: riscv: Add Ssqosid extension description" |
|
Patch 1: "[RFC,v5,01/18] dt-bindings: riscv: Add Ssqosid extension description" |
|
Patch 1: "[RFC,v5,01/18] dt-bindings: riscv: Add Ssqosid extension description" |
|
Patch 1: "[RFC,v5,01/18] dt-bindings: riscv: Add Ssqosid extension description" |
|
Patch 1: "[RFC,v5,01/18] dt-bindings: riscv: Add Ssqosid extension description" |
|
Patch 1: "[RFC,v5,01/18] dt-bindings: riscv: Add Ssqosid extension description" |
|
Patch 1: "[RFC,v5,01/18] dt-bindings: riscv: Add Ssqosid extension description" |
|
Patch 1: "[RFC,v5,01/18] dt-bindings: riscv: Add Ssqosid extension description" |
|
Patch 1: "[RFC,v5,01/18] dt-bindings: riscv: Add Ssqosid extension description" |
|
Patch 1: "[RFC,v5,01/18] dt-bindings: riscv: Add Ssqosid extension description" |
|
Patch 1: "[RFC,v5,01/18] dt-bindings: riscv: Add Ssqosid extension description" |
|
Patch 1: "[RFC,v5,01/18] dt-bindings: riscv: Add Ssqosid extension description" |
|
Patch 16: "[RFC,v5,16/18] ACPI: RISC-V: Parse RISC-V Quality of Service Controller (RQSC) table" |
|
Patch 16: "[RFC,v5,16/18] ACPI: RISC-V: Parse RISC-V Quality of Service Controller (RQSC) table" |
|
Patch 16: "[RFC,v5,16/18] ACPI: RISC-V: Parse RISC-V Quality of Service Controller (RQSC) table" |
|
Patch 16: "[RFC,v5,16/18] ACPI: RISC-V: Parse RISC-V Quality of Service Controller (RQSC) table" |
|
Patch 16: "[RFC,v5,16/18] ACPI: RISC-V: Parse RISC-V Quality of Service Controller (RQSC) table" |
|
Patch 16: "[RFC,v5,16/18] ACPI: RISC-V: Parse RISC-V Quality of Service Controller (RQSC) table" |
|
Patch 17: "[RFC,v5,17/18] ACPI: RISC-V: Add support for RISC-V Quality of Service Controller (RQSC)" |
|
Patch 17: "[RFC,v5,17/18] ACPI: RISC-V: Add support for RISC-V Quality of Service Controller (RQSC)" |
|
Patch 17: "[RFC,v5,17/18] ACPI: RISC-V: Add support for RISC-V Quality of Service Controller (RQSC)" |
|
Patch 17: "[RFC,v5,17/18] ACPI: RISC-V: Add support for RISC-V Quality of Service Controller (RQSC)" |
|
Patch 17: "[RFC,v5,17/18] ACPI: RISC-V: Add support for RISC-V Quality of Service Controller (RQSC)" |
|
Patch 17: "[RFC,v5,17/18] ACPI: RISC-V: Add support for RISC-V Quality of Service Controller (RQSC)" |
|
Patch 17: "[RFC,v5,17/18] ACPI: RISC-V: Add support for RISC-V Quality of Service Controller (RQSC)" |
|
Patch 17: "[RFC,v5,17/18] ACPI: RISC-V: Add support for RISC-V Quality of Service Controller (RQSC)" |
|
Patch 17: "[RFC,v5,17/18] ACPI: RISC-V: Add support for RISC-V Quality of Service Controller (RQSC)" |
|
Patch 17: "[RFC,v5,17/18] ACPI: RISC-V: Add support for RISC-V Quality of Service Controller (RQSC)" |
|
Patch 17: "[RFC,v5,17/18] ACPI: RISC-V: Add support for RISC-V Quality of Service Controller (RQSC)" |
|
Patch 17: "[RFC,v5,17/18] ACPI: RISC-V: Add support for RISC-V Quality of Service Controller (RQSC)" |
|
Patch 18: "[RFC,v5,18/18] riscv: enable resctrl filesystem for Ssqosid" |
|
Patch 18: "[RFC,v5,18/18] riscv: enable resctrl filesystem for Ssqosid" |
|
Patch 18: "[RFC,v5,18/18] riscv: enable resctrl filesystem for Ssqosid" |
|
Patch 18: "[RFC,v5,18/18] riscv: enable resctrl filesystem for Ssqosid" |
|
Patch 18: "[RFC,v5,18/18] riscv: enable resctrl filesystem for Ssqosid" |
|
Patch 18: "[RFC,v5,18/18] riscv: enable resctrl filesystem for Ssqosid" |
|
Patch 18: "[RFC,v5,18/18] riscv: enable resctrl filesystem for Ssqosid" |
|
Patch 18: "[RFC,v5,18/18] riscv: enable resctrl filesystem for Ssqosid" |
|
Patch 18: "[RFC,v5,18/18] riscv: enable resctrl filesystem for Ssqosid" |
|
Patch 18: "[RFC,v5,18/18] riscv: enable resctrl filesystem for Ssqosid" |
|
Patch 18: "[RFC,v5,18/18] riscv: enable resctrl filesystem for Ssqosid" |
|
Patch 18: "[RFC,v5,18/18] riscv: enable resctrl filesystem for Ssqosid" |
PR for series 1100121 applied to workflow__riscv__fixes
Name: riscv: add Ssqosid and CBQRI resctrl support
URL: https://patchwork.kernel.org/project/linux-riscv/list/?series=1100121
Version: 5